From d59584fc280e96cd1e577bd4e6983c34af3e748d Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Fri, 22 Aug 2025 11:26:50 +0800 Subject: [PATCH] =?UTF-8?q?bd=20=E9=A1=B5=E9=9D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/http.js | 7 ----- src/views/BDCenterView.vue | 52 ++++++++++++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/utils/http.js b/src/utils/http.js index c18b3fc..632b2e7 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -135,9 +135,6 @@ export async function request(url, options = {}) { } try { - if (DEBUG_MODE) { - console.log('🚀 API Request:', fullUrl, JSON.stringify(config.headers)) - } const response = await fetch(fullUrl, config) @@ -158,10 +155,6 @@ export async function request(url, options = {}) { const result = await response.json() - if (DEBUG_MODE) { - console.log('✅ API Response:', result) - } - // 检查业务状态 if (result.status === false) { throw new ApiError(result.errorMsg || result.message || `API Error: ${result.errorCode}`, { diff --git a/src/views/BDCenterView.vue b/src/views/BDCenterView.vue index 1fdfca1..33235f4 100644 --- a/src/views/BDCenterView.vue +++ b/src/views/BDCenterView.vue @@ -15,7 +15,13 @@
- {{ (userInfo.userNickname || userInfo.name).charAt(0) }} + + {{ getAvatarPlaceholder() }}

{{ userInfo.userNickname || userInfo.name }}

@@ -163,16 +169,15 @@ const connectToApp = async () => { // 用户信息 const userInfo = reactive({ - name: 'User1', - id: '1234567890', - userNickname: 'User1', - account: '1234567890' + userNickname: '', + id: '', + userAvatar: '', }) // 薪资信息 const salaryInfo = reactive({ - lastMonth: '12345', - thisMonth: '12345' + lastMonth: '', + thisMonth: '' }) // 获取团队成员数量 @@ -228,7 +233,8 @@ const fetchTeamEntry = async () => { // 更新用户信息显示 userInfo.userNickname = response.body.memberProfile.userNickname - userInfo.account = response.body.memberProfile.account + userInfo.id = response.body.memberProfile.account + userInfo.userAvatar = response.body.memberProfile.userAvatar } // 获取用户ID后检查身份 @@ -314,10 +320,25 @@ const transfer = () => { router.push('/transfer') } +// 处理头像图片加载失败 +const handleImageError = (event) => { + // 图片加载失败时,清空userAvatar,显示占位符 + userInfo.userAvatar = '' +} + +// 获取头像占位符(用户名首字母) +const getAvatarPlaceholder = () => { + if (userInfo.name && userInfo.name.length > 0) { + return userInfo.name.charAt(0).toUpperCase() + } + return 'U' // 默认显示 'U' +} + // 页面加载时先连接APP,然后获取数据 onMounted(async () => { // 先连接APP获取认证信息 await connectToApp() + await fetchTeamEntry() await getAgentMonth() await fetchTeamMemberCount() }) @@ -403,6 +424,21 @@ onMounted(async () => { font-size: 20px; font-weight: 600; margin-right: 12px; + overflow: hidden; + position: relative; +} + +.avatar img { + width: 100%; + height: 100%; + object-fit: cover; + border-radius: 25px; +} + +.avatar .avatar-placeholder { + color: white; + font-size: 20px; + font-weight: 600; } .user-details {