小程序修改代码
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({
|
||||
|
Reference in New Issue
Block a user