提交 40d66ffe 编写于 作者: 张磊's avatar 张磊

name reg

上级 4bf97580
...@@ -66,20 +66,20 @@ export const formatDuring = (time) => { ...@@ -66,20 +66,20 @@ export const formatDuring = (time) => {
}; };
export function toDecimal2(x) { export function toDecimal2(x) {
if (isNaN(x)) { if (isNaN(x)) {
return ''; return '';
} }
const f = x / 100; const f = x / 100;
let s = f.toString(); let s = f.toString();
let rs = s.indexOf('.'); let rs = s.indexOf('.');
if (rs < 0) { if (rs < 0) {
rs = s.length; rs = s.length;
s += '.'; s += '.';
} }
while (s.length <= rs + 2) { while (s.length <= rs + 2) {
s += '0'; s += '0';
} }
return s; return s;
} }
/** /**
...@@ -90,18 +90,18 @@ export function toDecimal2(x) { ...@@ -90,18 +90,18 @@ export function toDecimal2(x) {
* birthDay:yyyy-MM-dd * birthDay:yyyy-MM-dd
*/ */
export function getBirthdayAndSex(idCard) { export function getBirthdayAndSex(idCard) {
const info = {}; const info = {};
const birth = (idCard.length === 18) ? idCard.slice(6, 14) : idCard.slice(6, 12); const birth =
// 18位:提取第17位数字;15位:提取最后一位数字 idCard.length === 18 ? idCard.slice(6, 14) : idCard.slice(6, 12);
const order = (idCard.length === 18) ? idCard.slice(-2, -1) : idCard.slice(-1); // 18位:提取第17位数字;15位:提取最后一位数字
info.birthDay = (idCard.length === 18) ? ([birth.slice(0, 4), const order = idCard.length === 18 ? idCard.slice(-2, -1) : idCard.slice(-1);
birth.slice(4, 6), birth.slice(-2) info.birthDay =
]).join('-') : ([ idCard.length === 18
'19' + birth.slice(0, 2), birth.slice(2, 4), ? [birth.slice(0, 4), birth.slice(4, 6), birth.slice(-2)].join('-')
birth.slice(-2) : ['19' + birth.slice(0, 2), birth.slice(2, 4), birth.slice(-2)].join(
]).join('-'); '-'
// 余数为0代表女性,不为0代表男性 );
info.sex = (order % 2 === 0 ? 0 : 1); // 余数为0代表女性,不为0代表男性
return info; info.sex = order % 2 === 0 ? 0 : 1;
return info;
} }
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册