hookehuyr

refactor(奖励页面): 移除创建者相关逻辑并简化代码

移除RewardDetail和Rewards页面中与创建者相关的条件渲染和逻辑
简化Rewards页面积分显示逻辑,直接从API获取用户积分
删除未使用的分享功能代码
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
57 57
58 58
59 <!-- Bottom Button --> 59 <!-- Bottom Button -->
60 - <view v-if="isCreator" class="fixed bottom-0 left-0 right-0 p-4 bg-white border-t border-gray-100"> 60 + <view class="fixed bottom-0 left-0 right-0 p-4 bg-white border-t border-gray-100">
61 <nut-button 61 <nut-button
62 type="primary" 62 type="primary"
63 size="large" 63 size="large"
...@@ -82,7 +82,6 @@ import { getCouponDetailAPI, redeemCouponAPI } from '@/api/coupon'; ...@@ -82,7 +82,6 @@ import { getCouponDetailAPI, redeemCouponAPI } from '@/api/coupon';
82 // 导入主题颜色 82 // 导入主题颜色
83 import { THEME_COLORS } from '@/utils/config'; 83 import { THEME_COLORS } from '@/utils/config';
84 84
85 -const isCreator = ref(false);
86 const couponId = ref(''); 85 const couponId = ref('');
87 86
88 // 优惠券详情数据 87 // 优惠券详情数据
...@@ -191,19 +190,12 @@ const initData = async (options = {}) => { ...@@ -191,19 +190,12 @@ const initData = async (options = {}) => {
191 couponId.value = options.id; 190 couponId.value = options.id;
192 } 191 }
193 192
194 - // 获取用户信息,判断是否为创建者
195 - const { code, data } = await getUserProfileAPI();
196 - if (code) {
197 - isCreator.value = data?.user?.is_creator || false;
198 - }
199 -
200 // 获取优惠券详情 193 // 获取优惠券详情
201 if (couponId.value) { 194 if (couponId.value) {
202 await fetchCouponDetail(); 195 await fetchCouponDetail();
203 } 196 }
204 } catch (error) { 197 } catch (error) {
205 console.error('初始化数据失败:', error); 198 console.error('初始化数据失败:', error);
206 - isCreator.value = false;
207 } 199 }
208 }; 200 };
209 201
...@@ -215,37 +207,28 @@ useLoad((options) => { ...@@ -215,37 +207,28 @@ useLoad((options) => {
215 }); 207 });
216 208
217 useDidShow(() => { 209 useDidShow(() => {
218 - // 页面显示时只获取用户信息,不重新获取优惠券详情
219 - getUserProfileAPI().then(({ code, data }) => {
220 - if (code) {
221 - isCreator.value = data?.user?.is_creator || false;
222 - }
223 - }).catch(error => {
224 - console.error('获取用户信息失败:', error);
225 - isCreator.value = false;
226 - });
227 }); 210 });
228 211
229 212
230 /** 213 /**
231 * 处理分享按钮点击事件 214 * 处理分享按钮点击事件
232 */ 215 */
233 -const shareBtnClick = () => { 216 +// const shareBtnClick = () => {
234 - // 显示分享选项菜单 217 +// // 显示分享选项菜单
235 - Taro.showActionSheet({ 218 +// Taro.showActionSheet({
236 - itemList: ['分享给朋友'], 219 +// itemList: ['分享给朋友'],
237 - success: (res) => { 220 +// success: (res) => {
238 - if (res.tapIndex === 0) { 221 +// if (res.tapIndex === 0) {
239 - // 分享给朋友 222 +// // 分享给朋友
240 - Taro.showToast({ 223 +// Taro.showToast({
241 - title: '请点击右上角分享给朋友', 224 +// title: '请点击右上角分享给朋友',
242 - icon: 'none', 225 +// icon: 'none',
243 - duration: 2000 226 +// duration: 2000
244 - }); 227 +// });
245 - } 228 +// }
246 - } 229 +// }
247 - }); 230 +// });
248 -} 231 +// }
249 232
250 /** 233 /**
251 * 定义分享给朋友的内容 234 * 定义分享给朋友的内容
......
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-08 13:37:45 4 + * @LastEditTime: 2025-09-13 15:59:26
5 * @FilePath: /lls_program/src/pages/Rewards/index.vue 5 * @FilePath: /lls_program/src/pages/Rewards/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
8 <template> 8 <template>
9 <view class="min-h-screen flex flex-col bg-white"> 9 <view class="min-h-screen flex flex-col bg-white">
10 <!-- Blue header background --> 10 <!-- Blue header background -->
11 - <view v-if="isCreator" class="bg-blue-500 h-48 absolute w-full top-0 left-0 z-0"></view> 11 + <view class="bg-blue-500 h-48 absolute w-full top-0 left-0 z-0"></view>
12 - <!-- <AppHeader title="兑换中心" :showBack="false" /> -->
13 <!-- Content --> 12 <!-- Content -->
14 <view class="relative z-10 flex-1 pb-20"> 13 <view class="relative z-10 flex-1 pb-20">
15 <!-- Points display --> 14 <!-- Points display -->
16 - <view v-if="isCreator" class="pt-8 pb-8 flex flex-col items-center"> 15 + <view class="pt-8 pb-8 flex flex-col items-center">
17 <h2 class="text-4xl font-bold text-white mb-1">{{ totalPoints }}分</h2> 16 <h2 class="text-4xl font-bold text-white mb-1">{{ totalPoints }}分</h2>
18 <p class="text-white text-opacity-80">我的积分</p> 17 <p class="text-white text-opacity-80">我的积分</p>
19 </view> 18 </view>
20 <!-- Main content --> 19 <!-- Main content -->
21 <view class="bg-white rounded-t-3xl px-4 pt-5"> 20 <view class="bg-white rounded-t-3xl px-4 pt-5">
22 -<!-- <!~~ Points strategy section ~~>
23 - <view v-if="!isCreator" class="mb-8 bg-gradient-to-br from-blue-50 to-indigo-50 rounded-2xl p-5 shadow-sm border border-blue-100">
24 - <view class="flex justify-between items-center mb-4">
25 - <h3 class="text-lg font-medium text-gray-800">积分攻略</h3>
26 - <view @tap="handleViewAll" class="text-blue-500 text-sm flex items-center hover:text-blue-600">
27 - 查看全部
28 - <!~~ <Right size="16" /> ~~>
29 - </view>
30 - </view>
31 - <!~~ Strategy cards ~~>
32 - <view v-if="isStrategyExpanded" class="space-y-3 mb-4 transition-all duration-300">
33 - <view class="bg-white border border-gray-100 p-4 rounded-lg flex items-start shadow-sm">
34 - <view class="w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center mr-3">
35 - <My size="20" class="text-blue-500" />
36 - </view>
37 - <view>
38 - <h4 class="font-medium">每日同步步数可获得积分</h4>
39 - <p class="text-sm text-gray-600">
40 - 每100步可兑换1积分,每日上限200积分
41 - </p>
42 - </view>
43 - </view>
44 - <view class="bg-white border border-gray-100 p-4 rounded-lg flex items-start shadow-sm">
45 - <view class="w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center mr-3">
46 - <My size="20" class="text-blue-500" />
47 - </view>
48 - <view>
49 - <h4 class="font-medium">家人陪伴健步有奖励积分</h4>
50 - <p class="text-sm text-gray-600">
51 - 一起健步晒合影每天可获得额外100积分
52 - </p>
53 - </view>
54 - </view>
55 - <view class="bg-white border border-gray-100 p-4 rounded-lg flex items-start shadow-sm">
56 - <view class="w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center mr-3">
57 - <My size="20" class="text-blue-500" />
58 - </view>
59 - <view>
60 - <h4 class="font-medium">邀请家人加入家庭,人数达标奖励</h4>
61 - <p class="text-sm text-gray-600">
62 - 邀请的家人达到5位,获得500奖励积分
63 - </p>
64 - </view>
65 - </view>
66 - </view>
67 - <!~~ Expand/Collapse button at bottom ~~>
68 - <view @tap="toggleStrategyExpand" class="flex justify-center items-center py-2 cursor-pointer hover:bg-blue-100 rounded-lg transition-colors">
69 - <ArrowUp v-if="isStrategyExpanded" size="16" class="text-gray-500" />
70 - <ArrowDown v-else size="16" class="text-gray-500" />
71 - </view>
72 - </view>-->
73 - <!-- Quick exchange options -->
74 <!-- Search bar --> 21 <!-- Search bar -->
75 <view class="mb-6"> 22 <view class="mb-6">
76 <view class="relative"> 23 <view class="relative">
...@@ -126,7 +73,7 @@ ...@@ -126,7 +73,7 @@
126 </view> 73 </view>
127 <view class="ml-4 px-4 py-2 bg-blue-500 text-white rounded-lg text-sm flex-shrink-0" 74 <view class="ml-4 px-4 py-2 bg-blue-500 text-white rounded-lg text-sm flex-shrink-0"
128 @click="goToRewardDetail(reward)"> 75 @click="goToRewardDetail(reward)">
129 - {{ isCreator ? reward.points_cost + '分兑换' : '查看' }} 76 + {{ reward.points_cost + '分兑换' }}
130 </view> 77 </view>
131 </view> 78 </view>
132 79
...@@ -164,8 +111,6 @@ const selectedPoints = ref(null); ...@@ -164,8 +111,6 @@ const selectedPoints = ref(null);
164 const sortOrder = ref('desc'); // 'asc' or 'desc' 111 const sortOrder = ref('desc'); // 'asc' or 'desc'
165 112
166 const totalPoints = ref(0); 113 const totalPoints = ref(0);
167 -const isCreator = ref(false);
168 -const isStrategyExpanded = ref(false); // 积分攻略展开状态,默认收起
169 114
170 // 页面参数 115 // 页面参数
171 const pageParams = ref({ 116 const pageParams = ref({
...@@ -286,6 +231,7 @@ const fetchCouponList = async (reset = false) => { ...@@ -286,6 +231,7 @@ const fetchCouponList = async (reset = false) => {
286 const coupons = data?.coupons || []; 231 const coupons = data?.coupons || [];
287 if (reset) { 232 if (reset) {
288 couponList.value = coupons; 233 couponList.value = coupons;
234 + totalPoints.value = data?.user_points || 0;
289 currentPage.value = 0; 235 currentPage.value = 0;
290 } else { 236 } else {
291 couponList.value = [...couponList.value, ...coupons]; 237 couponList.value = [...couponList.value, ...coupons];
...@@ -312,27 +258,6 @@ const initData = async () => { ...@@ -312,27 +258,6 @@ const initData = async () => {
312 id: params.id || '' 258 id: params.id || ''
313 }; 259 };
314 260
315 - // 获取用户信息,判断是否为创建者
316 - try {
317 - const { code, data } = await getUserProfileAPI();
318 - if (code) {
319 - isCreator.value = data?.user?.is_creator || false;
320 - // 只有创建者才显示积分并获取家庭数据
321 - if (isCreator.value) {
322 - // 获取家庭首页数据,从中提取总积分
323 - const familyData = await getFamilyDashboardAPI();
324 - if (familyData.code) {
325 - totalPoints.value = familyData.data.family.total_points || 0;
326 - } else {
327 - totalPoints.value = 0;
328 - }
329 - }
330 - }
331 - } catch (error) {
332 - console.error('获取用户信息失败:', error);
333 - isCreator.value = false;
334 - }
335 -
336 // 获取积分兑换相关数据 261 // 获取积分兑换相关数据
337 await Promise.all([ 262 await Promise.all([
338 fetchPointRanges(), 263 fetchPointRanges(),
......