feat(RewardDetail): 添加分享来源处理逻辑
处理来自分享页面的跳转逻辑,根据来源参数决定跳转目标 移除未使用的用户信息接口导入
Showing
2 changed files
with
20 additions
and
7 deletions
| ... | @@ -75,7 +75,6 @@ | ... | @@ -75,7 +75,6 @@ |
| 75 | <script setup> | 75 | <script setup> |
| 76 | import { ref } from 'vue'; | 76 | import { ref } from 'vue'; |
| 77 | import Taro, { useDidShow, useLoad } from '@tarojs/taro'; | 77 | import Taro, { useDidShow, useLoad } from '@tarojs/taro'; |
| 78 | -import { getUserProfileAPI } from '@/api/user'; | ||
| 79 | import { handleSharePageAuth, addShareFlag } from '@/utils/authRedirect'; | 78 | import { handleSharePageAuth, addShareFlag } from '@/utils/authRedirect'; |
| 80 | // 导入接口 | 79 | // 导入接口 |
| 81 | import { getCouponDetailAPI, redeemCouponAPI } from '@/api/coupon'; | 80 | import { getCouponDetailAPI, redeemCouponAPI } from '@/api/coupon'; |
| ... | @@ -83,6 +82,7 @@ import { getCouponDetailAPI, redeemCouponAPI } from '@/api/coupon'; | ... | @@ -83,6 +82,7 @@ import { getCouponDetailAPI, redeemCouponAPI } from '@/api/coupon'; |
| 83 | import { THEME_COLORS } from '@/utils/config'; | 82 | import { THEME_COLORS } from '@/utils/config'; |
| 84 | 83 | ||
| 85 | const couponId = ref(''); | 84 | const couponId = ref(''); |
| 85 | +const fromShare = ref(0); | ||
| 86 | 86 | ||
| 87 | // 优惠券详情数据 | 87 | // 优惠券详情数据 |
| 88 | const reward = ref({ | 88 | const reward = ref({ |
| ... | @@ -166,9 +166,17 @@ const handleRedeem = async () => { | ... | @@ -166,9 +166,17 @@ const handleRedeem = async () => { |
| 166 | 166 | ||
| 167 | // 延迟跳转到我的优惠券页面 | 167 | // 延迟跳转到我的优惠券页面 |
| 168 | setTimeout(() => { | 168 | setTimeout(() => { |
| 169 | - Taro.navigateBack({ | 169 | + // 分享成功后,跳转到个人中心 |
| 170 | - delta: 1 | 170 | + if (fromShare.value) { |
| 171 | - }); | 171 | + Taro.navigateTo({ |
| 172 | + url: '/pages/Profile/index' | ||
| 173 | + }); | ||
| 174 | + } else { | ||
| 175 | + // 非分享场景,返回上一页 | ||
| 176 | + Taro.navigateBack({ | ||
| 177 | + delta: 1 | ||
| 178 | + }); | ||
| 179 | + } | ||
| 172 | }, 2000); | 180 | }, 2000); |
| 173 | } else { | 181 | } else { |
| 174 | throw new Error(redeemResponse?.message || '兑换失败'); | 182 | throw new Error(redeemResponse?.message || '兑换失败'); |
| ... | @@ -190,6 +198,11 @@ const initData = async (options = {}) => { | ... | @@ -190,6 +198,11 @@ const initData = async (options = {}) => { |
| 190 | couponId.value = options.id; | 198 | couponId.value = options.id; |
| 191 | } | 199 | } |
| 192 | 200 | ||
| 201 | + // 获取分享参数 | ||
| 202 | + if (options.from_share) { | ||
| 203 | + fromShare.value = options.from_share; | ||
| 204 | + } | ||
| 205 | + | ||
| 193 | // 获取优惠券详情 | 206 | // 获取优惠券详情 |
| 194 | if (couponId.value) { | 207 | if (couponId.value) { |
| 195 | await fetchCouponDetail(); | 208 | await fetchCouponDetail(); |
| ... | @@ -206,8 +219,8 @@ useLoad((options) => { | ... | @@ -206,8 +219,8 @@ useLoad((options) => { |
| 206 | }); | 219 | }); |
| 207 | }); | 220 | }); |
| 208 | 221 | ||
| 209 | -useDidShow(() => { | 222 | +// useDidShow(() => { |
| 210 | -}); | 223 | +// }); |
| 211 | 224 | ||
| 212 | 225 | ||
| 213 | /** | 226 | /** | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-08-27 17:47:26 | 2 | * @Date: 2025-08-27 17:47:26 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-09-13 15:59:26 | 4 | + * @LastEditTime: 2025-09-13 16:22:18 |
| 5 | * @FilePath: /lls_program/src/pages/Rewards/index.vue | 5 | * @FilePath: /lls_program/src/pages/Rewards/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> | ... | ... |
-
Please register or login to post a comment