fix: rank

This commit is contained in:
zzc
2026-02-25 21:17:47 +08:00
parent 4c53fa9f65
commit 756a49bbf5

View File

@@ -167,8 +167,8 @@
> >
<view <view
class="rank-tab-mini" class="rank-tab-mini"
:class="{ active: currentTab === 'frame' }" :class="{ active: currentTab === 'avatar' }"
@tap="switchTab('frame')" @tap="switchTab('avatar')"
>头像</view >头像</view
> >
<view <view
@@ -191,7 +191,11 @@
<view class="rank-num" :class="'rank-' + (index + 1)">{{ <view class="rank-num" :class="'rank-' + (index + 1)">{{
index + 1 index + 1
}}</view> }}</view>
<image :src="item.thumb" mode="aspectFill" class="rank-thumb" /> <image
:src="item?.resourceInfo?.url"
mode="aspectFill"
class="rank-thumb"
/>
<view class="rank-info"> <view class="rank-info">
<view class="rank-title-row"> <view class="rank-title-row">
<text class="rank-title">{{ item.title }}</text> <text class="rank-title">{{ item.title }}</text>
@@ -231,7 +235,7 @@ import { ref, onMounted, computed } from "vue";
import { getStatusBarHeight } from "@/utils/system"; import { getStatusBarHeight } from "@/utils/system";
import { onShareAppMessage, onShareTimeline, onShow } from "@dcloudio/uni-app"; import { onShareAppMessage, onShareTimeline, onShow } from "@dcloudio/uni-app";
import { useUserStore } from "@/stores/user"; import { useUserStore } from "@/stores/user";
import { getRecommendList } from "@/api/system"; import { getRecommendList, getRankList } from "@/api/system";
import { getUserSignInfo, userSignIn } from "@/api/user"; import { getUserSignInfo, userSignIn } from "@/api/user";
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue"; import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
@@ -298,6 +302,10 @@ const greetingText = computed(() => {
return "晚上好"; return "晚上好";
}); });
const getThumbUrl = (url) => {
return `${url}?imageView2/1/w/340/h/600/q/80`;
};
const handleLogin = () => { const handleLogin = () => {
if (!userInfo.value.nickName) { if (!userInfo.value.nickName) {
uni.$emit("show-login-popup"); uni.$emit("show-login-popup");
@@ -342,44 +350,23 @@ const fetchUserSingInfo = async () => {
}; };
const fetchRankingData = async () => { const fetchRankingData = async () => {
// 模拟数据或调用 API try {
// 实际项目中可以调用 getRecommendList 并根据 currentTab 筛选 const res = await getRankList(currentTab.value);
// 这里先使用 Mock 数据展示 UI if (res && Array.isArray(res)) {
rankingList.value = [ rankingList.value = res.slice(0, 10);
{ } else {
id: 1, rankingList.value = [];
title: "龙马精神限定框", }
thumb: "https://file.lihailezzc.com/resource/avatar_frame_horse_gold.png", } catch (e) {
usageCount: "2.4w", console.error("fetchRankingData error", e);
likes: "12.8k", rankingList.value = [];
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",
},
];
}; };
const switchTab = (tab) => { const switchTab = (tab) => {
if (currentTab.value === tab) return;
currentTab.value = tab; currentTab.value = tab;
// TODO: 根据 tab 筛选或重新请求数据 fetchRankingData();
// 此处仅做 UI 演示,实际需对接筛选逻辑
}; };
const onNoticeTap = () => { const onNoticeTap = () => {
@@ -443,7 +430,7 @@ const navTo = (url) => {
}; };
const onRankItemTap = (item) => { const onRankItemTap = (item) => {
if (item.type === "frame") { if (item.type === "avatar") {
uni.navigateTo({ url: `/pages/avatar/index?id=${item.id}` }); uni.navigateTo({ url: `/pages/avatar/index?id=${item.id}` });
} else if (item.type === "card") { } else if (item.type === "card") {
uni.switchTab({ url: "/pages/make/index" }); uni.switchTab({ url: "/pages/make/index" });