2024-12-01 11:56:54 +00:00
|
|
|
|
import cityList from './city';
|
2025-01-13 13:07:00 +00:00
|
|
|
|
import {url} from '../request'
|
2024-11-10 07:01:22 +00:00
|
|
|
|
Page({
|
2024-11-19 10:12:40 +00:00
|
|
|
|
data: {
|
2024-12-01 11:56:54 +00:00
|
|
|
|
cityList,
|
|
|
|
|
cascaderValue: ['34', '330'],
|
|
|
|
|
cascaderVisible: false,
|
2024-11-19 10:12:40 +00:00
|
|
|
|
},
|
2024-11-10 07:01:22 +00:00
|
|
|
|
onLoad() {},
|
2024-11-19 10:12:40 +00:00
|
|
|
|
ruzhu(){
|
2025-01-13 13:07:00 +00:00
|
|
|
|
if (!this.validateForm()) {
|
|
|
|
|
return; // 验证未通过,阻止提交
|
|
|
|
|
}
|
|
|
|
|
my.request({
|
|
|
|
|
url: url+'/api/business/add',
|
|
|
|
|
method: 'POST',
|
|
|
|
|
data: {
|
|
|
|
|
address: this.data.selectedOption,
|
|
|
|
|
backIdCard: this.data.backIdCard,
|
|
|
|
|
businessName: this.data.businessName,
|
|
|
|
|
businessPhone: this.data.phone,
|
|
|
|
|
frontIdCard:this.data.frontIdCard,
|
|
|
|
|
license: this.data.yingyeimage,
|
|
|
|
|
shopkeeper: this.data.person,
|
|
|
|
|
userAccount: this.data.userAccount,
|
|
|
|
|
userPassword: this.data.userPassword
|
|
|
|
|
},
|
|
|
|
|
headers: {
|
|
|
|
|
'content-type': 'application/json', //默认值
|
|
|
|
|
},
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: (res)=> {
|
|
|
|
|
console.log(res);
|
|
|
|
|
my.alert({ content: '正在审核中,请耐心等待' });
|
|
|
|
|
my.navigateBack()
|
|
|
|
|
},
|
|
|
|
|
fail: function (error) {
|
|
|
|
|
console.error('fail: ', JSON.stringify(error));
|
|
|
|
|
},
|
|
|
|
|
});
|
2024-11-19 10:12:40 +00:00
|
|
|
|
},
|
2025-01-13 13:07:00 +00:00
|
|
|
|
// 获取数据
|
2024-11-19 10:12:40 +00:00
|
|
|
|
businessName(e) {
|
|
|
|
|
this.setData({
|
|
|
|
|
businessName: e.detail.value,
|
|
|
|
|
});
|
|
|
|
|
console.log(e.detail.value);
|
|
|
|
|
},
|
|
|
|
|
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);
|
|
|
|
|
},
|
2025-01-13 13:07:00 +00:00
|
|
|
|
// idcard(e) {
|
|
|
|
|
// this.setData({
|
|
|
|
|
// idcard: e.detail.value,
|
|
|
|
|
// });
|
|
|
|
|
// console.log(e.detail.value);
|
|
|
|
|
// },
|
|
|
|
|
userAccount(e) {
|
|
|
|
|
this.setData({
|
|
|
|
|
userAccount: e.detail.value,
|
|
|
|
|
});
|
|
|
|
|
console.log(e.detail.value);
|
|
|
|
|
},
|
|
|
|
|
userPassword(e) {
|
2024-11-19 10:12:40 +00:00
|
|
|
|
this.setData({
|
2025-01-13 13:07:00 +00:00
|
|
|
|
userPassword: e.detail.value,
|
2024-11-19 10:12:40 +00:00
|
|
|
|
});
|
|
|
|
|
console.log(e.detail.value);
|
|
|
|
|
},
|
2025-01-13 13:07:00 +00:00
|
|
|
|
// 地点选择
|
|
|
|
|
handleCascaderPickerChange(cascaderValue, selectedOption, e) {
|
|
|
|
|
console.log('cityChange', cascaderValue, selectedOption, e);
|
|
|
|
|
},
|
|
|
|
|
handleCascaderOnOk(cascaderValue, selectedOption, e) {
|
|
|
|
|
console.log('cityOk', cascaderValue, selectedOption, e);
|
|
|
|
|
const selectedCityLabels = selectedOption.map(option => option.label).join(' ');
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
selectedOption: selectedCityLabels
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log('Selected cities:', this.data.selectedOption);
|
|
|
|
|
},
|
|
|
|
|
// 前端校验
|
|
|
|
|
validateForm() {
|
|
|
|
|
// 验证店铺名(非空)
|
|
|
|
|
if (!this.data.businessName) {
|
|
|
|
|
my.showToast({
|
|
|
|
|
content: '店铺名不能为空',
|
|
|
|
|
type: 'none',
|
|
|
|
|
duration: 2000,
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!this.data.userPassword&&this.data.userPassword.length>=8) {
|
|
|
|
|
my.showToast({
|
|
|
|
|
content: '密码不能为空,并且不少于8位',
|
|
|
|
|
type: 'none',
|
|
|
|
|
duration: 2000,
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!this.data.userAccount) {
|
|
|
|
|
my.showToast({
|
|
|
|
|
content: '账号不能为空',
|
|
|
|
|
type: 'none',
|
|
|
|
|
duration: 2000,
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!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;
|
|
|
|
|
}
|
|
|
|
|
// 验证图片是否上传
|
|
|
|
|
if (!this.data.yingyeimage) {
|
|
|
|
|
my.showToast({
|
|
|
|
|
content: '请上传营业执照',
|
|
|
|
|
type: 'none',
|
|
|
|
|
duration: 2000,
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.data.frontIdCard) {
|
|
|
|
|
my.showToast({
|
|
|
|
|
content: '请上传身份证正面照',
|
|
|
|
|
type: 'none',
|
|
|
|
|
duration: 2000,
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.data.backIdCard) {
|
|
|
|
|
my.showToast({
|
|
|
|
|
content: '请上传身份证反面照',
|
|
|
|
|
type: 'none',
|
|
|
|
|
duration: 2000,
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true; // 所有验证通过
|
|
|
|
|
},
|
|
|
|
|
onChange(fileList) {
|
|
|
|
|
|
|
|
|
|
console.log('图片列表:', fileList);
|
|
|
|
|
},
|
|
|
|
|
// 营业执照
|
|
|
|
|
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({
|
|
|
|
|
yingyeimage:cunchu.data,
|
|
|
|
|
})
|
|
|
|
|
console.log(this.data.yingyeimage,'hhhhhhhhhhhhhhh');
|
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
console.log('上传失败:', err);
|
|
|
|
|
reject();
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 身份证正面
|
|
|
|
|
onUpload1(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({
|
|
|
|
|
frontIdCard:cunchu.data,
|
|
|
|
|
})
|
|
|
|
|
console.log(this.data.yingyeimage,'hhhhhhhhhhhhhhh');
|
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
console.log('上传失败:', err);
|
|
|
|
|
reject();
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 身份证反面
|
|
|
|
|
onUpload2(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({
|
|
|
|
|
backIdCard:cunchu.data,
|
|
|
|
|
})
|
|
|
|
|
console.log(this.data.yingyeimage,'hhhhhhhhhhhhhhh');
|
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
console.log('上传失败:', err);
|
|
|
|
|
reject();
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
2024-11-10 07:01:22 +00:00
|
|
|
|
});
|