From 756a49bbf53d75718f76c627e2afbc5bde6c4a3b Mon Sep 17 00:00:00 2001 From: zzc <1761997216@qq.com> Date: Wed, 25 Feb 2026 21:17:47 +0800 Subject: [PATCH] fix: rank --- pages/index/index.vue | 65 +++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 472e005..c6283dd 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -167,8 +167,8 @@ > 头像 {{ index + 1 }} - + {{ item.title }} @@ -231,7 +235,7 @@ import { ref, onMounted, computed } from "vue"; import { getStatusBarHeight } from "@/utils/system"; import { onShareAppMessage, onShareTimeline, onShow } from "@dcloudio/uni-app"; import { useUserStore } from "@/stores/user"; -import { getRecommendList } from "@/api/system"; +import { getRecommendList, getRankList } from "@/api/system"; import { getUserSignInfo, userSignIn } from "@/api/user"; import LoginPopup from "@/components/LoginPopup/LoginPopup.vue"; @@ -298,6 +302,10 @@ const greetingText = computed(() => { return "晚上好"; }); +const getThumbUrl = (url) => { + return `${url}?imageView2/1/w/340/h/600/q/80`; +}; + const handleLogin = () => { if (!userInfo.value.nickName) { uni.$emit("show-login-popup"); @@ -342,44 +350,23 @@ const fetchUserSingInfo = async () => { }; const fetchRankingData = async () => { - // 模拟数据或调用 API - // 实际项目中可以调用 getRecommendList 并根据 currentTab 筛选 - // 这里先使用 Mock 数据展示 UI - rankingList.value = [ - { - id: 1, - title: "龙马精神限定框", - thumb: "https://file.lihailezzc.com/resource/avatar_frame_horse_gold.png", - usageCount: "2.4w", - likes: "12.8k", - isHot: true, - type: "frame", - }, - { - id: 2, - title: "锦绣江山动态壁纸", - thumb: "https://file.lihailezzc.com/resource/wallpaper_snow_red.png", - usageCount: "1.8w", - likes: "9.2k", - isHot: false, - type: "wallpaper", - }, - { - id: 3, - title: "万事大吉贺卡模板", - thumb: "https://file.lihailezzc.com/resource/card_template_1.png", - usageCount: "9.5k", - likes: "4.1k", - isHot: false, - type: "card", - }, - ]; + try { + const res = await getRankList(currentTab.value); + if (res && Array.isArray(res)) { + rankingList.value = res.slice(0, 10); + } else { + rankingList.value = []; + } + } catch (e) { + console.error("fetchRankingData error", e); + rankingList.value = []; + } }; const switchTab = (tab) => { + if (currentTab.value === tab) return; currentTab.value = tab; - // TODO: 根据 tab 筛选或重新请求数据 - // 此处仅做 UI 演示,实际需对接筛选逻辑 + fetchRankingData(); }; const onNoticeTap = () => { @@ -443,7 +430,7 @@ const navTo = (url) => { }; const onRankItemTap = (item) => { - if (item.type === "frame") { + if (item.type === "avatar") { uni.navigateTo({ url: `/pages/avatar/index?id=${item.id}` }); } else if (item.type === "card") { uni.switchTab({ url: "/pages/make/index" });