teamInfo 问题处理
This commit is contained in:
parent
c328d0e9fb
commit
ae3a1a63bb
@ -3,12 +3,13 @@ import { useRouter } from 'vue-router'
|
||||
import {
|
||||
getBankBalance,
|
||||
getMemberProfile,
|
||||
getTeamMemberWorkStatistics
|
||||
getTeamMemberWorkStatistics,
|
||||
getTeamEntry
|
||||
} from '../api/wallet.js'
|
||||
import { connectApplication, parseAccessOrigin, parseHeader, setHttpHeaders, isInApp } from '../utils/appBridge.js'
|
||||
import { appConnectionManager, isAppConnected, getAppHeaderInfo } from '../utils/appConnectionManager.js'
|
||||
import { checkAndRedirect } from '../utils/routeGuard.js'
|
||||
import {getUserId, getUserProfile} from '../utils/userStore.js'
|
||||
import {getTeamInfo, getUserId, getUserProfile, setTeamInfo} from '../utils/userStore.js'
|
||||
import { showError } from '../utils/toast.js'
|
||||
|
||||
/**
|
||||
@ -214,6 +215,51 @@ export function usePageInitialization(options = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取团队信息
|
||||
*/
|
||||
const fetchTeamInfo = async () => {
|
||||
if (!needsTeamInfo) return
|
||||
|
||||
const teamInfo = getTeamInfo()
|
||||
if (teamInfo) return teamInfo
|
||||
|
||||
try {
|
||||
console.debug('🏢 Fetching team information...')
|
||||
const response = await getTeamEntry()
|
||||
|
||||
if (response && response.status && response.body) {
|
||||
console.debug('✅ Team information retrieved successfully')
|
||||
// 缓存团队信息
|
||||
setTeamInfo(response.body.teamProfile || response.body)
|
||||
} else {
|
||||
console.warn('⚠️ Team entry response invalid or empty')
|
||||
setTeamInfo(null)
|
||||
}
|
||||
} catch (error) {
|
||||
console.debug('🔴 Team info fetch error:', error)
|
||||
|
||||
// 处理特定错误码
|
||||
if (error.response && error.response.body && error.response.body.errorCode) {
|
||||
const errorCode = error.response.body.errorCode
|
||||
|
||||
switch (errorCode) {
|
||||
case 6025:
|
||||
console.debug('🚫 User is not a team member (6025)')
|
||||
break
|
||||
case 6010:
|
||||
console.debug('🚫 Team not found or disbanded (6010)')
|
||||
break
|
||||
default:
|
||||
console.debug('❌ Other team error:', errorCode, error.response.body.message)
|
||||
}
|
||||
}
|
||||
|
||||
// 静默处理错误,不向上抛出
|
||||
setTeamInfo(null)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取银行余额
|
||||
*/
|
||||
@ -273,7 +319,7 @@ export function usePageInitialization(options = {}) {
|
||||
dataPromises.push(fetchUserInfo())
|
||||
|
||||
if (needsTeamInfo) {
|
||||
// dataPromises.push()
|
||||
dataPromises.push(fetchTeamInfo())
|
||||
}
|
||||
|
||||
if (needsBankBalance) {
|
||||
@ -366,6 +412,8 @@ export function usePageInitialization(options = {}) {
|
||||
// 方法
|
||||
connectToApp,
|
||||
initializePageData,
|
||||
fetchUserInfo,
|
||||
fetchTeamInfo,
|
||||
fetchBankBalance,
|
||||
fetchWorkStatistics,
|
||||
handleImageError,
|
||||
|
||||
@ -24,6 +24,21 @@ export function setUserInfo(memberProfile, teamInfo = null) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单独设置团队信息缓存
|
||||
* @param {Object} teamInfo - 团队信息
|
||||
*/
|
||||
export function setTeamInfo(teamInfo) {
|
||||
teamInfoCache = teamInfo
|
||||
|
||||
// 存储到localStorage以便持久化
|
||||
if (teamInfo) {
|
||||
localStorage.setItem('teamInfo', JSON.stringify(teamInfo))
|
||||
} else {
|
||||
localStorage.removeItem('teamInfo')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息缓存
|
||||
* @returns {Object|null} 用户资料
|
||||
|
||||
@ -250,6 +250,7 @@ const {
|
||||
handleImageError,
|
||||
getAvatarPlaceholder
|
||||
} = usePageInitializationWithConfig('AGENCY_CENTER', {
|
||||
needsTeamInfo: true,
|
||||
onDataLoaded: (data) => {
|
||||
fetchTeamMemberCount()
|
||||
|
||||
|
||||
@ -151,6 +151,7 @@ const {
|
||||
handleImageError,
|
||||
getAvatarPlaceholder
|
||||
} = usePageInitializationWithConfig('BD_CENTER', {
|
||||
needsTeamInfo: true,
|
||||
onDataLoaded: () => {
|
||||
getAgentMonth()
|
||||
fetchTeamMemberCount()
|
||||
|
||||
@ -174,7 +174,9 @@ const {
|
||||
taskInfo,
|
||||
handleImageError,
|
||||
getAvatarPlaceholder
|
||||
} = usePageInitializationWithConfig('HOST_CENTER')
|
||||
} = usePageInitializationWithConfig('HOST_CENTER', {
|
||||
needsTeamInfo: true,
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user