添加了修改头像的功能

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

@ -47,7 +47,7 @@ Page({
break;
}
this.setData({ showRole });
if (options.role === 'manger') this.setData({isShowArr: [true, true, true]})
if (options.role === 'manager') this.setData({isShowArr: [true, true, true]})
else if (options.role === 'supervisor') this.setData({isShowArr: [false, true, true]})
else if (options.role === 'staff') this.setData({isShowArr: [false, false, true]})
const trueCount = this.data.isShowArr.filter(v => v === true).length;

View File

@ -157,6 +157,16 @@ Page({
wx.showToast({ title: '姓名只能为中英文', icon: 'none' });
return;
}
// 校验身份证号
const idCardReg = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
if (!idCardReg.test(idcard)) {
wx.showToast({
title: '身份证号格式不正确',
icon: 'none'
})
return ;
}
// 提交表单数据到后端
wx.request({
@ -175,7 +185,7 @@ Page({
success: res => {
console.log('后端返回的申请---->', res);
if (res.data.code === 1) {
wx.showToast({ title: '验证通过,提交成功', icon: 'success' });
wx.showToast({ title: '提交成功', icon: 'success' });
// 清空表单内容
this.setData({
@ -189,7 +199,7 @@ Page({
credential: '' // 清空凭证
});
} else {
wx.showToast({ title: '系统错误', icon: 'error' });
wx.showToast({ title: res.data.message, icon: 'none' });
}
}
});

View File

@ -54,6 +54,7 @@
bindinput="onInput"
data-field="code"
value="{{code}}"
maxlength="6"
/>
<view
class="flex-col justify-start items-center shrink-0 text-wrapper_3 ml-16"

View File

@ -9,9 +9,11 @@
padding: 67.5rpx 49.69rpx 84.38rpx 51.56rpx;
background-color: #ffffff;
width: 100%;
overflow-y: auto;
overflow-x: hidden;
height: 100%;
position: fixed;
bottom: 0;
overflow: auto;
height: calc(100vh - 1rpx);
}
.image {
width: 232.5rpx;
@ -84,7 +86,7 @@
background-color: #ffffff00;
}
.section_3 {
padding: 19.69rpx 16.88rpx;
padding: 30.69rpx 16.88rpx;
background-color: #ffffff;
border-radius: 9.38rpx;
box-shadow: 0rpx 3.75rpx 7.5rpx #00000040;
@ -169,7 +171,7 @@
padding: 13.13rpx 16.26rpx 15rpx 16.26rpx;
}
.input_2 {
padding: 16.88rpx 16.26rpx 11.25rpx 16.26rpx;
padding: 0 16.88rpx;
}
.input_3 {
padding: 16.88rpx 16.26rpx 11.25rpx 16.26rpx;

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;

View File

@ -1,4 +1,5 @@
export const local='http://localhost:9091';
export const caozhe = 'http://160.202.242.36:9093'
export const dev = 'http://160.202.242.36:9091';
export const test = 'http://160.202.242.36:9092';
export const localTest = 'http://localhost:9092';