mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-15 22:16:45 +08:00
卡单代码
This commit is contained in:
52
src/views/ebiz/cardList/js/verification.js
Normal file
52
src/views/ebiz/cardList/js/verification.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import changeFifteenToEighteen from '@/assets/js/utils/changeFifteenToEighteen'
|
||||
import idNoCheck from '@/assets/js/utils/idNoCheck'
|
||||
import utilsAge from '@/assets/js/utils/age'
|
||||
|
||||
//身份证带出出生日期,性别,年龄
|
||||
export function idToData(idNo) {
|
||||
//非空
|
||||
if (!idNo.trim()) {
|
||||
return {
|
||||
text: '证件号码不能为空'
|
||||
}
|
||||
}
|
||||
|
||||
// 证件号码规则校验
|
||||
if (!idNoCheck.isIdno(idNo)) {
|
||||
return {
|
||||
text: '您填写的证件号码有误'
|
||||
}
|
||||
}
|
||||
|
||||
//如果是15位身份证号先转为18位
|
||||
if (idNo.length == 15) {
|
||||
idNo = changeFifteenToEighteen(idNo)
|
||||
}
|
||||
let birthday = getBirthById(idNo)
|
||||
let age = utilsAge.getAge(birthday, new Date())
|
||||
let sex = getSexById(idNo)
|
||||
return {
|
||||
birthday,
|
||||
age,
|
||||
sex
|
||||
}
|
||||
}
|
||||
|
||||
function getBirthById(idNo) {
|
||||
// 获取生日
|
||||
var year = idNo.substr(6, 4)
|
||||
var month = idNo.substr(10, 2)
|
||||
var day = idNo.substr(12, 2)
|
||||
return year + '-' + month + '-' + day
|
||||
}
|
||||
|
||||
function getSexById(idNo) {
|
||||
// 获取性别
|
||||
if (idNo.charAt(16) >= '0' && idNo.charAt(16) <= '9') {
|
||||
if (parseInt(idNo.charAt(16)) % 2 == 0) {
|
||||
return '1'
|
||||
} else {
|
||||
return '0'
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user