let year = this.idCard.slice(6, 10) * 1, //截取身份证年份
month = this.idCard.slice(10, 12) * 1,//截取身份证月份
date = this.idCard.slice(12, 14) * 1,//截取身份证日期
curYear = new Date().getFullYear(), //获取当前年
curMonth = new Date().getMonth() + 1,//获取当月
curDate = new Date().getDate()//获取当日期
if (
year + 18 > curYear ||
(year + 18 == curYear && month < curMonth) ||
(year + 18 == curYear && month == curMonth && date < curDate)
) {
//小于18周岁
this.$dialog.toast({
mes: '被保险人年龄需在18周岁~55周岁(含)',
timeout: 1500,
})
} else if (
year + 56 > curYear ||
(year + 56 == curYear && month > curMonth) ||
(year + 56 == curYear && month == curMonth && date > curDate)
) {
//大于55岁
this.$dialog.toast({
mes: '被保险人年龄需在18周岁~55周岁(含)',
timeout: 1500,
})
} else {
//符合要求
// this.giftGetState()
this.handleShowPopup(0, 6)
}
身份证年龄限制
最新推荐文章于 2024-05-20 17:02:17 发布