添加了修改头像的功能

This commit is contained in:
2025-08-08 13:48:37 +08:00
parent 990f1850b1
commit 85df7bfc4e
8 changed files with 107 additions and 27 deletions

View File

@ -20,15 +20,67 @@ Page({
userRole: "",
title: '查看绩效',
id: 0,
globalImgUrl
},
// 跳转课程订单页面
courseOrder() {
wx.navigateTo({
url: '/pages/course/courseOrderList/courseOrderList',
})
},
updateAvatar(e) {
const { avatarUrl } = e.detail
this.uploadAvatar(avatarUrl)
},
uploadAvatar(filePath) {
wx.showLoading({ title: '上传中...' });
wx.uploadFile({
url: baseUrl + '/file/upload',
filePath,
name: 'file',
formData: {
biz: 'default'
},
success: res => {
wx.hideLoading();
let result = JSON.parse(res.data);
console.log(result)
if (result.code === 1) {
this.setData({userAvatar: result.data})
this.updateUserInfo(result.data)
} else {
wx.showToast({
title: result.message || '上传失败',
icon: 'none'
});
}
},
fail: err => {
wx.hideLoading();
console.error('uploadFile fail', err);
wx.showToast({ title: '网络错误,上传失败', icon: 'none' });
}
});
},
updateUserInfo(view) {
const token = wx.getStorageSync('token')
wx.request({
url: baseUrl + '/userInfo/modify/avatar',
method: 'POST',
header: {
Authorization: token
},
data: {
templateString: view
},
success: res => {
console.log(res.data)
},
fail: err => {
wx.showToast({ title: '用户头像更新失败', icon: 'none' });
}
})
},
// 跳转结算记录页面
gotoSettlementRecord() {
wx.navigateTo({
@ -142,7 +194,6 @@ Page({
let result = res.data.data
this.setData({
nickName: result.nickName,
// TODO 头像未连接
userAvatar: result.userAvatar,
phoneNumber: result.phoneNumber,
userAccount: result.userAccount,
@ -214,10 +265,10 @@ Page({
// 跳转主管排名
gotoSupervisorRank(e) {
console.log(e);
console.log(e)
const {userRole} = this.data
console.log('========fds===>', userRole)
if (userRole === 'staff' || userRole === 'user') {
console.log('===========>', userRole)
if (userRole === 'staff') {
wx.showToast({
title: '无权限',
icon: 'error'
@ -225,7 +276,7 @@ Page({
return ;
}
wx.navigateTo({
url: `/pages/dashboardModule/performanceRanking/performanceRanking?role=${userRole}`,
url: `/pages/dashboardModule/performanceRanking/performanceRanking?role=manager`,
})
},
@ -242,7 +293,7 @@ Page({
return ;
}
wx.navigateTo({
url: `/pages/dashboardModule/performanceRanking/performanceRanking?role=${userRole}`,
url: `/pages/dashboardModule/performanceRanking/performanceRanking?role=staff`,
})
},