外国人永久居住证证件号码长度为15位的时候去掉生日和性别校验

This commit is contained in:
liu.xiaofeng@ebiz-digits.com
2024-02-23 09:31:25 +08:00
parent 04f6a287eb
commit 77ebee1efe

View File

@@ -52,16 +52,16 @@ function getBirthById(idNo) {
} }
function getSexById(idNo) { function getSexById(idNo) {
if(idNo.length == 15){ // if(idNo.length == 15){
// 获取性别 // // 获取性别
if (idNo.charAt(13) >= '0' && idNo.charAt(13) <= '9') { // if (idNo.charAt(13) >= '0' && idNo.charAt(13) <= '9') {
if (parseInt(idNo.charAt(13)) % 2 == 0) { // if (parseInt(idNo.charAt(13)) % 2 == 0) {
return '1' // return '1'
} else { // } else {
return '0' // return '0'
} // }
} // }
} // }
if(idNo.length == 18) { if(idNo.length == 18) {
// 获取性别 // 获取性别
if (idNo.charAt(16) >= '0' && idNo.charAt(16) <= '9') { if (idNo.charAt(16) >= '0' && idNo.charAt(16) <= '9') {
@@ -109,19 +109,19 @@ export function idNoCheck8(userInfo,type) {
} }
} }
} }
if(userInfo.idNo.length == 15) { // if(userInfo.idNo.length == 15) {
// 获取生日 // // 获取生日
let year = '19' + userInfo.idNo.substr(7, 2) // let year = '19' + userInfo.idNo.substr(7, 2)
let month = userInfo.idNo.substr(9, 2) // let month = userInfo.idNo.substr(9, 2)
let day = userInfo.idNo.substr(11, 2) // let day = userInfo.idNo.substr(11, 2)
let thisBirthday = year + '-' + month + '-' + day // let thisBirthday = year + '-' + month + '-' + day
if(thisBirthday != userInfo.birthday) { // if(thisBirthday != userInfo.birthday) {
console.log('12321321321',thisBirthday) // console.log('12321321321',thisBirthday)
return { // return {
text: '出生日期必须与证件号码中的生日一致' // text: '出生日期必须与证件号码中的生日一致'
} // }
} // }
} // }
if(userInfo.idNo.length == 18) { if(userInfo.idNo.length == 18) {
// 获取生日 // 获取生日
let year = userInfo.idNo.substr(6, 4) let year = userInfo.idNo.substr(6, 4)
@@ -134,14 +134,15 @@ export function idNoCheck8(userInfo,type) {
} }
} }
} }
let thisSex = getSexById(userInfo.idNo) if(userInfo.idNo.length == 18){
if(thisSex != userInfo.sex) { let thisSex = getSexById(userInfo.idNo)
console.log('sexxxxxx',thisSex) if(thisSex != userInfo.sex) {
console.log('sexxxxxx',userInfo.sex) return {
return { text: '性别必须与证件号码中的一致'
text: '性别必须与证件号码中的一致' }
} }
} }
if (userInfo.nativeplace == '1' || userInfo.nativeplace == '2' || userInfo.nativeplace == '3' || userInfo.nativeplace == '4') { if (userInfo.nativeplace == '1' || userInfo.nativeplace == '2' || userInfo.nativeplace == '3' || userInfo.nativeplace == '4') {
return { return {
text: '外国人永久居留身份证不能选择中国国籍' text: '外国人永久居留身份证不能选择中国国籍'