fix(userId): 调整获取userId的获取方式
This commit is contained in:
parent
257a7d6712
commit
080c7ac8dd
@ -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) //每秒更新
|
||||
|
||||
@ -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(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user