Commit d4d0284a authored by lrw's avatar lrw

手机、身份证 检验

parent bde3dd45
......@@ -74,7 +74,7 @@
<span style="color:red;display: inline-block; vertical-align:inherit;margin-right:4upx" v-if="item.required">*</span>
{{index+1}}{{item.label}}</view>
<input class="text-right" :placeholder="item.placeholder" :type="item.controType" :value="form[item.value]" name="input"
@input="updateInputVal($event,item.value)"></input>
@input="updateInputVal($event,item.value)" @blur="inputBlur($event,item)"></input>
</view>
</template>
<view class="margin-top-xs" v-show="item.child && childItem.show" v-for="(childItem,childIndex) in item.child" :key="childItem.value">
......@@ -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({
......
......@@ -820,6 +820,7 @@
uni.navigateBack()
uni.showToast({
icon: 'success',
title:'提交成功'
})
} else {
uni.showToast({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment