Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
a500a22c
Commit
a500a22c
authored
Apr 15, 2020
by
zhaoxiqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
87c19f2f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
1 deletions
+76
-1
bpo-web/app/base/api/impl/econtractApi.js
+1
-0
bpo-web/app/base/service/impl/entcontractSve.js
+0
-1
bpo-web/app/base/utils/idcardClient.js
+75
-0
No files found.
bpo-web/app/base/api/impl/econtractApi.js
View file @
a500a22c
...
@@ -847,6 +847,7 @@ class EcontractApi {
...
@@ -847,6 +847,7 @@ class EcontractApi {
if
(
!
param
.
idNo
)
{
if
(
!
param
.
idNo
)
{
return
this
.
returnjson
(
-
1
,
"请提供该用户身份证号"
)
return
this
.
returnjson
(
-
1
,
"请提供该用户身份证号"
)
}
}
console
.
log
(
await
this
.
idcardClient
.
validateIdCard
(
param
.
idNo
));
if
(
!
await
this
.
idcardClient
.
checkIDCard
(
param
.
idNo
))
{
if
(
!
await
this
.
idcardClient
.
checkIDCard
(
param
.
idNo
))
{
return
this
.
returnjson
(
-
1
,
"身份证格式不正确"
);
return
this
.
returnjson
(
-
1
,
"身份证格式不正确"
);
}
}
...
...
bpo-web/app/base/service/impl/entcontractSve.js
View file @
a500a22c
...
@@ -469,7 +469,6 @@ class EntcontractService extends ServiceBase {
...
@@ -469,7 +469,6 @@ class EntcontractService extends ServiceBase {
data
:
data
,
data
:
data
,
});
});
console
.
log
(
"段经理接口返回==============="
,
rs
);
console
.
log
(
"有赞商户创建result:"
,
rs
.
data
);
console
.
log
(
"有赞商户创建result:"
,
rs
.
data
);
var
reso
=
rs
.
data
;
var
reso
=
rs
.
data
;
var
erchants
=
await
this
.
yzmerchantsignedDao
.
findOne
({
var
erchants
=
await
this
.
yzmerchantsignedDao
.
findOne
({
...
...
bpo-web/app/base/utils/idcardClient.js
View file @
a500a22c
...
@@ -82,6 +82,81 @@ class IdcardClient {
...
@@ -82,6 +82,81 @@ class IdcardClient {
info
.
age
=
Number
(
age
);
info
.
age
=
Number
(
age
);
return
info
;
return
info
;
}
}
/*
* 身份证15位编码规则:dddddd yymmdd xx p
* dddddd:6位地区编码
* yymmdd: 出生年(两位年)月日,如:910215
* xx: 顺序编码,系统产生,无法确定
* p: 性别,奇数为男,偶数为女
*
* 身份证18位编码规则:dddddd yyyymmdd xxx y
* dddddd:6位地区编码
* yyyymmdd: 出生年(四位年)月日,如:19910215
* xxx:顺序编码,系统产生,无法确定,奇数为男,偶数为女
* y: 校验码,该位数值可通过前17位计算获得
*
* 前17位号码加权因子为 Wi = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ]
* 验证位 Y = [ 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2 ]
* 如果验证码恰好是10,为了保证身份证是十八位,那么第十八位将用X来代替
* 校验位计算公式:Y_P = mod( ∑(Ai×Wi),11 )
* i为身份证号码1...17 位; Y_P为校验码Y所在校验码数组位置
*/
async
validateIdCard
(
idCard
)
{
//15位和18位身份证号码的正则表达式
var
regIdCard
=
/^
(
^
[
1-9
]\d{7}((
0
\d)
|
(
1
[
0-2
]))(([
0|1|2
]\d)
|3
[
0-1
])\d{3}
$
)
|
(
^
[
1-9
]\d{5}[
1-9
]\d{3}((
0
\d)
|
(
1
[
0-2
]))(([
0|1|2
]\d)
|3
[
0-1
])((\d{4})
|
\d{3}[
Xx
])
$
)
$/
;
//如果通过该验证,说明身份证格式正确,但准确性还需计算
if
(
regIdCard
.
test
(
idCard
))
{
if
(
idCard
.
length
==
18
)
{
var
idCardWi
=
new
Array
(
7
,
9
,
10
,
5
,
8
,
4
,
2
,
1
,
6
,
3
,
7
,
9
,
10
,
5
,
8
,
4
,
2
);
//将前17位加权因子保存在数组里
var
idCardY
=
new
Array
(
1
,
0
,
10
,
9
,
8
,
7
,
6
,
5
,
4
,
3
,
2
);
//这是除以11后,可能产生的11位余数、验证码,也保存成数组
var
idCardWiSum
=
0
;
//用来保存前17位各自乖以加权因子后的总和
for
(
var
i
=
0
;
i
<
17
;
i
++
)
{
idCardWiSum
+=
idCard
.
substring
(
i
,
i
+
1
)
*
idCardWi
[
i
];
}
var
idCardMod
=
idCardWiSum
%
11
;
//计算出校验码所在数组的位置
var
idCardLast
=
idCard
.
substring
(
17
);
//得到最后一位身份证号码
//如果等于2,则说明校验码是10,身份证号码最后一位应该是X
if
(
idCardMod
==
2
)
{
if
(
idCardLast
==
"X"
||
idCardLast
==
"x"
)
{
return
"恭喜通过验证啦!"
;
}
else
{
return
"身份证号码错误!"
;
}
}
else
{
//用计算出的验证码与最后一位身份证号码匹配,如果一致,说明通过,否则是无效的身份证号码
if
(
idCardLast
==
idCardY
[
idCardMod
])
{
return
"恭喜通过验证啦!"
;
}
else
{
return
"身份证号码错误!"
;
}
}
}
}
else
{
return
"身份证格式不正确!"
;
}
}
}
}
module
.
exports
=
IdcardClient
;
module
.
exports
=
IdcardClient
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment