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
class="rank-tab-mini"
:class="{ active: currentTab === 'frame' }"
@tap="switchTab('frame')"
:class="{ active: currentTab === 'avatar' }"
@tap="switchTab('avatar')"
>头像</view
>
<view
@@ -191,7 +191,11 @@
<view class="rank-num" :class="'rank-' + (index + 1)">{{
index + 1
}}</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-title-row">
<text class="rank-title">{{ item.title }}</text>
@@ -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" });