export function IdCard(UUserCard, num) {
// console.log(UUserCard)
if(num == 1) {
//获取出生日期
var birth = UUserCard.substring(6, 10) + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14);
// var birth = birthtype.split('-').map(function(aa){return +aa}).join('-');
return birth;
}
if(num == 2) {
//获取性别
if(parseInt(UUserCard.substr(16, 1)) % 2 == 1) {
//男
return "男";
} else {
//女
return "女";
}
}
if(num == 3) {
//获取年龄
var myDate = new Date();
var month = myDate.getMonth() + 1;
var day = myDate.getDate();
var age = myDate.getFullYear() - UUserCard.substring(6, 10) - 1;
if(UUserCard.substring(10, 12) < month || UUserCard.substring(10, 12) == month && UUserCard.substring(12, 14) <= day) {
age++;
}
return age;
}
}
检验身份证号(https://blog.csdn.net/M_SSY/article/details/86749136)后判断出生日期和性别