外国人证件有效期计算逻辑修改

This commit is contained in:
liu.xiaofeng@ebiz-digits.com
2024-02-22 19:32:20 +08:00
parent 9b067a1821
commit 04f6a287eb

View File

@@ -73,8 +73,16 @@ function getSexById(idNo) {
} }
} }
} }
function js_date_time(unixtime) {
var dateTime = new Date(parseInt(unixtime))
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1;
var day = dateTime.getDate();
var timeSpanStr = year + '-' + month + '-' + day;
return timeSpanStr;
}
export function idNoCheck8(userInfo) { export function idNoCheck8(userInfo,type) {
if(!userInfo.idNo) { if(!userInfo.idNo) {
return { return {
text: '证件号码不能为空' text: '证件号码不能为空'
@@ -144,34 +152,74 @@ export function idNoCheck8(userInfo) {
text: '证件截止日期不能为空' text: '证件截止日期不能为空'
} }
} }
let thisAge = utilsAge.getAge(userInfo.birthday, new Date(userInfo.certificateValidate))
if(thisAge < 18) { if(type == 'cardList') {
let currentDate = new Date(userInfo.certificateValidate); let thisAge = utilsAge.getAge(userInfo.birthday, new Date())
currentDate.setFullYear(currentDate.getFullYear() + 5); // 添加年份 if(thisAge < 18) {
currentDate.setMonth(currentDate.getMonth(), currentDate.getDate() - 1); let date1 = new Date(userInfo.certiexpiredate.replace(/-/g,'/'));
let thisDate = currentDate.toLocaleString().replace(/\//g, "-") let date2 = date1.setFullYear(date1.getFullYear() - 5);
let date = new Date(thisDate); let date3 = date2+(1000*60*60*24)
let options = { year: 'numeric', month: '2-digit', day: '2-digit' }; let date4 = js_date_time(date3)
let localizedStr = date.toLocaleString('zh-CN', options); let thisAge = utilsAge.getAge(userInfo.birthday, new Date(date4.replace(/-/g,'/')))
let thislocalizedStr = localizedStr.replace(/\//g, "-") if(thisAge > 18) {
if(thislocalizedStr != userInfo.certiexpiredate) { return {
return { text: '外国人永久居留身份证证件有效期有误'
text: '外国人永久居留身份证证件有效期有误' }
} }
} }
} if(thisAge >= 18 && thisAge <= 22) {
if(thisAge >= 18) { let date1 = new Date(userInfo.certiexpiredate.replace(/-/g,'/'));
let currentDate = new Date(userInfo.certificateValidate); let date2 = date1.setFullYear(date1.getFullYear() - 5);
currentDate.setFullYear(currentDate.getFullYear() + 10); // 添加年份 let date3 = date2+(1000*60*60*24)
currentDate.setMonth(currentDate.getMonth(), currentDate.getDate() - 1); let date4 = js_date_time(date3)
let thisDate = currentDate.toLocaleString().replace(/\//g, "-")
let date = new Date(thisDate); let date5 = new Date(userInfo.certiexpiredate.replace(/-/g,'/'));
let options = { year: 'numeric', month: '2-digit', day: '2-digit' }; let date6 = date5.setFullYear(date5.getFullYear() - 10);
let localizedStr = date.toLocaleString('zh-CN', options); let date7 = date6+(1000*60*60*24)
let thislocalizedStr = localizedStr.replace(/\//g, "-") let date8 = js_date_time(date7)
if(thislocalizedStr != userInfo.certiexpiredate) {
return { let thisAge1 = utilsAge.getAge(userInfo.birthday, new Date(date4.replace(/-/g,'/')))
text: '外国人永久居留身份证证件有效期有误' let thisAge2 = utilsAge.getAge(userInfo.birthday, new Date(date8.replace(/-/g,'/')))
if(thisAge1 >= 18 && thisAge2 < 18){
return {
text: '外国人永久居留身份证证件有效期有误'
}
}
}
if(thisAge >= 23) {
let date1 = new Date(userInfo.certiexpiredate.replace(/-/g,'/'));
let date2 = date1.setFullYear(date1.getFullYear() - 10);
let date3 = date2+(1000*60*60*24)
let date4 = js_date_time(date3)
let thisAge = utilsAge.getAge(userInfo.birthday, new Date(date4.replace(/-/g,'/')))
if(thisAge < 18) {
return {
text: '外国人永久居留身份证证件有效期有误'
}
}
}
} else {
let thisAge = utilsAge.getAge(userInfo.birthday, new Date(userInfo.certificateValidate))
if(thisAge < 18) {
let date1 = new Date(userInfo.certificateValidate.replace(/-/g,'/'));
let date2 = date1.setFullYear(date1.getFullYear() + 5);
let date3 = date2-(1000*60*60*24)
let date4 = js_date_time(date3)
if(date4 != userInfo.certiexpiredate) {
return {
text: '外国人永久居留身份证证件有效期有误'
}
}
}
if(thisAge >= 18) {
let date1 = new Date(userInfo.certificateValidate.replace(/-/g,'/'));
let date2 = date1.setFullYear(date1.getFullYear() + 10);
let date3 = date2-(1000*60*60*24)
let date4 = js_date_time(date3)
if(date4 != userInfo.certiexpiredate) {
return {
text: '外国人永久居留身份证证件有效期有误'
}
} }
} }
} }