From af041ddd0c7de97701f0c6ef83ff17593def47ed Mon Sep 17 00:00:00 2001 From: "liu.xiaofeng@ebiz-digits.com" Date: Wed, 20 Sep 2023 11:38:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=87=AA=E5=8A=A8=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E8=AF=81=E4=BB=B6=E5=BC=80=E5=A7=8B=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E6=88=AA=E6=AD=A2=E6=97=A5=E6=9C=9F=E7=9A=84?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/utils/countCredentialValidity.js | 231 ++++++------------ src/views/ebiz/sale/InsuredInfo.vue | 5 +- 2 files changed, 78 insertions(+), 158 deletions(-) diff --git a/src/assets/js/utils/countCredentialValidity.js b/src/assets/js/utils/countCredentialValidity.js index ed7128a9d..ce6843faa 100644 --- a/src/assets/js/utils/countCredentialValidity.js +++ b/src/assets/js/utils/countCredentialValidity.js @@ -1,167 +1,88 @@ +import utilsAge from '@/assets/js/utils/age' export default { //计算身份证起始日期 - getStartDate: function(age, endDate) { + getStartDate: function(birthday, endDate) { let startDate = '' //证件起始日期 - let thisDate = new Date() //当年日期 - let thisyear = thisDate.getFullYear() //当前年份 + let startage = '' + let endage = utilsAge.getAge(birthday, new Date(endDate)) - if (age < 16) { - /** - * @Author: LiuXiaoFeng - * @Description: 16周岁以下的证件有效期为5年 - * @Date: 2023/7/4 - **/ - startDate = String(Number(endDate.slice(0,4)) - 5) + endDate.slice(4,11) - } else if (age >= 16 && age <= 21) { - /** - * @Author: LiuXiaoFeng - * @Description: 16周岁~21周岁的证件有效期为10年或5年 - * @Date: 2023/7/4 - **/ - if (age - (10 - (endDate.slice(0,4) - thisyear)) < 16 ) { - /** - * @Author: LiuXiaoFeng - * @Description: 如果证件有效期为10年 根据证件截止日期 判断10年前的年龄 如果小于16周岁 那么证件有效期就是5年 - * @Date: 2023/7/5 - **/ - startDate = String(Number(endDate.slice(0,4)) - 5) + endDate.slice(4,11) - } else { - startDate = String(Number(endDate.slice(0,4)) - 10) + endDate.slice(4,11) - } - } else if(age >= 22 && age <= 25) { - /** - * @Author: LiuXiaoFeng - * @Description: 22周岁~25周岁的证件有效期为10年 - * @Date: 2023/7/4 - **/ - startDate = String(Number(endDate.slice(0,4)) - 10) + endDate.slice(4,11) - } else if (age >= 26 && age <= 35) { - /** - * @Author: LiuXiaoFeng - * @Description: 26周岁~35周岁的证件有效期为20年或10年 - * @Date: 2023/7/4 - **/ - if (age - (20 - (endDate.slice(0,4) - thisyear)) < 26 ) { - /** - * @Author: LiuXiaoFeng - * @Description: 如果证件有效期为20年 根据证件截止日期 判断20年前的年龄 如果小于26周岁 那么证件有效期就是10年 - * @Date: 2023/7/5 - **/ - startDate = String(Number(endDate.slice(0,4)) - 10) + endDate.slice(4,11) - } else { - startDate = String(Number(endDate.slice(0,4)) - 20) + endDate.slice(4,11) - } - } else if (age >= 36 && age <= 45) { - /** - * @Author: LiuXiaoFeng - * @Description: 36周岁~45周岁的证件有效期为20年 - * @Date: 2023/7/4 - **/ - startDate = String(Number(endDate.slice(0,4)) + 20) + endDate.slice(4,11) - } else if (age >= 46 && age <= 65) { - /** - * @Author: LiuXiaoFeng - * @Description: 46周岁~65周岁的证件有效期为20年或长期 - * @Date: 2023/7/4 - **/ - if (age - (20 - (endDate.slice(0,4) - thisyear)) < 46 ) { - /** - * @Author: LiuXiaoFeng - * @Description: 如果证件有效期为20年 根据证件截止日期 判断20年前的年龄 如果小于46周岁 那么证件有效期就是20年 - * @Date: 2023/7/5 - **/ - startDate = String(Number(endDate.slice(0,4)) - 20) + endDate.slice(4,11) - } - } else if (age > 65) { - /** - * @Author: LiuXiaoFeng - * @Description: 65周岁以上的证件有效期为长期 - * @Date: 2023/7/4 - **/ + /** + * @Author: LiuXiaoFeng + * @Description: 未满16周岁的公民申领的居民身份证有效期为5年 + * @Date: 2023/7/4 + **/ + if (endage - 5 < 16) { + return startDate = String(Number(endDate.slice(0,4)) - 5) + endDate.slice(4,11) + } + /** + * @Author: LiuXiaoFeng + * @Description: 年满16周岁至25周岁的公民申领的居民身份证有效期为10年 + * @Date: 2023/7/4 + **/ + else if (endage - 5 >= 16 && endage - 10 <= 25) { + startDate = String(Number(endDate.slice(0,4)) - 10) + endDate.slice(4,11) + startage = utilsAge.getAge(birthday, new Date(startDate)) + if(startage >= 16 && startage <= 25){ + return startDate + } + } + /** + * @Author: LiuXiaoFeng + * @Description: 年满26周岁至45周岁的公民申领的居民身份证有效期为20年 + * @Date: 2023/7/4 + **/ + else if(endage - 10 >= 26 && endage - 20 <= 45) { + startDate = String(Number(endDate.slice(0,4)) - 20) + endDate.slice(4,11) + startage = utilsAge.getAge(birthday, new Date(startDate)) + if(startage >= 26 && startage <= 45){ + return startDate + } + } + /** + * @Author: LiuXiaoFeng + * @Description: 年满46周岁的公民申领居民身份证有效期为长期 + * @Date: 2023/7/4 + **/ + else if (endage - 20 >= 46) { + return startDate } - return startDate }, //计算身份证截止日期 - getEndDate: function(age, startDate) { + getEndDate: function(birthday, startDate) { let endDate = '' //证件截止日期 - let thisDate = new Date() //当年日期 - let thisyear = thisDate.getFullYear() //当前年份 - - if (age < 16) { - /** - * @Author: LiuXiaoFeng - * @Description: 16周岁以下的证件有效期为5年 - * @Date: 2023/7/4 - **/ - endDate = String(Number(startDate.slice(0,4)) + 5) + startDate.slice(4,11) - } else if (age >= 16 && age <= 21) { - /** - * @Author: LiuXiaoFeng - * @Description: 16周岁~21周岁的证件有效期为10年或5年 - * @Date: 2023/7/4 - **/ - if (age - (thisyear - startDate.slice(0,4)) < 16 ) { - /** - * @Author: LiuXiaoFeng - * @Description: 根据证件起始日期计算办证时年龄 如果办证时年龄小于16周岁 那么证件有效期就是5年 - * @Date: 2023/7/5 - **/ - endDate = String(Number(startDate.slice(0,4)) + 5) + startDate.slice(4,11) - } else { - endDate = String(Number(startDate.slice(0,4)) + 10) + startDate.slice(4,11) - } - } else if(age >= 22 && age <= 25) { - /** - * @Author: LiuXiaoFeng - * @Description: 22周岁~25周岁的证件有效期为10年 - * @Date: 2023/7/4 - **/ - endDate = String(Number(startDate.slice(0,4)) + 10) + startDate.slice(4,11) - } else if (age >= 26 && age <= 35) { - /** - * @Author: LiuXiaoFeng - * @Description: 26周岁~35周岁的证件有效期为20年或10年 - * @Date: 2023/7/4 - **/ - if (age - (thisyear - startDate.slice(0,4)) < 26 ) { - /** - * @Author: LiuXiaoFeng - * @Description: 根据证件起始日期计算办证时年龄 如果办证时年龄小于26周岁 那么证件有效期就是10年 - * @Date: 2023/7/5 - **/ - endDate = String(Number(startDate.slice(0,4)) + 10) + startDate.slice(4,11) - } else { - endDate = String(Number(startDate.slice(0,4)) + 20) + startDate.slice(4,11) - } - } else if (age >= 36 && age <= 45) { - /** - * @Author: LiuXiaoFeng - * @Description: 36周岁~45周岁的证件有效期为20年 - * @Date: 2023/7/4 - **/ - endDate = String(Number(startDate.slice(0,4)) + 20) + startDate.slice(4,11) - } else if (age >= 46 && age <= 65) { - /** - * @Author: LiuXiaoFeng - * @Description: 46周岁~65周岁的证件有效期为20年或长期 - * @Date: 2023/7/4 - **/ - if (age - (thisyear - startDate.slice(0,4)) < 46 ) { - /** - * @Author: LiuXiaoFeng - * @Description: 根据证件起始日期计算办证时年龄 如果办证时年龄小于46周岁 那么证件有效期就是20年 - * @Date: 2023/7/5 - **/ - endDate = String(Number(startDate.slice(0,4)) + 20) + startDate.slice(4,11) - } - } else if (age > 65) { - /** - * @Author: LiuXiaoFeng - * @Description: 65周岁以上的证件有效期为长期 - * @Date: 2023/7/4 - **/ + let startage = utilsAge.getAge(birthday, new Date(startDate)) + /** + * @Author: LiuXiaoFeng + * @Description: 未满16周岁的公民申领的居民身份证有效期为5年 + * @Date: 2023/7/4 + **/ + if (startage < 16) { + return endDate = String(Number(startDate.slice(0, 4)) + 5) + startDate.slice(4, 11) + } + /** + * @Author: LiuXiaoFeng + * @Description: 年满16周岁至25周岁的公民申领的居民身份证有效期为10年 + * @Date: 2023/7/4 + **/ + else if (startage >= 16 && startage <= 25) { + return endDate = String(Number(startDate.slice(0, 4)) + 10) + startDate.slice(4, 11) + } + /** + * @Author: LiuXiaoFeng + * @Description: 年满26周岁至45周岁的公民申领的居民身份证有效期为20年 + * @Date: 2023/7/4 + **/ + else if (startage >= 26 && startage <= 45) { + return endDate = String(Number(startDate.slice(0, 4)) + 20) + startDate.slice(4, 11) + } + /** + * @Author: LiuXiaoFeng + * @Description: 年满46周岁的公民申领居民身份证有效期为长期 + * @Date: 2023/7/4 + **/ + else if (startage > 65) { + return endDate } - return endDate } } diff --git a/src/views/ebiz/sale/InsuredInfo.vue b/src/views/ebiz/sale/InsuredInfo.vue index bd383aa62..52db575eb 100644 --- a/src/views/ebiz/sale/InsuredInfo.vue +++ b/src/views/ebiz/sale/InsuredInfo.vue @@ -860,7 +860,7 @@ export default { // 长期按钮是否禁用 this.effectiveDateTypeAble = age <= 45 if(this.userInfo.birthday){ - this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(age,val) + this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(this.userInfo.birthday,val) } } } @@ -876,9 +876,8 @@ export default { } //身份证证件类型的判断 if (this.userInfo.idType == '1') { - let age = utilsAge.getAge(this.userInfo.birthday, new Date()) if(this.userInfo.birthday){ - this.userInfo.certificateValidate = countCredentialValidity.getStartDate(age,val) + this.userInfo.certificateValidate = countCredentialValidity.getStartDate(this.userInfo.birthday,val) } } }