mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-11 01:36:43 +08:00
校验修改
This commit is contained in:
@@ -2,6 +2,49 @@
|
||||
<div>
|
||||
<van-cell-group>
|
||||
<!-- 基本信息 -->
|
||||
<van-field
|
||||
:value="userInfo.idType | idToText('idType')"
|
||||
readonly
|
||||
label="证件类型"
|
||||
name="证件类型"
|
||||
right-icon="arrow"
|
||||
placeholder="请选择"
|
||||
@click="toSelect('2')"
|
||||
/>
|
||||
<van-field
|
||||
v-model="userInfo.customerIdNumber"
|
||||
label="证件号码"
|
||||
name="证件号码"
|
||||
placeholder="请输入"
|
||||
maxlength="18"
|
||||
@blur="getRelatedData(userInfo.customerIdNumber)"
|
||||
></van-field>
|
||||
<FieldDatePicter
|
||||
label="证件起始日期"
|
||||
name="证件起始日期"
|
||||
:value.sync="userInfo.certificateValidate"
|
||||
type="date"
|
||||
:flag="true"
|
||||
ref="certificateValidate"
|
||||
@confirm="onDateConfirm($event, '0')"
|
||||
></FieldDatePicter>
|
||||
<FieldDatePicter
|
||||
label="证件截止日期"
|
||||
name="证件截止日期"
|
||||
:value.sync="userInfo.certiexpiredate"
|
||||
type="date"
|
||||
:flag="true"
|
||||
ref="certiexpiredate"
|
||||
@confirm="onDateConfirm($event, '1')"
|
||||
></FieldDatePicter>
|
||||
<div class="van-hairline--bottom fs14 p10 clearfix">
|
||||
<van-checkbox
|
||||
v-model="userInfo.effectiveDateType"
|
||||
class="fr"
|
||||
:disabled="effectiveDateTypeAble"
|
||||
@change="isEnd"
|
||||
>长期</van-checkbox>
|
||||
</div>
|
||||
<select-radio
|
||||
:radios="sexRadio"
|
||||
label="性别"
|
||||
@@ -31,45 +74,9 @@
|
||||
:value.sync="userInfo.birthday"
|
||||
type="date"
|
||||
:flag="true"
|
||||
@confirm="onDateConfirm($event, '0')"
|
||||
@confirm="onDateConfirm($event, '2')"
|
||||
ref="birthday"
|
||||
></FieldDatePicter>
|
||||
<van-field
|
||||
:value="userInfo.idType | idToText('idType')"
|
||||
readonly
|
||||
label="证件类型"
|
||||
name="证件类型"
|
||||
right-icon="arrow"
|
||||
placeholder="请选择"
|
||||
@click="toSelect('2')"
|
||||
/>
|
||||
<van-field v-model="userInfo.customerIdNumber" label="证件号码" name="证件号码" placeholder="请输入"></van-field>
|
||||
<FieldDatePicter
|
||||
label="证件起始日期"
|
||||
name="证件起始日期"
|
||||
:value.sync="userInfo.certificateValidate"
|
||||
type="date"
|
||||
:flag="true"
|
||||
ref="certificateValidate"
|
||||
@confirm="onDateConfirm($event, '1')"
|
||||
></FieldDatePicter>
|
||||
<FieldDatePicter
|
||||
label="证件截止日期"
|
||||
name="证件截止日期"
|
||||
:value.sync="userInfo.certiexpiredate"
|
||||
type="date"
|
||||
:flag="true"
|
||||
ref="certiexpiredate"
|
||||
@confirm="onDateConfirm($event, '2')"
|
||||
></FieldDatePicter>
|
||||
<div class="van-hairline--bottom fs14 p10 clearfix">
|
||||
<van-checkbox
|
||||
v-model="userInfo.effectiveDateType"
|
||||
class="fr"
|
||||
:disabled="effectiveDateTypeAble"
|
||||
@change="isEnd"
|
||||
>长期</van-checkbox>
|
||||
</div>
|
||||
<van-field
|
||||
v-model="userInfo.email"
|
||||
label="电子邮箱"
|
||||
@@ -322,6 +329,7 @@ import areaList from '@/assets/js/utils/area'
|
||||
import utilsAge from '@/assets/js/utils/age'
|
||||
import getAreaName from '@/assets/js/utils/get-area-name'
|
||||
import idNoCheck from '@/assets/js/utils/idNoCheck'
|
||||
import { idToData } from '@/views/ebiz/customer/js/verification'
|
||||
import filter from '@/filters/index'
|
||||
import { constants } from 'crypto'
|
||||
import { userInfo } from 'os'
|
||||
@@ -428,6 +436,8 @@ export default {
|
||||
},
|
||||
//证件类型校验
|
||||
validateIdType() {
|
||||
// 计算年龄
|
||||
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
|
||||
//证件是身份证
|
||||
if (this.userInfo.idType == '1') {
|
||||
console.log('证件类型是身份证')
|
||||
@@ -437,10 +447,8 @@ export default {
|
||||
if ((parseInt(sexSign) % 2 == 0 && this.userInfo.customerSex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.customerSex != 0)) {
|
||||
return this.$toast('性别录入与身份证不符')
|
||||
}
|
||||
|
||||
//15位身份证第7-12位是生日位, 年月日
|
||||
let birthSign = this.userInfo.customerIdNumber.substr(6, 6)
|
||||
if (this.userInfo.birthday) {
|
||||
if (
|
||||
this.userInfo.birthday.substr(2, 2) != birthSign.substr(0, 2) ||
|
||||
this.userInfo.birthday.substr(5, 2) != birthSign.substr(2, 2) ||
|
||||
@@ -448,17 +456,14 @@ export default {
|
||||
) {
|
||||
return this.$toast('生日录入与身份证不符')
|
||||
}
|
||||
}
|
||||
} else if (this.userInfo.customerIdNumber.length == '18') {
|
||||
//18位身份证第17位是性别位, 奇男偶女
|
||||
let sexSign = this.userInfo.customerIdNumber.substr(16, 1)
|
||||
if ((parseInt(sexSign) % 2 == 0 && this.userInfo.customerSex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.customerSex != 0)) {
|
||||
return this.$toast('性别录入与身份证不符')
|
||||
}
|
||||
|
||||
//18位身份证第7-14位是生日位, 年月日
|
||||
let birthSign = this.userInfo.customerIdNumber.substr(6, 8)
|
||||
if (this.userInfo.birthday) {
|
||||
if (
|
||||
this.userInfo.birthday.substr(0, 4) != birthSign.substr(0, 4) ||
|
||||
this.userInfo.birthday.substr(5, 2) != birthSign.substr(4, 2) ||
|
||||
@@ -467,26 +472,58 @@ export default {
|
||||
return this.$toast('生日录入与身份证不符')
|
||||
}
|
||||
}
|
||||
}
|
||||
// // 证件号码规则校验
|
||||
// 证件号码规则校验
|
||||
if (!idNoCheck.isIdno(this.userInfo.customerIdNumber)) {
|
||||
return this.$toast('您填写的证件号码有误,只能为18位以内数字或字母组合')
|
||||
return this.$toast('您填写的证件号码有误')
|
||||
}
|
||||
//年龄在0-15周岁之间
|
||||
if (age <= 15) {
|
||||
if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1975-01-01')) {
|
||||
this.userInfo.certiexpiredate = ''
|
||||
this.$refs.certiexpiredate.date = ''
|
||||
return this.$toast('证件有效期不正常,未满16周岁的公民身份证有效期应小于等于5年')
|
||||
} else {
|
||||
//判断婚否
|
||||
if (this.userInfo.birthday && this.userInfo.marriage) {
|
||||
this.validateMarr()
|
||||
this.checkMarr()
|
||||
}
|
||||
//年龄在 16-25 周岁之间
|
||||
} else if (age >= 16 && age <= 25) {
|
||||
if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1980-01-01')) {
|
||||
this.userInfo.certiexpiredate = ''
|
||||
this.$refs.certiexpiredate.date = ''
|
||||
return this.$toast('证件有效期不正常,16周岁至25周岁公民身份证有效期应小于等于10年')
|
||||
} else {
|
||||
this.checkMarr()
|
||||
}
|
||||
//年龄在 26-45 周岁之间
|
||||
} else if (age >= 26 && age <= 45) {
|
||||
if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1990-01-01')) {
|
||||
this.userInfo.certiexpiredate = ''
|
||||
this.$refs.certiexpiredate.date = ''
|
||||
return this.$toast('证件有效期不正常,26周岁至45周岁公民身份证有效期应小于等于20年')
|
||||
} else {
|
||||
this.$parent.updateCustomerInfo()
|
||||
}
|
||||
} else {
|
||||
this.$parent.updateCustomerInfo()
|
||||
}
|
||||
//证件是户口本
|
||||
} else if (this.userInfo.idType == '2' && this.userInfo.customerIdNumber.length != 18) {
|
||||
console.log('证件类型是户口本')
|
||||
} else if (this.userInfo.idType == '2') {
|
||||
if (age >= 16) {
|
||||
return this.$toast('客户年龄在16周岁及以上,不能使用户口本作为有效证件')
|
||||
} else if (this.userInfo.customerIdNumber.length != 18) {
|
||||
return this.$toast('户口本的证件号码长度应等于18位')
|
||||
} else {
|
||||
this.checkMarr()
|
||||
}
|
||||
//证件是出生证明
|
||||
} else if (this.userInfo.idType == '3' && this.userInfo.customerIdNumber.length < 3) {
|
||||
console.log('证件类型是出生证')
|
||||
} else if (this.userInfo.idType == '3') {
|
||||
if (age >= 3) {
|
||||
return this.$toast('客户年龄在3周岁及以上,不能使用出生证作为有效证件')
|
||||
} else if (this.userInfo.customerIdNumber.length < 3) {
|
||||
return this.$toast('出生证须大于等于3个字符')
|
||||
} else {
|
||||
this.checkMarr()
|
||||
}
|
||||
//证件是护照
|
||||
} else if (this.userInfo.idType == '4' && this.userInfo.customerIdNumber.length < 3) {
|
||||
console.log('证件类型是护照')
|
||||
@@ -499,23 +536,14 @@ export default {
|
||||
} else if (!/^(H|M)[0-9]{8}$/.test(this.userInfo.customerIdNumber)) {
|
||||
return this.$toast('证件类型为港澳居民通行证的,证件号码首位字母为"H"/"M",证件号码第2位至第9位为阿拉伯数字')
|
||||
} else {
|
||||
//判断婚否
|
||||
if (this.userInfo.birthday && this.userInfo.marriage) {
|
||||
this.validateMarr()
|
||||
} else {
|
||||
this.$parent.updateCustomerInfo()
|
||||
}
|
||||
this.checkMarr()
|
||||
}
|
||||
//证件是台湾居民通行证
|
||||
} else if (this.userInfo.idType == '6' && this.userInfo.customerIdNumber.length != 8) {
|
||||
console.log('证件类型是台湾居民通行证')
|
||||
return this.$toast('证件类型为台湾居民通行证的,证件号码须为8位数字')
|
||||
} else {
|
||||
if (this.userInfo.birthday && this.userInfo.marriage) {
|
||||
this.validateMarr()
|
||||
} else {
|
||||
this.$parent.updateCustomerInfo()
|
||||
}
|
||||
this.checkMarr()
|
||||
}
|
||||
},
|
||||
//婚否校验
|
||||
@@ -531,6 +559,13 @@ export default {
|
||||
this.$parent.updateCustomerInfo()
|
||||
}
|
||||
},
|
||||
checkMarr() {
|
||||
if (this.userInfo.birthday && this.userInfo.marriage) {
|
||||
this.validateMarr()
|
||||
} else {
|
||||
this.$parent.updateCustomerInfo()
|
||||
}
|
||||
},
|
||||
censusInfo() {
|
||||
let area = [{ code: this.userInfo.province }, { code: this.userInfo.city }]
|
||||
this.census = getAreaName(area)
|
||||
@@ -551,19 +586,19 @@ export default {
|
||||
if (pickerType == '1') {
|
||||
this.columns = DataDictionary.nativeplace
|
||||
} else if (pickerType == '2') {
|
||||
if (this.userInfo.birthday) {
|
||||
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
|
||||
console.log('年纪', age)
|
||||
if (age >= 3 && age < 16) {
|
||||
this.columns = DataDictionary.birthType
|
||||
} else if (age >= 3 && age >= 16) {
|
||||
this.columns = DataDictionary.insuredIdType
|
||||
} else {
|
||||
this.columns = DataDictionary.idType
|
||||
}
|
||||
} else {
|
||||
this.columns = DataDictionary.idType
|
||||
}
|
||||
// if (this.userInfo.birthday) {
|
||||
// let age = utilsAge.getAge(this.userInfo.birthday, new Date())
|
||||
// if (age >= 3 && age < 16) {
|
||||
// this.columns = DataDictionary.birthType
|
||||
// } else if (age >= 3 && age >= 16) {
|
||||
// this.columns = DataDictionary.insuredIdType
|
||||
// } else {
|
||||
// this.columns = DataDictionary.idType
|
||||
// }
|
||||
// } else {
|
||||
// this.columns = DataDictionary.idType
|
||||
// }
|
||||
} else if (pickerType == '3') {
|
||||
this.columns = DataDictionary.degree
|
||||
// } else if (pickerType == '4') {
|
||||
@@ -588,10 +623,13 @@ export default {
|
||||
this.valueKey = value.text
|
||||
} else if (this.pickerType == '2') {
|
||||
;[this.userInfo.idType, this.idType] = [value.id, value.text]
|
||||
this.userInfo.customerIdNumber = this.userInfo.certificateValidate = this.userInfo.certiexpiredate = this.userInfo.birthday = ''
|
||||
this.userInfo.sex = '0'
|
||||
this.effectiveDateTypeAble = false
|
||||
//身份证,出生证明,护照以外的证件类型可以使用长期
|
||||
if (value.id == '1') {
|
||||
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
|
||||
this.effectiveDateTypeAble = !(age >= 45)
|
||||
this.effectiveDateTypeAble = age <= 45
|
||||
} else if (value.id == '2' || value.id == '3') {
|
||||
this.effectiveDateTypeAble = true
|
||||
} else {
|
||||
@@ -635,36 +673,9 @@ export default {
|
||||
},
|
||||
//证件起始截止日期
|
||||
onDateConfirm(val, type) {
|
||||
if (type == '0') {
|
||||
//出生日期
|
||||
if (Date.parse(val) > Date.parse(new Date())) {
|
||||
this.userInfo.birthday = ''
|
||||
this.$refs.birthday.date = ''
|
||||
return this.$toast('出生日期不晚于当日')
|
||||
}
|
||||
//长期判断
|
||||
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
|
||||
if (this.userInfo.idType == '1') {
|
||||
this.effectiveDateTypeAble = !(age >= 45)
|
||||
if (age < 45) {
|
||||
this.userInfo.effectiveDateType = false
|
||||
}
|
||||
}
|
||||
//年龄大于等于3岁不能使用出生证明
|
||||
if (age >= 3) {
|
||||
if (this.userInfo.idType == '3') {
|
||||
this.userInfo.idType = ''
|
||||
this.$toast('请选择正确的证件类型')
|
||||
}
|
||||
}
|
||||
//年龄大于等于16岁不能使用户口本
|
||||
if (age >= 16) {
|
||||
if (this.userInfo.idType == '2') {
|
||||
this.userInfo.idType = ''
|
||||
this.$toast('请选择正确的证件类型')
|
||||
}
|
||||
}
|
||||
} else if (type == '1') {
|
||||
switch (type) {
|
||||
case '0':
|
||||
{
|
||||
//证件起始日期
|
||||
//如果录入日期早于出生日期或晚于当前日期
|
||||
if (Date.parse(val) > Date.parse(new Date()) || Date.parse(val) < Date.parse(this.userInfo.birthday)) {
|
||||
@@ -676,10 +687,10 @@ export default {
|
||||
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
|
||||
// 长期按钮是否禁用
|
||||
this.effectiveDateTypeAble = age <= 45
|
||||
// if(age < 45){
|
||||
// this.userInfo.effectiveDateType = false
|
||||
// }
|
||||
} else {
|
||||
}
|
||||
break
|
||||
case '1':
|
||||
{
|
||||
//证件截止日期
|
||||
//如果已经勾选了长期
|
||||
if (this.userInfo.effectiveDateType) {
|
||||
@@ -695,6 +706,32 @@ export default {
|
||||
return this.$toast('您的证件已过期')
|
||||
}
|
||||
}
|
||||
break
|
||||
case '2':
|
||||
{
|
||||
//出生日期
|
||||
//如果录入日期晚于当前日期
|
||||
if (Date.parse(val) > Date.parse(new Date())) {
|
||||
this.userInfo.birthday = ''
|
||||
this.$refs.birthday.date = ''
|
||||
return this.$toast('出生日期不晚于当日')
|
||||
}
|
||||
//长期判断
|
||||
if (this.userInfo.idType == '1') {
|
||||
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
|
||||
this.effectiveDateTypeAble = age <= 45
|
||||
}
|
||||
//出生证有效期
|
||||
if (this.userInfo.idType == '3') {
|
||||
if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(val) > Date.parse('1973-01-01')) {
|
||||
this.userInfo.birthday = ''
|
||||
this.$refs.birthday.date = ''
|
||||
return this.$toast('出生证有效期或出生日期有误')
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
},
|
||||
//长期状态改变时
|
||||
isEnd(val) {
|
||||
@@ -707,6 +744,30 @@ export default {
|
||||
this.certiexpiredateRequired = true
|
||||
sessionStorage.setItem('isEnd', '')
|
||||
}
|
||||
},
|
||||
isEndFlag() {
|
||||
let idType = sessionStorage.getItem('idType')
|
||||
let birthday = sessionStorage.getItem('birthday')
|
||||
let age = utilsAge.getAge(birthday, new Date())
|
||||
if (idType == '1') {
|
||||
this.effectiveDateTypeAble = age <= 45
|
||||
} else if (idType == '2' || idType == '3') {
|
||||
this.effectiveDateTypeAble = true
|
||||
}
|
||||
},
|
||||
getRelatedData(val) {
|
||||
if (this.userInfo.idType != '1') {
|
||||
return
|
||||
}
|
||||
//如果证件校验不通过,恢复默认值
|
||||
if (idToData(val).text) {
|
||||
;[this.userInfo.customerSex, this.userInfo.birthday, this.effectiveDateTypeAble] = ['0', '', false]
|
||||
return this.$toast(idToData(val).text)
|
||||
}
|
||||
this.userInfo.effectiveDateType = false
|
||||
this.effectiveDateTypeAble = idToData(val).age < 45
|
||||
this.userInfo.birthday = idToData(val).birthday
|
||||
this.userInfo.customerSex = idToData(val).sex
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,6 +178,9 @@ export default {
|
||||
$this.userInfo.homeProvince = result.homeProvince
|
||||
$this.userInfo.homeCity = result.homeCity
|
||||
$this.userInfo.homeArea = result.homeArea
|
||||
sessionStorage.setItem('birthday', result.birthday)
|
||||
sessionStorage.setItem('idType', result.customerIdType)
|
||||
this.$refs.formBlock.isEndFlag()
|
||||
//查询职业名称
|
||||
// occupationList.forEach(first => {
|
||||
// first.subs.forEach(second => {
|
||||
|
||||
47
src/views/ebiz/customer/js/verification.js
Normal file
47
src/views/ebiz/customer/js/verification.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import changeFifteenToEighteen from '@/assets/js/utils/changeFifteenToEighteen'
|
||||
import idNoCheck from '@/assets/js/utils/idNoCheck'
|
||||
import utilsAge from '@/assets/js/utils/age'
|
||||
|
||||
//身份证带出出生日期,性别,年龄
|
||||
export function idToData(idNo) {
|
||||
// 证件号码规则校验
|
||||
if (idNo && !idNoCheck.isIdno(idNo)) {
|
||||
return {
|
||||
text: '您填写的证件号码有误'
|
||||
}
|
||||
}
|
||||
|
||||
//如果是15位身份证号先转为18位
|
||||
if (idNo && idNo.length == 15) {
|
||||
idNo = changeFifteenToEighteen(idNo)
|
||||
}
|
||||
let birthday = getBirthById(idNo)
|
||||
let age = utilsAge.getAge(birthday, new Date())
|
||||
let sex = getSexById(idNo)
|
||||
return {
|
||||
birthday,
|
||||
age,
|
||||
sex
|
||||
}
|
||||
}
|
||||
|
||||
function getBirthById(idNo) {
|
||||
// 获取生日
|
||||
if (idNo) {
|
||||
var year = idNo.substr(6, 4)
|
||||
var month = idNo.substr(10, 2)
|
||||
var day = idNo.substr(12, 2)
|
||||
return year + '-' + month + '-' + day
|
||||
}
|
||||
}
|
||||
|
||||
function getSexById(idNo) {
|
||||
// 获取性别
|
||||
if (idNo.charAt(16) >= '0' && idNo.charAt(16) <= '9') {
|
||||
if (parseInt(idNo.charAt(16)) % 2 == 0) {
|
||||
return '1'
|
||||
} else {
|
||||
return '0'
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user