weapps-plugin-jingtong-verify 1.6.0 → 1.6.1

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.
Files changed (59) hide show
  1. package/README.md +2 -1
  2. package/app.json +3 -11
  3. package/package.json +2 -2
  4. package/sdk.js +1 -32
  5. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.js +0 -3
  6. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.js +0 -5
  7. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.wxml +1 -1
  8. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-input.wxss +1 -9
  9. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.js +0 -8
  10. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.wxml +0 -2
  11. package/weapps-plugin-jingtong-verify/i18n/rules.js +5 -146
  12. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.js +12 -276
  13. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.wxml +1 -19
  14. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.wxss +1 -53
  15. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.js +12 -2
  16. package/weapps-plugin-jingtong-verify/pages/setting/setting.js +7 -10
  17. package/weapps-plugin-jingtong-verify/utils/request.js +1 -670
  18. package/weapps-plugin-jingtong-verify/utils/rules.js +1 -105
  19. package/weapps-plugin-jingtong-verify/utils/validate.js +1 -139
  20. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.js +0 -41
  21. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.json +0 -4
  22. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.wxml +0 -20
  23. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.wxss +0 -112
  24. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.js +0 -73
  25. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.json +0 -4
  26. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.wxml +0 -19
  27. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.wxss +0 -72
  28. package/weapps-plugin-jingtong-verify/images/bank-card-verify.png +0 -0
  29. package/weapps-plugin-jingtong-verify/images/chek_right.png +0 -0
  30. package/weapps-plugin-jingtong-verify/images/chevron-down.png +0 -0
  31. package/weapps-plugin-jingtong-verify/images/chevron-up.png +0 -0
  32. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.js +0 -506
  33. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.json +0 -8
  34. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.wxml +0 -79
  35. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.wxss +0 -212
  36. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.js +0 -1392
  37. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.json +0 -10
  38. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.wxml +0 -247
  39. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.wxss +0 -397
  40. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-sms-setting/bank-card-login-forgot-sms-setting.js +0 -66
  41. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-sms-setting/bank-card-login-forgot-sms-setting.wxml +0 -2
  42. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.js +0 -463
  43. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.json +0 -8
  44. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.wxml +0 -69
  45. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.wxss +0 -232
  46. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.js +0 -984
  47. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.json +0 -12
  48. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.wxml +0 -157
  49. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.wxss +0 -258
  50. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.js +0 -147
  51. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.json +0 -4
  52. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.wxml +0 -48
  53. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.wxss +0 -166
  54. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.js +0 -189
  55. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.json +0 -4
  56. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.wxml +0 -19
  57. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.wxss +0 -69
  58. package/weapps-plugin-jingtong-verify/utils/constantVal.js +0 -75
  59. package/weapps-plugin-jingtong-verify/utils/md5.js +0 -184
