diff --git a/src/views/ebiz/sale/js/verification.js b/src/views/ebiz/sale/js/verification.js index dbff8372a..5b9cde5de 100644 --- a/src/views/ebiz/sale/js/verification.js +++ b/src/views/ebiz/sale/js/verification.js @@ -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) { return { text: '证件号码不能为空' @@ -144,34 +152,74 @@ export function idNoCheck8(userInfo) { 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(type == 'cardList') { + let thisAge = utilsAge.getAge(userInfo.birthday, new Date()) + if(thisAge < 18) { + let date1 = new Date(userInfo.certiexpiredate.replace(/-/g,'/')); + let date2 = date1.setFullYear(date1.getFullYear() - 5); + 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: '外国人永久居留身份证证件有效期有误' + } } } - } - 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: '外国人永久居留身份证证件有效期有误' + if(thisAge >= 18 && thisAge <= 22) { + let date1 = new Date(userInfo.certiexpiredate.replace(/-/g,'/')); + let date2 = date1.setFullYear(date1.getFullYear() - 5); + let date3 = date2+(1000*60*60*24) + let date4 = js_date_time(date3) + + let date5 = new Date(userInfo.certiexpiredate.replace(/-/g,'/')); + let date6 = date5.setFullYear(date5.getFullYear() - 10); + let date7 = date6+(1000*60*60*24) + let date8 = js_date_time(date7) + + let thisAge1 = utilsAge.getAge(userInfo.birthday, new Date(date4.replace(/-/g,'/'))) + 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: '外国人永久居留身份证证件有效期有误' + } } } }