2024-12-03 11:59:36 +00:00
|
|
|
import {url} from '../request'
|
2024-12-01 11:56:54 +00:00
|
|
|
import cityList from './city';
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
cityList,
|
|
|
|
cascaderValue: ['34', '330'],
|
|
|
|
cascaderVisible: false,
|
2024-12-03 11:59:36 +00:00
|
|
|
businessName:'',
|
|
|
|
person:'',
|
|
|
|
phone:'',
|
|
|
|
idcard:'',
|
|
|
|
selectedOption:''
|
2024-12-01 11:56:54 +00:00
|
|
|
},
|
|
|
|
onLoad() {},
|
|
|
|
ruzhu(){
|
2024-12-03 11:59:36 +00:00
|
|
|
if (!this.validateForm()) {
|
|
|
|
return; // 验证未通过,阻止提交
|
|
|
|
}
|
|
|
|
my.getStorage({
|
|
|
|
key: 'userInfo',
|
|
|
|
success: (res) => {
|
|
|
|
const userInfo = res.data;
|
|
|
|
this.setData({
|
|
|
|
id: userInfo.id, // 获取 id
|
|
|
|
});
|
|
|
|
|
|
|
|
if (userInfo && userInfo.cookie) {
|
|
|
|
my.request({
|
|
|
|
url: url + '/api/manicurist/add',
|
|
|
|
method: 'POST',
|
|
|
|
data: {
|
2025-01-13 13:07:00 +00:00
|
|
|
certificate_path: this.data.zhengshu,
|
2024-12-03 11:59:36 +00:00
|
|
|
certification_number: this.data.idcard,
|
|
|
|
email: this.data.person,
|
2025-01-13 13:07:00 +00:00
|
|
|
gender: this.data.xingbie,
|
|
|
|
issuing_authority: this.data.selectedOption,
|
2024-12-17 11:46:10 +00:00
|
|
|
manicuristName: this.data.businessName,
|
2024-12-03 11:59:36 +00:00
|
|
|
phone: this.data.phone,
|
2025-01-13 13:07:00 +00:00
|
|
|
specialties: this.data.shanchang,
|
|
|
|
userId: userInfo.id
|
2024-12-03 11:59:36 +00:00
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Cookie': userInfo.cookie,
|
|
|
|
},
|
|
|
|
dataType: 'json',
|
|
|
|
success: (res) => {
|
2025-01-13 13:07:00 +00:00
|
|
|
console.log(res);
|
2024-12-17 11:46:10 +00:00
|
|
|
if(res.data.code===0){
|
|
|
|
my.navigateBack();
|
2025-01-13 13:07:00 +00:00
|
|
|
my.alert({content:'审核中请耐心等待'})
|
2024-12-17 11:46:10 +00:00
|
|
|
}
|
|
|
|
elif(res.data.code===50001)
|
|
|
|
{
|
2025-01-13 13:07:00 +00:00
|
|
|
my.alert({content:'姓名已存在或参数有误'})
|
2024-12-17 11:46:10 +00:00
|
|
|
}
|
|
|
|
elif(res.data.code===40100)
|
|
|
|
{
|
2025-01-13 13:07:00 +00:00
|
|
|
my.alert({content:'请先登录'})
|
2024-12-17 11:46:10 +00:00
|
|
|
}
|
2024-12-03 11:59:36 +00:00
|
|
|
},
|
|
|
|
fail: (error) => {
|
|
|
|
console.error('请求失败: ', JSON.stringify(error));
|
|
|
|
my.alert({ content: '请求失败,请稍后重试' });
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
my.alert({
|
|
|
|
content: '您未登录,请先登录。',
|
|
|
|
success: () => {
|
|
|
|
my.navigateTo({
|
|
|
|
url: '/pages/denglu/denglu',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-12-01 11:56:54 +00:00
|
|
|
},
|
|
|
|
businessName(e) {
|
|
|
|
this.setData({
|
|
|
|
businessName: e.detail.value,
|
|
|
|
});
|
|
|
|
console.log(e.detail.value);
|
|
|
|
},
|
2025-01-13 13:07:00 +00:00
|
|
|
shanchang(e) {
|
|
|
|
this.setData({
|
|
|
|
shanchang: e.detail.value,
|
|
|
|
});
|
|
|
|
console.log(e.detail.value);
|
|
|
|
},
|
|
|
|
xingbie(e) {
|
|
|
|
this.setData({
|
|
|
|
xingbie: e.detail.value,
|
|
|
|
});
|
|
|
|
console.log(e.detail.value);
|
|
|
|
},
|
2024-12-01 11:56:54 +00:00
|
|
|
person(e) {
|
|
|
|
this.setData({
|
|
|
|
person: e.detail.value,
|
|
|
|
});
|
|
|
|
console.log(e.detail.value);
|
|
|
|
},
|
|
|
|
phone(e) {
|
|
|
|
this.setData({
|
|
|
|
phone: e.detail.value,
|
|
|
|
});
|
|
|
|
console.log(e.detail.value);
|
|
|
|
},
|
|
|
|
idcard(e) {
|
|
|
|
this.setData({
|
|
|
|
idcard: e.detail.value,
|
|
|
|
});
|
|
|
|
console.log(e.detail.value);
|
|
|
|
},
|
|
|
|
// 选择地址的方法
|
|
|
|
handleCascaderPickerChange(cascaderValue, selectedOption, e) {
|
|
|
|
console.log('cityChange', cascaderValue, selectedOption, e);
|
|
|
|
},
|
|
|
|
handleCascaderOnOk(cascaderValue, selectedOption, e) {
|
|
|
|
console.log('cityOk', cascaderValue, selectedOption, e);
|
2024-12-03 11:59:36 +00:00
|
|
|
const selectedCityLabels = selectedOption.map(option => option.label).join(' ');
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
selectedOption: selectedCityLabels
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log('Selected cities:', this.data.selectedOption);
|
2024-12-01 11:56:54 +00:00
|
|
|
},
|
2024-12-03 11:59:36 +00:00
|
|
|
|
2024-12-01 11:56:54 +00:00
|
|
|
handleDismiss(e) {
|
|
|
|
my.showToast({
|
2024-12-03 11:59:36 +00:00
|
|
|
content: '取消操作',
|
2024-12-01 11:56:54 +00:00
|
|
|
});
|
|
|
|
console.log(e);
|
|
|
|
},
|
2024-12-03 11:59:36 +00:00
|
|
|
validateForm() {
|
|
|
|
// 验证姓名(非空)
|
|
|
|
if (!this.data.businessName) {
|
|
|
|
my.showToast({
|
|
|
|
content: '姓名不能为空',
|
|
|
|
type: 'none',
|
|
|
|
duration: 2000,
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 验证邮箱(简单的正则校验)
|
|
|
|
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
|
|
|
if (!this.data.person || !emailRegex.test(this.data.person)) {
|
|
|
|
my.showToast({
|
|
|
|
content: '请输入有效的电子邮箱',
|
|
|
|
type: 'none',
|
|
|
|
duration: 2000,
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 验证电话(简单的正则校验)
|
|
|
|
const phoneRegex = /^1[3-9]\d{9}$/;
|
|
|
|
if (!this.data.phone || !phoneRegex.test(this.data.phone)) {
|
|
|
|
my.showToast({
|
|
|
|
content: '请输入有效的手机号码',
|
|
|
|
type: 'none',
|
|
|
|
duration: 2000,
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 验证身份证号(简单的正则校验)
|
|
|
|
const idcardRegex = /^\d{17}(\d|X)$/;
|
|
|
|
if (!this.data.idcard || !idcardRegex.test(this.data.idcard)) {
|
|
|
|
my.showToast({
|
|
|
|
content: '请输入有效的身份证号',
|
|
|
|
type: 'none',
|
|
|
|
duration: 2000,
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 验证是否选择了城市
|
|
|
|
if (!this.data.selectedOption) {
|
|
|
|
my.showToast({
|
|
|
|
content: '请选择省市',
|
|
|
|
type: 'none',
|
|
|
|
duration: 2000,
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
2025-01-13 13:07:00 +00:00
|
|
|
if (!this.data.zhengshu) {
|
|
|
|
my.showToast({
|
|
|
|
content: '请选择省市',
|
|
|
|
type: 'none',
|
|
|
|
duration: 2000,
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!this.data.shanchang) {
|
|
|
|
my.showToast({
|
|
|
|
content: '请选择省市',
|
|
|
|
type: 'none',
|
|
|
|
duration: 2000,
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!this.data.xingbie) {
|
|
|
|
my.showToast({
|
|
|
|
content: '请选择省市',
|
|
|
|
type: 'none',
|
|
|
|
duration: 2000,
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
2024-12-03 11:59:36 +00:00
|
|
|
|
|
|
|
return true; // 所有验证通过
|
|
|
|
},
|
2025-01-13 13:07:00 +00:00
|
|
|
// 证明
|
|
|
|
onUpload(file) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
console.log('上传文件路径:', file); // 确保文件路径正确
|
|
|
|
my.uploadFile({
|
|
|
|
url: url + '/api/file/upload/server/not_login',
|
|
|
|
fileType: 'image',
|
|
|
|
name: 'file',
|
|
|
|
filePath: file.path,
|
|
|
|
formData: {
|
|
|
|
biz: 'card',
|
|
|
|
},
|
|
|
|
success: res => {
|
|
|
|
resolve(file.path);
|
|
|
|
console.log('上传成功:', res);
|
|
|
|
const cunchu = JSON.parse(res.data)
|
|
|
|
this.setData({
|
|
|
|
zhengshu:cunchu.data,
|
|
|
|
})
|
2025-01-21 13:56:53 +00:00
|
|
|
console.log(this.data.zhengshu,'hhhhhhhhhhhhhhh');
|
2025-01-13 13:07:00 +00:00
|
|
|
},
|
|
|
|
fail: (err) => {
|
|
|
|
console.log('上传失败:', err);
|
|
|
|
reject();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2025-01-21 13:56:53 +00:00
|
|
|
|
2024-12-01 11:56:54 +00:00
|
|
|
});
|