From 080c7ac8dd5564679beb3c922900db7c843c2f74 Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Mon, 22 Sep 2025 20:09:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(userId):=20=E8=B0=83=E6=95=B4=E8=8E=B7?= =?UTF-8?q?=E5=8F=96userId=E7=9A=84=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/TopList/TopList.vue | 26 +++++++++++++++++++++----- src/views/WeeklyStar/WeeklyStar.vue | 25 ++++++++++++++++++++----- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/views/TopList/TopList.vue b/src/views/TopList/TopList.vue index d4d1475..9a27a04 100644 --- a/src/views/TopList/TopList.vue +++ b/src/views/TopList/TopList.vue @@ -642,7 +642,6 @@ 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, @@ -650,7 +649,7 @@ import { getHistoryTopOne, } from '@/api/topList.js' import { useDebounce, useThrottle } from '@/utils/useDebounce' -import { usePageInitializationWithConfig } from '@/utils/pageConfig.js' +import { getMemberProfile } from '@/api/wallet' //vite动态批量导入图片 const imageModules = import.meta.glob('@/assets/images/TopList/*.{png,jpg,svg}', { eager: true }) @@ -662,6 +661,8 @@ const images = Object.fromEntries( }) ) +const userInfo = ref({}) + const visibleKingList = ref(true) const isInAppEnvironment = ref(false) // 检测是否在APP环境中 @@ -858,7 +859,12 @@ const getTopList = async (params) => { // 获取我的贡献 const getMyContribution = async () => { - const resWeekMyContribution = await getWeekMyContribution(getUserId()) + console.log('userInfo.value.id:', userInfo.value) + + let userId = userInfo.value.id + console.log('userId:', userId) + + const resWeekMyContribution = await getWeekMyContribution(userId) console.log('resWeekMyContribution:', resWeekMyContribution) if (resWeekMyContribution.status && resWeekMyContribution.body) { @@ -886,6 +892,17 @@ const getAllTopOne = async () => { } } +//获取用户信息 +const getUserInfo = async () => { + if (Object.keys(userInfo.value).length === 0) { + const resUserInfo = await getMemberProfile() + if (resUserInfo.status && resUserInfo.body) { + userInfo.value = resUserInfo.body + } + } + getMyContribution() // 获取我的贡献 +} + // 关闭弹窗 const closedPopup = () => { helpInfoShow.value = false @@ -914,9 +931,9 @@ const observer = new IntersectionObserver((entries) => { // 刷新页面数据 const updatePageData = () => { + getUserInfo() getTopList(kingListParams.value) // 获取国王榜单 getTopList(queenListParams.value) // 获取女王榜单 - getMyContribution() // 获取我的贡献 getRewardsAndGifts() //获取本周的礼物和国王和皇后top奖励列表 getAllTopOne() //获取近几个月的榜首国王女王 } @@ -924,7 +941,6 @@ const updatePageData = () => { // 组件挂载时检测环境 onMounted(() => { isInAppEnvironment.value = isInApp() - usePageInitializationWithConfig('APPLY') getCountdown() timer = setInterval(getCountdown, 1000) //每秒更新 diff --git a/src/views/WeeklyStar/WeeklyStar.vue b/src/views/WeeklyStar/WeeklyStar.vue index ab5ad7a..4ffd1f0 100644 --- a/src/views/WeeklyStar/WeeklyStar.vue +++ b/src/views/WeeklyStar/WeeklyStar.vue @@ -743,7 +743,7 @@ import TopUser from '@/components/WeeklyStar/topUser.vue' import maskLayer from '../../components/MaskLayer.vue' import { useDebounce, useThrottle } from '@/utils/useDebounce' import { usePageInitializationWithConfig } from '@/utils/pageConfig.js' -import { getUserId } from '@/utils/userStore.js' +import { getMemberProfile } from '@/api/wallet' import { showError, showWarning, showInfo, showSuccess } from '@/utils/toast.js' import { getWeekStarRanking, @@ -765,6 +765,8 @@ const images = Object.fromEntries( }) ) +const userInfo = ref({}) + const isInAppEnvironment = ref(false) // 检测是否在APP环境中 const helpInfoShow = ref(false) //帮助模块 const historyShow = ref(false) //历史模块 @@ -959,6 +961,18 @@ const showDetail = (type, quantity) => { } } +//获取用户信息 +const getUserInfo = async () => { + if (Object.keys(userInfo.value).length === 0) { + const resUserInfo = await getMemberProfile() + if (resUserInfo.status && resUserInfo.body) { + userInfo.value = resUserInfo.body + } + } + getMyThisWeekRanking() // 获取本周我的排名 + getThisWeekMyFragment() // 获取本周我的碎片 +} + // 获取本周排名 const getThisWeekRanking = async () => { const resWeekStarRanking = await getWeekStarRanking(RankingLoadParams.value) @@ -988,7 +1002,7 @@ const getHistoryRankingTop1 = async () => { // 获取本周我的排名 const getMyThisWeekRanking = async () => { let data = { - userId: getUserId(), + userId: userInfo.value.id, type: 'THIS_WEEK', } const resMyWeekStarRanking = await getMyWeekStarRanking(data) @@ -1032,7 +1046,7 @@ const getThisWeekExchangeGoods = async () => { // 获取本周我拥有的碎片 const getThisWeekMyFragment = async () => { let data = { - userId: getUserId(), + userId: userInfo.value.id, fragmentsIds: ['1968948330210508801'], } @@ -1048,11 +1062,12 @@ const getThisWeekMyFragment = async () => { const updatePageData = () => { getThisWeekRanking() // 获取本周排名 getHistoryRankingTop1() // 获取历史top1 - getMyThisWeekRanking() // 获取本周我的排名 + getThisWeekRewards() // 获取本周奖励 getThisWeekGifts() // 获取本周礼物 getThisWeekExchangeGoods() // 获取本周可兑换商品 - getThisWeekMyFragment() // 获取本周我的碎片 + + getUserInfo() } const debouceGetThisWeekRanking = useThrottle(() => {