feat(排行榜): 优化排行榜日期显示和数字滚动动画
添加截止昨日文本和排名提示,调整助力码位置 重构数字滚动组件逻辑,添加触发和重置方法 仅在特定tab显示家庭数量统计
Showing
2 changed files
with
43 additions
and
12 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-01-09 00:00:00 | 2 | * @Date: 2025-01-09 00:00:00 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-10-25 18:48:25 | 4 | + * @LastEditTime: 2025-10-25 19:35:03 |
| 5 | * @FilePath: /lls_program/src/components/RankingCard.vue | 5 | * @FilePath: /lls_program/src/components/RankingCard.vue |
| 6 | * @Description: 排行榜卡片组件 | 6 | * @Description: 排行榜卡片组件 |
| 7 | --> | 7 | --> |
| ... | @@ -42,13 +42,13 @@ | ... | @@ -42,13 +42,13 @@ |
| 42 | <view class="rank-content" :class="{ 'content-switching': isContentSwitching }"> | 42 | <view class="rank-content" :class="{ 'content-switching': isContentSwitching }"> |
| 43 | <!-- 排行榜日期 --> | 43 | <!-- 排行榜日期 --> |
| 44 | <view class="rank-date relative"> | 44 | <view class="rank-date relative"> |
| 45 | - <view class="flex items-center justify-center">{{ currentDate }} <IconFont name="ask" size="16" class="ml-2" @click="handleRankAskClick"></IconFont></view> | 45 | + <view class="flex items-center justify-center"><text class="mr-2">截止昨日</text>{{ currentDate }}<text v-if="activeTab !== 'shanghai'" class="ml-2">排名</text><IconFont name="ask" size="16" class="ml-2" @click="handleRankAskClick"></IconFont></view> |
| 46 | - <view v-if="activeTab === 'support'" class="absolute font-bold text-white bg-orange-500 top-0 rounded-full px-4 py-1" style="right: 30rpx; font-size: 23rpx;" @tap="joinOrganization">助力码</view> | 46 | + <view v-if="activeTab === 'support'" class="absolute font-bold text-white bg-orange-500 top-0 rounded-full px-4 py-1" style="right: 0rpx; top: 50rpx; font-size: 23rpx;" @tap="joinOrganization">助力码</view> |
| 47 | </view> | 47 | </view> |
| 48 | 48 | ||
| 49 | - <view class="relative mb-2 text-white"> | 49 | + <view v-if="activeTab === 'shanghai'" class="relative mb-2 text-white"> |
| 50 | <view class="flex items-center justify-center"> | 50 | <view class="flex items-center justify-center"> |
| 51 | - <text class="mr-2" style="font-size: 28rpx;">已加入</text> | 51 | + <text class="mr-2" style="font-size: 28rpx;">有</text> |
| 52 | <NumberRoll | 52 | <NumberRoll |
| 53 | ref="numberRollRef" | 53 | ref="numberRollRef" |
| 54 | :target-value="currentTotalFamilySum" | 54 | :target-value="currentTotalFamilySum" |
| ... | @@ -56,7 +56,7 @@ | ... | @@ -56,7 +56,7 @@ |
| 56 | :duration="1500" | 56 | :duration="1500" |
| 57 | :digit-delay="150" | 57 | :digit-delay="150" |
| 58 | /> | 58 | /> |
| 59 | - <text class="ml-2" style="font-size: 28rpx;">个家庭</text> | 59 | + <text class="ml-2" style="font-size: 28rpx;">组家庭参与排名</text> |
| 60 | </view> | 60 | </view> |
| 61 | </view> | 61 | </view> |
| 62 | 62 | ||
| ... | @@ -249,6 +249,29 @@ const currentTotalFamilySum = ref(0); | ... | @@ -249,6 +249,29 @@ const currentTotalFamilySum = ref(0); |
| 249 | // 数字滚动组件引用 | 249 | // 数字滚动组件引用 |
| 250 | const numberRollRef = ref(null) | 250 | const numberRollRef = ref(null) |
| 251 | 251 | ||
| 252 | +// 数字滚动触发状态 | ||
| 253 | +const hasTriggeredNumberRoll = ref(false) | ||
| 254 | + | ||
| 255 | +/** | ||
| 256 | + * 触发数字滚动动画 | ||
| 257 | + */ | ||
| 258 | +const triggerNumberRoll = () => { | ||
| 259 | + if (numberRollRef.value && numberRollRef.value.start) { | ||
| 260 | + hasTriggeredNumberRoll.value = true | ||
| 261 | + numberRollRef.value.start() | ||
| 262 | + } | ||
| 263 | +} | ||
| 264 | + | ||
| 265 | +/** | ||
| 266 | + * 重置数字滚动状态 | ||
| 267 | + */ | ||
| 268 | +const resetNumberRoll = () => { | ||
| 269 | + hasTriggeredNumberRoll.value = false | ||
| 270 | + if (numberRollRef.value && numberRollRef.value.reset) { | ||
| 271 | + numberRollRef.value.reset() | ||
| 272 | + } | ||
| 273 | +} | ||
| 274 | + | ||
| 252 | /** | 275 | /** |
| 253 | * 切换tab | 276 | * 切换tab |
| 254 | * @param {string} tab - tab名称 | 277 | * @param {string} tab - tab名称 |
| ... | @@ -302,6 +325,14 @@ const loadLeaderboardData = async (isInitialLoad = false) => { | ... | @@ -302,6 +325,14 @@ const loadLeaderboardData = async (isInitialLoad = false) => { |
| 302 | currentDate.value = response.data.yesterday | 325 | currentDate.value = response.data.yesterday |
| 303 | // TODO: 设置总家庭数 | 326 | // TODO: 设置总家庭数 |
| 304 | currentTotalFamilySum.value = 2318; | 327 | currentTotalFamilySum.value = 2318; |
| 328 | + | ||
| 329 | + // 数据加载完成后,延迟触发数字滚动动画 | ||
| 330 | + setTimeout(() => { | ||
| 331 | + resetNumberRoll() | ||
| 332 | + setTimeout(() => { | ||
| 333 | + triggerNumberRoll() | ||
| 334 | + }, 100) | ||
| 335 | + }, 300) | ||
| 305 | } | 336 | } |
| 306 | } catch (error) { | 337 | } catch (error) { |
| 307 | console.error('获取排行榜数据失败:', error) | 338 | console.error('获取排行榜数据失败:', error) | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-09-01 13:07:52 | 2 | * @Date: 2025-09-01 13:07:52 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-10-25 18:52:07 | 4 | + * @LastEditTime: 2025-10-25 19:36:34 |
| 5 | * @FilePath: /lls_program/src/pages/FamilyRank/index.vue | 5 | * @FilePath: /lls_program/src/pages/FamilyRank/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -40,14 +40,14 @@ | ... | @@ -40,14 +40,14 @@ |
| 40 | 40 | ||
| 41 | <!-- 排行榜日期 --> | 41 | <!-- 排行榜日期 --> |
| 42 | <view v-if="!loading" class="rank-date relative"> | 42 | <view v-if="!loading" class="rank-date relative"> |
| 43 | - <view class="flex items-center justify-center">{{ currentDate }} <IconFont name="ask" size="14" class="ml-2" @click="handleRankAskClick"></IconFont></view> | 43 | + <view class="flex items-center justify-center"><text class="mr-2">截止昨日</text>{{ currentDate }}<text v-if="activeTab !== 'shanghai'" class="ml-2">排名</text><IconFont name="ask" size="14" class="ml-2" @click="handleRankAskClick"></IconFont></view> |
| 44 | - <view v-if="activeTab === 'support'" class="absolute font-bold text-white bg-orange-500 top-0 rounded-full px-4 py-1" style="right: 70rpx; font-size: 23rpx;" @tap="joinOrganization">助力码</view> | 44 | + <view v-if="activeTab === 'support'" class="absolute font-bold text-white bg-orange-500 top-0 rounded-full px-4 py-1" style="right: 40rpx; top: 50rpx; font-size: 23rpx;" @tap="joinOrganization">助力码</view> |
| 45 | </view> | 45 | </view> |
| 46 | 46 | ||
| 47 | <!-- 参与家庭数量显示 --> | 47 | <!-- 参与家庭数量显示 --> |
| 48 | - <view v-if="!loading" class="family-count-display"> | 48 | + <view v-if="!loading && activeTab === 'shanghai'" class="family-count-display"> |
| 49 | <view class="flex items-center justify-center text-white mb-4"> | 49 | <view class="flex items-center justify-center text-white mb-4"> |
| 50 | - <text class="mr-2" style="font-size: 28rpx;">已加入</text> | 50 | + <text class="mr-2" style="font-size: 28rpx;">有</text> |
| 51 | <NumberRoll | 51 | <NumberRoll |
| 52 | ref="numberRollRef" | 52 | ref="numberRollRef" |
| 53 | :target-value="currentTotalFamilySum" | 53 | :target-value="currentTotalFamilySum" |
| ... | @@ -55,7 +55,7 @@ | ... | @@ -55,7 +55,7 @@ |
| 55 | :duration="1500" | 55 | :duration="1500" |
| 56 | :digit-delay="150" | 56 | :digit-delay="150" |
| 57 | /> | 57 | /> |
| 58 | - <text class="ml-2" style="font-size: 28rpx;">个家庭</text> | 58 | + <text class="ml-2" style="font-size: 28rpx;">组家庭参与排名</text> |
| 59 | </view> | 59 | </view> |
| 60 | </view> | 60 | </view> |
| 61 | 61 | ... | ... |
-
Please register or login to post a comment