Commit d4d0284a authored by lrw's avatar lrw

手机、身份证 检验

parent bde3dd45
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
<span style="color:red;display: inline-block; vertical-align:inherit;margin-right:4upx" v-if="item.required">*</span> <span style="color:red;display: inline-block; vertical-align:inherit;margin-right:4upx" v-if="item.required">*</span>
{{index+1}}{{item.label}}</view> {{index+1}}{{item.label}}</view>
<input class="text-right" :placeholder="item.placeholder" :type="item.controType" :value="form[item.value]" name="input" <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> </view>
</template> </template>
<view class="margin-top-xs" v-show="item.child && childItem.show" v-for="(childItem,childIndex) in item.child" :key="childItem.value"> <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 @@ ...@@ -488,6 +488,7 @@
titleClass: 'title', titleClass: 'title',
placeholder: '请输入联系方式', placeholder: '请输入联系方式',
type: 'input', type: 'input',
validator:validate.isPhone
}, },
{ {
label: '国籍', label: '国籍',
...@@ -1314,6 +1315,8 @@ ...@@ -1314,6 +1315,8 @@
titleClass: 'title', titleClass: 'title',
placeholder: '请输入身份证号/护照号', placeholder: '请输入身份证号/护照号',
type: 'input', type: 'input',
validator:validate.isIdCard
}, },
{ {
label: '户籍地址', label: '户籍地址',
...@@ -2063,6 +2066,17 @@ ...@@ -2063,6 +2066,17 @@
updateInputVal(event, props) { updateInputVal(event, props) {
this.form[props] = event.target.value 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) { updatePickerVal(event, item) {
const opts = item.opts const opts = item.opts
...@@ -2087,6 +2101,13 @@ ...@@ -2087,6 +2101,13 @@
formSubmit() { formSubmit() {
let flag = true let flag = true
let msg = '' let msg = ''
if(this.form.agree != 1) {
uni.showToast({
icon: 'none',
title: `请勾选知情同意书`
})
return
}
for (let i = 0; i < this.list.length; i++) { for (let i = 0; i < this.list.length; i++) {
if (this.list[i].required) { if (this.list[i].required) {
const val = this.form[this.list[i].value] const val = this.form[this.list[i].value]
...@@ -2098,6 +2119,14 @@ ...@@ -2098,6 +2119,14 @@
}) })
break 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) { if (!flag) {
break break
} }
...@@ -2113,6 +2142,7 @@ ...@@ -2113,6 +2142,7 @@
uni.navigateBack() uni.navigateBack()
uni.showToast({ uni.showToast({
icon: 'success', icon: 'success',
title:'提交成功'
}) })
} else { } else {
uni.showToast({ uni.showToast({
......
...@@ -820,6 +820,7 @@ ...@@ -820,6 +820,7 @@
uni.navigateBack() uni.navigateBack()
uni.showToast({ uni.showToast({
icon: 'success', icon: 'success',
title:'提交成功'
}) })
} else { } else {
uni.showToast({ 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