-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
101 lines (98 loc) · 2.72 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* 该文件名- index.js
* 编码作者- @king
* 创建日期- 2020/05/05 20:10
* 作者邮箱- [email protected]
* 修改时间-
* 修改备注-
* 编码内容-
*/
'use strict';
const idCard = require('idcard');
const zodiac = require('./libs/zodiac');
const alfy = require('alfy');
let idno = alfy.input;
let result_values = [];
if (typeof idno == "undefined") {
idno = idCard.generateIdcard();
result_values = [{
title: "随机生成",
subtitle: "身份证号:" + idno,
arg: idno
}];
} else {
let info = idCard.info(idno);
if (!info.valid) {
result_values = [{
title: "校验结果",
subtitle: "无效",
icon: {
path: "./images/result.png"
}
}];
} else {
let birthday = info.birthday.toString();
let zodiacValue = zodiac.getZodiac(birthday.slice(0, 4));
birthday = birthday.slice(0, 4) + "/" + birthday.slice(4, 6) + "/" + birthday.slice(6,8);
let gender = info.gender == "M" ? "男" : "女";
result_values = [
{
title: "校验结果",
subtitle: info.valid ? "正确" : "无效",
arg: info.valid ? "正确" : "无效",
icon: {
path: "./images/result.png"
}
},
{
title: "户籍地址",
subtitle: info.address,
arg: info.address,
icon: {
path: "./images/address.png"
}
},
{
title: "出生日期",
subtitle: birthday,
arg: birthday,
icon: {
path: "./images/birthday.png"
}
},
{
title: "年龄",
subtitle: info.age,
arg: info.age,
icon: {
path: "./images/age.png"
}
},
{
title: "生肖",
subtitle: zodiacValue,
arg: zodiacValue,
icon: {
path: "./images/shuxiao.png"
}
},
{
title: "星座",
subtitle: info.constellation,
arg: info.constellation,
icon: {
path: "./images/constellation.png"
}
},
{
title: "性别",
subtitle: gender,
arg: gender,
icon: {
path: "./images/xingbie.png"
}
},
];
}
}
alfy.output(result_values);