diff --git a/pages/fillIn/fillIn.vue b/pages/fillIn/fillIn.vue index c815e90220d298d831021308e628944d8af505d0..edbedd8c743f189958c973f57ee6556eedc7faef 100644 --- a/pages/fillIn/fillIn.vue +++ b/pages/fillIn/fillIn.vue @@ -74,7 +74,7 @@ * {{index+1}}、{{item.label}} + @input="updateInputVal($event,item.value)" @blur="inputBlur($event,item)"> @@ -488,6 +488,7 @@ titleClass: 'title', placeholder: '请输入联系方式', type: 'input', + validator:validate.isPhone }, { label: '国籍', @@ -1314,6 +1315,8 @@ titleClass: 'title', placeholder: '请输入身份证号/护照号', type: 'input', + validator:validate.isIdCard + }, { label: '户籍地址', @@ -2063,6 +2066,17 @@ updateInputVal(event, props) { this.form[props] = event.target.value }, + // 输入框失去焦点 + inputBlur(e,item) { + const val = e.detail.value + if(item.validator && !item.validator(val)) { + uni.showToast({ + icon: 'none', + title: `${item.label }填写错误` + }) + } + }, + // 更新下拉框绑定的表单内容 updatePickerVal(event, item) { const opts = item.opts @@ -2087,6 +2101,13 @@ formSubmit() { let flag = true let msg = '' + if(this.form.agree != 1) { + uni.showToast({ + icon: 'none', + title: `请勾选知情同意书` + }) + return + } for (let i = 0; i < this.list.length; i++) { if (this.list[i].required) { const val = this.form[this.list[i].value] @@ -2098,6 +2119,14 @@ }) break } + if(this.list[i].validator && !this.list[i].validator(val)) { + flag = false + uni.showToast({ + icon: 'none', + title: `第${i+1}项${this.list[i].label }填写错误` + }) + break + } if (!flag) { break } @@ -2113,6 +2142,7 @@ uni.navigateBack() uni.showToast({ icon: 'success', + title:'提交成功' }) } else { uni.showToast({ diff --git a/pages/fillInDay/fillInDay.vue b/pages/fillInDay/fillInDay.vue index 783ddb7070e79a0d5b33aab0693e714bb7a895cb..beb5f1259b84f372255d4719f0a34023c755d5e2 100644 --- a/pages/fillInDay/fillInDay.vue +++ b/pages/fillInDay/fillInDay.vue @@ -820,6 +820,7 @@ uni.navigateBack() uni.showToast({ icon: 'success', + title:'提交成功' }) } else { uni.showToast({