diff --git a/pages/profile/profile.vue b/pages/profile/profile.vue index 78c9922..2f83b3c 100644 --- a/pages/profile/profile.vue +++ b/pages/profile/profile.vue @@ -154,6 +154,7 @@ export default { rentAmount: 0, }, loading: false, + isAgent: false, } }, onLoad() { @@ -181,6 +182,7 @@ export default { this.fetchUserInfo(), this.fetchFinancialData(), this.fetchUserStats(), + this.getIsAgent(), ]) // 处理用户信息 @@ -232,16 +234,15 @@ export default { return response } catch (error) { console.error('获取用户信息失败:', error) - // 如果获取失败,使用默认数据 - return { - code: 200, - data: { - nickName: '昵称', - phonenumber: '123****1234', - avatar: '', - userId: '1', - }, - } + } + }, + + async getIsAgent() { + try { + const response = await isAgent() + this.isAgent = response.data + } catch (error) { + console.error('获取是否是代理失败:', error) } }, @@ -252,16 +253,6 @@ export default { return response } catch (error) { console.error('获取财务数据失败:', error) - // 如果获取失败,使用默认数据 - return { - code: 200, - data: { - balance: 0, - waitBalance: 0, - withdrawBalance: 0, - withdrawedBalance: 0, - }, - } } }, @@ -350,8 +341,7 @@ export default { }, async goToUserList() { - const response = await isAgent() - if (response.data) { + if (this.isAgent) { uni.navigateTo({ url: '/pages/useList/useList', }) @@ -364,8 +354,7 @@ export default { }, async goToSharePromotion() { - const response = await isAgent() - if (response.data) { + if (this.isAgent) { uni.navigateTo({ url: '/pages/agents/requestAgent', })