小程序修改代码
This commit is contained in:
@ -58,22 +58,35 @@ Page({
|
||||
// 搜索按钮点击
|
||||
onSearch() {
|
||||
const { role } = this.data;
|
||||
// 校验:确保主管名称、手机号和排序条件不能为空
|
||||
if (!this.data.nickName || !this.data.phoneNumber) {
|
||||
wx.showToast({
|
||||
title: '主管名称和手机号不能为空',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
// —— 新增:校验主管名称 ——
|
||||
const nameRegex = /^[\u4e00-\u9fa5]+$/;
|
||||
if (!this.data.nickName) {
|
||||
wx.showToast({ title: '主管名称不能为空', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (!nameRegex.test(this.data.nickName)) {
|
||||
wx.showToast({ title: '主管名称只能为汉字', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.data.selectedSortField === '待选择') {
|
||||
wx.showToast({
|
||||
title: '排序条件不能为空',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
// —— 新增:校验手机号 ——
|
||||
if (!this.data.phoneNumber) {
|
||||
wx.showToast({ title: '手机号不能为空', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (this.data.phoneNumber.length < 11) {
|
||||
wx.showToast({ title: '手机号不够11位', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
// 原排序条件校验,保持不变
|
||||
if (this.data.selectedSortField === '待选择') {
|
||||
wx.showToast({
|
||||
title: '排序条件不能为空',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示加载中
|
||||
wx.showLoading({
|
||||
|
@ -20,7 +20,7 @@ Page({
|
||||
onSearch() {
|
||||
const nickName = this.data.nickName.trim();
|
||||
const phoneNumber = this.data.phoneNumber.trim();
|
||||
const supervisorUserId = this.data;
|
||||
const { supervisorUserId } = this.data;
|
||||
|
||||
if (!nickName) {
|
||||
wx.showToast({ title: '请输入主管名称', icon: 'none' });
|
||||
@ -37,7 +37,11 @@ Page({
|
||||
header: {
|
||||
Authorization: wx.getStorageSync('token')
|
||||
},
|
||||
data: { nickName, phoneNumber, supervisorUserId},
|
||||
data: {
|
||||
nickName: nickName,
|
||||
phoneNumber: phoneNumber,
|
||||
supervisorUserId: supervisorUserId,
|
||||
},
|
||||
success: (res) => {
|
||||
console.log('--->后端返回记录',res.data);
|
||||
if (res.data.code === 1) {
|
||||
@ -105,7 +109,7 @@ Page({
|
||||
onLoad(options) {
|
||||
console.log('--->',options);
|
||||
this.setData({
|
||||
supervisorUserId: options.supId,
|
||||
supervisorUserId: options.id,
|
||||
})
|
||||
this.onSearchSupId();
|
||||
},
|
||||
|
@ -8,6 +8,7 @@ Page({
|
||||
showList: false, // 是否显示绩效列表
|
||||
performanceList: [], // 绩效列表数据,含 ratePercent 字段
|
||||
userRole: '', // 用户角色
|
||||
id: 0,
|
||||
},
|
||||
|
||||
onNameInput(e) {
|
||||
@ -20,6 +21,7 @@ Page({
|
||||
onSearch() {
|
||||
const nickName = this.data.nickName.trim();
|
||||
const phoneNumber = this.data.phoneNumber.trim();
|
||||
const { id } = this.data
|
||||
|
||||
if (!nickName) {
|
||||
wx.showToast({ title: '请输入主管名称', icon: 'none' });
|
||||
@ -36,7 +38,10 @@ Page({
|
||||
header: {
|
||||
Authorization: wx.getStorageSync('token')
|
||||
},
|
||||
data: { nickName, phoneNumber },
|
||||
data: {
|
||||
nickName: nickName,
|
||||
phoneNumber: phoneNumber,
|
||||
},
|
||||
success: (res) => {
|
||||
console.log('--->后端返回记录',res.data);
|
||||
if (res.data.code === 1) {
|
||||
@ -71,7 +76,8 @@ Page({
|
||||
onLoad(options) {
|
||||
console.log('--->',options);
|
||||
this.setData({
|
||||
userRole: options.role
|
||||
userRole: options.role,
|
||||
id: options.id,
|
||||
})
|
||||
let showRole = '';
|
||||
switch (options.role) {
|
||||
|
Reference in New Issue
Block a user