|
@@ -42,7 +42,8 @@ const updata_list = [
|
|
|
img: '/static/img/updata-user-img.png',
|
|
|
key: 'volunteerPicture',
|
|
|
ref: userImg,
|
|
|
- permission: [1, 2]
|
|
|
+ permission: [1, 2],
|
|
|
+ required: true
|
|
|
},
|
|
|
{
|
|
|
title: '个人身份证',
|
|
@@ -50,23 +51,26 @@ const updata_list = [
|
|
|
img: '/static/img/updata-user-img.png',
|
|
|
key: 'idCardPicture',
|
|
|
ref: zsImg,
|
|
|
- permission: [1, 2]
|
|
|
+ permission: [1, 2],
|
|
|
+ required: true
|
|
|
},
|
|
|
- // {
|
|
|
- // title: '职业、资质证书',
|
|
|
- // text: '上传您的职业、资质证书',
|
|
|
- // img: '/static/img/updata-user-img.png',
|
|
|
- // key: 'certificationPicture',
|
|
|
- // ref: zsImg,
|
|
|
- // permission: [1]
|
|
|
- // }
|
|
|
+ {
|
|
|
+ title: '职业、资质证书',
|
|
|
+ text: '上传您的职业、资质证书',
|
|
|
+ img: '/static/img/updata-user-img.png',
|
|
|
+ key: 'certificationPicture',
|
|
|
+ ref: zsImg,
|
|
|
+ permission: [1],
|
|
|
+ required: false
|
|
|
+ }
|
|
|
]
|
|
|
|
|
|
const cust_form_ref = ref(null);
|
|
|
|
|
|
const data = ref(null);
|
|
|
|
|
|
-const file_url=ref({});
|
|
|
+const file_url=reactive({});
|
|
|
+
|
|
|
|
|
|
const sex_status = {
|
|
|
'男': 0,
|
|
@@ -88,29 +92,39 @@ function onSubmit() {
|
|
|
// 校验表单并获取数据
|
|
|
// const res = await ;
|
|
|
cust_form_ref.value.onSubmit().then(async (res) => {
|
|
|
- console.log('===res===>', res);
|
|
|
- const parmas = {};
|
|
|
- for (const key in res) {
|
|
|
- parmas[key] = key == 'sex' ? sex_status[res[key]] : res[key];
|
|
|
+ console.log('===res===>', res,file_url);
|
|
|
+
|
|
|
+ //文件必传校验
|
|
|
+ for (let i = 0; i < updata_list.length; i++) {
|
|
|
+ const element = updata_list[i];
|
|
|
+ console.log(element.required , element.permission.includes(data.value.key) , file_url[element.key]);
|
|
|
+
|
|
|
+
|
|
|
+ const type = element.required && element.permission.includes(data.value.key) && !file_url[element.key];
|
|
|
+ console.log('element',element,type);
|
|
|
+
|
|
|
+ if (type) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请上传' + element.title,
|
|
|
+ icon: 'error'
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
- // const idCardPicture = await userImg.value.getFile();
|
|
|
- // idCardPicture && (parmas.idCardPicture = idCardPicture);
|
|
|
- // const volunteerPicture = await zsImg.value.getFile();
|
|
|
- // volunteerPicture && (parmas.volunteerPicture = volunteerPicture);
|
|
|
|
|
|
- console.log('xxxx', {
|
|
|
- ...parmas,
|
|
|
+ const parmas = {
|
|
|
serviceCategory: data.value.key,
|
|
|
- ...file_url.value
|
|
|
- });
|
|
|
+ ...file_url
|
|
|
+ };
|
|
|
+ for (const key in res) {
|
|
|
+ parmas[key] = key == 'sex' ? sex_status[res[key]] : res[key];
|
|
|
+ }
|
|
|
|
|
|
+ console.log('提交',parmas);
|
|
|
+
|
|
|
// return;
|
|
|
// 提交接口,注册人员
|
|
|
- const submit_res = await add({
|
|
|
- ...parmas,
|
|
|
- serviceCategory: data.value.key,
|
|
|
- ...file_url.value
|
|
|
- });
|
|
|
+ const submit_res = await add(parmas);
|
|
|
if(submit_res.code == 200){
|
|
|
uni.showToast({
|
|
|
title: '注册成功',
|
|
@@ -138,7 +152,9 @@ function onSubmit() {
|
|
|
|
|
|
function onChange({key,url}) {
|
|
|
console.log('onChange', key,url);
|
|
|
- file_url.value[key] = url;
|
|
|
+ Object.assign(file_url,{
|
|
|
+ [key]:url
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
|