feat: 优化积分兑换和仪表盘界面交互
- 在PointsCollector组件中添加兑换点击事件处理 - 修改RewardCategories页面兑换逻辑,增加线下兑换提示 - 重构Dashboard页面布局和样式,集成PointsCollector组件 - 更新按钮交互和图片资源
Showing
4 changed files
with
59 additions
and
42 deletions
| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | <view class="center-circle"> | 4 | <view class="center-circle"> |
| 5 | <view class="total-points"> | 5 | <view class="total-points"> |
| 6 | <text class="points-number">{{ animatedTotalPoints }}分</text> | 6 | <text class="points-number">{{ animatedTotalPoints }}分</text> |
| 7 | - <text class="points-label">去兑换</text> | 7 | + <text class="points-label" @tap="handleGoToRewards">去兑换</text> |
| 8 | </view> | 8 | </view> |
| 9 | </view> | 9 | </view> |
| 10 | 10 | ||
| ... | @@ -244,6 +244,16 @@ defineExpose({ | ... | @@ -244,6 +244,16 @@ defineExpose({ |
| 244 | onMounted(() => { | 244 | onMounted(() => { |
| 245 | floatingItems.value = generateMockData(); | 245 | floatingItems.value = generateMockData(); |
| 246 | }) | 246 | }) |
| 247 | + | ||
| 248 | +/** | ||
| 249 | + * 处理去兑换点击事件 | ||
| 250 | + */ | ||
| 251 | +const handleGoToRewards = () => { | ||
| 252 | + Taro.navigateTo({ | ||
| 253 | + url: '/pages/RewardCategories/index', | ||
| 254 | + }) | ||
| 255 | +} | ||
| 256 | + | ||
| 247 | </script> | 257 | </script> |
| 248 | 258 | ||
| 249 | <style lang="less"> | 259 | <style lang="less"> | ... | ... |
| 1 | <template> | 1 | <template> |
| 2 | - <view class="min-h-screen flex flex-col bg-white pb-16"> | 2 | + <view class="min-h-screen flex flex-col bg-white pb-16" style="background-color: #F9FAFB;"> |
| 3 | <!-- Hero section with family name and background image --> | 3 | <!-- Hero section with family name and background image --> |
| 4 | <view class="relative h-48"> | 4 | <view class="relative h-48"> |
| 5 | - <image src="/static/images/home/dashboard-bg.png" alt="Family background" class="w-full h-full object-cover" /> | 5 | + <image src="https://placehold.co/800x400/e2f3ff/0369a1?text=LFX&font=roboto" alt="Family background" class="w-full h-full object-cover" /> |
| 6 | <view class="absolute inset-0 bg-black bg-opacity-30 flex flex-col justify-end p-5"> | 6 | <view class="absolute inset-0 bg-black bg-opacity-30 flex flex-col justify-end p-5"> |
| 7 | - <button class="absolute top-4 right-4 text-white" @click="goToProfile"> | 7 | + <view class="absolute top-4 right-4 text-white" @click="goToProfile"> |
| 8 | <Setting size="24" /> | 8 | <Setting size="24" /> |
| 9 | - </button> | 9 | + </view> |
| 10 | <h1 class="text-white text-2xl font-bold">张爷爷的家庭</h1> | 10 | <h1 class="text-white text-2xl font-bold">张爷爷的家庭</h1> |
| 11 | <p class="text-white opacity-90">每日走万步,全家一起行</p> | 11 | <p class="text-white opacity-90">每日走万步,全家一起行</p> |
| 12 | </view> | 12 | </view> |
| 13 | </view> | 13 | </view> |
| 14 | 14 | ||
| 15 | <!-- Today's steps section --> | 15 | <!-- Today's steps section --> |
| 16 | - <view class="p-5"> | 16 | + <view class="px-5 py-6 bg-white rounded-xl shadow-md mx-4 mt-4"> |
| 17 | <view class="flex justify-between items-center mb-1"> | 17 | <view class="flex justify-between items-center mb-1"> |
| 18 | <span class="text-gray-500">今日</span> | 18 | <span class="text-gray-500">今日</span> |
| 19 | </view> | 19 | </view> |
| ... | @@ -24,36 +24,19 @@ | ... | @@ -24,36 +24,19 @@ |
| 24 | </span> | 24 | </span> |
| 25 | <span class="ml-1 text-gray-500">步</span> | 25 | <span class="ml-1 text-gray-500">步</span> |
| 26 | </view> | 26 | </view> |
| 27 | - <button class="bg-blue-500 text-white px-4 py-2 rounded-full text-sm" @click="handleSyncSteps"> | 27 | + <view class="bg-blue-500 text-white px-4 py-2 rounded-full text-sm" @click="handleCollectAll"> |
| 28 | - 一键汇总 | 28 | + 一键收取 |
| 29 | - </button> | 29 | + </view> |
| 30 | </view> | 30 | </view> |
| 31 | </view> | 31 | </view> |
| 32 | 32 | ||
| 33 | <!-- Points circles --> | 33 | <!-- Points circles --> |
| 34 | - <view class="flex justify-between px-5 my-4"> | 34 | + <view class="flex justify-between px-5 py-6 my-4 bg-white rounded-xl shadow-md mx-4"> |
| 35 | - <view class="flex flex-col items-center"> | 35 | + <PointsCollector ref="pointsCollectorRef" height="30vh" /> |
| 36 | - <view class="w-16 h-16 bg-blue-500 rounded-full flex flex-col items-center justify-center text-white"> | ||
| 37 | - <span class="text-sm">热血</span> | ||
| 38 | - <span class="text-sm font-bold">100分</span> | ||
| 39 | - </view> | ||
| 40 | - </view> | ||
| 41 | - <view class="flex flex-col items-center"> | ||
| 42 | - <view class="w-20 h-20 bg-blue-500 rounded-full flex flex-col items-center justify-center text-white"> | ||
| 43 | - <span class="text-sm">恒心</span> | ||
| 44 | - <span class="text-sm font-bold">900分</span> | ||
| 45 | - </view> | ||
| 46 | - </view> | ||
| 47 | - <view class="flex flex-col items-center"> | ||
| 48 | - <view class="w-24 h-24 bg-blue-600 rounded-full flex flex-col items-center justify-center text-white cursor-pointer" @click="goToRewards"> | ||
| 49 | - <span class="text-lg font-bold">8,760分</span> | ||
| 50 | - <span class="text-xs">去兑换 ></span> | ||
| 51 | - </view> | ||
| 52 | - </view> | ||
| 53 | </view> | 36 | </view> |
| 54 | 37 | ||
| 55 | <!-- Family step ranking --> | 38 | <!-- Family step ranking --> |
| 56 | - <view class="px-5 mt-6"> | 39 | + <view class="p-5 bg-white rounded-xl shadow-md mx-4"> |
| 57 | <view class="flex justify-between items-center mb-4"> | 40 | <view class="flex justify-between items-center mb-4"> |
| 58 | <h2 class="font-medium text-lg">今日家庭步数排行</h2> | 41 | <h2 class="font-medium text-lg">今日家庭步数排行</h2> |
| 59 | <span class="text-sm text-gray-500"> | 42 | <span class="text-sm text-gray-500"> |
| ... | @@ -72,27 +55,27 @@ | ... | @@ -72,27 +55,27 @@ |
| 72 | 55 | ||
| 73 | <!-- Photo button --> | 56 | <!-- Photo button --> |
| 74 | <view class="px-5 mt-6"> | 57 | <view class="px-5 mt-6"> |
| 75 | - <button class="w-full bg-blue-500 text-white py-3 rounded-lg flex items-center justify-center" @click="goToActivities"> | 58 | + <view class="w-full bg-blue-500 text-white py-3 rounded-lg flex items-center justify-center"> |
| 76 | - <Camera size="20" class="mr-2" /> | 59 | + <Photograph size="20" class="mr-2" /> |
| 77 | 拍照留念,奖励积分 | 60 | 拍照留念,奖励积分 |
| 78 | - </button> | 61 | + </view> |
| 79 | </view> | 62 | </view> |
| 80 | 63 | ||
| 81 | <!-- Family album --> | 64 | <!-- Family album --> |
| 82 | - <view class="px-5 mt-6"> | 65 | + <view class="p-5 mt-6 mb-6 bg-white rounded-xl shadow-md mx-4"> |
| 83 | <view class="flex justify-between items-center mb-2"> | 66 | <view class="flex justify-between items-center mb-2"> |
| 84 | <h2 class="font-medium text-lg">家庭相册</h2> | 67 | <h2 class="font-medium text-lg">家庭相册</h2> |
| 85 | - <button class="text-blue-500 flex items-center" @click="goToActivities"> | 68 | + <view class="text-blue-500 flex items-center" @click="goToActivities"> |
| 86 | 打开相册 <Right size="16" /> | 69 | 打开相册 <Right size="16" /> |
| 87 | - </button> | 70 | + </view> |
| 88 | </view> | 71 | </view> |
| 89 | <p class="text-sm text-gray-500 mb-3">记录每一个家庭活动瞬间</p> | 72 | <p class="text-sm text-gray-500 mb-3">记录每一个家庭活动瞬间</p> |
| 90 | <view class="grid grid-cols-2 gap-3"> | 73 | <view class="grid grid-cols-2 gap-3"> |
| 91 | <view class="rounded-lg overflow-hidden"> | 74 | <view class="rounded-lg overflow-hidden"> |
| 92 | - <image src="/static/images/home/album-1.png" alt="家庭活动照片" class="w-full h-32 object-cover" /> | 75 | + <image src="https://placehold.co/400x400/e2f3ff/0369a1?text=LFX&font=roboto" alt="家庭活动照片" class="w-full h-32 object-cover" /> |
| 93 | </view> | 76 | </view> |
| 94 | <view class="rounded-lg overflow-hidden"> | 77 | <view class="rounded-lg overflow-hidden"> |
| 95 | - <image src="/static/images/home/album-2.png" alt="家庭活动照片" class="w-full h-32 object-cover" /> | 78 | + <image src="https://placehold.co/400x400/e2f3ff/0369a1?text=LFX&font=roboto" alt="家庭活动照片" class="w-full h-32 object-cover" /> |
| 96 | </view> | 79 | </view> |
| 97 | </view> | 80 | </view> |
| 98 | </view> | 81 | </view> |
| ... | @@ -104,10 +87,21 @@ | ... | @@ -104,10 +87,21 @@ |
| 104 | <script setup> | 87 | <script setup> |
| 105 | import { ref, computed } from 'vue'; | 88 | import { ref, computed } from 'vue'; |
| 106 | import Taro from '@tarojs/taro'; | 89 | import Taro from '@tarojs/taro'; |
| 107 | -import { Setting, Camera, Right } from '@nutui/icons-vue-taro'; | 90 | +import { Setting, Photograph, Right } from '@nutui/icons-vue-taro'; |
| 108 | import BottomNav from '../../components/BottomNav.vue'; | 91 | import BottomNav from '../../components/BottomNav.vue'; |
| 92 | +import PointsCollector from '@/components/PointsCollector.vue' | ||
| 109 | 93 | ||
| 110 | const todaySteps = ref(2000); | 94 | const todaySteps = ref(2000); |
| 95 | +const pointsCollectorRef = ref(null) | ||
| 96 | + | ||
| 97 | +/** | ||
| 98 | + * 触发积分收集组件的一键收取 | ||
| 99 | + */ | ||
| 100 | +const handleCollectAll = () => { | ||
| 101 | + if (pointsCollectorRef.value) { | ||
| 102 | + pointsCollectorRef.value.collectAll() | ||
| 103 | + } | ||
| 104 | +} | ||
| 111 | 105 | ||
| 112 | // Mock data for family members | 106 | // Mock data for family members |
| 113 | const familyMembers = ref([ | 107 | const familyMembers = ref([ | ... | ... |
| ... | @@ -92,7 +92,7 @@ | ... | @@ -92,7 +92,7 @@ |
| 92 | import { ref, computed } from 'vue'; | 92 | import { ref, computed } from 'vue'; |
| 93 | import AppHeader from '../../components/AppHeader.vue'; | 93 | import AppHeader from '../../components/AppHeader.vue'; |
| 94 | import BottomNav from '../../components/BottomNav.vue'; | 94 | import BottomNav from '../../components/BottomNav.vue'; |
| 95 | -import { Right, My, Trophy, People } from '@nutui/icons-vue-taro'; | 95 | +import { Right, My } from '@nutui/icons-vue-taro'; |
| 96 | 96 | ||
| 97 | const activeTab = ref('all'); | 97 | const activeTab = ref('all'); |
| 98 | 98 | ... | ... |
| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | <!-- <AppHeader title="积分兑换" :showBack="false" /> --> | 3 | <!-- <AppHeader title="积分兑换" :showBack="false" /> --> |
| 4 | <view class="flex-1 pb-20"> | 4 | <view class="flex-1 pb-20"> |
| 5 | <view class="p-4 space-y-4"> | 5 | <view class="p-4 space-y-4"> |
| 6 | - <view v-for="category in categories" :key="category.id" class="rounded-lg overflow-hidden shadow-sm" @click="goToRewards"> | 6 | + <view v-for="(category, index) in categories" :key="category.id" class="rounded-lg overflow-hidden shadow-sm" @click="goToRewards(index)"> |
| 7 | <template v-if="category.id !== 'merchants'"> | 7 | <template v-if="category.id !== 'merchants'"> |
| 8 | <view class="relative h-40"> | 8 | <view class="relative h-40"> |
| 9 | <view class="absolute inset-0 bg-black bg-opacity-30 flex flex-col justify-end p-4 text-white" :style="{ background: category.bgColor || 'linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.6))' }"> | 9 | <view class="absolute inset-0 bg-black bg-opacity-30 flex flex-col justify-end p-4 text-white" :style="{ background: category.bgColor || 'linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.6))' }"> |
| ... | @@ -91,7 +91,20 @@ const categories = ref([ | ... | @@ -91,7 +91,20 @@ const categories = ref([ |
| 91 | } | 91 | } |
| 92 | ]); | 92 | ]); |
| 93 | 93 | ||
| 94 | -const goToRewards = () => { | 94 | +const goToRewards = (idx) => { |
| 95 | - Taro.navigateTo({ url: '/pages/Rewards/index' }); | 95 | + if (idx !== 1) { |
| 96 | + Taro.navigateTo({ url: '/pages/Rewards/index' }); | ||
| 97 | + } else { | ||
| 98 | + // 弹出确认提示框, 不用进行操作, 只是文本提示用户进行线下兑换 | ||
| 99 | + Taro.showModal({ | ||
| 100 | + title: '提示', | ||
| 101 | + content: '请联系客服进行线下兑换', | ||
| 102 | + showCancel: false | ||
| 103 | + }).then(res => { | ||
| 104 | + if (res.confirm) { | ||
| 105 | + // 点击了确认按钮 | ||
| 106 | + } | ||
| 107 | + }) | ||
| 108 | + } | ||
| 96 | }; | 109 | }; |
| 97 | </script> | 110 | </script> | ... | ... |
-
Please register or login to post a comment