fix(userId): 调整获取userId的获取方式

This commit is contained in:
hzj 2025-09-22 20:09:36 +08:00
parent 257a7d6712
commit 080c7ac8dd
2 changed files with 41 additions and 10 deletions

View File

@ -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) //

View File

@ -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(() => {