From 844175ba6c09fdd070be87a1e2dac0e11e33a9e4 Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Mon, 22 Sep 2025 15:35:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8F=82=E6=95=B0=EF=BC=8C=E5=B9=B6=E4=BF=AE=E5=A4=8D=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=92=8Chistory=E5=BC=B9=E7=AA=97=E7=9A=84=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/topList.js | 4 ++-- src/api/weeklyStar.js | 6 ++++-- src/views/TopList/TopList.vue | 33 +++++++++++++++++------------ src/views/WeeklyStar/WeeklyStar.vue | 10 ++++++--- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/api/topList.js b/src/api/topList.js index b643031..7c8a99f 100644 --- a/src/api/topList.js +++ b/src/api/topList.js @@ -15,9 +15,9 @@ export const getWeekTopList = async (data) => { } // 获取我本周贡献 -export const getWeekMyContribution = async () => { +export const getWeekMyContribution = async (userId) => { try { - const response = await get(`/activity/king-queen/user-contribute`) + const response = await get(`/activity/king-queen/user-contribute?userId=${userId}`) return response } catch (error) { console.error('Failed to get week my contribution:', error) diff --git a/src/api/weeklyStar.js b/src/api/weeklyStar.js index ed74116..75463b5 100644 --- a/src/api/weeklyStar.js +++ b/src/api/weeklyStar.js @@ -15,9 +15,11 @@ export const getWeekStarRanking = async (data) => { } // 获取我的排名 -export const getMyWeekStarRanking = async (type) => { +export const getMyWeekStarRanking = async (data) => { try { - const response = await get(`/activity/week-star/my-rank?type=${type}`) + const response = await get( + `/activity/week-star/my-rank?type=${data.type}&userId=${data.userId}` + ) return response } catch (error) { console.error('Failed to get my week star ranking:', error) diff --git a/src/views/TopList/TopList.vue b/src/views/TopList/TopList.vue index eaef96f..4279218 100644 --- a/src/views/TopList/TopList.vue +++ b/src/views/TopList/TopList.vue @@ -633,6 +633,7 @@ import { isInApp } from '../../utils/appBridge.js' import { computed, onMounted, onUnmounted, ref } from 'vue' import borderImg from '../../components/TopList/borderImg.vue' import maskLayer from '../../components/MaskLayer.vue' +import { getUserId } from '@/utils/userStore.js' import { getWeekTopList, getWeekMyContribution, @@ -656,20 +657,23 @@ const isInAppEnvironment = ref(false) // 检测是否在APP环境中 const historyList = ref([]) // 榜首历史记录 const showTopOne = computed(() => { + let topNew = [] + if (historyList.value[historyIndex.value].wealth) + topNew.push({ + type: 'topKing', + Frame: images.kingFrame, + userInfo: historyList.value[historyIndex.value].wealth || {}, + }) + if (historyList.value[historyIndex.value].charm) { + topNew.push({ + type: 'topQueen', + Frame: images.queenFrame, + userInfo: historyList.value[historyIndex.value].charm || {}, + }) + } return { group: historyList.value[historyIndex.value].group, - top: [ - { - type: 'topKing', - Frame: images.kingFrame, - userInfo: historyList.value[historyIndex.value].wealth, - }, - { - type: 'topQueen', - Frame: images.queenFrame, - userInfo: historyList.value[historyIndex.value].charm, - }, - ], + top: topNew, } }) const historyIndex = ref(0) @@ -677,6 +681,9 @@ const historyIndex = ref(0) const changeHistoryIndex = (num) => { let index = historyIndex.value + num let length = historyList.value.length + console.log('index:', index) + console.log('length:', length) + if (index >= 0 && index < length) { historyIndex.value = index } @@ -814,7 +821,7 @@ const getTopList = async (params) => { // 获取我的贡献 const getMyContribution = async () => { - const resWeekMyContribution = await getWeekMyContribution() + const resWeekMyContribution = await getWeekMyContribution(getUserId()) console.log('resWeekMyContribution:', resWeekMyContribution) if (resWeekMyContribution.status && resWeekMyContribution.body) { diff --git a/src/views/WeeklyStar/WeeklyStar.vue b/src/views/WeeklyStar/WeeklyStar.vue index eeb4abb..54c8edf 100644 --- a/src/views/WeeklyStar/WeeklyStar.vue +++ b/src/views/WeeklyStar/WeeklyStar.vue @@ -853,7 +853,7 @@ const handleImageError = (e, type) => { // 头像资源出错处理 const defaultAvatarUrl = (e) => { console.log('头像资源出错') - e.target.src = images.defaultAvatar + e.target.src = '/src/assets/images/WeeklyStar/defaultAvatar.png' } // 选中要兑换的商品 @@ -964,7 +964,7 @@ const getThisWeekRanking = async () => { if ( resWeekStarRanking.status && resWeekStarRanking.body && - resWeekStarRanking.body.rankUsers.records + resWeekStarRanking.body.rankUsers?.records ) { let rankUsers = resWeekStarRanking.body.rankUsers Ranking.value.push(...rankUsers.records) @@ -985,7 +985,11 @@ const getHistoryRankingTop1 = async () => { // 获取本周我的排名 const getMyThisWeekRanking = async () => { - const resMyWeekStarRanking = await getMyWeekStarRanking('THIS_WEEK') + let data = { + userId: getUserId(), + type: 'THIS_WEEK', + } + const resMyWeekStarRanking = await getMyWeekStarRanking(data) console.log('resMyWeekStarRanking:', resMyWeekStarRanking) if (resMyWeekStarRanking.status && resMyWeekStarRanking.body) { myRanking.value = resMyWeekStarRanking.body