添加了修改头像的功能

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`,
})
},

View File

@ -212,13 +212,16 @@
<view class="flex-col page">
<view class="flex-row justify-between section">
<view class="flex-row items-center self-center">
<button open-type="chooseAvatar" bind:chooseavatar="updateAvatar">
<image
class="image"
src="./images/logo.png"
src="{{globalImgUrl + userAvatar}}"
mode="aspectFill"
/>
</button>
<view class="flex-col ml-6">
<text class="self-start font text">{{ nickName }}</text>
<view class="flex-row items-center self-stretch group_2 mt-9" bind:tap="gotoCall">
<view class="flex-row items-center self-stretch group_2 mt-9" bindtap="gotoCall">
<image
class="image_3"
src="./images/dianhua.png"
@ -248,21 +251,21 @@
</view>
<view class="flex-col mt-22" >
<view class="flex-row items-start equal-division section_3" wx:if="{{ userRole != 'user' }}">
<view class="flex-col items-center equal-division-item_1 group_3" bind:tap="checkPerformance">
<view class="flex-col items-center equal-division-item_1 group_3" bindtap="checkPerformance">
<image
class="image_5"
src="./images/zhijinxiangqing.png"
/>
<text class="font text_5 mt-6">{{title}}</text>
</view>
<view class="flex-col items-center equal-division-item_2 equal-division-item" bind:tap="gotoSupervisorRank" data-userRole="{{ 'manager' }}">
<view class="flex-col items-center equal-division-item_2 equal-division-item" bindtap="gotoSupervisorRank" data-userRole="{{ 'manager' }}">
<image
class="image_5"
src="./images/tixianzhanghu.png"
/>
<text class="font text_6 mt-6">主管排名</text>
</view>
<view class="flex-col items-center equal-division-item_3 group_5" bind:tap="gotoStaffRank" data-userRole="{{ 'supervisor' }}">
<view class="flex-col items-center equal-division-item_3 group_5" bindtap="gotoStaffRank" data-userRole="{{ 'supervisor' }}">
<image
class="image_5"
src="./images/tixianjilu.png"
@ -272,7 +275,7 @@
</view>
<view class="flex-col list">
<view class="flex-row justify-between items-center section_4" wx:if="{{isShowOrder}}">
<view class="flex-row items-center" bind:tap="courseOrder">
<view class="flex-row items-center" bindtap="courseOrder">
<image
class="shrink-0 image_6"
src="./images/zhanghaoshezhi.png"
@ -284,7 +287,7 @@
src="./images/xiajiantou.png"
/>
</view>
<view class="flex-row justify-between items-center section_4 mt-11" bind:tap="gotoDashboard" wx:if="{{ userRole !== 'user' }}">
<view class="flex-row justify-between items-center section_4 mt-11" bindtap="gotoDashboard" wx:if="{{ userRole !== 'user' }}">
<view class="flex-row items-center">
<image
class="shrink-0 image_6"
@ -297,7 +300,7 @@
src="./images/xiajiantou.png"
/>
</view>
<view class="flex-row justify-between items-center section_4 mt-11" bind:tap="zhshezhi">
<view class="flex-row justify-between items-center section_4 mt-11" bindtap="zhshezhi">
<view class="flex-row items-center">
<image
class="shrink-0 image_6"

View File

@ -19,13 +19,25 @@
height: 100%;
}
.section {
padding: 15rpx 13.13rpx 26.25rpx;
padding: 15rpx 13.13rpx;
background-color: #ffffff;
border-radius: 8.33rpx;
}
.image {
width: 161.25rpx;
height: 161.25rpx;
padding: 10rpx;
width: 151.25rpx;
height: 151.25rpx;
}
button {
/* 去掉默认最小宽度 */
min-width: 0 !important;
/* 确保宽度随内容自适应 */
width: auto !important;
/* 下面是其他重置,保证“隐形” */
background: transparent !important;
border: none !important;
padding: 0 !important;
margin: 0 !important;
}
.font {
font-size: 26.25rpx;
@ -67,7 +79,7 @@
}
.group {
margin-top: 33.75rpx;
width: 163.72rpx;
width: 133.72rpx;
}
.image_2 {
margin-left: 17.48rpx;