import utilsAge from '@/assets/js/utils/age' export default { //计算身份证起始日期 getStartDate: function(birthday, endDate) { let startDate = '' //证件起始日期 let startage = '' let endage = utilsAge.getAge(birthday, new Date(endDate)) /** * @Author: LiuXiaoFeng * @Description: 未满16周岁的公民申领的居民身份证有效期为5年 * @Date: 2023/7/4 **/ if (endage - 5 < 16) { let date2_29 = endDate.slice(5, 11) if(date2_29 == '02-29'){ let thisyear = Number(endDate.slice(0, 4)) - 5 if (thisyear % 4 == 0 && thisyear % 100 != 0 || thisyear % 400 == 0){ startDate = thisyear + '-02-29' } else { startDate = thisyear + '-02-28' } }else{ 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){ let date2_29 = endDate.slice(5, 11) if(date2_29 == '02-29') { let thisyear = Number(endDate.slice(0, 4)) - 10 if (thisyear % 4 == 0 && thisyear % 100 != 0 || thisyear % 400 == 0){ startDate = thisyear + '-02-29' } else { startDate = thisyear + '-02-28' } } else { 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){ let date2_29 = endDate.slice(5, 11) if(date2_29 == '02-29') { let thisyear = Number(endDate.slice(0, 4)) - 20 if (thisyear % 4 == 0 && thisyear % 100 != 0 || thisyear % 400 == 0){ startDate = thisyear + '-02-29' } else { startDate = thisyear + '-02-28' } } else { startDate } } } /** * @Author: LiuXiaoFeng * @Description: 年满46周岁的公民申领居民身份证有效期为长期 * @Date: 2023/7/4 **/ else if (endage - 20 >= 46) { startDate } if(new Date(birthday).getTime() >= new Date(startDate).getTime() || new Date().getTime() < new Date(startDate).getTime()){ startDate = '' } return startDate }, //计算身份证截止日期 getEndDate: function(birthday, startDate) { let endDate = '' //证件截止日期 let startage = utilsAge.getAge(birthday, new Date(startDate)) /** * @Author: LiuXiaoFeng * @Description: 未满16周岁的公民申领的居民身份证有效期为5年 * @Date: 2023/7/4 **/ if (startage < 16) { let date2_29 = startDate.slice(5, 11) if(date2_29 == '02-29') { let thisyear = Number(startDate.slice(0, 4)) + 5 if (thisyear % 4 == 0 && thisyear % 100 != 0 || thisyear % 400 == 0){ return endDate = thisyear + '-02-29' } else { return endDate = thisyear + '-02-28' } } else { 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) { let date2_29 = startDate.slice(5, 11) if(date2_29 == '02-29') { let thisyear = Number(startDate.slice(0, 4)) + 10 if (thisyear % 4 == 0 && thisyear % 100 != 0 || thisyear % 400 == 0){ return endDate = thisyear + '-02-29' } else { return endDate = thisyear + '-02-28' } } else { 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) { let date2_29 = startDate.slice(5, 11) if(date2_29 == '02-29') { let thisyear = Number(startDate.slice(0, 4)) + 20 if (thisyear % 4 == 0 && thisyear % 100 != 0 || thisyear % 400 == 0){ return endDate = thisyear + '-02-29' } else { return endDate = thisyear + '-02-28' } } else { return endDate = String(Number(startDate.slice(0, 4)) + 20) + startDate.slice(4, 11) } } /** * @Author: LiuXiaoFeng * @Description: 年满46周岁的公民申领居民身份证有效期为长期 * @Date: 2023/7/4 **/ else if (startage > 45) { return endDate } }, //计算户口本截止日期 getEndDate2: function(birthday, startDate) { let endDate = '' let date2_29 = startDate.slice(5, 11) if(date2_29 == '02-29'){ let thisyear = Number(startDate.slice(0, 4)) + 16 if (thisyear % 4 == 0 && thisyear % 100 != 0 || thisyear % 400 == 0){ return endDate = thisyear + '-02-29' } else { return endDate = thisyear + '-02-28' } }else{ return endDate = String(Number(startDate.slice(0, 4)) + 16) + startDate.slice(4, 11) } } }