weapps-plugin-jingtong-verify 1.10.1 → 1.10.3
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/components/drainage-modal/drainage-modal.wxml +1 -1
- package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.js +13 -1
- package/weapps-plugin-jingtong-verify/pages/setting/setting.js +3 -1
- package/weapps-plugin-jingtong-verify/utils/index.js +23 -1
- package/weapps-plugin-jingtong-verify/utils/request.js +243 -79
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# SDK #
|
|
2
|
-
1.10.
|
|
2
|
+
1.10.3
|
package/package.json
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
<image class="bg-image" src="https://js.jt.beijing.gov.cn/jt/APP/APP-xiazai.png"></image>
|
|
4
4
|
<image class="btn-image" src="https://js.jt.beijing.gov.cn/jt/APP/APP-zhidao.png" bind:tap="handleOk"></image>
|
|
5
5
|
<view class="btns">
|
|
6
|
-
<view class="btn" bind:tap="handleCopy" data-link='https://apps.apple.com/cn/app/%E4%BA%AC%E9%80%9A/id6749835625'>苹果用户:点击即可复制下载链接</view>
|
|
7
6
|
<view class="btn" bind:tap="handleCopy" data-link='https://app.jt.beijing.gov.cn/api/file/external/jtfs/download/latest'>安卓用户:点击即可复制下载链接</view>
|
|
8
7
|
<view class="btn" bind:tap="handleCopy" data-link='https://appgallery.huawei.com/app/detail?id=com.bjbdc.jingtong.hos&channelId=SHARE&source=appshare'>鸿蒙用户:点击即可复制下载链接</view>
|
|
8
|
+
<view class="btn" bind:tap="handleCopy" data-link='https://apps.apple.com/cn/app/%E4%BA%AC%E9%80%9A/id6749835625'>苹果用户:点击即可复制下载链接</view>
|
|
9
9
|
</view>
|
|
10
10
|
</view>
|
|
11
11
|
</view>
|
|
@@ -191,7 +191,7 @@ Page({
|
|
|
191
191
|
// 自定义校验提示文本
|
|
192
192
|
customTipsMsg: '',
|
|
193
193
|
// 显示引流modal
|
|
194
|
-
showDrainageModal:
|
|
194
|
+
showDrainageModal: false
|
|
195
195
|
},
|
|
196
196
|
|
|
197
197
|
handleDrainageModalOk() {
|
|
@@ -200,6 +200,16 @@ Page({
|
|
|
200
200
|
})
|
|
201
201
|
},
|
|
202
202
|
|
|
203
|
+
getDrainageModalIsShow() {
|
|
204
|
+
const that = this
|
|
205
|
+
jingtongVerifyRequest.getDrainageModalIsShow().then(res => {
|
|
206
|
+
console.log('getDrainageModalIsShow: ', res)
|
|
207
|
+
that.setData({
|
|
208
|
+
showDrainageModal: res && res.isShow === 1
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
},
|
|
212
|
+
|
|
203
213
|
/**
|
|
204
214
|
* 生命周期函数--监听页面加载
|
|
205
215
|
*/
|
|
@@ -211,6 +221,8 @@ Page({
|
|
|
211
221
|
|
|
212
222
|
// 初始化操作,回填证件类型为身份证的身份信息
|
|
213
223
|
this.initUserInfo()
|
|
224
|
+
// 查询引流弹窗是否显示
|
|
225
|
+
this.getDrainageModalIsShow()
|
|
214
226
|
},
|
|
215
227
|
|
|
216
228
|
// 初始化操作,回填证件类型为身份证的身份信息
|
|
@@ -283,8 +283,10 @@ Page({
|
|
|
283
283
|
// 进行微信人脸识别
|
|
284
284
|
toWxFace(name, idCardNumber) {
|
|
285
285
|
let sessionInfo = this.data.sessionInfo
|
|
286
|
+
// 前端输入正式码字后将其转换为pua码字,再传给微信进行刷脸
|
|
287
|
+
const convertToPuaName = utils.convertToPua(name)
|
|
286
288
|
wx.startFacialRecognitionVerify({
|
|
287
|
-
name,
|
|
289
|
+
name: convertToPuaName,
|
|
288
290
|
idCardNumber,
|
|
289
291
|
checkAliveType: '2',
|
|
290
292
|
success(res) {
|
|
@@ -286,6 +286,27 @@ 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
|
+
|
|
289
310
|
module.exports = {
|
|
290
311
|
validate,
|
|
291
312
|
awaitTo,
|
|
@@ -302,5 +323,6 @@ module.exports = {
|
|
|
302
323
|
greaterCurrentTime,
|
|
303
324
|
getCurrentTime,
|
|
304
325
|
getBirthByIDCard,
|
|
305
|
-
getCurrentDate
|
|
326
|
+
getCurrentDate,
|
|
327
|
+
convertToPua
|
|
306
328
|
}
|
|
@@ -3,7 +3,10 @@ const {
|
|
|
3
3
|
DecrtptAES,
|
|
4
4
|
encryptSM3
|
|
5
5
|
} = require('./tifadmin_config')
|
|
6
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
flow
|
|
8
|
+
} = require("@wecity/weda-plugin-utils");
|
|
9
|
+
const utils = require('./index.js');
|
|
7
10
|
|
|
8
11
|
var tifdid = ''
|
|
9
12
|
var isGettingUserInfo = false
|
|
@@ -106,7 +109,11 @@ function getOptions(options) {
|
|
|
106
109
|
|
|
107
110
|
function init(opt) {
|
|
108
111
|
console.log('auth sdk init', opt)
|
|
109
|
-
const {
|
|
112
|
+
const {
|
|
113
|
+
paasid,
|
|
114
|
+
appid,
|
|
115
|
+
tifhost
|
|
116
|
+
} = opt
|
|
110
117
|
wx.setStorageSync('tif.paasid', paasid)
|
|
111
118
|
wx.setStorageSync('tif.appid', appid)
|
|
112
119
|
wx.setStorageSync('tif.host', tifhost)
|
|
@@ -144,7 +151,7 @@ function _request(options, retryTime = 3) {
|
|
|
144
151
|
if (!!tifEncrypt) {
|
|
145
152
|
options.header['x-tif-encrypt'] = "true"
|
|
146
153
|
}
|
|
147
|
-
let oldsucc = (options && options.success) || (()=>{})
|
|
154
|
+
let oldsucc = (options && options.success) || (() => {})
|
|
148
155
|
// console.log(oldsucc, '============oldsucc=========')
|
|
149
156
|
options.success = function (res) {
|
|
150
157
|
if (options.hideLoadingWhenSucc) {
|
|
@@ -194,7 +201,7 @@ function getSessionId() {
|
|
|
194
201
|
return new Promise((resolve, reject) => {
|
|
195
202
|
const sid = wx.getStorageSync('tif.sid') || ''
|
|
196
203
|
console.log('===拦截获取storage中的tif.sid===', sid)
|
|
197
|
-
|
|
204
|
+
|
|
198
205
|
if (sid) {
|
|
199
206
|
resolve(sid)
|
|
200
207
|
} else {
|
|
@@ -235,9 +242,18 @@ function fetchSessionId() {
|
|
|
235
242
|
success: res => {
|
|
236
243
|
console.log('login res:', res)
|
|
237
244
|
isGettingUserInfo = false;
|
|
238
|
-
const {
|
|
245
|
+
const {
|
|
246
|
+
data,
|
|
247
|
+
errcode
|
|
248
|
+
} = res.data
|
|
239
249
|
if (errcode === 0 && data.session_id) {
|
|
240
|
-
let {
|
|
250
|
+
let {
|
|
251
|
+
session_id,
|
|
252
|
+
uid,
|
|
253
|
+
openid,
|
|
254
|
+
real_name,
|
|
255
|
+
credential_id
|
|
256
|
+
} = data
|
|
241
257
|
|
|
242
258
|
// 存到local
|
|
243
259
|
// 本地存入openid,人工审核状态查询时使用
|
|
@@ -275,7 +291,11 @@ function fetchSessionId() {
|
|
|
275
291
|
|
|
276
292
|
// 微信手机号授权
|
|
277
293
|
function _loginPhone(options) {
|
|
278
|
-
const {
|
|
294
|
+
const {
|
|
295
|
+
encryptedData: encrypted_data,
|
|
296
|
+
iv,
|
|
297
|
+
source = ''
|
|
298
|
+
} = options
|
|
279
299
|
|
|
280
300
|
return new Promise((resolve, reject) => {
|
|
281
301
|
// 对手机号进行解密
|
|
@@ -294,7 +314,10 @@ function _loginPhone(options) {
|
|
|
294
314
|
isGettingUserInfo = false;
|
|
295
315
|
if (res.data.errcode === 0) {
|
|
296
316
|
const data = res.data.data
|
|
297
|
-
let {
|
|
317
|
+
let {
|
|
318
|
+
real_name,
|
|
319
|
+
credential_id
|
|
320
|
+
} = data
|
|
298
321
|
runUserInfoCallback({
|
|
299
322
|
name: real_name,
|
|
300
323
|
id: credential_id,
|
|
@@ -329,11 +352,18 @@ function _loginPhone(options) {
|
|
|
329
352
|
function _faceVerifyWithIdCard(params) {
|
|
330
353
|
return new Promise((resolve, reject) => {
|
|
331
354
|
const [tifhost, appid, paasid] = getOptions(['tifhost', 'appid', 'paasid'])
|
|
332
|
-
const {
|
|
333
|
-
|
|
355
|
+
const {
|
|
356
|
+
person_type,
|
|
357
|
+
id_card_number,
|
|
358
|
+
name
|
|
359
|
+
} = params
|
|
360
|
+
|
|
361
|
+
// 前端输入正式码字后将其转换为pua码字,再传给微信进行刷脸
|
|
362
|
+
const convertToPuaName = utils.convertToPua(name)
|
|
363
|
+
|
|
334
364
|
wx.startFacialRecognitionVerify({
|
|
335
365
|
userIdKey: person_type == '10' ? '' : params.user_id_key,
|
|
336
|
-
name,
|
|
366
|
+
name: convertToPuaName,
|
|
337
367
|
idCardNumber: id_card_number,
|
|
338
368
|
checkAliveType: '2',
|
|
339
369
|
success(res) {
|
|
@@ -346,7 +376,11 @@ function _faceVerifyWithIdCard(params) {
|
|
|
346
376
|
title: '认证中...'
|
|
347
377
|
})
|
|
348
378
|
|
|
349
|
-
let {
|
|
379
|
+
let {
|
|
380
|
+
isbind,
|
|
381
|
+
cid_type,
|
|
382
|
+
verify_expire_time
|
|
383
|
+
} = params
|
|
350
384
|
|
|
351
385
|
_request({
|
|
352
386
|
url: `${tifhost}/api/check_face_verify_result`,
|
|
@@ -364,14 +398,17 @@ function _faceVerifyWithIdCard(params) {
|
|
|
364
398
|
success: res => {
|
|
365
399
|
console.log('check_face_verify_result成功', res)
|
|
366
400
|
wx.hideLoading()
|
|
367
|
-
let {
|
|
401
|
+
let {
|
|
402
|
+
errcode,
|
|
403
|
+
data
|
|
404
|
+
} = res.data
|
|
368
405
|
if (errcode !== 0) {
|
|
369
406
|
return reject(JSON.stringify(res.data))
|
|
370
407
|
}
|
|
371
408
|
try {
|
|
372
409
|
console.log('===========try-catch===========')
|
|
373
410
|
wx.setStorageSync('tif.sid', data.session_id)
|
|
374
|
-
} catch(err) {
|
|
411
|
+
} catch (err) {
|
|
375
412
|
// 重新静默登录
|
|
376
413
|
fetchSessionId()
|
|
377
414
|
}
|
|
@@ -460,7 +497,10 @@ function _getLoginConfig(options) {
|
|
|
460
497
|
url: tifhost + '/api/get_login_config',
|
|
461
498
|
method: 'GET',
|
|
462
499
|
success: res => {
|
|
463
|
-
let {
|
|
500
|
+
let {
|
|
501
|
+
errcode,
|
|
502
|
+
data
|
|
503
|
+
} = res.data
|
|
464
504
|
if (errcode === 0) {
|
|
465
505
|
options && options.success && options.success(data)
|
|
466
506
|
} else {
|
|
@@ -475,19 +515,24 @@ function _getLoginConfig(options) {
|
|
|
475
515
|
|
|
476
516
|
function _getSession(options) {
|
|
477
517
|
const [tifhost] = getOptions(['tifhost'])
|
|
478
|
-
|
|
518
|
+
|
|
479
519
|
return _request({
|
|
480
520
|
url: tifhost + '/tif/sys/session',
|
|
481
521
|
tifEncrypt: true,
|
|
482
522
|
success: res => {
|
|
483
523
|
console.log('request _getSession success: ', res)
|
|
484
|
-
const {
|
|
524
|
+
const {
|
|
525
|
+
errcode,
|
|
526
|
+
data
|
|
527
|
+
} = res.data
|
|
485
528
|
if (errcode === 0) {
|
|
486
|
-
const {
|
|
529
|
+
const {
|
|
530
|
+
name = '', cid = '', phone = '', caPhone = '', passport_number = ''
|
|
531
|
+
} = data
|
|
487
532
|
if (name && name.indexOf('tif_') >= 0) {
|
|
488
533
|
try {
|
|
489
534
|
data.name = DecrtptAES(name.split('tif_')[1])
|
|
490
|
-
} catch(err) {
|
|
535
|
+
} catch (err) {
|
|
491
536
|
console.log('name捕获错误')
|
|
492
537
|
data.name = name
|
|
493
538
|
}
|
|
@@ -495,7 +540,7 @@ function _getSession(options) {
|
|
|
495
540
|
if (cid && cid.indexOf('tif_') >= 0) {
|
|
496
541
|
try {
|
|
497
542
|
data.cid = DecrtptAES(cid.split('tif_')[1])
|
|
498
|
-
} catch(err) {
|
|
543
|
+
} catch (err) {
|
|
499
544
|
console.log('cid捕获错误')
|
|
500
545
|
data.cid = cid
|
|
501
546
|
}
|
|
@@ -503,7 +548,7 @@ function _getSession(options) {
|
|
|
503
548
|
if (phone && phone.indexOf('tif_') >= 0) {
|
|
504
549
|
try {
|
|
505
550
|
data.phone = DecrtptAES(phone.split('tif_')[1])
|
|
506
|
-
} catch(err) {
|
|
551
|
+
} catch (err) {
|
|
507
552
|
console.log('phone捕获错误')
|
|
508
553
|
data.phone = phone
|
|
509
554
|
}
|
|
@@ -511,7 +556,7 @@ function _getSession(options) {
|
|
|
511
556
|
if (caPhone && caPhone.indexOf('tif_') >= 0) {
|
|
512
557
|
try {
|
|
513
558
|
data.caPhone = DecrtptAES(caPhone.split('tif_')[1])
|
|
514
|
-
} catch(err) {
|
|
559
|
+
} catch (err) {
|
|
515
560
|
console.log('caPhone捕获错误')
|
|
516
561
|
data.caPhone = caPhone
|
|
517
562
|
}
|
|
@@ -519,7 +564,7 @@ function _getSession(options) {
|
|
|
519
564
|
if (passport_number && passport_number.indexOf('tif_') >= 0) {
|
|
520
565
|
try {
|
|
521
566
|
data.passport_number = DecrtptAES(passport_number.split('tif_')[1])
|
|
522
|
-
} catch(err) {
|
|
567
|
+
} catch (err) {
|
|
523
568
|
console.log('passport_number捕获错误')
|
|
524
569
|
data.passport_number = passport_number
|
|
525
570
|
}
|
|
@@ -564,7 +609,10 @@ function _confirmPhone() {
|
|
|
564
609
|
data: submitData,
|
|
565
610
|
success: res => {
|
|
566
611
|
wx.hideLoading();
|
|
567
|
-
let {
|
|
612
|
+
let {
|
|
613
|
+
errcode,
|
|
614
|
+
data
|
|
615
|
+
} = res.data
|
|
568
616
|
if (errcode !== 0) {
|
|
569
617
|
if (errcode === 4035) {
|
|
570
618
|
// 获取ca手机号码失败,跳转到绑定手机号码页面
|
|
@@ -599,7 +647,10 @@ function _logOut() {
|
|
|
599
647
|
url: `${tifhost}/api/mp/logout`,
|
|
600
648
|
success: res => {
|
|
601
649
|
wx.hideLoading();
|
|
602
|
-
let {
|
|
650
|
+
let {
|
|
651
|
+
errcode,
|
|
652
|
+
data
|
|
653
|
+
} = res.data
|
|
603
654
|
if (errcode !== 0) {
|
|
604
655
|
return reject(JSON.stringify(res.data))
|
|
605
656
|
}
|
|
@@ -616,7 +667,11 @@ function _logOut() {
|
|
|
616
667
|
// 账号注销
|
|
617
668
|
function _logOff(options) {
|
|
618
669
|
const [tifhost, appid, paasid] = getOptions(['tifhost', 'appid', 'paasid'])
|
|
619
|
-
const {
|
|
670
|
+
const {
|
|
671
|
+
id_card_number,
|
|
672
|
+
name,
|
|
673
|
+
verify_result
|
|
674
|
+
} = options
|
|
620
675
|
|
|
621
676
|
const submitData = Object.assign({}, {
|
|
622
677
|
appid,
|
|
@@ -632,7 +687,10 @@ function _logOff(options) {
|
|
|
632
687
|
data: submitData,
|
|
633
688
|
success: res => {
|
|
634
689
|
wx.hideLoading();
|
|
635
|
-
let {
|
|
690
|
+
let {
|
|
691
|
+
errcode,
|
|
692
|
+
data
|
|
693
|
+
} = res.data
|
|
636
694
|
if (errcode !== 0) {
|
|
637
695
|
return reject(JSON.stringify(res.data))
|
|
638
696
|
}
|
|
@@ -649,7 +707,7 @@ function _logOff(options) {
|
|
|
649
707
|
// 银行卡身份核验接口
|
|
650
708
|
function _bankCardAuth(options) {
|
|
651
709
|
const [tifhost, appid, paasid] = getOptions(['tifhost', 'appid', 'paasid'])
|
|
652
|
-
const {
|
|
710
|
+
const {
|
|
653
711
|
name,
|
|
654
712
|
id_card_number,
|
|
655
713
|
isbind,
|
|
@@ -700,7 +758,7 @@ function _bankCardAuth(options) {
|
|
|
700
758
|
// 外国人护照核验接口
|
|
701
759
|
function _passportAuth(options) {
|
|
702
760
|
const [tifhost, appid, paasid] = getOptions(['tifhost', 'appid', 'paasid'])
|
|
703
|
-
const {
|
|
761
|
+
const {
|
|
704
762
|
sur_name,
|
|
705
763
|
id_card_number,
|
|
706
764
|
phone,
|
|
@@ -735,7 +793,10 @@ function _passportAuth(options) {
|
|
|
735
793
|
data: submitData,
|
|
736
794
|
success: res => {
|
|
737
795
|
wx.hideLoading();
|
|
738
|
-
let {
|
|
796
|
+
let {
|
|
797
|
+
errcode,
|
|
798
|
+
data
|
|
799
|
+
} = res.data
|
|
739
800
|
if (errcode !== 0) {
|
|
740
801
|
return reject(JSON.stringify(res.data))
|
|
741
802
|
}
|
|
@@ -758,14 +819,22 @@ function _getPassportInfo(options) {
|
|
|
758
819
|
method: 'GET',
|
|
759
820
|
tifEncrypt: true,
|
|
760
821
|
success: res => {
|
|
761
|
-
let {
|
|
822
|
+
let {
|
|
823
|
+
errcode,
|
|
824
|
+
data
|
|
825
|
+
} = res.data
|
|
762
826
|
if (errcode === 0) {
|
|
763
|
-
const {
|
|
827
|
+
const {
|
|
828
|
+
first_name,
|
|
829
|
+
sur_name,
|
|
830
|
+
id_card_number,
|
|
831
|
+
phone = ''
|
|
832
|
+
} = data
|
|
764
833
|
if (first_name && first_name.indexOf('tif_') >= 0) {
|
|
765
834
|
console.log('解密first_name')
|
|
766
835
|
try {
|
|
767
836
|
data.first_name = DecrtptAES(first_name.split('tif_')[1])
|
|
768
|
-
} catch(err) {
|
|
837
|
+
} catch (err) {
|
|
769
838
|
console.log('first_name捕获错误')
|
|
770
839
|
data.first_name = first_name
|
|
771
840
|
}
|
|
@@ -774,7 +843,7 @@ function _getPassportInfo(options) {
|
|
|
774
843
|
console.log('解密sur_name')
|
|
775
844
|
try {
|
|
776
845
|
data.sur_name = DecrtptAES(sur_name.split('tif_')[1])
|
|
777
|
-
} catch(err) {
|
|
846
|
+
} catch (err) {
|
|
778
847
|
console.log('sur_name捕获错误')
|
|
779
848
|
data.sur_name = sur_name
|
|
780
849
|
}
|
|
@@ -783,7 +852,7 @@ function _getPassportInfo(options) {
|
|
|
783
852
|
console.log('解密id_card_number')
|
|
784
853
|
try {
|
|
785
854
|
data.id_card_number = DecrtptAES(id_card_number.split('tif_')[1])
|
|
786
|
-
} catch(err) {
|
|
855
|
+
} catch (err) {
|
|
787
856
|
console.log('id_card_number捕获错误')
|
|
788
857
|
data.id_card_number = id_card_number
|
|
789
858
|
}
|
|
@@ -792,7 +861,7 @@ function _getPassportInfo(options) {
|
|
|
792
861
|
console.log('解密phone')
|
|
793
862
|
try {
|
|
794
863
|
data.phone = DecrtptAES(phone.split('tif_')[1])
|
|
795
|
-
} catch(err) {
|
|
864
|
+
} catch (err) {
|
|
796
865
|
console.log('phone捕获错误')
|
|
797
866
|
data.phone = phone
|
|
798
867
|
}
|
|
@@ -817,7 +886,9 @@ function _deletePassportAuth(options) {
|
|
|
817
886
|
method: 'GET',
|
|
818
887
|
success: res => {
|
|
819
888
|
console.log('删除核验信息接口res', res)
|
|
820
|
-
let {
|
|
889
|
+
let {
|
|
890
|
+
errcode
|
|
891
|
+
} = res.data
|
|
821
892
|
if (errcode !== 0) {
|
|
822
893
|
options && options.fail && options.fail(JSON.stringify(res.data))
|
|
823
894
|
} else {
|
|
@@ -856,7 +927,11 @@ function _personToken(e) {
|
|
|
856
927
|
method: 'POST',
|
|
857
928
|
tifEncrypt: true,
|
|
858
929
|
success: res => {
|
|
859
|
-
let {
|
|
930
|
+
let {
|
|
931
|
+
errcode,
|
|
932
|
+
errmsg,
|
|
933
|
+
data
|
|
934
|
+
} = res.data
|
|
860
935
|
if (errcode !== 0) {
|
|
861
936
|
if (errcode === 4035) {
|
|
862
937
|
if (e && e.from === 'sdk') {
|
|
@@ -869,8 +944,8 @@ function _personToken(e) {
|
|
|
869
944
|
}
|
|
870
945
|
} else {
|
|
871
946
|
if (errcode === 2034) {
|
|
872
|
-
|
|
873
|
-
|
|
947
|
+
// 重新静默登录
|
|
948
|
+
fetchSessionId()
|
|
874
949
|
}
|
|
875
950
|
wx.showToast({
|
|
876
951
|
title: errmsg || 'person_token获取失败',
|
|
@@ -882,12 +957,14 @@ function _personToken(e) {
|
|
|
882
957
|
} else {
|
|
883
958
|
// 存储
|
|
884
959
|
wx.setStorageSync('tif.CAUniqueId', data.uniqueId)
|
|
885
|
-
const {
|
|
960
|
+
const {
|
|
961
|
+
phone = ''
|
|
962
|
+
} = data
|
|
886
963
|
if (phone && phone.indexOf('tif_') >= 0) {
|
|
887
964
|
console.log('解密phone')
|
|
888
965
|
try {
|
|
889
966
|
data.phone = DecrtptAES(phone.split('tif_')[1])
|
|
890
|
-
} catch(err) {
|
|
967
|
+
} catch (err) {
|
|
891
968
|
console.log('phone捕获错误')
|
|
892
969
|
data.phone = phone
|
|
893
970
|
}
|
|
@@ -912,7 +989,11 @@ function _operateFaceFailCount(options) {
|
|
|
912
989
|
const [tifhost] = getOptions(['tifhost'])
|
|
913
990
|
|
|
914
991
|
return new Promise((resolve, reject) => {
|
|
915
|
-
const {
|
|
992
|
+
const {
|
|
993
|
+
cid,
|
|
994
|
+
age,
|
|
995
|
+
count
|
|
996
|
+
} = options
|
|
916
997
|
_request({
|
|
917
998
|
url: `${tifhost}/api/check_limit`,
|
|
918
999
|
method: 'POST',
|
|
@@ -924,7 +1005,10 @@ function _operateFaceFailCount(options) {
|
|
|
924
1005
|
age,
|
|
925
1006
|
},
|
|
926
1007
|
success: res => {
|
|
927
|
-
let {
|
|
1008
|
+
let {
|
|
1009
|
+
errcode,
|
|
1010
|
+
data
|
|
1011
|
+
} = res.data
|
|
928
1012
|
if (errcode !== 0) {
|
|
929
1013
|
return reject(JSON.stringify(res.data))
|
|
930
1014
|
}
|
|
@@ -945,7 +1029,10 @@ function _getUserReadStatus() {
|
|
|
945
1029
|
_request({
|
|
946
1030
|
url: `${tifhost}/api/get_user_read_status`,
|
|
947
1031
|
success: res => {
|
|
948
|
-
let {
|
|
1032
|
+
let {
|
|
1033
|
+
errcode,
|
|
1034
|
+
data
|
|
1035
|
+
} = res.data
|
|
949
1036
|
if (errcode !== 0) {
|
|
950
1037
|
return reject(JSON.stringify(res.data))
|
|
951
1038
|
}
|
|
@@ -970,7 +1057,10 @@ function _setUserReadStatus(needRead = true) {
|
|
|
970
1057
|
needRead
|
|
971
1058
|
},
|
|
972
1059
|
success: res => {
|
|
973
|
-
let {
|
|
1060
|
+
let {
|
|
1061
|
+
errcode,
|
|
1062
|
+
data
|
|
1063
|
+
} = res.data
|
|
974
1064
|
if (errcode !== 0) {
|
|
975
1065
|
return reject(JSON.stringify(res.data))
|
|
976
1066
|
}
|
|
@@ -1033,14 +1123,18 @@ function _caEncrypt(options) {
|
|
|
1033
1123
|
birthday = '',
|
|
1034
1124
|
} = options
|
|
1035
1125
|
|
|
1036
|
-
const {
|
|
1126
|
+
const {
|
|
1127
|
+
verifyType,
|
|
1128
|
+
supportType,
|
|
1129
|
+
supportTypeMore
|
|
1130
|
+
} = faceReceptionTypeMap[cid_type]
|
|
1037
1131
|
let verify_type = verifyType
|
|
1038
1132
|
let support_type = birthday ? supportTypeMore : supportType
|
|
1039
1133
|
|
|
1040
1134
|
if (cid_type === '516' && nation !== 'CHN') {
|
|
1041
1135
|
// 港澳居民来往内地通行证(非中国籍)
|
|
1042
1136
|
verify_type = '108'
|
|
1043
|
-
support_type = '146'
|
|
1137
|
+
support_type = '146'
|
|
1044
1138
|
}
|
|
1045
1139
|
|
|
1046
1140
|
const data = {
|
|
@@ -1064,7 +1158,10 @@ function _caEncrypt(options) {
|
|
|
1064
1158
|
method: 'POST',
|
|
1065
1159
|
data,
|
|
1066
1160
|
success: res => {
|
|
1067
|
-
let {
|
|
1161
|
+
let {
|
|
1162
|
+
errcode,
|
|
1163
|
+
data
|
|
1164
|
+
} = res.data
|
|
1068
1165
|
if (errcode !== 0) {
|
|
1069
1166
|
return reject(JSON.stringify(res.data))
|
|
1070
1167
|
}
|
|
@@ -1098,8 +1195,18 @@ function _faceVerifyWithUserIdKey(options) {
|
|
|
1098
1195
|
title: `${dict.showLoading[language]}`
|
|
1099
1196
|
})
|
|
1100
1197
|
|
|
1101
|
-
let {
|
|
1102
|
-
isbind,
|
|
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 = ''
|
|
1103
1210
|
} = options
|
|
1104
1211
|
|
|
1105
1212
|
let paramsData = {
|
|
@@ -1128,7 +1235,10 @@ function _faceVerifyWithUserIdKey(options) {
|
|
|
1128
1235
|
success: res => {
|
|
1129
1236
|
console.log('check_face_verify_result成功', res)
|
|
1130
1237
|
wx.hideLoading()
|
|
1131
|
-
let {
|
|
1238
|
+
let {
|
|
1239
|
+
errcode,
|
|
1240
|
+
data
|
|
1241
|
+
} = res.data
|
|
1132
1242
|
if (errcode !== 0) {
|
|
1133
1243
|
return reject(JSON.stringify(res.data))
|
|
1134
1244
|
}
|
|
@@ -1136,9 +1246,9 @@ function _faceVerifyWithUserIdKey(options) {
|
|
|
1136
1246
|
try {
|
|
1137
1247
|
console.log('===========try-catch===========')
|
|
1138
1248
|
wx.setStorageSync('tif.sid', data.session_id)
|
|
1139
|
-
} catch(err) {
|
|
1140
|
-
|
|
1141
|
-
|
|
1249
|
+
} catch (err) {
|
|
1250
|
+
// 重新静默登录
|
|
1251
|
+
fetchSessionId()
|
|
1142
1252
|
}
|
|
1143
1253
|
_getSession({
|
|
1144
1254
|
success: (session) => {
|
|
@@ -1165,20 +1275,30 @@ function _faceVerifyWithUserIdKey(options) {
|
|
|
1165
1275
|
function _fetchFaceVerify(options) {
|
|
1166
1276
|
console.log('====对外API拉起人脸options:====', options)
|
|
1167
1277
|
const params = options.params || {}
|
|
1168
|
-
const {
|
|
1278
|
+
const {
|
|
1279
|
+
cid_type,
|
|
1280
|
+
id_card_number,
|
|
1281
|
+
name
|
|
1282
|
+
} = params
|
|
1169
1283
|
|
|
1170
1284
|
// 证件类型拦截
|
|
1171
1285
|
const cidTypeList = ['111', '516', '511', '553', '414', '17', '18']
|
|
1172
1286
|
if (!cidTypeList.includes(cid_type)) {
|
|
1173
|
-
return faceFail(options, {
|
|
1287
|
+
return faceFail(options, {
|
|
1288
|
+
'errMsg': `传入的证件类型不存在:${cid_type}`
|
|
1289
|
+
})
|
|
1174
1290
|
}
|
|
1175
1291
|
|
|
1176
1292
|
// 必填字段校验
|
|
1177
1293
|
if (!id_card_number) {
|
|
1178
|
-
return faceFail(options, {
|
|
1294
|
+
return faceFail(options, {
|
|
1295
|
+
'errMsg': 'id_card_number字段缺失'
|
|
1296
|
+
})
|
|
1179
1297
|
}
|
|
1180
1298
|
if (!name) {
|
|
1181
|
-
return faceFail(options, {
|
|
1299
|
+
return faceFail(options, {
|
|
1300
|
+
'errMsg': 'name字段缺失'
|
|
1301
|
+
})
|
|
1182
1302
|
}
|
|
1183
1303
|
|
|
1184
1304
|
wx.showLoading({
|
|
@@ -1188,9 +1308,11 @@ function _fetchFaceVerify(options) {
|
|
|
1188
1308
|
|
|
1189
1309
|
// 身份证
|
|
1190
1310
|
if (cid_type === '111') {
|
|
1311
|
+
// 前端输入正式码字后将其转换为pua码字,再传给微信进行刷脸
|
|
1312
|
+
const convertToPuaName = utils.convertToPua(name)
|
|
1191
1313
|
wx.startFacialRecognitionVerify({
|
|
1192
1314
|
userIdKey: '',
|
|
1193
|
-
name,
|
|
1315
|
+
name: convertToPuaName,
|
|
1194
1316
|
idCardNumber: id_card_number,
|
|
1195
1317
|
checkAliveType: '2',
|
|
1196
1318
|
success: res => {
|
|
@@ -1208,15 +1330,21 @@ function _fetchFaceVerify(options) {
|
|
|
1208
1330
|
} else {
|
|
1209
1331
|
// 外国人永居证:国籍必填
|
|
1210
1332
|
if (cid_type === '553' && !params.nation) {
|
|
1211
|
-
return faceFail(options, {
|
|
1333
|
+
return faceFail(options, {
|
|
1334
|
+
'errMsg': 'nation字段缺失'
|
|
1335
|
+
})
|
|
1212
1336
|
}
|
|
1213
1337
|
// 港澳、台湾居住证:通行证号码/证件生效日期必填
|
|
1214
1338
|
if (cid_type === '17' || cid_type === '18') {
|
|
1215
1339
|
if (!params.passport_number) {
|
|
1216
|
-
return faceFail(options, {
|
|
1340
|
+
return faceFail(options, {
|
|
1341
|
+
'errMsg': 'passport_number字段缺失'
|
|
1342
|
+
})
|
|
1217
1343
|
}
|
|
1218
1344
|
if (!params.validity_period) {
|
|
1219
|
-
return faceFail(options, {
|
|
1345
|
+
return faceFail(options, {
|
|
1346
|
+
'errMsg': 'validity_period字段缺失'
|
|
1347
|
+
})
|
|
1220
1348
|
}
|
|
1221
1349
|
}
|
|
1222
1350
|
// 出入境人脸
|
|
@@ -1240,15 +1368,19 @@ function _fetchFaceVerify(options) {
|
|
|
1240
1368
|
console.log('ca加密err', err)
|
|
1241
1369
|
try {
|
|
1242
1370
|
return faceFail(options, JSON.parse(err))
|
|
1243
|
-
} catch(catchErr) {
|
|
1244
|
-
return faceFail(options, {
|
|
1371
|
+
} catch (catchErr) {
|
|
1372
|
+
return faceFail(options, {
|
|
1373
|
+
'errMsg': '人脸识别不支持电脑端,请使用真机'
|
|
1374
|
+
})
|
|
1245
1375
|
}
|
|
1246
1376
|
})
|
|
1247
1377
|
}
|
|
1248
1378
|
}
|
|
1249
1379
|
|
|
1250
1380
|
function faceFail(options, res) {
|
|
1251
|
-
const {
|
|
1381
|
+
const {
|
|
1382
|
+
errCode = '', errMsg = '', errmsg = ''
|
|
1383
|
+
} = res
|
|
1252
1384
|
let title = errMsg || errmsg || '人脸识别失败,请重试!'
|
|
1253
1385
|
|
|
1254
1386
|
// 常见状态码处理
|
|
@@ -1296,16 +1428,16 @@ function _userEntityReport(options) {
|
|
|
1296
1428
|
|
|
1297
1429
|
const {
|
|
1298
1430
|
phone = '',
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1431
|
+
sex = '',
|
|
1432
|
+
user_status = '1',
|
|
1433
|
+
certType = '',
|
|
1434
|
+
openid = '',
|
|
1435
|
+
last_login_time = '',
|
|
1436
|
+
user_date_of_birth = ''
|
|
1305
1437
|
} = options
|
|
1306
1438
|
|
|
1307
1439
|
const paramsBase = {
|
|
1308
|
-
business_id:
|
|
1440
|
+
business_id: wx.getStorageSync('tif.CAUniqueId') || '', // 业务账号,使用统一认证唯一ID,业务系统下的唯一标识
|
|
1309
1441
|
wx_unionid: openid, // 传openid
|
|
1310
1442
|
sourcefrom: 'wx', // 来源
|
|
1311
1443
|
encrypt_mobile: encryptSM3(phone) || '', // 手机号,使用SM3不可逆加密的手机号
|
|
@@ -1333,7 +1465,10 @@ function _userEntityReport(options) {
|
|
|
1333
1465
|
data: paramsFull,
|
|
1334
1466
|
success: res => {
|
|
1335
1467
|
console.log('==埋点接口返回res==', res)
|
|
1336
|
-
let {
|
|
1468
|
+
let {
|
|
1469
|
+
code,
|
|
1470
|
+
data
|
|
1471
|
+
} = res.data
|
|
1337
1472
|
if (code !== 0) {
|
|
1338
1473
|
return reject(JSON.stringify(res.data))
|
|
1339
1474
|
}
|
|
@@ -1353,7 +1488,7 @@ function _updateSB(options) {
|
|
|
1353
1488
|
|
|
1354
1489
|
const {
|
|
1355
1490
|
sex = '',
|
|
1356
|
-
|
|
1491
|
+
birthday = '',
|
|
1357
1492
|
} = options
|
|
1358
1493
|
|
|
1359
1494
|
const data = {
|
|
@@ -1367,14 +1502,17 @@ function _updateSB(options) {
|
|
|
1367
1502
|
method: 'POST',
|
|
1368
1503
|
data,
|
|
1369
1504
|
success: res => {
|
|
1370
|
-
let {
|
|
1505
|
+
let {
|
|
1506
|
+
errcode,
|
|
1507
|
+
data
|
|
1508
|
+
} = res.data
|
|
1371
1509
|
if (errcode !== 0) {
|
|
1372
1510
|
return reject(res.data)
|
|
1373
1511
|
}
|
|
1374
1512
|
try {
|
|
1375
1513
|
console.log('===========try-catch===========', data)
|
|
1376
1514
|
wx.setStorageSync('tif.sid', data.session_id)
|
|
1377
|
-
} catch(err) {
|
|
1515
|
+
} catch (err) {
|
|
1378
1516
|
// 重新静默登录
|
|
1379
1517
|
fetchSessionId()
|
|
1380
1518
|
}
|
|
@@ -1387,6 +1525,30 @@ function _updateSB(options) {
|
|
|
1387
1525
|
})
|
|
1388
1526
|
}
|
|
1389
1527
|
|
|
1528
|
+
// 查询引流窗口是否显示
|
|
1529
|
+
function getDrainageModalIsShow() {
|
|
1530
|
+
const [tifhost] = getOptions(['tifhost'])
|
|
1531
|
+
|
|
1532
|
+
return new Promise((resolve, reject) => {
|
|
1533
|
+
_request({
|
|
1534
|
+
url: `${tifhost}/ebus/tifapi/qianduan/drainageModal`,
|
|
1535
|
+
success: res => {
|
|
1536
|
+
let {
|
|
1537
|
+
statusCode,
|
|
1538
|
+
data
|
|
1539
|
+
} = res
|
|
1540
|
+
if (statusCode !== 200) {
|
|
1541
|
+
return reject(JSON.stringify(res))
|
|
1542
|
+
}
|
|
1543
|
+
return resolve(data)
|
|
1544
|
+
},
|
|
1545
|
+
fail: err => {
|
|
1546
|
+
return reject(JSON.stringify(err.data))
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1549
|
+
})
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1390
1552
|
module.exports = {
|
|
1391
1553
|
init,
|
|
1392
1554
|
|
|
@@ -1438,7 +1600,7 @@ module.exports = {
|
|
|
1438
1600
|
deletePassportAuth: _deletePassportAuth,
|
|
1439
1601
|
|
|
1440
1602
|
// 获取personToken
|
|
1441
|
-
personToken:
|
|
1603
|
+
personToken: _personToken,
|
|
1442
1604
|
|
|
1443
1605
|
// 获取/设置人脸失败次数
|
|
1444
1606
|
operateFaceFailCount: _operateFaceFailCount,
|
|
@@ -1462,5 +1624,7 @@ module.exports = {
|
|
|
1462
1624
|
userEntityReport: _userEntityReport,
|
|
1463
1625
|
|
|
1464
1626
|
// 更新性别+出生日期
|
|
1465
|
-
updateSB: _updateSB
|
|
1627
|
+
updateSB: _updateSB,
|
|
1628
|
+
|
|
1629
|
+
getDrainageModalIsShow
|
|
1466
1630
|
}
|