weapps-plugin-jingtong-verify 1.10.3 → 1.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/weapps-plugin-jingtong-verify/pages/setting/setting.js +1 -3
- package/weapps-plugin-jingtong-verify/utils/country.js +3 -3
- package/weapps-plugin-jingtong-verify/utils/index.js +1 -23
- package/weapps-plugin-jingtong-verify/utils/request.js +79 -220
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# SDK #
|
|
2
|
-
1.10.
|
|
2
|
+
1.10.2
|
package/package.json
CHANGED
|
@@ -283,10 +283,8 @@ Page({
|
|
|
283
283
|
// 进行微信人脸识别
|
|
284
284
|
toWxFace(name, idCardNumber) {
|
|
285
285
|
let sessionInfo = this.data.sessionInfo
|
|
286
|
-
// 前端输入正式码字后将其转换为pua码字,再传给微信进行刷脸
|
|
287
|
-
const convertToPuaName = utils.convertToPua(name)
|
|
288
286
|
wx.startFacialRecognitionVerify({
|
|
289
|
-
name
|
|
287
|
+
name,
|
|
290
288
|
idCardNumber,
|
|
291
289
|
checkAliveType: '2',
|
|
292
290
|
success(res) {
|
|
@@ -39,7 +39,7 @@ const nation = [
|
|
|
39
39
|
{ name: "(COOK ISLANDS)库克群岛", value: "COK", key: "C" },
|
|
40
40
|
{ name: "(COLOMBIA)哥伦比亚", value: "COL", key: "C" },
|
|
41
41
|
{ name: "(COMOROS)科摩罗", value: "COM", key: "C" },
|
|
42
|
-
{ name: "(CAPE VERDE)佛得角", value: "
|
|
42
|
+
{ name: "(CAPE VERDE)佛得角", value: "CPV", key: "C" },
|
|
43
43
|
{ name: "(COSTA RICA)哥斯达黎加", value: "CRI", key: "C" },
|
|
44
44
|
{ name: "(CUBA)古巴", value: "CUB", key: "C" },
|
|
45
45
|
{ name: "(CYPRUS)塞浦路斯", value: "CYP", key: "C" },
|
|
@@ -117,7 +117,7 @@ const nation = [
|
|
|
117
117
|
{ name: "(MONTENEGRO)黑山", value: "MNE", key: "M" },
|
|
118
118
|
{ name: "(MONGOLIA)蒙古", value: "MNG", key: "M" },
|
|
119
119
|
{ name: "(MOZAMBIQUE)莫桑比克", value: "MOZ", key: "M" },
|
|
120
|
-
{ name: "(MAURITANIA)毛里塔尼亚", value: "
|
|
120
|
+
{ name: "(MAURITANIA)毛里塔尼亚", value: "MRT", key: "M" },
|
|
121
121
|
{ name: "(MAURITIUS)毛里求斯", value: "MUS", key: "M" },
|
|
122
122
|
{ name: "(MALAWI)马拉维", value: "MWI", key: "M" },
|
|
123
123
|
{ name: "(MALAYSIA)马来西亚", value: "MYS", key: "M" },
|
|
@@ -157,7 +157,7 @@ const nation = [
|
|
|
157
157
|
{ name: "(SUDAN)苏丹", value: "SDN", key: "S" },
|
|
158
158
|
{ name: "(SENEGAL)塞内加尔", value: "SEN", key: "S" },
|
|
159
159
|
{ name: "(SINGAPORE)新加坡", value: "SGP", key: "S" },
|
|
160
|
-
{ name: "(SOLOMON ISLANDS)所罗门群岛", value: "
|
|
160
|
+
{ name: "(SOLOMON ISLANDS)所罗门群岛", value: "SLB", key: "S" },
|
|
161
161
|
{ name: "(SIERRA LEONE)塞拉利昂", value: "SLE", key: "S" },
|
|
162
162
|
{ name: "(SAN MARINO)圣马力诺", value: "SMR", key: "S" },
|
|
163
163
|
{ name: "(SOMALI)索马里", value: "SOM", key: "S" },
|
|
@@ -286,27 +286,6 @@ function getBirthByIDCard(idCard) {
|
|
|
286
286
|
return `${yearBirth}-${monthBirth}-${dayBirth}`
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
// 生僻字转换映射表:正式码字符 -> PUA字符(用转义形式)
|
|
290
|
-
const mapping = {
|
|
291
|
-
"\u{2C2A4}": "\uE348", // 𬊤 ->
|
|
292
|
-
"\u{2C386}": "\uE362", // 𬎆 ->
|
|
293
|
-
"\u{2E9F5}": "\uE43B", // 𮧵 ->
|
|
294
|
-
"\u{321D5}": "\uE5D6", // 𲇕 ->
|
|
295
|
-
"\u{2C029}": "\uE303", // 𬀩 ->
|
|
296
|
-
"\u{303A0}": "\uE2E7", // 𰎠 ->
|
|
297
|
-
"\u{2B37D}": "\uE3DD", // 𫍽 ->
|
|
298
|
-
"\u{2CC56}": "\uE43E", // 𬱖 ->
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// 转换函数:遍历姓名字符串,逐个替换
|
|
302
|
-
function convertToPua(fullName) {
|
|
303
|
-
let result = "";
|
|
304
|
-
for (let ch of fullName) {
|
|
305
|
-
result += mapping[ch] || ch; // 不在映射表中的保留原字符
|
|
306
|
-
}
|
|
307
|
-
return result;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
289
|
module.exports = {
|
|
311
290
|
validate,
|
|
312
291
|
awaitTo,
|
|
@@ -323,6 +302,5 @@ module.exports = {
|
|
|
323
302
|
greaterCurrentTime,
|
|
324
303
|
getCurrentTime,
|
|
325
304
|
getBirthByIDCard,
|
|
326
|
-
getCurrentDate
|
|
327
|
-
convertToPua
|
|
305
|
+
getCurrentDate
|
|
328
306
|
}
|
|
@@ -3,10 +3,7 @@ const {
|
|
|
3
3
|
DecrtptAES,
|
|
4
4
|
encryptSM3
|
|
5
5
|
} = require('./tifadmin_config')
|
|
6
|
-
const {
|
|
7
|
-
flow
|
|
8
|
-
} = require("@wecity/weda-plugin-utils");
|
|
9
|
-
const utils = require('./index.js');
|
|
6
|
+
const { flow } = require("@wecity/weda-plugin-utils");
|
|
10
7
|
|
|
11
8
|
var tifdid = ''
|
|
12
9
|
var isGettingUserInfo = false
|
|
@@ -109,11 +106,7 @@ function getOptions(options) {
|
|
|
109
106
|
|
|
110
107
|
function init(opt) {
|
|
111
108
|
console.log('auth sdk init', opt)
|
|
112
|
-
const {
|
|
113
|
-
paasid,
|
|
114
|
-
appid,
|
|
115
|
-
tifhost
|
|
116
|
-
} = opt
|
|
109
|
+
const { paasid, appid, tifhost } = opt
|
|
117
110
|
wx.setStorageSync('tif.paasid', paasid)
|
|
118
111
|
wx.setStorageSync('tif.appid', appid)
|
|
119
112
|
wx.setStorageSync('tif.host', tifhost)
|
|
@@ -151,7 +144,7 @@ function _request(options, retryTime = 3) {
|
|
|
151
144
|
if (!!tifEncrypt) {
|
|
152
145
|
options.header['x-tif-encrypt'] = "true"
|
|
153
146
|
}
|
|
154
|
-
let oldsucc = (options && options.success) || (()
|
|
147
|
+
let oldsucc = (options && options.success) || (()=>{})
|
|
155
148
|
// console.log(oldsucc, '============oldsucc=========')
|
|
156
149
|
options.success = function (res) {
|
|
157
150
|
if (options.hideLoadingWhenSucc) {
|
|
@@ -201,7 +194,7 @@ function getSessionId() {
|
|
|
201
194
|
return new Promise((resolve, reject) => {
|
|
202
195
|
const sid = wx.getStorageSync('tif.sid') || ''
|
|
203
196
|
console.log('===拦截获取storage中的tif.sid===', sid)
|
|
204
|
-
|
|
197
|
+
|
|
205
198
|
if (sid) {
|
|
206
199
|
resolve(sid)
|
|
207
200
|
} else {
|
|
@@ -242,18 +235,9 @@ function fetchSessionId() {
|
|
|
242
235
|
success: res => {
|
|
243
236
|
console.log('login res:', res)
|
|
244
237
|
isGettingUserInfo = false;
|
|
245
|
-
const {
|
|
246
|
-
data,
|
|
247
|
-
errcode
|
|
248
|
-
} = res.data
|
|
238
|
+
const { data, errcode } = res.data
|
|
249
239
|
if (errcode === 0 && data.session_id) {
|
|
250
|
-
let {
|
|
251
|
-
session_id,
|
|
252
|
-
uid,
|
|
253
|
-
openid,
|
|
254
|
-
real_name,
|
|
255
|
-
credential_id
|
|
256
|
-
} = data
|
|
240
|
+
let { session_id, uid, openid, real_name, credential_id } = data
|
|
257
241
|
|
|
258
242
|
// 存到local
|
|
259
243
|
// 本地存入openid,人工审核状态查询时使用
|
|
@@ -291,11 +275,7 @@ function fetchSessionId() {
|
|
|
291
275
|
|
|
292
276
|
// 微信手机号授权
|
|
293
277
|
function _loginPhone(options) {
|
|
294
|
-
const {
|
|
295
|
-
encryptedData: encrypted_data,
|
|
296
|
-
iv,
|
|
297
|
-
source = ''
|
|
298
|
-
} = options
|
|
278
|
+
const { encryptedData: encrypted_data, iv, source = '' } = options
|
|
299
279
|
|
|
300
280
|
return new Promise((resolve, reject) => {
|
|
301
281
|
// 对手机号进行解密
|
|
@@ -314,10 +294,7 @@ function _loginPhone(options) {
|
|
|
314
294
|
isGettingUserInfo = false;
|
|
315
295
|
if (res.data.errcode === 0) {
|
|
316
296
|
const data = res.data.data
|
|
317
|
-
let {
|
|
318
|
-
real_name,
|
|
319
|
-
credential_id
|
|
320
|
-
} = data
|
|
297
|
+
let { real_name, credential_id } = data
|
|
321
298
|
runUserInfoCallback({
|
|
322
299
|
name: real_name,
|
|
323
300
|
id: credential_id,
|
|
@@ -352,18 +329,11 @@ function _loginPhone(options) {
|
|
|
352
329
|
function _faceVerifyWithIdCard(params) {
|
|
353
330
|
return new Promise((resolve, reject) => {
|
|
354
331
|
const [tifhost, appid, paasid] = getOptions(['tifhost', 'appid', 'paasid'])
|
|
355
|
-
const {
|
|
356
|
-
|
|
357
|
-
id_card_number,
|
|
358
|
-
name
|
|
359
|
-
} = params
|
|
360
|
-
|
|
361
|
-
// 前端输入正式码字后将其转换为pua码字,再传给微信进行刷脸
|
|
362
|
-
const convertToPuaName = utils.convertToPua(name)
|
|
363
|
-
|
|
332
|
+
const { person_type, id_card_number, name } = params
|
|
333
|
+
|
|
364
334
|
wx.startFacialRecognitionVerify({
|
|
365
335
|
userIdKey: person_type == '10' ? '' : params.user_id_key,
|
|
366
|
-
name
|
|
336
|
+
name,
|
|
367
337
|
idCardNumber: id_card_number,
|
|
368
338
|
checkAliveType: '2',
|
|
369
339
|
success(res) {
|
|
@@ -376,11 +346,7 @@ function _faceVerifyWithIdCard(params) {
|
|
|
376
346
|
title: '认证中...'
|
|
377
347
|
})
|
|
378
348
|
|
|
379
|
-
let {
|
|
380
|
-
isbind,
|
|
381
|
-
cid_type,
|
|
382
|
-
verify_expire_time
|
|
383
|
-
} = params
|
|
349
|
+
let { isbind, cid_type, verify_expire_time } = params
|
|
384
350
|
|
|
385
351
|
_request({
|
|
386
352
|
url: `${tifhost}/api/check_face_verify_result`,
|
|
@@ -398,17 +364,14 @@ function _faceVerifyWithIdCard(params) {
|
|
|
398
364
|
success: res => {
|
|
399
365
|
console.log('check_face_verify_result成功', res)
|
|
400
366
|
wx.hideLoading()
|
|
401
|
-
let {
|
|
402
|
-
errcode,
|
|
403
|
-
data
|
|
404
|
-
} = res.data
|
|
367
|
+
let { errcode, data } = res.data
|
|
405
368
|
if (errcode !== 0) {
|
|
406
369
|
return reject(JSON.stringify(res.data))
|
|
407
370
|
}
|
|
408
371
|
try {
|
|
409
372
|
console.log('===========try-catch===========')
|
|
410
373
|
wx.setStorageSync('tif.sid', data.session_id)
|
|
411
|
-
} catch
|
|
374
|
+
} catch(err) {
|
|
412
375
|
// 重新静默登录
|
|
413
376
|
fetchSessionId()
|
|
414
377
|
}
|
|
@@ -497,10 +460,7 @@ function _getLoginConfig(options) {
|
|
|
497
460
|
url: tifhost + '/api/get_login_config',
|
|
498
461
|
method: 'GET',
|
|
499
462
|
success: res => {
|
|
500
|
-
let {
|
|
501
|
-
errcode,
|
|
502
|
-
data
|
|
503
|
-
} = res.data
|
|
463
|
+
let { errcode, data } = res.data
|
|
504
464
|
if (errcode === 0) {
|
|
505
465
|
options && options.success && options.success(data)
|
|
506
466
|
} else {
|
|
@@ -515,24 +475,19 @@ function _getLoginConfig(options) {
|
|
|
515
475
|
|
|
516
476
|
function _getSession(options) {
|
|
517
477
|
const [tifhost] = getOptions(['tifhost'])
|
|
518
|
-
|
|
478
|
+
|
|
519
479
|
return _request({
|
|
520
480
|
url: tifhost + '/tif/sys/session',
|
|
521
481
|
tifEncrypt: true,
|
|
522
482
|
success: res => {
|
|
523
483
|
console.log('request _getSession success: ', res)
|
|
524
|
-
const {
|
|
525
|
-
errcode,
|
|
526
|
-
data
|
|
527
|
-
} = res.data
|
|
484
|
+
const { errcode, data } = res.data
|
|
528
485
|
if (errcode === 0) {
|
|
529
|
-
const {
|
|
530
|
-
name = '', cid = '', phone = '', caPhone = '', passport_number = ''
|
|
531
|
-
} = data
|
|
486
|
+
const { name = '', cid = '', phone = '', caPhone = '', passport_number = '' } = data
|
|
532
487
|
if (name && name.indexOf('tif_') >= 0) {
|
|
533
488
|
try {
|
|
534
489
|
data.name = DecrtptAES(name.split('tif_')[1])
|
|
535
|
-
} catch
|
|
490
|
+
} catch(err) {
|
|
536
491
|
console.log('name捕获错误')
|
|
537
492
|
data.name = name
|
|
538
493
|
}
|
|
@@ -540,7 +495,7 @@ function _getSession(options) {
|
|
|
540
495
|
if (cid && cid.indexOf('tif_') >= 0) {
|
|
541
496
|
try {
|
|
542
497
|
data.cid = DecrtptAES(cid.split('tif_')[1])
|
|
543
|
-
} catch
|
|
498
|
+
} catch(err) {
|
|
544
499
|
console.log('cid捕获错误')
|
|
545
500
|
data.cid = cid
|
|
546
501
|
}
|
|
@@ -548,7 +503,7 @@ function _getSession(options) {
|
|
|
548
503
|
if (phone && phone.indexOf('tif_') >= 0) {
|
|
549
504
|
try {
|
|
550
505
|
data.phone = DecrtptAES(phone.split('tif_')[1])
|
|
551
|
-
} catch
|
|
506
|
+
} catch(err) {
|
|
552
507
|
console.log('phone捕获错误')
|
|
553
508
|
data.phone = phone
|
|
554
509
|
}
|
|
@@ -556,7 +511,7 @@ function _getSession(options) {
|
|
|
556
511
|
if (caPhone && caPhone.indexOf('tif_') >= 0) {
|
|
557
512
|
try {
|
|
558
513
|
data.caPhone = DecrtptAES(caPhone.split('tif_')[1])
|
|
559
|
-
} catch
|
|
514
|
+
} catch(err) {
|
|
560
515
|
console.log('caPhone捕获错误')
|
|
561
516
|
data.caPhone = caPhone
|
|
562
517
|
}
|
|
@@ -564,7 +519,7 @@ function _getSession(options) {
|
|
|
564
519
|
if (passport_number && passport_number.indexOf('tif_') >= 0) {
|
|
565
520
|
try {
|
|
566
521
|
data.passport_number = DecrtptAES(passport_number.split('tif_')[1])
|
|
567
|
-
} catch
|
|
522
|
+
} catch(err) {
|
|
568
523
|
console.log('passport_number捕获错误')
|
|
569
524
|
data.passport_number = passport_number
|
|
570
525
|
}
|
|
@@ -609,10 +564,7 @@ function _confirmPhone() {
|
|
|
609
564
|
data: submitData,
|
|
610
565
|
success: res => {
|
|
611
566
|
wx.hideLoading();
|
|
612
|
-
let {
|
|
613
|
-
errcode,
|
|
614
|
-
data
|
|
615
|
-
} = res.data
|
|
567
|
+
let { errcode, data } = res.data
|
|
616
568
|
if (errcode !== 0) {
|
|
617
569
|
if (errcode === 4035) {
|
|
618
570
|
// 获取ca手机号码失败,跳转到绑定手机号码页面
|
|
@@ -647,10 +599,7 @@ function _logOut() {
|
|
|
647
599
|
url: `${tifhost}/api/mp/logout`,
|
|
648
600
|
success: res => {
|
|
649
601
|
wx.hideLoading();
|
|
650
|
-
let {
|
|
651
|
-
errcode,
|
|
652
|
-
data
|
|
653
|
-
} = res.data
|
|
602
|
+
let { errcode, data } = res.data
|
|
654
603
|
if (errcode !== 0) {
|
|
655
604
|
return reject(JSON.stringify(res.data))
|
|
656
605
|
}
|
|
@@ -667,11 +616,7 @@ function _logOut() {
|
|
|
667
616
|
// 账号注销
|
|
668
617
|
function _logOff(options) {
|
|
669
618
|
const [tifhost, appid, paasid] = getOptions(['tifhost', 'appid', 'paasid'])
|
|
670
|
-
const {
|
|
671
|
-
id_card_number,
|
|
672
|
-
name,
|
|
673
|
-
verify_result
|
|
674
|
-
} = options
|
|
619
|
+
const { id_card_number, name, verify_result } = options
|
|
675
620
|
|
|
676
621
|
const submitData = Object.assign({}, {
|
|
677
622
|
appid,
|
|
@@ -687,10 +632,7 @@ function _logOff(options) {
|
|
|
687
632
|
data: submitData,
|
|
688
633
|
success: res => {
|
|
689
634
|
wx.hideLoading();
|
|
690
|
-
let {
|
|
691
|
-
errcode,
|
|
692
|
-
data
|
|
693
|
-
} = res.data
|
|
635
|
+
let { errcode, data } = res.data
|
|
694
636
|
if (errcode !== 0) {
|
|
695
637
|
return reject(JSON.stringify(res.data))
|
|
696
638
|
}
|
|
@@ -707,7 +649,7 @@ function _logOff(options) {
|
|
|
707
649
|
// 银行卡身份核验接口
|
|
708
650
|
function _bankCardAuth(options) {
|
|
709
651
|
const [tifhost, appid, paasid] = getOptions(['tifhost', 'appid', 'paasid'])
|
|
710
|
-
const {
|
|
652
|
+
const {
|
|
711
653
|
name,
|
|
712
654
|
id_card_number,
|
|
713
655
|
isbind,
|
|
@@ -758,7 +700,7 @@ function _bankCardAuth(options) {
|
|
|
758
700
|
// 外国人护照核验接口
|
|
759
701
|
function _passportAuth(options) {
|
|
760
702
|
const [tifhost, appid, paasid] = getOptions(['tifhost', 'appid', 'paasid'])
|
|
761
|
-
const {
|
|
703
|
+
const {
|
|
762
704
|
sur_name,
|
|
763
705
|
id_card_number,
|
|
764
706
|
phone,
|
|
@@ -793,10 +735,7 @@ function _passportAuth(options) {
|
|
|
793
735
|
data: submitData,
|
|
794
736
|
success: res => {
|
|
795
737
|
wx.hideLoading();
|
|
796
|
-
let {
|
|
797
|
-
errcode,
|
|
798
|
-
data
|
|
799
|
-
} = res.data
|
|
738
|
+
let { errcode, data } = res.data
|
|
800
739
|
if (errcode !== 0) {
|
|
801
740
|
return reject(JSON.stringify(res.data))
|
|
802
741
|
}
|
|
@@ -819,22 +758,14 @@ function _getPassportInfo(options) {
|
|
|
819
758
|
method: 'GET',
|
|
820
759
|
tifEncrypt: true,
|
|
821
760
|
success: res => {
|
|
822
|
-
let {
|
|
823
|
-
errcode,
|
|
824
|
-
data
|
|
825
|
-
} = res.data
|
|
761
|
+
let { errcode, data } = res.data
|
|
826
762
|
if (errcode === 0) {
|
|
827
|
-
const {
|
|
828
|
-
first_name,
|
|
829
|
-
sur_name,
|
|
830
|
-
id_card_number,
|
|
831
|
-
phone = ''
|
|
832
|
-
} = data
|
|
763
|
+
const { first_name, sur_name, id_card_number, phone = '' } = data
|
|
833
764
|
if (first_name && first_name.indexOf('tif_') >= 0) {
|
|
834
765
|
console.log('解密first_name')
|
|
835
766
|
try {
|
|
836
767
|
data.first_name = DecrtptAES(first_name.split('tif_')[1])
|
|
837
|
-
} catch
|
|
768
|
+
} catch(err) {
|
|
838
769
|
console.log('first_name捕获错误')
|
|
839
770
|
data.first_name = first_name
|
|
840
771
|
}
|
|
@@ -843,7 +774,7 @@ function _getPassportInfo(options) {
|
|
|
843
774
|
console.log('解密sur_name')
|
|
844
775
|
try {
|
|
845
776
|
data.sur_name = DecrtptAES(sur_name.split('tif_')[1])
|
|
846
|
-
} catch
|
|
777
|
+
} catch(err) {
|
|
847
778
|
console.log('sur_name捕获错误')
|
|
848
779
|
data.sur_name = sur_name
|
|
849
780
|
}
|
|
@@ -852,7 +783,7 @@ function _getPassportInfo(options) {
|
|
|
852
783
|
console.log('解密id_card_number')
|
|
853
784
|
try {
|
|
854
785
|
data.id_card_number = DecrtptAES(id_card_number.split('tif_')[1])
|
|
855
|
-
} catch
|
|
786
|
+
} catch(err) {
|
|
856
787
|
console.log('id_card_number捕获错误')
|
|
857
788
|
data.id_card_number = id_card_number
|
|
858
789
|
}
|
|
@@ -861,7 +792,7 @@ function _getPassportInfo(options) {
|
|
|
861
792
|
console.log('解密phone')
|
|
862
793
|
try {
|
|
863
794
|
data.phone = DecrtptAES(phone.split('tif_')[1])
|
|
864
|
-
} catch
|
|
795
|
+
} catch(err) {
|
|
865
796
|
console.log('phone捕获错误')
|
|
866
797
|
data.phone = phone
|
|
867
798
|
}
|
|
@@ -886,9 +817,7 @@ function _deletePassportAuth(options) {
|
|
|
886
817
|
method: 'GET',
|
|
887
818
|
success: res => {
|
|
888
819
|
console.log('删除核验信息接口res', res)
|
|
889
|
-
let {
|
|
890
|
-
errcode
|
|
891
|
-
} = res.data
|
|
820
|
+
let { errcode } = res.data
|
|
892
821
|
if (errcode !== 0) {
|
|
893
822
|
options && options.fail && options.fail(JSON.stringify(res.data))
|
|
894
823
|
} else {
|
|
@@ -927,11 +856,7 @@ function _personToken(e) {
|
|
|
927
856
|
method: 'POST',
|
|
928
857
|
tifEncrypt: true,
|
|
929
858
|
success: res => {
|
|
930
|
-
let {
|
|
931
|
-
errcode,
|
|
932
|
-
errmsg,
|
|
933
|
-
data
|
|
934
|
-
} = res.data
|
|
859
|
+
let { errcode, errmsg, data } = res.data
|
|
935
860
|
if (errcode !== 0) {
|
|
936
861
|
if (errcode === 4035) {
|
|
937
862
|
if (e && e.from === 'sdk') {
|
|
@@ -944,8 +869,8 @@ function _personToken(e) {
|
|
|
944
869
|
}
|
|
945
870
|
} else {
|
|
946
871
|
if (errcode === 2034) {
|
|
947
|
-
|
|
948
|
-
|
|
872
|
+
// 重新静默登录
|
|
873
|
+
fetchSessionId()
|
|
949
874
|
}
|
|
950
875
|
wx.showToast({
|
|
951
876
|
title: errmsg || 'person_token获取失败',
|
|
@@ -957,14 +882,12 @@ function _personToken(e) {
|
|
|
957
882
|
} else {
|
|
958
883
|
// 存储
|
|
959
884
|
wx.setStorageSync('tif.CAUniqueId', data.uniqueId)
|
|
960
|
-
const {
|
|
961
|
-
phone = ''
|
|
962
|
-
} = data
|
|
885
|
+
const { phone = '' } = data
|
|
963
886
|
if (phone && phone.indexOf('tif_') >= 0) {
|
|
964
887
|
console.log('解密phone')
|
|
965
888
|
try {
|
|
966
889
|
data.phone = DecrtptAES(phone.split('tif_')[1])
|
|
967
|
-
} catch
|
|
890
|
+
} catch(err) {
|
|
968
891
|
console.log('phone捕获错误')
|
|
969
892
|
data.phone = phone
|
|
970
893
|
}
|
|
@@ -989,11 +912,7 @@ function _operateFaceFailCount(options) {
|
|
|
989
912
|
const [tifhost] = getOptions(['tifhost'])
|
|
990
913
|
|
|
991
914
|
return new Promise((resolve, reject) => {
|
|
992
|
-
const {
|
|
993
|
-
cid,
|
|
994
|
-
age,
|
|
995
|
-
count
|
|
996
|
-
} = options
|
|
915
|
+
const { cid, age, count } = options
|
|
997
916
|
_request({
|
|
998
917
|
url: `${tifhost}/api/check_limit`,
|
|
999
918
|
method: 'POST',
|
|
@@ -1005,10 +924,7 @@ function _operateFaceFailCount(options) {
|
|
|
1005
924
|
age,
|
|
1006
925
|
},
|
|
1007
926
|
success: res => {
|
|
1008
|
-
let {
|
|
1009
|
-
errcode,
|
|
1010
|
-
data
|
|
1011
|
-
} = res.data
|
|
927
|
+
let { errcode, data } = res.data
|
|
1012
928
|
if (errcode !== 0) {
|
|
1013
929
|
return reject(JSON.stringify(res.data))
|
|
1014
930
|
}
|
|
@@ -1029,10 +945,7 @@ function _getUserReadStatus() {
|
|
|
1029
945
|
_request({
|
|
1030
946
|
url: `${tifhost}/api/get_user_read_status`,
|
|
1031
947
|
success: res => {
|
|
1032
|
-
let {
|
|
1033
|
-
errcode,
|
|
1034
|
-
data
|
|
1035
|
-
} = res.data
|
|
948
|
+
let { errcode, data } = res.data
|
|
1036
949
|
if (errcode !== 0) {
|
|
1037
950
|
return reject(JSON.stringify(res.data))
|
|
1038
951
|
}
|
|
@@ -1057,10 +970,7 @@ function _setUserReadStatus(needRead = true) {
|
|
|
1057
970
|
needRead
|
|
1058
971
|
},
|
|
1059
972
|
success: res => {
|
|
1060
|
-
let {
|
|
1061
|
-
errcode,
|
|
1062
|
-
data
|
|
1063
|
-
} = res.data
|
|
973
|
+
let { errcode, data } = res.data
|
|
1064
974
|
if (errcode !== 0) {
|
|
1065
975
|
return reject(JSON.stringify(res.data))
|
|
1066
976
|
}
|
|
@@ -1123,18 +1033,14 @@ function _caEncrypt(options) {
|
|
|
1123
1033
|
birthday = '',
|
|
1124
1034
|
} = options
|
|
1125
1035
|
|
|
1126
|
-
const {
|
|
1127
|
-
verifyType,
|
|
1128
|
-
supportType,
|
|
1129
|
-
supportTypeMore
|
|
1130
|
-
} = faceReceptionTypeMap[cid_type]
|
|
1036
|
+
const { verifyType, supportType, supportTypeMore } = faceReceptionTypeMap[cid_type]
|
|
1131
1037
|
let verify_type = verifyType
|
|
1132
1038
|
let support_type = birthday ? supportTypeMore : supportType
|
|
1133
1039
|
|
|
1134
1040
|
if (cid_type === '516' && nation !== 'CHN') {
|
|
1135
1041
|
// 港澳居民来往内地通行证(非中国籍)
|
|
1136
1042
|
verify_type = '108'
|
|
1137
|
-
support_type = '146'
|
|
1043
|
+
support_type = '146'
|
|
1138
1044
|
}
|
|
1139
1045
|
|
|
1140
1046
|
const data = {
|
|
@@ -1158,10 +1064,7 @@ function _caEncrypt(options) {
|
|
|
1158
1064
|
method: 'POST',
|
|
1159
1065
|
data,
|
|
1160
1066
|
success: res => {
|
|
1161
|
-
let {
|
|
1162
|
-
errcode,
|
|
1163
|
-
data
|
|
1164
|
-
} = res.data
|
|
1067
|
+
let { errcode, data } = res.data
|
|
1165
1068
|
if (errcode !== 0) {
|
|
1166
1069
|
return reject(JSON.stringify(res.data))
|
|
1167
1070
|
}
|
|
@@ -1195,18 +1098,8 @@ function _faceVerifyWithUserIdKey(options) {
|
|
|
1195
1098
|
title: `${dict.showLoading[language]}`
|
|
1196
1099
|
})
|
|
1197
1100
|
|
|
1198
|
-
let {
|
|
1199
|
-
isbind,
|
|
1200
|
-
cid_type,
|
|
1201
|
-
verify_expire_time,
|
|
1202
|
-
name,
|
|
1203
|
-
id_card_number,
|
|
1204
|
-
passport_number,
|
|
1205
|
-
validity_period,
|
|
1206
|
-
nation,
|
|
1207
|
-
cid_expire_date = '',
|
|
1208
|
-
sex = 0,
|
|
1209
|
-
birthday = ''
|
|
1101
|
+
let {
|
|
1102
|
+
isbind, cid_type, verify_expire_time, name, id_card_number, passport_number, validity_period, nation, cid_expire_date = '', sex = 0, birthday = ''
|
|
1210
1103
|
} = options
|
|
1211
1104
|
|
|
1212
1105
|
let paramsData = {
|
|
@@ -1235,10 +1128,7 @@ function _faceVerifyWithUserIdKey(options) {
|
|
|
1235
1128
|
success: res => {
|
|
1236
1129
|
console.log('check_face_verify_result成功', res)
|
|
1237
1130
|
wx.hideLoading()
|
|
1238
|
-
let {
|
|
1239
|
-
errcode,
|
|
1240
|
-
data
|
|
1241
|
-
} = res.data
|
|
1131
|
+
let { errcode, data } = res.data
|
|
1242
1132
|
if (errcode !== 0) {
|
|
1243
1133
|
return reject(JSON.stringify(res.data))
|
|
1244
1134
|
}
|
|
@@ -1246,9 +1136,9 @@ function _faceVerifyWithUserIdKey(options) {
|
|
|
1246
1136
|
try {
|
|
1247
1137
|
console.log('===========try-catch===========')
|
|
1248
1138
|
wx.setStorageSync('tif.sid', data.session_id)
|
|
1249
|
-
} catch
|
|
1250
|
-
|
|
1251
|
-
|
|
1139
|
+
} catch(err) {
|
|
1140
|
+
// 重新静默登录
|
|
1141
|
+
fetchSessionId()
|
|
1252
1142
|
}
|
|
1253
1143
|
_getSession({
|
|
1254
1144
|
success: (session) => {
|
|
@@ -1275,30 +1165,20 @@ function _faceVerifyWithUserIdKey(options) {
|
|
|
1275
1165
|
function _fetchFaceVerify(options) {
|
|
1276
1166
|
console.log('====对外API拉起人脸options:====', options)
|
|
1277
1167
|
const params = options.params || {}
|
|
1278
|
-
const {
|
|
1279
|
-
cid_type,
|
|
1280
|
-
id_card_number,
|
|
1281
|
-
name
|
|
1282
|
-
} = params
|
|
1168
|
+
const { cid_type, id_card_number, name } = params
|
|
1283
1169
|
|
|
1284
1170
|
// 证件类型拦截
|
|
1285
1171
|
const cidTypeList = ['111', '516', '511', '553', '414', '17', '18']
|
|
1286
1172
|
if (!cidTypeList.includes(cid_type)) {
|
|
1287
|
-
return faceFail(options, {
|
|
1288
|
-
'errMsg': `传入的证件类型不存在:${cid_type}`
|
|
1289
|
-
})
|
|
1173
|
+
return faceFail(options, {'errMsg': `传入的证件类型不存在:${cid_type}`})
|
|
1290
1174
|
}
|
|
1291
1175
|
|
|
1292
1176
|
// 必填字段校验
|
|
1293
1177
|
if (!id_card_number) {
|
|
1294
|
-
return faceFail(options, {
|
|
1295
|
-
'errMsg': 'id_card_number字段缺失'
|
|
1296
|
-
})
|
|
1178
|
+
return faceFail(options, {'errMsg': 'id_card_number字段缺失'})
|
|
1297
1179
|
}
|
|
1298
1180
|
if (!name) {
|
|
1299
|
-
return faceFail(options, {
|
|
1300
|
-
'errMsg': 'name字段缺失'
|
|
1301
|
-
})
|
|
1181
|
+
return faceFail(options, {'errMsg': 'name字段缺失'})
|
|
1302
1182
|
}
|
|
1303
1183
|
|
|
1304
1184
|
wx.showLoading({
|
|
@@ -1308,11 +1188,9 @@ function _fetchFaceVerify(options) {
|
|
|
1308
1188
|
|
|
1309
1189
|
// 身份证
|
|
1310
1190
|
if (cid_type === '111') {
|
|
1311
|
-
// 前端输入正式码字后将其转换为pua码字,再传给微信进行刷脸
|
|
1312
|
-
const convertToPuaName = utils.convertToPua(name)
|
|
1313
1191
|
wx.startFacialRecognitionVerify({
|
|
1314
1192
|
userIdKey: '',
|
|
1315
|
-
name
|
|
1193
|
+
name,
|
|
1316
1194
|
idCardNumber: id_card_number,
|
|
1317
1195
|
checkAliveType: '2',
|
|
1318
1196
|
success: res => {
|
|
@@ -1330,21 +1208,15 @@ function _fetchFaceVerify(options) {
|
|
|
1330
1208
|
} else {
|
|
1331
1209
|
// 外国人永居证:国籍必填
|
|
1332
1210
|
if (cid_type === '553' && !params.nation) {
|
|
1333
|
-
return faceFail(options, {
|
|
1334
|
-
'errMsg': 'nation字段缺失'
|
|
1335
|
-
})
|
|
1211
|
+
return faceFail(options, {'errMsg': 'nation字段缺失'})
|
|
1336
1212
|
}
|
|
1337
1213
|
// 港澳、台湾居住证:通行证号码/证件生效日期必填
|
|
1338
1214
|
if (cid_type === '17' || cid_type === '18') {
|
|
1339
1215
|
if (!params.passport_number) {
|
|
1340
|
-
return faceFail(options, {
|
|
1341
|
-
'errMsg': 'passport_number字段缺失'
|
|
1342
|
-
})
|
|
1216
|
+
return faceFail(options, {'errMsg': 'passport_number字段缺失'})
|
|
1343
1217
|
}
|
|
1344
1218
|
if (!params.validity_period) {
|
|
1345
|
-
return faceFail(options, {
|
|
1346
|
-
'errMsg': 'validity_period字段缺失'
|
|
1347
|
-
})
|
|
1219
|
+
return faceFail(options, {'errMsg': 'validity_period字段缺失'})
|
|
1348
1220
|
}
|
|
1349
1221
|
}
|
|
1350
1222
|
// 出入境人脸
|
|
@@ -1368,19 +1240,15 @@ function _fetchFaceVerify(options) {
|
|
|
1368
1240
|
console.log('ca加密err', err)
|
|
1369
1241
|
try {
|
|
1370
1242
|
return faceFail(options, JSON.parse(err))
|
|
1371
|
-
} catch
|
|
1372
|
-
return faceFail(options, {
|
|
1373
|
-
'errMsg': '人脸识别不支持电脑端,请使用真机'
|
|
1374
|
-
})
|
|
1243
|
+
} catch(catchErr) {
|
|
1244
|
+
return faceFail(options, {'errMsg': '人脸识别不支持电脑端,请使用真机'})
|
|
1375
1245
|
}
|
|
1376
1246
|
})
|
|
1377
1247
|
}
|
|
1378
1248
|
}
|
|
1379
1249
|
|
|
1380
1250
|
function faceFail(options, res) {
|
|
1381
|
-
const {
|
|
1382
|
-
errCode = '', errMsg = '', errmsg = ''
|
|
1383
|
-
} = res
|
|
1251
|
+
const { errCode = '', errMsg = '', errmsg = '' } = res
|
|
1384
1252
|
let title = errMsg || errmsg || '人脸识别失败,请重试!'
|
|
1385
1253
|
|
|
1386
1254
|
// 常见状态码处理
|
|
@@ -1428,16 +1296,16 @@ function _userEntityReport(options) {
|
|
|
1428
1296
|
|
|
1429
1297
|
const {
|
|
1430
1298
|
phone = '',
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1299
|
+
sex = '',
|
|
1300
|
+
user_status = '1',
|
|
1301
|
+
certType = '',
|
|
1302
|
+
openid = '',
|
|
1303
|
+
last_login_time = '',
|
|
1304
|
+
user_date_of_birth = ''
|
|
1437
1305
|
} = options
|
|
1438
1306
|
|
|
1439
1307
|
const paramsBase = {
|
|
1440
|
-
business_id:
|
|
1308
|
+
business_id: wx.getStorageSync('tif.CAUniqueId') || '', // 业务账号,使用统一认证唯一ID,业务系统下的唯一标识
|
|
1441
1309
|
wx_unionid: openid, // 传openid
|
|
1442
1310
|
sourcefrom: 'wx', // 来源
|
|
1443
1311
|
encrypt_mobile: encryptSM3(phone) || '', // 手机号,使用SM3不可逆加密的手机号
|
|
@@ -1465,10 +1333,7 @@ function _userEntityReport(options) {
|
|
|
1465
1333
|
data: paramsFull,
|
|
1466
1334
|
success: res => {
|
|
1467
1335
|
console.log('==埋点接口返回res==', res)
|
|
1468
|
-
let {
|
|
1469
|
-
code,
|
|
1470
|
-
data
|
|
1471
|
-
} = res.data
|
|
1336
|
+
let { code, data } = res.data
|
|
1472
1337
|
if (code !== 0) {
|
|
1473
1338
|
return reject(JSON.stringify(res.data))
|
|
1474
1339
|
}
|
|
@@ -1488,7 +1353,7 @@ function _updateSB(options) {
|
|
|
1488
1353
|
|
|
1489
1354
|
const {
|
|
1490
1355
|
sex = '',
|
|
1491
|
-
|
|
1356
|
+
birthday = '',
|
|
1492
1357
|
} = options
|
|
1493
1358
|
|
|
1494
1359
|
const data = {
|
|
@@ -1502,17 +1367,14 @@ function _updateSB(options) {
|
|
|
1502
1367
|
method: 'POST',
|
|
1503
1368
|
data,
|
|
1504
1369
|
success: res => {
|
|
1505
|
-
let {
|
|
1506
|
-
errcode,
|
|
1507
|
-
data
|
|
1508
|
-
} = res.data
|
|
1370
|
+
let { errcode, data } = res.data
|
|
1509
1371
|
if (errcode !== 0) {
|
|
1510
1372
|
return reject(res.data)
|
|
1511
1373
|
}
|
|
1512
1374
|
try {
|
|
1513
1375
|
console.log('===========try-catch===========', data)
|
|
1514
1376
|
wx.setStorageSync('tif.sid', data.session_id)
|
|
1515
|
-
} catch
|
|
1377
|
+
} catch(err) {
|
|
1516
1378
|
// 重新静默登录
|
|
1517
1379
|
fetchSessionId()
|
|
1518
1380
|
}
|
|
@@ -1533,10 +1395,7 @@ function getDrainageModalIsShow() {
|
|
|
1533
1395
|
_request({
|
|
1534
1396
|
url: `${tifhost}/ebus/tifapi/qianduan/drainageModal`,
|
|
1535
1397
|
success: res => {
|
|
1536
|
-
let {
|
|
1537
|
-
statusCode,
|
|
1538
|
-
data
|
|
1539
|
-
} = res
|
|
1398
|
+
let { statusCode, data } = res
|
|
1540
1399
|
if (statusCode !== 200) {
|
|
1541
1400
|
return reject(JSON.stringify(res))
|
|
1542
1401
|
}
|
|
@@ -1600,7 +1459,7 @@ module.exports = {
|
|
|
1600
1459
|
deletePassportAuth: _deletePassportAuth,
|
|
1601
1460
|
|
|
1602
1461
|
// 获取personToken
|
|
1603
|
-
personToken:
|
|
1462
|
+
personToken: _personToken,
|
|
1604
1463
|
|
|
1605
1464
|
// 获取/设置人脸失败次数
|
|
1606
1465
|
operateFaceFailCount: _operateFaceFailCount,
|