@@ -1,1392 +0,0 @@
1
- const jingtongVerifyRequest = require('../../utils/request')
2
- const constantVals = require('../../utils/constantVal')
3
- const rulesConfig = require("../../utils/rules")
4
- const utils = require("../../utils/index")
5
- const MD5 = require("../../utils/md5")
6
- const { flow } = require("@wecity/weda-plugin-utils");
7
- import { SDKTrack, setAccountInfo } from '../../utils/QDTrackerNew/QDTrackerMain'
8
- let cidType = '111'
9
- let Nation = 'CHN'
10
- Page({
11
-
12
- /**
13
- * 页面的初始数据
14
- */
15
- data: {
16
- language: 'zh_CN', // 语言环境:默认中文
17
- formData: {
18
- cid_type: '111', // 证件类型
19
- name: '', // 姓名
20
- strCid: '', // 身份证号码(脱敏)
21
- id_card_number: '', // 证件号码
22
- verify_type: '101', // 身份证 固定值101
23
- verify_expire_time: '', // 登录有效期
24
- support_type: '0x40' // 4:姓名+证件号+有效起始及结束日期 0x40:姓名+证件号 0x42:姓名+证件号+人像
25
- },
26
- showTipModal: false,
27
- rules: rulesConfig.setNewPwdInfoRules('zh_CN'),
28
- validateType: {
29
- id_card_number(value) {
30
- return utils.validate.checkCid(value, cidType, Nation).data
31
- },
32
- name(value) {
33
- return utils.validate.checkName(value, cidType).data
34
- },
35
- },
36
- formSafeData: {
37
- cid_type: '111', // 证件类型
38
- strCid: '', // 身份证号码(脱敏)
39
- id_card_number: '', // 证件号码
40
- phone_number: '', // 手机号
41
- verification_code: '' //验证码
42
- },
43
- formSafeDataCodeMobile: '', // 根据证件号码获取的手机号尾号
44
- formSafeDataCode: '', // 接口返回的验证码
45
- getFormSafeDataCodeTime: '', // 调接口返回的验证码时间
46
- formSafeDataCodeTimeOut: 60, // 接口返回的验证码过期时间(秒)默认1分钟
47
- phoneNumberEndTitle: '', // 手机号尾号提示
48
- safeRules: rulesConfig.safeVerificationInfoRules('zh_CN'),
49
- validateSafeType: {
50
- id_card_number(value) {
51
- return utils.validate.checkCid(value, cidType, Nation).data
52
- },
53
- phone_number(value) {
54
- return utils.validate.checkPhone(value).data
55
- },
56
- },
57
- formPwdData: {
58
- bank_card_password: '',
59
- bank_card_pwd_password: ''
60
- },
61
- pwdRules: rulesConfig.bankCardSetNewPwdRules('zh_CN'),
62
- validatePwdType: {
63
- bank_card_password(value) {
64
- return utils.validate.checkBankCardLoginPwd(value).data
65
- },
66
- bank_card_pwd_password(value, formPwdData) {
67
- console.log(formPwdData)
68
- console.log(formPwdData.bank_card_password)
69
- return utils.validate.checkBankCardLoginPwd(value).data && utils.validate.checkConfirmPwd(value, formPwdData.bank_card_password).data
70
- },
71
- },
72
- passwordStrength: 0, // 密码强度等级 0-3
73
- passwordStrengthText: '弱',
74
- currentStep: 0, // 当前步骤,从0开始
75
- steps: [
76
- { title: '信息确认' },
77
- { title: '安全验证' },
78
- { title: '重置密码' }
79
- ],
80
- // 是否显示自定义校验提示
81
- showCustomTips: false,
82
- // 自定义校验提示文本
83
- customTipsMsg: '',
84
- // 获取验证参数
85
- verificationText: '发送验证码',
86
- countdown: 0,
87
- isCountingDown: false,
88
- isSendSms: true, // 是否发送验证码
89
- maxRetryCount: 3, // 最大重试次数
90
- retryCount: 0, // 当前重试次数
91
- // 收不到验证码提示框
92
- showNotGetVerificationCodeTipModal: false,
93
- // 人脸识别认证弹窗
94
- showToOtherModal: false,
95
- submitMode: '',
96
- idCardType: {
97
- '111': '1',// 大陆
98
- '414': '2',// 护照
99
- '516': '3',// 港澳台通行证
100
- '511': '4',// 台胞证
101
- '5': '5' // 其他未指定类型
102
- },
103
- showTipFaceModal: false,
104
- set_type: 3, // 1:人脸认证,2:银行卡,3:短信
105
- isIdCardSuccess: false, //第二步安全验证,验证身份证号是否当前本人的身份证号
106
- isShowPasswordStrength: false,// 是否显示密码强度
107
- submitSafeMode:'',
108
- },
109
- /**
110
- * 生命周期函数--监听页面加载
111
- */
112
- onLoad(options) {
113
- const that = this
114
- this.setData({
115
- validatePwdType: {
116
- // 单字段复杂度校验:仅依赖 value
117
- bank_card_password(value) {
118
- return utils.validate.checkBankCardLoginPwd(value).data
119
- },
120
- // 确认密码:通过闭包读取最新的整表单数据(尤其是主密码)
121
- bank_card_pwd_password(value) {
122
- console.log('检测')
123
- console.log(that.data.formPwdData)
124
- const mainPwd = (that.data && that.data.formPwdData && that.data.formPwdData.bank_card_password) || ''
125
- return utils.validate.checkConfirmPwd(value, mainPwd).data
126
- },
127
- }
128
- })
129
- if(options.idCardNumber) {
130
- let { formData, formSafeData } = this.data
131
- formData.id_card_number = options.idCardNumber
132
- formData.strCid = options.strCid
133
- formData.name = options.name
134
- formData.cid_type = options.cid_type
135
- formData.verify_expire_time = options.verify_expire_time
136
- formSafeData.cid_type = options.cid_type
137
- // formSafeData.id_card_number = options.idCardNumber
138
- // formSafeData.strCid = options.strCid
139
- this.setData({
140
- formData: formData,
141
- formSafeData: formSafeData
142
- })
143
- }
144
- if(options.source_type){
145
- if(options.isSuccess){
146
- this.setData({
147
- currentStep: 0,
148
- set_type: 2
149
- })
150
- } else {
151
- this.setData({
152
- currentStep: 2,
153
- set_type: 2
154
- })
155
- }
156
- }
157
- },
158
- // 下一步
159
- nextStep() {
160
- if (this.data.currentStep < this.data.steps.length - 1) {
161
- this.setData({
162
- currentStep: this.data.currentStep + 1
163
- });
164
- // if(this.data.currentStep == 1){
165
- // this.getTailNumber()
166
- // }
167
- }
168
- },
169
- /**
170
- * 获取手机号尾号并设置证件号码
171
- */
172
- getTailNumber () {
173
- // let value = e.detail.value
174
- let value = this.data.formSafeData.id_card_number
175
- if(value === '' || value === null){
176
- return
177
- }
178
- const { formData, formSafeData } = this.data
179
- let params = {
180
- "cid_type": formData.cid_type, // 证件类型
181
- "name": formData.name, // 姓名
182
- "strCid": formData.strCid, // 身份证号码(脱敏)
183
- "id_card_number": formSafeData.id_card_number, // 证件号码
184
- "verify_type": '101', // 身份证 固定值101
185
- "verify_expire_time": formData.verify_expire_time, // 登录有效期
186
- "support_type": '0x40' // 4:姓名+证件号+有效起始及结束日期 0x40:姓名+证件号 0x42:姓名+证件号+人像
187
- }
188
- console.log('结果')
189
- // console.log(this.toOtherWay(params, 2, value))
190
-
191
- // this.toOtherWay(params, 2, value)
192
- setTimeout(() => {
193
- // console.log(this.data.isIdCardSuccess)
194
- this.toGetTailNumber(value)
195
- }, 100)
196
- },
197
- toGetTailNumber (value) {
198
- // const { isIdCardSuccess } = this.data
199
- // if(!isIdCardSuccess){
200
- // return
201
- // }
202
- // let value = e.detail.value
203
- // const { id_card_number, strCid } = this.data.formSafeData
204
- // let { formSafeData } = this.data
205
- // formSafeData.id_card_number = id_card_number
206
- // formSafeData.strCid = strCid
207
- // this.setData({
208
- // formSafeData: formSafeData
209
- // })
210
- jingtongVerifyRequest.getTailNumber(value).then(res => {
211
- console.log('获取手机号尾号')
212
- console.log(res)
213
- if(res.errcode !== 0){
214
- this.setData({
215
- formSafeDataCodeMobile: '',
216
- phoneNumberEndTitle: ''
217
- })
218
- } else {
219
- if(res.errcode === 0) {
220
- if(res.data.phone !== ''){
221
- this.setData({
222
- formSafeDataCodeMobile: res.data.phone,
223
- phoneNumberEndTitle: '(尾号' + res.data.phone + ')'
224
- })
225
- } else {
226
- this.setData({
227
- formSafeDataCodeMobile: '',
228
- phoneNumberEndTitle: ''
229
- })
230
- }
231
- } else {
232
- wx.showToast({
233
- title: data.errmsg,
234
- icon: 'none',
235
- duration: 2000
236
- })
237
- }
238
- }
239
- })
240
- },
241
- // 上一步(可选)
242
- prevStep() {
243
- if (this.data.currentStep > 0) {
244
- this.setData({
245
- currentStep: this.data.currentStep - 1
246
- });
247
- }
248
- },
249
-
250
- // 跳转到指定步骤(可选)
251
- goToStep(stepIndex) {
252
- this.setData({
253
- currentStep: stepIndex
254
- });
255
- },
256
-
257
- // 步骤点击事件(可选)
258
- onStepTap(e) {
259
- const { index } = e.detail;
260
- console.log('点击了步骤:', index);
261
- // 可以在这里添加跳转逻辑
262
- },
263
- /**
264
- * 跳转到人脸识别
265
- * @param {} e
266
- */
267
- async handleFormSubmit (e) {
268
- const isOther = this.data.submitMode === 'other'
269
- const formValid = e.detail.validStatus
270
- if(isOther){
271
- // 自定义英文名校验(与现有一致)
272
- const customValid = this.data.language !== 'en' ? { valid: true, msg: '' } : this.validateFullname()
273
-
274
- if (!formValid || !customValid.valid) {
275
- // 与现有提示优先级一致
276
- const formErrList = e.detail.value || []
277
- if (!formValid && customValid.valid) {
278
- } else if (formValid && !customValid.valid) {
279
- } else {
280
- const needPrior = formErrList.find(i => ["id_card_number", "nation"].includes(i.name))
281
-
282
- }
283
- this.setData({
284
- submitMode: ''
285
- })
286
- return
287
- }
288
- // 通过后再跳“其他方式”业务(可按需补入参清洗,沿用 handleFormSubmit 的清洗逻辑)
289
- this.toOtherWay(this.data.formData, 1)
290
- return
291
- }
292
-
293
- const customValid = this.data.language !== 'en' ? { valid: true, msg: '' } : this.validateFullname()
294
- if (!formValid || !customValid.valid) {
295
- // 自定义校验字段有问题,获取表单错误列表
296
- const formErrList = e.detail.value
297
- // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
298
- if (!formValid && customValid.valid) {
299
- return
300
- }
301
- // 如果表单校验没有问题,自定义校验有问题,则显示自定义校验错误提示
302
- if (formValid && !customValid.valid) {
303
- return
304
- }
305
- return
306
- }
307
- // 去验证人脸
308
- this.toFaceVerify()
309
- },
310
- /**
311
- * 去验证人脸
312
- */
313
- async toFaceVerify() {
314
- console.log('验证能否人脸识别')
315
- // 缓存人脸识别失败数据
316
- let faceFailCount = constantVals.getStorageWithExpire(constantVals.bank_card_forgot_face_fail_count)
317
- let faceFailTime = constantVals.getStorageWithExpire(constantVals.bank_card_forgot_face_fail_time)
318
- // 存在首次人脸识别失败时间
319
- if(faceFailTime) {
320
- // 判断人脸识别失败次数是否大于或等于3次,是的话,就要判断是否在10分钟不能人脸识别限制内
321
- if(faceFailCount >= 3){
322
- console.log(faceFailCount)
323
- // 当前时间
324
- const now = Date.now()
325
-
326
- // 判断是否在10分钟内(1小时 = 3600 * 1000 毫秒)
327
- const isWithinOneHour = (now - faceFailTime) < (10 * 60 * 1000)
328
- console.log('当前仍在10分钟限制内')
329
- console.log(isWithinOneHour)
330
- if(isWithinOneHour) {
331
- // 判断银行卡核验是否在锁定期内,在的话,不能跳转,提示改为直接提示
332
- const bankCardFailTime = constantVals.getStorageWithExpire(constantVals.bank_card_verify_fail_time)
333
- if(bankCardFailTime){
334
- // 当前时间
335
- const now = Date.now()
336
-
337
- // 判断是否在10分钟内(1小时 = 3600 * 1000 毫秒)
338
- const isWithinOneHour = (now - bankCardFailTime) < (10 * 60 * 1000)
339
- if(isWithinOneHour){
340
- console.log('当前仍在10分钟限制内')
341
- }
342
- this.setData({
343
- showTipFaceModal: true
344
- })
345
- } else {
346
- console.log('当前仍在10分钟限制内')
347
- this.setData({
348
- showToOtherModal: true
349
- })
350
- }
351
- return
352
- }
353
- }
354
- }
355
- // 判断是否是PC端登录
356
- await this.getDevice()
357
- wx.showLoading({
358
- title: '验证中',
359
- })
360
- const params = {
361
- 'id_card_number': this.data.formData.id_card_number,
362
- 'type': 1,
363
- 'isCount': true
364
- }
365
- setTimeout(() => {
366
- jingtongVerifyRequest.getVerifyLimit(params).then(res =>{
367
- console.log('获取人脸识别失败次数结果')
368
- console.log(res)
369
- console.log(res.data)
370
- if(res.errcode === 0 ) {
371
- const { data } = res
372
- if(data.times >= 3){
373
- wx.hideLoading()
374
- // 人脸错误次数大于3次,提示
375
- this.setData({
376
- showToOtherModal: true
377
- })
378
- return
379
- }
380
- jingtongVerifyRequest.verifyIdcard(this.data.formData).then(res => {
381
- console.log('获取身份证二要素核验结果')
382
- console.log(res)
383
- if(res.errcode === 0){
384
- wx.hideLoading()
385
- // 可以进行人脸
386
- this.faceVerifyIng()
387
- } else {
388
- wx.showToast({
389
- title: res.errmsg,
390
- icon: 'none',
391
- duration: 2000
392
- })
393
- }
394
- return
395
- }).finally(() => {
396
- wx.hideLoading()
397
- })
398
- } else {
399
- wx.showToast({
400
- title: res.errmsg,
401
- icon: 'none',
402
- duration: 2000
403
- })
404
- return
405
- }
406
- }).finally(() => {
407
- wx.hideLoading()
408
- })
409
- }, 1000)
410
- },
411
- async faceVerifyIng() {
412
- const { formData } = this.data
413
- const params = {
414
- "id_card_number": formData.id_card_number,
415
- "name": formData.name,
416
- "cid_type": formData.cid_type,
417
- "verify_expire_time": formData.verify_expire_time,
418
- "isbind": 1
419
- }
420
- const [err, session] = await utils.awaitTo(
421
- jingtongVerifyRequest.setNewPwdToFaceVerifyWithIdCard(params))
422
- console.log('设置新登录密码人脸认证')
423
- console.log(err)
424
- console.log(session)
425
-
426
- if (err) {
427
- const { errmsg, errMsg, errCode } = JSON.parse(err)
428
- // 缓存人脸识别失败数据
429
- let faceFailCount = constantVals.getStorageWithExpire(constantVals.bank_card_forgot_face_fail_count)
430
- if(faceFailCount >= 3) {
431
- faceFailCount = 0
432
- }
433
- faceFailCount = faceFailCount + 1
434
- constantVals.setStorageWithExpire(constantVals.bank_card_forgot_face_fail_count, faceFailCount)
435
- if(faceFailCount === 1){
436
- constantVals.setStorageWithExpire(constantVals.bank_card_forgot_face_fail_time, Date.now(), 10 * 60)
437
- }
438
- // 此处应要有埋点上报
439
- wx.showToast({
440
- title: errMsg,
441
- icon: 'none',
442
- duration: 3000
443
- })
444
- if (errCode) {
445
- let errCodeArr = [10002, 10003, 10004, 10005, 10012, 10057, 90002, 90003, 90004, 90005, 90006, 90100, 90023, 90024, 90025]
446
- if (errCodeArr.indexOf(errCode) >= 0) {
447
- console.log('在指定的错误码范围内,人脸失败次数+1')
448
- // 设置人脸失败次数
449
- // await this.fetchFaceFailCount(true, errCode)
450
- }
451
- // 人脸识别异常温馨提示弹窗
452
- // this.handleFaceError(errCode)
453
- }
454
- } else {
455
- // 此处需要埋点处理
456
-
457
- console.log('认证成功返回页面数据:', session)
458
- // 人脸识别成功清空失败缓存数据
459
- constantVals.removeStorage(constantVals.bank_card_forgot_face_fail_count)
460
- constantVals.removeStorage(constantVals.bank_card_forgot_face_fail_time)
461
- // 保存刷脸成功时间戳
462
- let timeStamp = new Date().getTime()
463
- wx.setStorageSync('tif.faceTimeStamp', timeStamp)
464
- this.setData({
465
- currentStep: 2,
466
- set_type: 1
467
- });
468
- }
469
- },
470
- // 判断是否是PC端登录
471
- getDevice() {
472
- return new Promise((resolve, reject) => {
473
- const systemInfo = wx.getDeviceInfo();
474
- console.log('systemInfo', systemInfo)
475
- if (['windows', 'mac'].includes(systemInfo.platform)) {
476
- console.log('当前为电脑端微信');
477
- wx.showToast({
478
- title: '请您使用移动端京通小程序',
479
- icon: 'none',
480
- duration: 3000
481
- })
482
- return
483
- } else {
484
- console.log('当前为手机端');
485
- resolve()
486
- }
487
- })
488
- },
489
- // 输入框去空
490
- handleChange(e) {
491
- let value = e.detail.value
492
- let formId = (e && e.currentTarget && e.currentTarget.id) || (e && e.target && e.target.id) || ''
493
-
494
- // 删除前后空格
495
- if (typeof value === 'string' && formId !== 'cid_type') {
496
- value = value.trim()
497
- }
498
- if (formId) {
499
- this.setData({ [`formData.${formId}`]: value })
500
- }
501
- },
502
- showQuestionTip() {
503
- this.setData({
504
- showTipModal: true
505
- })
506
- },
507
- handleModalOk () {
508
- this.setData({
509
- showNotGetVerificationCodeTipModal: false,
510
- showTipModal: false
511
- })
512
- },
513
- // 输入框去空
514
- handleSafeChange(e) {
515
- let value = e.detail.value
516
- let formId = (e && e.currentTarget && e.currentTarget.id) || (e && e.target && e.target.id) || ''
517
-
518
- // 删除前后空格
519
- if (typeof value === 'string' && formId !== 'cid_type') {
520
- value = value.trim()
521
- }
522
- if (formId) {
523
- this.setData({ [`formSafeData.${formId}`]: value })
524
- }
525
- },
526
- // 设置密码输入框变化处理
527
- handlePwdChange(e) {
528
- let value = e.detail.value
529
- let formId = (e && e.currentTarget && e.currentTarget.id) || (e && e.target && e.target.id) || ''
530
-
531
- if (typeof value === 'string' && formId !== 'cid_type') {
532
- value = value.trim()
533
- }
534
-
535
- if (formId) {
536
- this.setData({ [`formPwdData.${formId}`]: value })
537
- }
538
- },
539
- handlePwdStrongChange(e) {
540
- let value = e.detail.value
541
- let formId = (e && e.currentTarget && e.currentTarget.id) || (e && e.target && e.target.id) || ''
542
- if (typeof value === 'string' && formId !== 'cid_type') {
543
- value = value.trim()
544
- }
545
- // 如果是密码字段,计算强度
546
- if (formId === 'bank_card_password') {
547
- this.calculatePasswordStrength(value)
548
- }
549
- },
550
- // 计算密码强度
551
- calculatePasswordStrength(password) {
552
- let strength = 0
553
- let strengthText = '弱'
554
-
555
- if (!password) {
556
- this.setData({
557
- passwordStrength: 0,
558
- passwordStrengthText: '弱'
559
- })
560
- return
561
- }
562
-
563
- // 长度检查
564
- if (password.length >= 8) {
565
- strength++
566
- }
567
-
568
- // 包含数字
569
- if (/\d/.test(password)) {
570
- strength++
571
- }
572
-
573
- // 包含字母
574
- if (/[a-zA-Z]/.test(password)) {
575
- strength++
576
- }
577
-
578
- // 包含特殊字符
579
- if (/[!@#$%^&*(),.?":{}|<>]/.test(password)) {
580
- strength++
581
- }
582
-
583
- // 根据强度设置文本
584
- if (strength >= 4) {
585
- strengthText = '强'
586
- } else if (strength >= 2) {
587
- strengthText = '中'
588
- } else {
589
- strengthText = '弱'
590
- }
591
- // 此处判断密码强度
592
- jingtongVerifyRequest.verifyPwdStrength(password).then(res => {
593
- console.log(res)
594
- const { errcode, data } = res
595
- if(errcode === 0){
596
- console.log(strength)
597
- // 根据强度设置文本
598
- if (data.score >= 90) {
599
- strength = 3
600
- strengthText = '强'
601
- } else if (data.score >= 75) {
602
- strength = 3
603
- strengthText = '强'
604
- } else if (data.score >= 65) {
605
- strength = 2
606
- strengthText = '中'
607
- } else if (data.score >= 50) {
608
- strength = 2
609
- strengthText = '中'
610
- } else {
611
- strength = 1
612
- strengthText = '弱'
613
- }
614
-
615
- this.setData({
616
- passwordStrength: Math.min(strength, 3), // 最多显示3个等级
617
- passwordStrengthText: strengthText,
618
- isShowPasswordStrength: true
619
- })
620
- }
621
- })
622
- },
623
- // 其他方式
624
- handletoOther () {
625
- console.log('启用sms验证')
626
- // 方案B
627
- this.data.submitMode = 'other' // 设置来源标记
628
- const form = this.selectComponent('#form')
629
- if (form && typeof form.handleSubmit === 'function') {
630
- // 触发表单的内置校验流程,结果会回调到 handleFormSubmit
631
- form.handleSubmit()
632
- } else {
633
- wx.showToast({ title: '表单未就绪,请稍后再试', icon: 'none' })
634
- }
635
- // this.nextStep()
636
- // wx.navigateTo({
637
- // url: '/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-sms-setting/bank-card-login-forgot-sms-setting',
638
- // })
639
- },
640
- /**
641
- * 其他方式实际处理
642
- */
643
- toOtherWay(params, type, value) {
644
- wx.showLoading({
645
- title: '验证中',
646
- })
647
- setTimeout(() => {
648
- jingtongVerifyRequest.verifyIdcard(params).then(res =>{
649
- console.log('点击其他方式-获取身份证二要素核验结果')
650
- console.log(res)
651
- const { errcode }= res
652
- if(errcode === 0){
653
- // 判断type,1为信息确认,2为信息确认并获取手机号尾号,目前业务不需要走type=2
654
- if(type === 1) {
655
- wx.hideLoading()
656
- this.setData({
657
- set_type: 3
658
- })
659
- // 先去根据身份证校验手机号,正确才能走下一步,不然只能走人脸识别
660
- this.toCheckPhoneByIdCard()
661
- } else {
662
- this.setData({
663
- isIdCardSuccess: true
664
- })
665
- this.sendVerificationCode()
666
- wx.hideLoading()
667
- // this.toGetTailNumber(value)
668
- }
669
- } else {
670
- wx.hideLoading()
671
- wx.showToast({
672
- title: res.errmsg,
673
- icon: 'none',
674
- duration: 2000
675
- })
676
- this.setData({
677
- isIdCardSuccess: false
678
- })
679
- }
680
- }).finally(() => {
681
- wx.hideLoading()
682
- })
683
- }, 1500)
684
- },
685
- /**
686
- * 根据身份证校验手机号,正确才能走下一步,不然只能走人脸识别
687
- */
688
- toCheckPhoneByIdCard() {
689
- const { id_card_number } = this.data.formData
690
- const checkPhoneByIdCardParam = {
691
- "id_card_number": id_card_number,
692
- "phone_number": ''
693
- }
694
- jingtongVerifyRequest.getInfoCheck(checkPhoneByIdCardParam).then(res => {
695
- const { errmsg, errcode }= res
696
- if(errcode === 0){
697
- if(res.data.phone_suffix) {
698
- this.setData({
699
- formSafeDataCodeMobile: res.data.phone_suffix,
700
- phoneNumberEndTitle: '(尾号' + res.data.phone_suffix + ')'
701
- })
702
- // 下一步
703
- this.nextStep()
704
- } else {
705
- wx.showToast({
706
- title: '手机绑定状态异常,请使用人脸识别方式验证',
707
- icon: 'none',
708
- duration: 3000
709
- })
710
- this.setData({
711
- formSafeDataCodeMobile: '',
712
- phoneNumberEndTitle: ''
713
- })
714
- }
715
- } else {
716
- wx.showToast({
717
- title: errmsg,
718
- icon: 'none',
719
- duration: 3000
720
- })
721
- }
722
- })
723
- },
724
- // 其他方式
725
- handletoSendVerificationCode () {
726
- console.log('启用sms验证')
727
- try {
728
- // 临时保存并移除 verification_code
729
- const tempCode = this.data.formSafeData.verification_code
730
- const tempFormSafeData = { ...this.data.formSafeData }
731
- delete tempFormSafeData.verification_code
732
-
733
- this.setData({
734
- submitSafeMode: 'other',
735
- formSafeData: tempFormSafeData,
736
- _tempVerificationCode: tempCode // 临时保存验证码
737
- })
738
-
739
- const form = this.selectComponent('#formSafe')
740
- if (form && typeof form.handleSubmit === 'function') {
741
- form.handleSubmit()
742
- } else {
743
- // 恢复 verification_code
744
- this.setData({
745
- formSafeData: { ...this.data.formSafeData, verification_code: tempCode },
746
- submitSafeMode: '',
747
- _tempVerificationCode: '' // 清空临时验证码
748
- })
749
- }
750
- } catch (error) {
751
- // 恢复 verification_code
752
- this.setData({
753
- formSafeData: { ...this.data.formSafeData, verification_code: tempCode },
754
- submitSafeMode: '',
755
- _tempVerificationCode: '' // 清空临时保存验证码
756
- })
757
- }
758
- },
759
- /**
760
- * 发送验证码
761
- */
762
- sendVerificationCode () {
763
- wx.showLoading({
764
- title: '发送中',
765
- })
766
- if(!this.data.isIdCardSuccess){
767
- wx.showToast({
768
- title: '身份证号码验证没有通过,请重新填写',
769
- icon: 'none'
770
- });
771
- return;
772
- }
773
- if (this.data.isCountingDown) {
774
- return;
775
- }
776
-
777
- // 检查重试次数
778
- // if (this.data.retryCount >= this.data.maxRetryCount) {
779
- // wx.showToast({
780
- // title: '今日发送次数已达上限',
781
- // icon: 'none'
782
- // });
783
- // return;
784
- // }
785
- console.log(this.data.formSafeData)
786
- console.log(this.data.formSafeData.phone_number)
787
- const { phone_number } = this.data.formSafeData
788
- // 验证手机号格式
789
- if (!this.validatePhone(phone_number)) {
790
- wx.showToast({
791
- title: '请输入正确的手机号',
792
- icon: 'none'
793
- });
794
- return;
795
- }
796
- // 判断手机尾号是否一致
797
- const { formSafeDataCodeMobile } = this.data
798
- const phoneEndNumber = phone_number.slice(-4)
799
- if(phoneEndNumber !== formSafeDataCodeMobile) {
800
- wx.showToast({
801
- title: '手机号码与绑定号码不一致,请重新输入',
802
- icon: 'none',
803
- duration: 2000
804
- })
805
- return
806
- }
807
- if(formSafeDataCodeMobile === ''){
808
- wx.showToast({
809
- title: '手机号码与绑定手机号码不一致,请检查后输入',
810
- icon: 'none',
811
- duration: 2000
812
- });
813
- return;
814
- }
815
- this.sendSmsCode(phone_number);
816
- },
817
- // 验证手机号
818
- validatePhone(phone) {
819
- console.log(phone)
820
- const phoneReg = /^1[3-9]\d{9}$/;
821
- return phoneReg.test(phone);
822
- },
823
- // 实际-发送短信验证码
824
- sendSmsCode(phoneNumber) {
825
- wx.showLoading({
826
- title: '发送中...'
827
- });
828
- // 模拟发送请求
829
- setTimeout(() => {
830
- wx.hideLoading();
831
- // 调接口获取短信验证码
832
- jingtongVerifyRequest.sendSmsCode(phoneNumber).then(res => {
833
- console.log(res.data)
834
- const { data, errcode, errmsg } = res
835
- if(errcode === 0){
836
- wx.showToast({
837
- title: '验证码已发送',
838
- icon: 'success'
839
- });
840
- this.startCountdown();
841
- this.setData({
842
- isSendSms: true,
843
- // retryCount: this.data.retryCount + 1,
844
- formSafeDataCode: data.code,
845
- getFormSafeDataCodeTime: Date.now()
846
- });
847
- } else {
848
- wx.showToast({
849
- title: errmsg || '验证码获取已超10次,请明天再试。',
850
- icon: 'none',
851
- duration: 2500
852
- });
853
- }
854
- })
855
-
856
- // 模拟成功响应
857
- // const isSuccess = Math.random() > 0.9; // 80% 成功率
858
- // if (isSuccess) {
859
- // wx.showToast({
860
- // title: '验证码已发送',
861
- // icon: 'success'
862
- // });
863
- // this.startCountdown();
864
- // this.setData({
865
- // retryCount: this.data.retryCount + 1
866
- // });
867
- // } else {
868
- // wx.showToast({
869
- // title: '发送失败,请重试',
870
- // icon: 'none'
871
- // });
872
- // }
873
- }, 1500);
874
- },
875
- // 开始倒计时
876
- startCountdown() {
877
- this.setData({
878
- countdown: 60,
879
- isCountingDown: true,
880
- verificationText: '已发送(60s)'
881
- });
882
-
883
- this.countdownTimer = setInterval(() => {
884
- const newCountdown = this.data.countdown - 1;
885
-
886
- if (newCountdown <= 0) {
887
- this.setData({
888
- countdown: 0,
889
- isCountingDown: false,
890
- verificationText: '重新发送'
891
- });
892
- clearInterval(this.countdownTimer);
893
- this.countdownTimer = null;
894
- } else {
895
- this.setData({
896
- countdown: newCountdown,
897
- verificationText: `已发送(${newCountdown}s)`
898
- });
899
- }
900
- }, 1000);
901
- },
902
- /**
903
- * 打开收不到验证码提示框
904
- */
905
- handleNotVerificationTipModal () {
906
- this.setData({
907
- showNotGetVerificationCodeTipModal: true
908
- })
909
- },
910
- /**
911
- * 关闭收不到验证码提示框
912
- */
913
- handleNotGetVerificationCodeTipModalCancel() {
914
- this.setData({
915
- showNotGetVerificationCodeTipModal: false
916
- })
917
- },
918
- /**
919
- * 验证身份证号,手机号,短信验证码
920
- */
921
- async handleSafeFormSubmit (e) {
922
- console.log('进行身份证号码、手机号,短信验证码信息验证')
923
- const formValid = e.detail.validStatus
924
- const isSafeOther = this.data.submitSafeMode === 'other'
925
- if (isSafeOther){
926
- const customValid = this.data.language !== 'en' ? { valid: true, msg: '' } : this.validateFullname()
927
- this.data.submitSafeMode = ''
928
- if (!formValid || !customValid.valid) {
929
- // 自定义校验字段有问题,获取表单错误列表
930
- const formErrList = e.detail.value
931
- // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
932
- if (!formValid && customValid.valid) {
933
- // 校验通过,恢复 verification_code 并发送验证码
934
- const tempCode = this.data._tempVerificationCode || ''
935
- this.setData({
936
- formSafeData: { ...this.data.formSafeData, verification_code: tempCode }
937
- })
938
- return
939
- }
940
- // 如果表单校验没有问题,自定义校验有问题,则显示自定义校验错误提示
941
- if (formValid && !customValid.valid) {
942
- // 校验通过,恢复 verification_code 并发送验证码
943
- const tempCode = this.data._tempVerificationCode || ''
944
- this.setData({
945
- formSafeData: { ...this.data.formSafeData, verification_code: tempCode }
946
- })
947
- return
948
- }
949
- return
950
- }
951
- const { formData, formSafeData } = this.data
952
-
953
- // 校验通过,恢复 verification_code 并发送验证码
954
- const tempCode = this.data._tempVerificationCode || ''
955
- this.setData({
956
- formSafeData: { ...this.data.formSafeData, verification_code: tempCode }
957
- })
958
- let params = {
959
- 'id_card_number': formSafeData.id_card_number, // 证件号码
960
- 'name': formData.name,
961
- 'verify_type': '101', // 身份证 固定值101
962
- 'support_type': '0x40' // 4:姓名+证件号+有效起始及结束日期 0x40:姓名+证件号 0x42:姓名+证件号+人像
963
- }
964
- this.toOtherWay(params, 2, '')
965
- return
966
- }
967
- const customValid = this.data.language !== 'en' ? { valid: true, msg: '' } : this.validateFullname()
968
- if (!formValid || !customValid.valid) {
969
- // 自定义校验字段有问题,获取表单错误列表
970
- const formErrList = e.detail.value
971
- // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
972
- if (!formValid && customValid.valid) {
973
- return
974
- }
975
- // 如果表单校验没有问题,自定义校验有问题,则显示自定义校验错误提示
976
- if (formValid && !customValid.valid) {
977
- return
978
- }
979
- return
980
- }
981
- console.log('md加密验证码')
982
- console.log(MD5(this.data.formSafeData.verification_code).toString())
983
- // 判断手机尾号是否一致
984
- const { formSafeData,formSafeDataCodeMobile } = this.data
985
- let { phone_number } = formSafeData
986
- const phoneEndNumber = phone_number.slice(-4)
987
- if(phoneEndNumber !== formSafeDataCodeMobile) {
988
- wx.showToast({
989
- title: '手机号码与绑定号码不一致,请重新输入',
990
- icon: 'none',
991
- duration: 2000
992
- })
993
- return
994
- }
995
- // 判断是否发送验证码以及验证码是否过期
996
- const { isSendSms } = this.data
997
- if(!isSendSms) {
998
- wx.showToast({
999
- title: '没检验验证码,请发送验证码',
1000
- icon: 'none',
1001
- duration: 2000
1002
- })
1003
- return
1004
- }
1005
- let nowDateTime = Date.now()
1006
- const { getFormSafeDataCodeTime, formSafeDataCodeTimeOut, formSafeDataCode } = this.data
1007
- const secondDiff = Math.floor((nowDateTime - getFormSafeDataCodeTime) / 1000);
1008
- if (secondDiff > formSafeDataCodeTimeOut) {
1009
- wx.showToast({
1010
- title: '短信验证码已过期,请重新获取',
1011
- icon: 'none',
1012
- duration: 2000
1013
- })
1014
- return
1015
- }
1016
- // const ms5Code = MD5(this.data.formSafeData.verification_code).toString()
1017
- // if ( formSafeDataCode !== ms5Code) {
1018
- // wx.showToast({
1019
- // title: '验证码不一致,请重新输入',
1020
- // icon: 'none',
1021
- // duration: 2000
1022
- // })
1023
- // return
1024
- // }
1025
-
1026
- // 接口校验验证码
1027
- const smsCodeParam = {
1028
- "mobile": formSafeData.phone_number,
1029
- "mobileCode": formSafeData.verification_code
1030
- }
1031
- jingtongVerifyRequest.verifySmsCode(smsCodeParam).then(res => {
1032
- const { errcode, errmsg } = res
1033
- if (errcode === 0) {
1034
- if(!res.data.success){
1035
- wx.showToast({
1036
- title: '验证码校验失败,请重新输入。',
1037
- icon: 'none',
1038
- duration: 2000
1039
- })
1040
- return
1041
- } else{
1042
- this.nextStep()
1043
- }
1044
- } else {
1045
- wx.showToast({
1046
- title: errmsg || '验证码校验失败,请重新输入。',
1047
- icon: 'none',
1048
- duration: 2000
1049
- })
1050
- return
1051
- }
1052
- })
1053
- },
1054
- /**
1055
- * 确认设置密码
1056
- */
1057
- async handlePwdFormSubmit (e) {
1058
- console.log('进行确认设置密码')
1059
- const formValid = e.detail.validStatus
1060
- const customValid = this.data.language !== 'en' ? { valid: true, msg: '' } : this.validateFullname()
1061
- if (!formValid || !customValid.valid) {
1062
- // 自定义校验字段有问题,获取表单错误列表
1063
- const formErrList = e.detail.value
1064
- // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
1065
- if (!formValid && customValid.valid) {
1066
- return
1067
- }
1068
- // 如果表单校验没有问题,自定义校验有问题,则显示自定义校验错误提示
1069
- if (formValid && !customValid.valid) {
1070
- return
1071
- }
1072
- return
1073
- }
1074
- // 点击确定出现该提示
1075
- wx.showLoading({
1076
- title: '验证中',
1077
- mask: true // 防止用户点击
1078
- })
1079
- console.log(this.data.formSafeData)
1080
- console.log(this.data.formPwdData)
1081
- const { formData, formSafeData, formPwdData, idCardType, formSafeDataCode, set_type } = this.data
1082
- let setType = set_type === 3 ? formSafeData.cid_type : formData.cid_type
1083
- let params = {
1084
- "password": formPwdData.bank_card_password,
1085
- "id_card_number": set_type === 3 ? formSafeData.id_card_number : formData.id_card_number,
1086
- "id_type": idCardType[setType],
1087
- "code": set_type === 3 ? formSafeData.verification_code : '',
1088
- "mobile": set_type === 3 ? formSafeData.phone_number : ''
1089
- }
1090
- setTimeout(() => {
1091
- jingtongVerifyRequest.modifyPassword(params).then(res => {
1092
- console.log('设置新密码')
1093
- wx.hideLoading()
1094
- if(res.errcode === 0) {
1095
- const { success } = res.data
1096
- if(success) {
1097
- // 应进行账密登录,就是走密码登录,登录成功直接跳转回/pages/index/index
1098
- this.toLoginByPwd()
1099
- // wx.reLaunch({
1100
- // url: '/pages/index/index',
1101
- // })
1102
- }
1103
- } else {
1104
- wx.showToast({
1105
- title: res.errmsg,
1106
- icon: 'none',
1107
- duration: 2000
1108
- })
1109
- }
1110
- }).finally(() => {
1111
- wx.hideLoading()
1112
- })
1113
- }, 1500)
1114
- },
1115
- async toLoginByPwd() {
1116
- const { formData, formPwdData, idCardType } = this.data
1117
- const params = {
1118
- "password": formPwdData.bank_card_password,
1119
- "id_card_number": formData.id_card_number,
1120
- "id_type": idCardType[formData.cid_type],
1121
- "cid_type": formData.cid_type,
1122
- "login_verify_type": 1,
1123
- "verify_expire_time": formData.verify_expire_time,
1124
- "nation": Nation,
1125
- "isbind": 1,
1126
- "certName": formData.name
1127
- }
1128
- const [err, session ] = await utils.awaitTo (jingtongVerifyRequest.pwdLogin(params))
1129
- if(err){
1130
- console.log('忘记密码-重新设置密码-账号密码登录失败')
1131
- console.log(err)
1132
- } else {
1133
- console.log('忘记密码-重新设置密码-账号密码登录成功')
1134
- console.log(session)
1135
- // 保存银行卡核验成功时间戳
1136
- let timeStamp = new Date().getTime()
1137
- wx.setStorageSync('tif.bankCardTimeStamp', timeStamp)
1138
- this.authSuccess(session)
1139
- }
1140
- },
1141
- // 跳转去银行卡验证设置密码
1142
- handleToBankCard() {
1143
- console.log('====跳转去银行卡验证设置密码====')
1144
- // 跳转去银行卡验证设置密码
1145
- this.setData({
1146
- showToOtherModal: false
1147
- }, () => {
1148
- setTimeout(() => {
1149
- wx.navigateTo({
1150
- url: '/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify?id_card_number='+ this.data.formData.id_card_number
1151
- + '&cid_type=' + this.data.formData.cid_type
1152
- + '&name=' + this.data.formData.name
1153
- + '&verify_expire_time=' + this.data.formData.verify_expire_time
1154
- + '&source_type=2'
1155
- + '&checkType=2',
1156
- })
1157
- }, 100)
1158
- })
1159
- },
1160
- // 关闭提示框
1161
- handleToCancel () {
1162
- this.setData({
1163
- showToOtherModal: false
1164
- })
1165
- },
1166
- openEye(e) {
1167
- console.log(e)
1168
- const isOpen = e.detail.isOpen
1169
- const key = e.currentTarget.id
1170
- const strKey = e.currentTarget.dataset.star
1171
- console.log('isOpen', isOpen)
1172
- console.log('key', key)
1173
- console.log('strKey', strKey)
1174
- if (isOpen) {
1175
- console.log('显示脱敏')
1176
- const { id_card_number } = this.data.formData
1177
- const value = utils.hideIdCard(id_card_number, '111')
1178
- console.log('value', value)
1179
- this.setData({
1180
- [`formData.${strKey}`]: value
1181
- })
1182
- } else {
1183
- console.log('删除脱敏,显示明文')
1184
- this.setData({
1185
- [`formData.${strKey}`]: ''
1186
- })
1187
- }
1188
- },
1189
- handleFaceModalOk () {
1190
- this.setData({
1191
- showNotGetVerificationCodeTipModal: false,
1192
- showTipModal: false,
1193
- showTipFaceModal: false
1194
- })
1195
- },
1196
- // 认证成功后续操作
1197
- async authSuccess(session, isEn = false) {
1198
- console.log('====判断是否真的登录成功=====')
1199
- console.log(session)
1200
- if (!session) {
1201
- wx.showToast({
1202
- title: '登录态失效,请重试',
1203
- icon: 'none',
1204
- duration: 2000
1205
- })
1206
- return
1207
- }
1208
- const { face_time, realname_time, cid, has_phone, certType } = session
1209
- if ((!face_time && !realname_time) || !cid) {
1210
- wx.showToast({
1211
- title: `登录态失效请重试: ${this.data.formData.cid_type}`,
1212
- icon: 'none',
1213
- duration: 2000
1214
- })
1215
- return
1216
- }
1217
-
1218
- wx.showToast({
1219
- title: isEn ? 'Verification successful, redirecting...': '验证成功, 跳转中…',
1220
- icon: 'none',
1221
- duration: 5000,
1222
- mask: true
1223
- })
1224
-
1225
- const cidType = session.cid_type
1226
-
1227
- // 本地存储表单核验成功数据
1228
- wx.setStorageSync('tif.formDataSuccess', session)
1229
-
1230
- // 将弹窗标识设置为不需要弹窗
1231
- jingtongVerifyRequest.setUserReadStatus(false).then(() => {
1232
- console.log('设置弹窗标识成功')
1233
- }).catch(err => {
1234
- console.log('设置弹窗标识失败', err)
1235
- })
1236
-
1237
- setTimeout(() => {
1238
- if (this.data.needUnite === "true") {
1239
- // this.setData({
1240
- // needUnite: ''
1241
- // })
1242
-
1243
- console.log('进入业务总入口, 判断是否有手机号码', has_phone)
1244
-
1245
- // 登录成功回调 => 业务侧操作事项
1246
- wx.$_ServiceConfiguration && wx.$_ServiceConfiguration.methods && wx.$_ServiceConfiguration.methods._loginSuccessCallBack && wx.$_ServiceConfiguration.methods._loginSuccessCallBack(session)
1247
-
1248
- if (has_phone) {
1249
- const realPhone = wx.getStorageSync('tif.realPhone') || ''
1250
- const caPhone = wx.getStorageSync('tif.caPhone') || ''
1251
- const confirmTime = wx.getStorageSync('tif.tel_confirm_time') || ''
1252
-
1253
- console.log('realPhone', realPhone)
1254
- console.log('caPhone', caPhone)
1255
- console.log('confirmTime', confirmTime)
1256
-
1257
- if (realPhone !== caPhone && confirmTime && (!utils.completeDate(new Date(Number(confirmTime + '000')), 6))) {
1258
- // 埋点上报事件:自然人登录
1259
- this.loginTracker(1, cidType)
1260
-
1261
- this.setData({
1262
- hadSuccessLogin: true
1263
- })
1264
-
1265
- // 【phone与caPhone不同】且【tel_confirm_time大于6个月】
1266
- // 数据库手机号码有效期大于6个月
1267
- flow.redirectTo({
1268
- url: '../confirm-phone/confirm-phone'
1269
- })
1270
- } else {
1271
- jingtongVerifyRequest.personToken({
1272
- source: '11'
1273
- }).then(async data => {
1274
- // 设置用户账号信息
1275
- setAccountInfo(session.openid)
1276
-
1277
- // 埋点上报事件:自然人登录
1278
- this.loginTracker(1, cidType)
1279
-
1280
- this.setData({
1281
- hadSuccessLogin: true
1282
- })
1283
-
1284
- // 埋点 - 个人用户实体全属性上报
1285
- let last_login_time = utils.getCurrentTime()
1286
- wx.setStorageSync('tif.lastLoginTime', last_login_time)
1287
- const userEntityReportData = Object.assign(session, {
1288
- user_status: '1',
1289
- last_login_time,
1290
- user_date_of_birth: session.cid_type === '111' ? utils.getBirthByIDCard(session.cid) : ''
1291
- })
1292
- await utils.awaitTo(jingtongVerifyRequest.userEntityReport(userEntityReportData))
1293
-
1294
- setTimeout(() => {
1295
- flow.resolve({
1296
- token: data
1297
- })
1298
- wx.reLaunch({
1299
- url: '/pages/index/index' // 主包页面路径
1300
- })
1301
- }, 1200)
1302
- })
1303
- }
1304
- } else {
1305
- // 埋点上报事件:自然人登录
1306
- this.loginTracker(1, cidType)
1307
-
1308
- this.setData({
1309
- hadSuccessLogin: true
1310
- })
1311
-
1312
- flow.redirectTo({
1313
- url: '../bind-phone/bind-phone?source=3'
1314
- })
1315
- }
1316
- } else {
1317
- console.log('返回主包')
1318
- flow.resolve()
1319
- wx.reLaunch({
1320
- url: '/pages/index/index' // 主包页面路径
1321
- })
1322
- }
1323
- }, 800)
1324
- },
1325
- // 埋点上报事件:自然人登录
1326
- loginTracker(login_status = 1, cidType) {
1327
- SDKTrack('nature_person_login', {
1328
- // 1 登录成功;2 登录失败-身份信息核验失败;3 登录失败-人脸核验失败
1329
- // 4 登录失败-电子营业执照核验失败;5 登录失败-账号密码输入错误
1330
- // 6 取消登录(包含点击温馨提示的“取消”,点击请法人登录的×,在登录页面点击左上角返回按钮退出登录)
1331
- // 7 退出小程序终止登录;old_1 历史数据:除登录成功之外的所有情况
1332
- login_status,
1333
- login_certificate: this.data.certTypeMap[cidType] || 1, // 证件类型
1334
- invoke_location: '', // 调起位置
1335
- login_validity_period: this.data.formData.verify_expire_time / 24 || '' // 免登录时间
1336
- })
1337
- },
1338
- /**
1339
- * 生命周期函数--监听页面初次渲染完成
1340
- */
1341
- onReady() {
1342
-
1343
- },
1344
-
1345
- /**
1346
- * 生命周期函数--监听页面显示
1347
- */
1348
- onShow() {
1349
-
1350
- },
1351
-
1352
- /**
1353
- * 生命周期函数--监听页面隐藏
1354
- */
1355
- onHide() {
1356
- this.clearTimer();
1357
- },
1358
-
1359
- /**
1360
- * 生命周期函数--监听页面卸载
1361
- */
1362
- onUnload() {
1363
- this.clearTimer();
1364
- },
1365
- // 清理定时器
1366
- clearTimer() {
1367
- if (this.countdownTimer) {
1368
- clearInterval(this.countdownTimer);
1369
- this.countdownTimer = null;
1370
- }
1371
- },
1372
- /**
1373
- * 页面相关事件处理函数--监听用户下拉动作
1374
- */
1375
- onPullDownRefresh() {
1376
-
1377
- },
1378
-
1379
- /**
1380
- * 页面上拉触底事件的处理函数
1381
- */
1382
- onReachBottom() {
1383
-
1384
- },
1385
-
1386
- /**
1387
- * 用户点击右上角分享
1388
- */
1389
- onShareAppMessage() {
1390
-
1391
- }
1392
- })