hookehuyr

feat(分享功能): 为活动和兑换券页面添加分享功能

为ActivitiesCover和RewardDetail页面添加微信分享功能配置
在ShareButton组件中使用原生分享按钮
实现onShareAppMessage方法定义分享内容
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
12 <view v-if="showOptions" class="share-popover"> 12 <view v-if="showOptions" class="share-popover">
13 <view class="popover-arrow"></view> 13 <view class="popover-arrow"></view>
14 <view class="popover-content"> 14 <view class="popover-content">
15 - <view @tap="handleShareActivity" class="popover-item"> 15 + <view class="popover-item" style="padding: 0; padding-top: 8rpx;">
16 - <text>活动</text> 16 + <button id="share" data-name="shareBtn" open-type="share" style="font-size: 28rpx;padding: 0; background-color: white; line-height: 2;">活动</button>
17 </view> 17 </view>
18 <view class="popover-divider"></view> 18 <view class="popover-divider"></view>
19 <view @tap="handleSharePoster" class="popover-item"> 19 <view @tap="handleSharePoster" class="popover-item">
......
1 /* 1 /*
2 * @Date: 2025-08-28 14:50:55 2 * @Date: 2025-08-28 14:50:55
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-08-28 14:51:20 4 + * @LastEditTime: 2025-09-04 12:07:53
5 * @FilePath: /lls_program/src/pages/ActivitiesCover/index.config.js 5 * @FilePath: /lls_program/src/pages/ActivitiesCover/index.config.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
8 export default { 8 export default {
9 navigationBarTitleText: '活动海报', 9 navigationBarTitleText: '活动海报',
10 + enableShareAppMessage: true,
11 + enableShareTimeline: true,
10 usingComponents: { 12 usingComponents: {
11 }, 13 },
12 } 14 }
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-09-03 15:54:59 4 + * @LastEditTime: 2025-09-04 12:09:01
5 * @FilePath: /lls_program/src/pages/ActivitiesCover/index.vue 5 * @FilePath: /lls_program/src/pages/ActivitiesCover/index.vue
6 * @Description: 活动海报页面 - 展示活动信息并处理定位授权 6 * @Description: 活动海报页面 - 展示活动信息并处理定位授权
7 --> 7 -->
...@@ -267,10 +267,36 @@ const handleJoinActivity = async () => { ...@@ -267,10 +267,36 @@ const handleJoinActivity = async () => {
267 */ 267 */
268 const onShareActivity = () => { 268 const onShareActivity = () => {
269 console.log('分享活动海报') 269 console.log('分享活动海报')
270 - show_post.value = true 270 + // 分享给朋友
271 - startGeneratePoster() 271 + Taro.showToast({
272 + title: '请点击右上角分享给朋友',
273 + icon: 'none',
274 + duration: 2000
275 + });
276 +}
277 +
278 +/**
279 + * 定义分享给朋友的内容
280 + * @returns {Object} 分享配置对象
281 + */
282 +const onShareAppMessage = () => {
283 + return {
284 + title: '分享活动海报',
285 + path: '/pages/ActivitiesCover/index',
286 + success: (res) => {
287 + console.log('分享成功', res)
288 + },
289 + fail: (err) => {
290 + console.error('分享失败', err)
291 + }
292 + }
272 } 293 }
273 294
295 +// 导出分享方法供Taro使用
296 +defineExpose({
297 + onShareAppMessage,
298 +})
299 +
274 /** 300 /**
275 * 处理分享海报事件 301 * 处理分享海报事件
276 */ 302 */
......
1 /* 1 /*
2 * @Date: 2025-08-27 18:25:42 2 * @Date: 2025-08-27 18:25:42
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-08-28 09:39:10 4 + * @LastEditTime: 2025-09-04 12:07:38
5 * @FilePath: /lls_program/src/pages/RewardDetail/index.config.js 5 * @FilePath: /lls_program/src/pages/RewardDetail/index.config.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
8 export default { 8 export default {
9 - navigationBarTitleText: '兑换券详情' 9 + navigationBarTitleText: '兑换券详情',
10 + enableShareAppMessage: true,
11 + enableShareTimeline: true
10 } 12 }
......
1 <template> 1 <template>
2 <view class="min-h-screen bg-white pb-24"> 2 <view class="min-h-screen bg-white pb-24">
3 - <!-- <AppHeader title="优惠券详情" :showBack="true" /> --> 3 + <!-- 分享按钮 -->
4 + <button id="share" data-name="shareBtn" open-type="share" style="font-size: 1.05rem; padding: 0; position: fixed; right: 40rpx; top: 40rpx; z-index: 1000;color: white; width: 80rpx; height: 80rpx; border-radius: 50%; background: rgba(0, 0, 0, 0.6);">分享</button>
4 <!-- Top Image --> 5 <!-- Top Image -->
5 <view class="w-full h-48"> 6 <view class="w-full h-48">
6 <image :src="reward.image" class="w-full h-full object-cover" /> 7 <image :src="reward.image" class="w-full h-full object-cover" />
...@@ -140,4 +141,46 @@ const initData = async () => { ...@@ -140,4 +141,46 @@ const initData = async () => {
140 useDidShow(() => { 141 useDidShow(() => {
141 initData(); 142 initData();
142 }); 143 });
144 +
145 +
146 +/**
147 + * 处理分享按钮点击事件
148 + */
149 +const shareBtnClick = () => {
150 + // 显示分享选项菜单
151 + Taro.showActionSheet({
152 + itemList: ['分享给朋友'],
153 + success: (res) => {
154 + if (res.tapIndex === 0) {
155 + // 分享给朋友
156 + Taro.showToast({
157 + title: '请点击右上角分享给朋友',
158 + icon: 'none',
159 + duration: 2000
160 + });
161 + }
162 + }
163 + });
164 +}
165 +
166 +/**
167 + * 定义分享给朋友的内容
168 + * @returns {Object} 分享配置对象
169 + */
170 +const onShareAppMessage = () => {
171 + return {
172 + title: `${reward.value.title} - 仅需${reward.value.points}积分`,
173 + path: `/pages/RewardDetail/index?id=${reward.value.id}`,
174 + imageUrl: reward.value.image
175 + }
176 +}
177 +
178 +// 导出分享方法供Taro使用
179 +defineExpose({
180 + onShareAppMessage,
181 +})
143 </script> 182 </script>
183 +
184 +<style lang="less">
185 +
186 +</style>
......