This commit is contained in:
2025-12-12 01:44:41 +08:00
parent 21abcaff53
commit 2f1d732a36
46 changed files with 7756 additions and 484 deletions

View File

@@ -7,8 +7,8 @@
<view class="avatar-circle"></view>
</view>
<view class="user-detail">
<view class="user-name">用户名字</view>
<view class="user-id">ID: 1234565</view>
<view class="user-name">{{ userInfo.name || '用户' }}</view>
<view class="user-id">ID: {{ userInfo.id }}</view>
</view>
</view>
</view>
@@ -48,16 +48,46 @@
</template>
<script>
import userAPI from '@/api/user.js'
export default {
data() {
return {
userInfo: {
name: '用户名字',
id: '1234565'
name: '',
id: '',
phone: '',
username: ''
}
};
},
onLoad() {
this.loadUserInfo()
},
onShow() {
// 每次显示时刷新用户信息
this.loadUserInfo()
},
methods: {
/**
* 加载用户信息
*/
async loadUserInfo() {
try {
const res = await userAPI.getUserInfo()
this.userInfo = {
name: res.name || res.username || res.realName || '用户',
id: res.id || res.userId || '',
phone: res.phone || res.mobile || '',
username: res.username || res.account || ''
}
} catch (err) {
console.error('加载用户信息失败:', err)
// 失败时不显示错误提示,使用默认值
}
},
goToMyRegistration() {
uni.navigateTo({
url: '/pages/my-registration/my-registration'
@@ -69,9 +99,8 @@ export default {
});
},
handleChangePassword() {
uni.showToast({
title: '修改密码功能',
icon: 'none'
uni.navigateTo({
url: '/pages/change-password/change-password'
});
},
handleContactUs() {
@@ -86,10 +115,21 @@ export default {
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
// 清除本地存储的token
uni.removeStorageSync('token')
uni.removeStorageSync('userInfo')
uni.showToast({
title: '退出成功',
icon: 'success'
});
})
// 延迟跳转到登录页
setTimeout(() => {
uni.reLaunch({
url: '/pages/login/login'
})
}, 1500)
}
}
});