From 4fbb0e9470d07097b308c3b57877ed6cfcd2163e Mon Sep 17 00:00:00 2001 From: "liu.xiaofeng@ebiz-digits.com" Date: Mon, 22 Jan 2024 11:35:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=95=E8=A2=AB=E5=8F=97=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=A7=84=E5=88=99=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ebiz/sale/AddBeneficiaryInfo.vue | 25 ++- src/views/ebiz/sale/InsuredInfo.vue | 30 ++-- src/views/ebiz/sale/InsuredPerson.vue | 25 ++- src/views/ebiz/sale/js/verification.js | 171 ++++++++++++++++----- 4 files changed, 190 insertions(+), 61 deletions(-) diff --git a/src/views/ebiz/sale/AddBeneficiaryInfo.vue b/src/views/ebiz/sale/AddBeneficiaryInfo.vue index dcaa65f4b..dd6896545 100644 --- a/src/views/ebiz/sale/AddBeneficiaryInfo.vue +++ b/src/views/ebiz/sale/AddBeneficiaryInfo.vue @@ -247,7 +247,7 @@ import utilsAge from '@/assets/js/utils/age' import IdentityCardScan from '@/components/ebiz/sale/IdentityCardScan' import CustomerPicker from '@/components/ebiz/customer/CustomerPicker' import idNoCheck from '@/assets/js/utils/idNoCheck' -import { idToData } from './js/verification' +import {idNoCheck8, idToData} from './js/verification' import { selectComp } from './js/methods' import getAreaName from '@/assets/js/utils/getAreaNameForSale' import { getOrderDetail, checkAppointBnf } from '@/api/ebiz/sale/sale' @@ -961,7 +961,8 @@ export default { } } //证件类型是户口本 - } else if (this.userInfo.idType == '2') { + } + else if (this.userInfo.idType == '2') { if (age >= 16) { return this.$toast('客户年龄在16周岁以上,不能使用户口本作为有效证件') } @@ -1009,7 +1010,8 @@ export default { return this.$toast('您填写的证件号码有误') } //证件类型是出生证明 - } else if (this.userInfo.idType == '3') { + } + else if (this.userInfo.idType == '3') { if (age >= 2) { return this.$toast('客户年龄在2周岁及以上,不能使用出生证作为有效证件') } @@ -1019,20 +1021,29 @@ export default { return this.$toast('您填写的证件号码有误') } //证件类型是护照 - } else if (this.userInfo.idType == '4') { + } + else if (this.userInfo.idType == '4') { if (this.userInfo.nativeplace == '1') { return this.$toast('“证件类型”为“外国人护照”,“国籍”不能选择为“中国”哦~') } - } else if (this.userInfo.idType == '5') { + } + else if (this.userInfo.idType == '5') { console.log(this.userInfo.nativeplace, 'nativeplace') if (this.userInfo.nativeplace != '2' && this.userInfo.nativeplace != '3') { return this.$toast('“证件类型”为“港澳居民来往内地通行证”,“国籍”请选择“中国香港”或“中国澳门”哦~') } - } else if (this.userInfo.idType == '6') { + } + else if (this.userInfo.idType == '6') { if (this.userInfo.nativeplace != '4') { return this.$toast('“证件类型”为“台湾居民来往大陆通行证”,“国籍”请选择“中国台湾”~') } - } else if (this.userInfo.idType == '9') { + } + else if (this.userInfo.idType == '8') { + if (idNoCheck8(this.userInfo).text){ + return this.$toast(idNoCheck8(this.userInfo).text) + } + } + else if (this.userInfo.idType == '9') { if (this.userInfo.nativeplace != '2' && this.userInfo.nativeplace != '3' && this.userInfo.nativeplace != '4') { return this.$toast('“证件类型”为“港澳台居民居住证”,“国籍”请选择“中国香港”、“中国澳门”或“中国台湾”~') } diff --git a/src/views/ebiz/sale/InsuredInfo.vue b/src/views/ebiz/sale/InsuredInfo.vue index 11fd8d5eb..d14ffaedd 100644 --- a/src/views/ebiz/sale/InsuredInfo.vue +++ b/src/views/ebiz/sale/InsuredInfo.vue @@ -460,7 +460,7 @@ import IdentityCardScan from '@/components/ebiz/sale/IdentityCardScan' import idNoCheck from '@/assets/js/utils/idNoCheck' import beforeDate from '@/assets/js/utils/getBeforeDate.js' - import { idToData } from './js/verification' + import { idToData, idNoCheck8 } from './js/verification' import { selectComp, getIdentityInfo } from './js/methods' import SearchField from '@/components/common/SearchField' import riskRules from '@/views/ebiz/common/risk-rules' @@ -1241,28 +1241,39 @@ } } //证件类型是户口本 - } else if (this.userInfo.idType == '2') { + } + else if (this.userInfo.idType == '2') { if (age > 16) { return this.$toast('客户年龄在16周岁以上,不能使用户口本作为有效证件') } - } else if (this.userInfo.idType == '3') { + } + else if (this.userInfo.idType == '3') { if (age >= 2) { return this.$toast('客户年龄在2周岁及以上,不能使用出生证作为有效证件') } - } else if (this.userInfo.idType == '4') { + } + else if (this.userInfo.idType == '4') { if (this.userInfo.nativeplace == '1') { return this.$toast('“证件类型”为“外国人护照”,“国籍”不能选择为“中国”哦~') } - } else if (this.userInfo.idType == '5') { + } + else if (this.userInfo.idType == '5') { console.log(this.userInfo.nativeplace, 'nativeplace') if (this.userInfo.nativeplace != 2 && this.userInfo.nativeplace != 3) { return this.$toast('“证件类型”为“港澳居民来往内地通行证”,“国籍”请选择“中国香港”或“中国澳门”哦~') } - } else if (this.userInfo.idType == '6') { + } + else if (this.userInfo.idType == '6') { if (this.userInfo.nativeplace != 4) { return this.$toast('“证件类型”为“台湾居民来往大陆通行证”,“国籍”请选择“中国台湾”~') } - } else if (this.userInfo.idType == '9') { + } + else if (this.userInfo.idType == '8') { + if (idNoCheck8(this.userInfo).text){ + return this.$toast(idNoCheck8(this.userInfo).text) + } + } + else if (this.userInfo.idType == '9') { if (this.userInfo.nativeplace != 2 && this.userInfo.nativeplace != 3 && this.userInfo.nativeplace != 4) { return this.$toast('“证件类型”为“港澳台居民居住证”,“国籍”请选择“中国香港”、“中国澳门”或“中国台湾”~') } @@ -1636,11 +1647,6 @@ // this.userInfo.effectiveDateType = false } } - if(this.userInfo.idType == '8'){ - this.userInfo.birthday = idToData(val).birthday - this.userInfo.sex = idToData(val).sex - console.log(this.userInfo.birthday) - } }, }, diff --git a/src/views/ebiz/sale/InsuredPerson.vue b/src/views/ebiz/sale/InsuredPerson.vue index ab6dd1ae7..5e16e1bab 100644 --- a/src/views/ebiz/sale/InsuredPerson.vue +++ b/src/views/ebiz/sale/InsuredPerson.vue @@ -493,7 +493,7 @@ import IdentityCardScan from '@/components/ebiz/sale/IdentityCardScan' import idNoCheck from '@/assets/js/utils/idNoCheck' import beforeDate from '@/assets/js/utils/getBeforeDate.js' - import { idToData } from './js/verification' + import {idNoCheck8, idToData} from './js/verification' import { selectComp, getIdentityInfo } from './js/methods' import IndexBar from '@/components/ebiz/sale/IndexBar' import SearchField from '@/components/common/SearchField' @@ -1540,7 +1540,8 @@ // } //证件类型是户口本 - } else if (this.userInfo.idType == '2') { + } + else if (this.userInfo.idType == '2') { if (this.userInfo.nativeplace != '1') { return this.$toast('证件类型”为“身份证,国籍必须为中国哦') } @@ -1591,7 +1592,8 @@ // return this.$toast('户口本的证件号码长度应等于18位') // } //证件类型是出生证明 - } else if (this.userInfo.idType == '3') { + } + else if (this.userInfo.idType == '3') { if (age >= 2) { return this.$toast('客户年龄在2周岁及以上,不能使用出生证作为有效证件') } @@ -1604,20 +1606,29 @@ // return this.$toast('出生证须大于等于3个字符') // } //证件类型是护照 - } else if (this.userInfo.idType == '4') { + } + else if (this.userInfo.idType == '4') { if (this.userInfo.nativeplace == '1') { return this.$toast('“证件类型”为“外国人护照”,“国籍”不能选择为“中国”哦~') } - } else if (this.userInfo.idType == '5') { + } + else if (this.userInfo.idType == '5') { console.log(this.userInfo.nativeplace, 'nativeplace') if (this.userInfo.nativeplace != 2 && this.userInfo.nativeplace != 3) { return this.$toast('“证件类型”为“港澳居民来往内地通行证”,“国籍”请选择“中国香港”或“中国澳门”哦~') } - } else if (this.userInfo.idType == '6') { + } + else if (this.userInfo.idType == '6') { if (this.userInfo.nativeplace != 4) { return this.$toast('“证件类型”为“台湾居民来往大陆通行证”,“国籍”请选择“中国台湾”~') } - } else if (this.userInfo.idType == '9') { + } + else if (this.userInfo.idType == '8') { + if (idNoCheck8(this.userInfo).text){ + return this.$toast(idNoCheck8(this.userInfo).text) + } + } + else if (this.userInfo.idType == '9') { if (this.userInfo.nativeplace != 2 && this.userInfo.nativeplace != 3 && this.userInfo.nativeplace != 4) { return this.$toast('“证件类型”为“港澳台居民居住证”,“国籍”请选择“中国香港”、“中国澳门”或“中国台湾”~') } diff --git a/src/views/ebiz/sale/js/verification.js b/src/views/ebiz/sale/js/verification.js index affcb0609..1d9c0ab4f 100644 --- a/src/views/ebiz/sale/js/verification.js +++ b/src/views/ebiz/sale/js/verification.js @@ -24,30 +24,6 @@ export function idToData(idNo) { text: '您填写的证件号码有误' } } - console.log('12321321321') - let birthday = getBirthById(idNo) - let age = utilsAge.getAge(birthday, new Date()) - let sex = getSexById(idNo) - return { - birthday, - age, - sex - } -} - -//外国人永久居留身份证带出出生日期,性别,年龄 -export function idToData8(idNo) { - //非空 - if (!idNo.trim()) { - return { - text: '证件号码不能为空' - } - } - if (idNo.length != 15 && idNo.length != 18) { - return { - text: '外国人永久居留身份证位数有误' - } - } let birthday = getBirthById(idNo) let age = utilsAge.getAge(birthday, new Date()) let sex = getSexById(idNo) @@ -59,20 +35,145 @@ export function idToData8(idNo) { } function getBirthById(idNo) { - // 获取生日 - var year = idNo.substr(6, 4) - var month = idNo.substr(10, 2) - var day = idNo.substr(12, 2) - return year + '-' + month + '-' + day + if(idNo.length == 15) { + // 获取生日 + let year = '19' + idNo.substr(6, 2) + let month = idNo.substr(8, 2) + let day = idNo.substr(10, 2) + return year + '-' + month + '-' + day + } + if(idNo.length == 18) { + // 获取生日 + let year = idNo.substr(6, 4) + let month = idNo.substr(10, 2) + let 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' + if(idNo.length == 15){ + // 获取性别 + if (idNo.charAt(14) >= '0' && idNo.charAt(14) <= '9') { + if (parseInt(idNo.charAt(14)) % 2 == 0) { + return '1' + } else { + return '0' + } + } + } + if(idNo.length == 18) { + // 获取性别 + if (idNo.charAt(16) >= '0' && idNo.charAt(16) <= '9') { + if (parseInt(idNo.charAt(16)) % 2 == 0) { + return '1' + } else { + return '0' + } } } } + +export function idNoCheck8(userInfo) { + if(!userInfo.idNo) { + return { + text: '证件号码不能为空' + } + } + if(userInfo.idNo.length != 15 && userInfo.idNo.length != 18) { + return { + text: '外国人永久居留身份证位数有误' + } + } + if(userInfo.idNo.length == 15) { + let reg = /^[A-Za-z]{3}\d{12}$/ + if(!reg.test(userInfo.idNo)) { + return { + text: '外国人永久居留身份证位数有误' + } + } + } + if(userInfo.idNo.length == 18) { + let reg = / (^9\d{17}$)|(^9\d{16}(\d|X|x)$)/ + if(!reg.test(userInfo.idNo)) { + return { + text: '外国人永久居留身份证位数有误' + } + } + } + if(userInfo.idNo.length == 15) { + // 获取生日 + let year = '19' + userInfo.idNo.substr(6, 2) + let month = userInfo.idNo.substr(8, 2) + let day = userInfo.idNo.substr(10, 2) + let thisBirthday = year + '-' + month + '-' + day + if(thisBirthday != userInfo.birthday) { + return { + text: '出生日期必须与证件号码中的生日一致' + } + } + } + if(userInfo.idNo.length == 18) { + // 获取生日 + let year = userInfo.idNo.substr(6, 4) + let month = userInfo.idNo.substr(10, 2) + let day = userInfo.idNo.substr(12, 2) + let thisBirthday = year + '-' + month + '-' + day + if(thisBirthday != userInfo.birthday) { + return { + text: '出生日期必须与证件号码中的生日一致' + } + } + } + let thisSex = getSexById(userInfo.idNo) + if(thisSex != userInfo.sex) { + return { + text: '性别必须与证件号码中的一致' + } + } + if (userInfo.nativeplace == '1' || userInfo.nativeplace == '2' || userInfo.nativeplace == '3' || userInfo.nativeplace == '4') { + return { + text: '外国人永久居留身份证不能选择中国国籍' + } + } + if(!userInfo.certiexpiredate) { + return { + text: '证件截止日期不能为空' + } + } + let thisAge = utilsAge.getAge(userInfo.birthday, new Date(userInfo.certificateValidate)) + if(thisAge < 18) { + let currentDate = new Date(userInfo.certificateValidate); + currentDate.setFullYear(currentDate.getFullYear() + 5); // 添加年份 + currentDate.setMonth(currentDate.getMonth(), currentDate.getDate() - 1); + let thisDate = currentDate.toLocaleString().replace(/\//g, "-") + let date = new Date(thisDate); + let options = { year: 'numeric', month: '2-digit', day: '2-digit' }; + let localizedStr = date.toLocaleString('zh-CN', options); + let thislocalizedStr = localizedStr.replace(/\//g, "-") + if(thislocalizedStr != userInfo.certiexpiredate) { + return { + text: '外国人永久居留身份证证件有效期有误' + } + } + } + if(thisAge >= 18) { + let currentDate = new Date(userInfo.certificateValidate); + currentDate.setFullYear(currentDate.getFullYear() + 10); // 添加年份 + currentDate.setMonth(currentDate.getMonth(), currentDate.getDate() - 1); + let thisDate = currentDate.toLocaleString().replace(/\//g, "-") + let date = new Date(thisDate); + let options = { year: 'numeric', month: '2-digit', day: '2-digit' }; + let localizedStr = date.toLocaleString('zh-CN', options); + let thislocalizedStr = localizedStr.replace(/\//g, "-") + if(thislocalizedStr != userInfo.certiexpiredate) { + return { + text: '外国人永久居留身份证证件有效期有误' + } + } + } + return { + text:'' + } +} +