weapps-plugin-jingtong-verify 1.5.1 → 1.5.2

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "weapps-plugin-jingtong-verify",
3
3
  "pluginName": "weapps-plugin-jingtong-verify",
4
4
  "pluginType": "mp",
5
- "version": "1.5.1",
5
+ "version": "1.5.2",
6
6
  "description": "",
7
7
  "main": "sdk.js",
8
8
  "author": "tongyirenzheng",
package/sdk.js CHANGED
@@ -1,5 +1,7 @@
1
1
  const jingtongVerifyRequest = require('./weapps-plugin-jingtong-verify/utils/request')
2
2
  const { nation } = require("./weapps-plugin-jingtong-verify/utils/country")
3
+ // const jingtongVerifyRequest = require('./utils/request')
4
+ // const { nation } = require("./utils/country")
3
5
  const {
4
6
  flow,
5
7
  config
@@ -24,6 +26,13 @@ const parseOptions = (options) => {
24
26
  return options
25
27
  }
26
28
 
29
+ // 身份验证
30
+ exports.goToFace = () => {
31
+ console.log('跳转到子包 === 身份验证服务')
32
+ return flow.createFlow('/weapps-plugin-jingtong-verify/pages/face-verify/face-verify', {
33
+ needUnite: 'false' // 需串联起来
34
+ })
35
+ }
27
36
  // 获取会话
28
37
  exports.getSession = (options) => {
29
38
  // 对参数做兼容性处理
@@ -70,7 +79,29 @@ const toBindPhone = (source) => {
70
79
  source
71
80
  })
72
81
  }
73
-
82
+ // 去设置登录密码
83
+ exports.goToBankCardLoginPwdSetting = (options) => {
84
+ console.log('跳转到子包 === 设置登录密码')
85
+ // 对参数做兼容性处理
86
+ let optionsParse = parseOptions(options)
87
+ jingtongVerifyRequest.getSession({
88
+ success: res => {
89
+ console.log(res)
90
+ return flow.createFlow('/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting',{
91
+ "name": res.name,
92
+ "idCardNumber": res.cid,
93
+ "strCid": res.star_cid,
94
+ "cid_type": res.cid_type,
95
+ "verify_expire_time": res.verify_expire_time
96
+ })
97
+ },
98
+ fail: fail => {
99
+ console.log('getSession-fail', fail)
100
+ optionsParse && optionsParse.fail && optionsParse.fail(fail)
101
+ }
102
+ })
103
+
104
+ }
74
105
  // 比较两个时间 time1,time2均为日期类型
75
106
  // 判断当前日期与time1日期是否相差小于6月
76
107
  const completeDate = (time1, m) => {
@@ -344,6 +344,12 @@ const rules = {
344
344
  en: 'Please enter your login password'
345
345
  }
346
346
  },
347
+ verification_code: {
348
+ required: {
349
+ zh_CN: '请输入验证码',
350
+ en: 'Please enter the verification code'
351
+ }
352
+ },
347
353
  },
348
354
  // 忘记密码设置新密码
349
355
  bankCardSetNewPwdRules: {
@@ -192,6 +192,13 @@
192
192
  align-items: center;
193
193
  justify-content: center;
194
194
  border-radius: 10rpx;
195
+ color: #62667a;
196
+ text-align: center;
197
+ font-family: "PingFang SC";
198
+ font-size: 17px;
199
+ font-style: normal;
200
+ font-weight: 500;
201
+ line-height: normal;
195
202
  }
196
203
 
197
204
  .readonly-input input {
@@ -132,6 +132,8 @@ Page({
132
132
  formData.cid_type = options.cid_type
133
133
  formData.verify_expire_time = options.verify_expire_time
134
134
  formSafeData.cid_type = options.cid_type
135
+ formSafeData.id_card_number = options.idCardNumber
136
+ formSafeData.strCid = options.strCid
135
137
  this.setData({
136
138
  formData: formData,
137
139
  formSafeData: formSafeData
@@ -157,16 +159,17 @@ Page({
157
159
  this.setData({
158
160
  currentStep: this.data.currentStep + 1
159
161
  });
160
- if(this.data.currentStep == 1){
161
- // this.getTailNumber()
162
- }
162
+ // if(this.data.currentStep == 1){
163
+ // this.getTailNumber()
164
+ // }
163
165
  }
164
166
  },
165
167
  /**
166
168
  * 获取手机号尾号并设置证件号码
167
169
  */
168
- getTailNumber (e) {
169
- let value = e.detail.value
170
+ getTailNumber () {
171
+ // let value = e.detail.value
172
+ let value = this.data.formSafeData.id_card_number
170
173
  if(value === '' || value === null){
171
174
  return
172
175
  }
@@ -181,19 +184,19 @@ Page({
181
184
  "support_type": '0x40' // 4:姓名+证件号+有效起始及结束日期 0x40:姓名+证件号 0x42:姓名+证件号+人像
182
185
  }
183
186
  console.log('结果')
184
- console.log(this.toOtherWay(params, 2, value))
187
+ // console.log(this.toOtherWay(params, 2, value))
185
188
 
186
- this.toOtherWay(params, 2, value)
187
- // setTimeout(() => {
188
- // console.log(this.data.isIdCardSuccess)
189
- // // this.toGetTailNumber(value)
190
- // }, 100)
189
+ // this.toOtherWay(params, 2, value)
190
+ setTimeout(() => {
191
+ // console.log(this.data.isIdCardSuccess)
192
+ this.toGetTailNumber(value)
193
+ }, 100)
191
194
  },
192
195
  toGetTailNumber (value) {
193
- const { isIdCardSuccess } = this.data
194
- if(!isIdCardSuccess){
195
- return
196
- }
196
+ // const { isIdCardSuccess } = this.data
197
+ // if(!isIdCardSuccess){
198
+ // return
199
+ // }
197
200
  // let value = e.detail.value
198
201
  // const { id_card_number, strCid } = this.data.formSafeData
199
202
  // let { formSafeData } = this.data
@@ -645,11 +648,13 @@ Page({
645
648
  const { errcode }= res
646
649
  if(errcode === 0){
647
650
  wx.hideLoading()
651
+ // 判断type,1为信息确认,2为信息确认并获取手机号尾号,目前业务不需要走type=2
648
652
  if(type === 1) {
649
653
  this.setData({
650
654
  set_type: 3
651
655
  })
652
- this.nextStep()
656
+ // 先去根据身份证校验手机号,正确才能走下一步,不然只能走人脸识别
657
+ this.toCheckPhoneByIdCard()
653
658
  } else {
654
659
  this.setData({
655
660
  isIdCardSuccess: true
@@ -672,17 +677,56 @@ Page({
672
677
  })
673
678
  }, 1500)
674
679
  },
680
+ /**
681
+ * 根据身份证校验手机号,正确才能走下一步,不然只能走人脸识别
682
+ */
683
+ toCheckPhoneByIdCard() {
684
+ const { id_card_number } = this.data.formData
685
+ const checkPhoneByIdCardParam = {
686
+ "id_card_number": id_card_number,
687
+ "phone_number": ''
688
+ }
689
+ jingtongVerifyRequest.getInfoCheck(checkPhoneByIdCardParam).then(res => {
690
+ const { errmsg, errcode }= res
691
+ if(errcode === 0){
692
+ if(res.data.phone_suffix) {
693
+ this.setData({
694
+ formSafeDataCodeMobile: res.data.phone_suffix,
695
+ phoneNumberEndTitle: '(尾号' + res.data.phone_suffix + ')'
696
+ })
697
+ // 下一步
698
+ this.nextStep()
699
+ } else {
700
+ wx.showToast({
701
+ title: '手机绑定状态异常,请使用人脸识别方式验证',
702
+ icon: 'none',
703
+ duration: 3000
704
+ })
705
+ this.setData({
706
+ formSafeDataCodeMobile: '',
707
+ phoneNumberEndTitle: ''
708
+ })
709
+ }
710
+ } else {
711
+ wx.showToast({
712
+ title: errmsg,
713
+ icon: 'none',
714
+ duration: 3000
715
+ })
716
+ }
717
+ })
718
+ },
675
719
  /**
676
720
  * 发送验证码
677
721
  */
678
722
  sendVerificationCode () {
679
- if(!this.data.isIdCardSuccess){
680
- wx.showToast({
681
- title: '身份证号码验证没有通过,请重新验证',
682
- icon: 'none'
683
- });
684
- return;
685
- }
723
+ // if(!this.data.isIdCardSuccess){
724
+ // wx.showToast({
725
+ // title: '身份证号码验证没有通过,请重新验证',
726
+ // icon: 'none'
727
+ // });
728
+ // return;
729
+ // }
686
730
  if (this.data.isCountingDown) {
687
731
  return;
688
732
  }
@@ -744,8 +788,8 @@ Page({
744
788
  // 调接口获取短信验证码
745
789
  jingtongVerifyRequest.sendSmsCode(phoneNumber).then(res => {
746
790
  console.log(res.data)
747
- const { data } = res
748
- if(data.errcode === 0){
791
+ const { data, errcode, errmsg } = res
792
+ if(errcode === 0){
749
793
  wx.showToast({
750
794
  title: '验证码已发送',
751
795
  icon: 'success'
@@ -754,12 +798,12 @@ Page({
754
798
  this.setData({
755
799
  isSendSms: true,
756
800
  retryCount: this.data.retryCount + 1,
757
- formSafeDataCode: data.data.code,
801
+ formSafeDataCode: data.code,
758
802
  getFormSafeDataCodeTime: Date.now()
759
803
  });
760
804
  } else {
761
805
  wx.showToast({
762
- title: '发送失败,请重试',
806
+ title: errmsg || '发送失败,稍后请重试',
763
807
  icon: 'none'
764
808
  });
765
809
  }
@@ -891,7 +935,34 @@ Page({
891
935
  })
892
936
  return
893
937
  }
894
- this.nextStep()
938
+
939
+ // 接口校验验证码
940
+ const smsCodeParam = {
941
+ "mobile": formSafeData.phone_number,
942
+ "mobileCode": formSafeData.verification_code
943
+ }
944
+ jingtongVerifyRequest.verifySmsCode(smsCodeParam).then(res => {
945
+ const { errcode, errmsg } = res
946
+ if (errcode === 0) {
947
+ if(!res.data.success){
948
+ wx.showToast({
949
+ title: '验证码不正确,请重新输入',
950
+ icon: 'none',
951
+ duration: 2000
952
+ })
953
+ return
954
+ } else{
955
+ this.nextStep()
956
+ }
957
+ } else {
958
+ wx.showToast({
959
+ title: errmsg,
960
+ icon: 'none',
961
+ duration: 2000
962
+ })
963
+ return
964
+ }
965
+ })
895
966
  },
896
967
  /**
897
968
  * 确认设置密码
@@ -993,7 +1064,8 @@ Page({
993
1064
  + '&cid_type=' + this.data.formData.cid_type
994
1065
  + '&name=' + this.data.formData.name
995
1066
  + '&verify_expire_time=' + this.data.formData.verify_expire_time
996
- + '&source_type=2',
1067
+ + '&source_type=2'
1068
+ + '&checkType=2',
997
1069
  })
998
1070
  }, 100)
999
1071
  })
@@ -51,14 +51,10 @@
51
51
  label="证件号码"
52
52
  placeholder="请输入本人证件号码"
53
53
  value="{{ formData.strCid || formData.id_card_number }}"
54
- showEye="{{ formData.id_card_number }}"
55
- isOpen="{{ !formData.strCid }}"
56
54
  clearable="{{ false }}"
57
55
  class="readonly-input"
58
- isOpen="{{ !formData.strCid }}"
59
56
  showQuestion="{{ true }}"
60
57
  bind:showQuestionTip="showQuestionTip"
61
- bind:openEye="openEye"
62
58
  />
63
59
  </view>
64
60
  </g-form>
@@ -80,7 +76,7 @@
80
76
  bind:submit="handleSafeFormSubmit"
81
77
  >
82
78
  <view class="form-item-wrap">
83
- <!-- <g-input
79
+ <g-input
84
80
  id="id_card_number"
85
81
  data-star="strCid"
86
82
  label="身份证号码"
@@ -88,16 +84,16 @@
88
84
  value="{{ formSafeData.strCid || formSafeData.id_card_number }}"
89
85
  clearable="{{ false }}"
90
86
  class="readonly-input"
91
- isOpen="{{ !formSafeData.strCid }}"
92
- bind:change="handleSafeChange"
87
+ isOpen="{{ !formSafeData.strCid }}"
93
88
  showQuestion="{{ true }}"
94
89
  bind:showQuestionTip="showQuestionTip"
95
- /> -->
96
-
90
+ />
91
+
92
+ <!-- bind:change="handleSafeChange" -->
97
93
  <!-- isOpen="{{ !formData.strCid }}" -->
98
94
  <!-- bind:openEye="openEye" -->
99
95
  <!-- showEye="{{ formData.id_card_number }}" -->
100
- <g-input
96
+ <!-- <g-input
101
97
  id="id_card_number"
102
98
  data-star="strCid"
103
99
  label="身份证号码"
@@ -108,7 +104,7 @@
108
104
  showQuestion="{{ true }}"
109
105
  bind:showQuestionTip="showQuestionTip"
110
106
  bind:blur="getTailNumber"
111
- />
107
+ /> -->
112
108
  </view>
113
109
  <!-- 手机号码 -->
114
110
  <view class="form-item-wrap">
@@ -192,12 +188,13 @@
192
188
  bind:blur="handlePwdStrongChange"
193
189
  />
194
190
  </view>
195
- <!-- 确认登录密码 -->
191
+ <!-- 确认新密码 -->
196
192
  <view class="form-item-wrap">
197
193
  <g-input
198
194
  id="bank_card_pwd_password"
199
- label="确认登录密码"
195
+ label="确认新密码"
200
196
  placeholder="请再次输入新登录密码"
197
+ placeholder-class="bank-card-verify-placeholder"
201
198
  value="{{ formPwdData.bank_card_pwd_password }}"
202
199
  clearable="true"
203
200
  password="true"
@@ -194,6 +194,7 @@
194
194
  justify-content: center;
195
195
  border-radius: 10rpx;
196
196
  color: #CE0022;
197
+ font-size: 34rpx;
197
198
  }
198
199
 
199
200
  /* 步骤条以及内容 */
@@ -40,6 +40,7 @@
40
40
  <g-input
41
41
  id="bank_card_password"
42
42
  placeholder="请输入登录密码"
43
+ placeholder-class="bank-card-verify-placeholder"
43
44
  value="{{ formData.bank_card_password }}"
44
45
  clearable="true"
45
46
  password="true"
@@ -54,6 +55,7 @@
54
55
  id="bank_card_pwd_password"
55
56
  label="确认登录密码"
56
57
  placeholder="请再次输入登录密码"
58
+ placeholder-class="bank-card-verify-placeholder"
57
59
  value="{{ formData.bank_card_pwd_password }}"
58
60
  clearable="true"
59
61
  password="true"
@@ -2,7 +2,9 @@
2
2
  const jingtongVerifyRequest = require('../../utils/request')
3
3
  const constantVal = require("../../utils/constantVal")
4
4
  const rulesConfig = require("../../utils/rules")
5
+ const MD5 = require("../../utils/md5")
5
6
  const utils = require("../../utils/index")
7
+ const { flow } = require("@wecity/weda-plugin-utils");
6
8
  let cidType = '111'
7
9
  let Nation = 'CHN'
8
10
  Page({
@@ -22,7 +24,8 @@ Page({
22
24
  bank_phone:'', // 绑定手机号
23
25
  verify_expire_time: '', // 登录有效时间
24
26
  nation: 'CHN',
25
- is_bind: '1'
27
+ is_bind: '1',
28
+ verification_code: '', // 验证码
26
29
  },
27
30
  rules: rulesConfig.bankCardRules('zh_CN'),
28
31
  validateType: {
@@ -38,6 +41,21 @@ Page({
38
41
  bank_phone(value) {
39
42
  return utils.validate.checkPhone(value).data
40
43
  },
44
+ // 新增验证码验证
45
+ verification_code(value) {
46
+ // 如果 source_type 为 2,跳过验证
47
+ if (this.data.source_type === '2') {
48
+ return true
49
+ }
50
+ // 验证码不能为空
51
+ if (!value || value.trim() === '') {
52
+ return false
53
+ }
54
+ // 验证码格式:4-8位数字或字母数字组合
55
+ // const codeReg = /^[a-zA-Z0-9]{4,8}$/
56
+ // return codeReg.test(value.trim())
57
+ return utils.validate.checkVerificationCode(value).data
58
+ }
41
59
  },
42
60
  idCardType: {
43
61
  '111': '1',// 大陆
@@ -71,21 +89,39 @@ Page({
71
89
  // 自定义校验提示文本
72
90
  customTipsMsg: '',
73
91
  source_type: '1', // 来源,1是没有设置密码,直接进入;2是重新设置密码的时候,人脸识别限制了,进来的
74
- showTipModal: false
92
+ showTipModal: false,
93
+ // 获取验证参数
94
+ verificationText: '发送验证码',
95
+ countdown: 0,
96
+ isCountingDown: false,
97
+ isSendSms: true, // 是否发送验证码
98
+ maxRetryCount: 3, // 最大重试次数
99
+ retryCount: 0, // 当前重试次数
100
+ bankInfoSuccess: false, // 首次设置密码进入,银行卡信息核验是否成功,默认失败
101
+ formDataVerificationCode: '', // 接口返回的验证码
102
+ formDataCodeMobile: '', // 根据证件号码获取的手机号尾号
103
+ isFormDataCodeMobile: false, // 默认填写的手机号与实际手机号不匹配
104
+ checkType: '', //// 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
105
+ // 收不到验证码提示框
106
+ showNotGetVerificationCodeTipModal: false,
75
107
  },
76
108
 
77
109
  /**
78
110
  * 生命周期函数--监听页面加载
79
111
  */
80
112
  onLoad(options) {
81
- let { formData } = this.data
113
+ let { formData, checkType } = this.data
82
114
  formData.cardholder_name = options.name
83
115
  formData.id_card_number = options.id_card_number
84
116
  formData.strCid = options.strCid
85
117
  formData.verify_expire_time = options.verify_expire_time
118
+ checkType = options.checkType
86
119
  this.setData({
87
- formData: formData
120
+ formData: formData,
121
+ checkType: checkType
88
122
  })
123
+ console.log('判断后面跳转类型')
124
+ console.log(this.data.checkType)
89
125
  if(options.source_type) {
90
126
  console.log('接收到类型')
91
127
  console.log(options.source_type)
@@ -194,11 +230,51 @@ Page({
194
230
  }
195
231
  }
196
232
  }
233
+ console.log('md加密验证码')
234
+ console.log(MD5(formData.verification_code).toString())
197
235
  // 点击确定出现该提示
198
236
  wx.showLoading({
199
237
  title: '验证中...',
200
238
  mask: true // 防止用户点击
201
239
  })
240
+ const { formDataVerificationCode } = this.data
241
+ const ms5Code = MD5(formData.verification_code).toString()
242
+ if ( formDataVerificationCode !== ms5Code) {
243
+ wx.showToast({
244
+ title: '验证码不一致,请重新输入',
245
+ icon: 'none',
246
+ duration: 2000
247
+ })
248
+ wx.hideLoading()
249
+ return
250
+ }
251
+ // 接口验证短信验证码
252
+ if(source_type !== '2'){
253
+ const verSmsCodeParam = {
254
+ "mobile": formData.bank_phone,
255
+ "monbileCode": formData.verification_code
256
+ }
257
+ jingtongVerifyRequest.verifySmsCode(verSmsCodeParam).then(res => {
258
+ const { errcode, errmsg } = res
259
+ if(errcode !== 0){
260
+ wx.showToast({
261
+ title: errmgs,
262
+ icon: 'none',
263
+ duration: 2000
264
+ })
265
+ return
266
+ } else{
267
+ if(!res.data.success) {
268
+ wx.showToast({
269
+ title: '验证码不正确,请重新输入',
270
+ icon: 'none',
271
+ duration: 2000
272
+ })
273
+ return
274
+ }
275
+ }
276
+ })
277
+ }
202
278
  const param = {
203
279
  'id_card_number': formData.id_card_number,
204
280
  'type': 2,
@@ -270,16 +346,31 @@ Page({
270
346
  // 清空核验银行卡错误缓存
271
347
  constantVal.removeStorage(constantVal.bank_card_verify_fail_count)
272
348
  constantVal.removeStorage(constantVal.bank_card_verify_fail_time)
273
-
274
- wx.showToast({
275
- title: '验证成功,跳转中…',
276
- icon: 'none',
277
- duration: 1500
278
- })
279
- const { cardholder_name, id_card_number, strCid, cid_type, verify_expire_time } = formData
280
- wx.navigateTo({
281
- url: '/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting?name=' + cardholder_name + '&idCardNumber=' + id_card_number + '&strCid=' + utils.hideIdCard(id_card_number, '111') + '&cid_type=' + cid_type + '&verify_expire_time=' + verify_expire_time,
349
+ // 验证成功,这里跳转页面
350
+ jingtongVerifyRequest.getSession({
351
+ success: res => {
352
+ // 保存银行卡核验成功时间戳
353
+ let timeStamp = new Date().getTime()
354
+ wx.setStorageSync('tif.bankCardTimeStamp', timeStamp)
355
+ wx.setStorageSync('tif.formDataSuccess', res)
356
+ }
282
357
  })
358
+
359
+ if(this.data.checkType === 3){
360
+ flow.redirectTo({
361
+ url: '../bind-phone/bind-phone?source=3'
362
+ })
363
+ } else {
364
+ wx.showToast({
365
+ title: '验证成功,跳转中…',
366
+ icon: 'none',
367
+ duration: 1500
368
+ })
369
+ const { cardholder_name, id_card_number, strCid, cid_type, verify_expire_time } = formData
370
+ wx.navigateTo({
371
+ url: '/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting?name=' + cardholder_name + '&idCardNumber=' + id_card_number + '&strCid=' + utils.hideIdCard(id_card_number, '111') + '&cid_type=' + cid_type + '&verify_expire_time=' + verify_expire_time,
372
+ })
373
+ }
283
374
  } else {
284
375
  const { errmsg } = res
285
376
  if(bankCardFailCount >= 3){
@@ -465,6 +556,218 @@ Page({
465
556
  showTipModal: false
466
557
  })
467
558
  },
559
+
560
+ // 发送验证码
561
+ sendVerificationCode() {
562
+ if (this.data.isCountingDown) {
563
+ return;
564
+ }
565
+
566
+ // 检查重试次数
567
+ if (this.data.retryCount >= this.data.maxRetryCount) {
568
+ wx.showToast({
569
+ title: '今日发送次数已达上限',
570
+ icon: 'none'
571
+ });
572
+ return;
573
+ }
574
+ const { formData } = this.data
575
+ if(formData.bank_phone === ''){
576
+ wx.showToast({
577
+ title: '手机号码与绑定手机号码不一致,请检查后输入',
578
+ icon: 'none',
579
+ duration: 2000
580
+ });
581
+ return;
582
+ }
583
+ // 验证手机号格式
584
+ if (!this.validatePhone(formData.bank_phone)) {
585
+ wx.showToast({
586
+ title: '请输入正确的手机号',
587
+ icon: 'none'
588
+ });
589
+ return;
590
+ }
591
+ // this.toGetPhoneCodeByIdCard()
592
+ this.checkBankCardInfo()
593
+ console.log(this.data.bankInfoSuccess)
594
+
595
+ },
596
+ sendSmsCode(phoneNumber) {
597
+ wx.showLoading({
598
+ title: '发送中...'
599
+ });
600
+ // 调接口获取短信验证码
601
+ jingtongVerifyRequest.sendSmsCode(phoneNumber).then(res => {
602
+ console.log(res.data)
603
+ const { data, errcode, errmsg } = res
604
+ wx.hideLoading()
605
+ if(errcode === 0){
606
+ wx.showToast({
607
+ title: '验证码已发送',
608
+ icon: 'success'
609
+ });
610
+ this.startCountdown();
611
+ this.setData({
612
+ isSendSms: true,
613
+ retryCount: this.data.retryCount + 1,
614
+ formDataVerificationCode: data.code
615
+ });
616
+ } else {
617
+ wx.showToast({
618
+ title: errmsg || '发送失败,稍后请重试',
619
+ icon: 'none'
620
+ });
621
+ }
622
+ })
623
+ },
624
+ // 开始倒计时
625
+ startCountdown() {
626
+ this.setData({
627
+ countdown: 60,
628
+ isCountingDown: true,
629
+ verificationText: '已发送(60s)'
630
+ });
631
+
632
+ this.countdownTimer = setInterval(() => {
633
+ const newCountdown = this.data.countdown - 1;
634
+
635
+ if (newCountdown <= 0) {
636
+ this.setData({
637
+ countdown: 0,
638
+ isCountingDown: false,
639
+ verificationText: '重新发送'
640
+ });
641
+ clearInterval(this.countdownTimer);
642
+ this.countdownTimer = null;
643
+ } else {
644
+ this.setData({
645
+ countdown: newCountdown,
646
+ verificationText: `已发送(${newCountdown}s)`
647
+ });
648
+ }
649
+ }, 1000);
650
+ },
651
+ // 获取手机号尾号并设置手机号是否匹配
652
+ toGetPhoneCodeByIdCard(){
653
+ const { formData } = this.data
654
+ const phoneCodeParam = {
655
+ "id_card_number" : formData.id_card_number,
656
+ "mobile": formData.bank_phone
657
+ }
658
+ jingtongVerifyRequest.getInfoCheck(phoneCodeParam).then(res => {
659
+ const { errcode, errmsg } = res
660
+ if(errcode === 0){
661
+ this.setData({
662
+ isFormDataCodeMobile: res.data.is_matched
663
+ })
664
+ } else {
665
+ wx.showToast({
666
+ title: errmsg,
667
+ icon: "none",
668
+ duration: 3000
669
+ })
670
+ }
671
+ })
672
+ },
673
+ // 验证手机号
674
+ validatePhone(phone) {
675
+ console.log(phone)
676
+ const phoneReg = /^1[3-9]\d{9}$/;
677
+ return phoneReg.test(phone);
678
+ },
679
+ // 银行卡号失焦检测
680
+ bankCardToCheckBankInfo() {
681
+ const { formData, source_type }= this.data
682
+ // 设置密码才进行检测,如果是忘记密码进入的,不走这里
683
+ if(source_type != 2){
684
+ // 手机号号是否填写,填写就进行银行卡核验
685
+ if(formData.phone_number){
686
+ console.log('填写了')
687
+ // this.checkBankCardInfo()
688
+ }
689
+ }
690
+ },
691
+ // 手机号失焦检测
692
+ phoneToCheckBankInfo(){
693
+ const { formData, source_type }= this.data
694
+ // 设置密码才进行检测,如果是忘记密码进入的,不走这里
695
+ if(source_type != 2) {
696
+ // 银行卡号是否填写,填写就进行银行卡核验
697
+ if(formData.bank_card_account){
698
+ console.log('填写了')
699
+ // this.checkBankCardInfo()
700
+ }
701
+ }
702
+ },
703
+ // 银行卡核验-仅核验
704
+ checkBankCardInfo() {
705
+ wx.showLoading({
706
+ title: '验证中…',
707
+ })
708
+ const { formData, idCardType }= this.data
709
+ console.log('参数')
710
+ console.log(formData)
711
+ const checkBankCardParam = {
712
+ 'id_card_number': formData.id_card_number,
713
+ "cert_name": formData.cardholder_name,
714
+ "verify_type": '110',
715
+ "support_type": '110',
716
+ "id_type": idCardType[formData.cid_type],
717
+ "account_no": formData.bank_card_account,
718
+ "mobile": formData.bank_phone,
719
+ "isbind": 1,
720
+ "cid_type": "111"
721
+ }
722
+ jingtongVerifyRequest.setNewPwdToBankCardVerifyWithIdCard(checkBankCardParam).then(res =>{
723
+ console.log('请求结果')
724
+ console.log(res)
725
+ wx.hideLoading()
726
+ const { errcode, errmsg } = res
727
+ //核验通过,进行标记
728
+ if(errcode === 0){
729
+ this.setData({
730
+ bankInfoSuccess: true
731
+ })
732
+ // 手机号匹配,进行发送验证码
733
+ if(this.data.bankInfoSuccess){
734
+ const { formData } = this.data
735
+ this.sendSmsCode(formData.bank_phone)
736
+ }
737
+ } else {
738
+ wx.showToast({
739
+ title: errmsg,
740
+ icon: 'none',
741
+ duration: 3000
742
+ })
743
+ this.setData({
744
+ bankInfoSuccess: false
745
+ })
746
+ }
747
+ }).catch(error => {
748
+ wx.showToast({
749
+ title: '请求异常',
750
+ icon: 'none',
751
+ duration: 3000
752
+ })
753
+ })
754
+ },
755
+ /**
756
+ * 打开收不到验证码提示框
757
+ */
758
+ handleNotVerificationTipModal () {
759
+ this.setData({
760
+ showNotGetVerificationCodeTipModal: true
761
+ })
762
+ },
763
+ /**
764
+ * 关闭收不到验证码提示框
765
+ */
766
+ handleNotGetVerificationCodeTipModalCancel() {
767
+ this.setData({
768
+ showNotGetVerificationCodeTipModal: false
769
+ })
770
+ },
468
771
  /**
469
772
  * 页面相关事件处理函数--监听用户下拉动作
470
773
  */
@@ -68,6 +68,7 @@
68
68
  value="{{ formData.bank_card_account }}"
69
69
  clearable="true"
70
70
  bind:change="handleChange"
71
+ bind:blur="bankCardToCheckBankInfo"
71
72
  />
72
73
  </view>
73
74
  <view class="form-item-wrap">
@@ -79,9 +80,36 @@
79
80
  value="{{ formData.bank_phone }}"
80
81
  clearable="true"
81
82
  bind:change="handleChange"
83
+ bind:blur="phoneToCheckBankInfo"
82
84
  />
83
85
  </view>
84
- <view class="describe-box" style="margin-top: 50rpx">
86
+ <!-- 验证码 -->
87
+ <view class="form-item-wrap" wx:if="{{source_type != 2}}">
88
+ <g-input
89
+ id="verification_code"
90
+ label="验证码"
91
+ placeholder="请填写短信验证码"
92
+ value="{{ formData.verification_code }}"
93
+ clearable="true"
94
+ bind:change="handleChange"
95
+ append="true"
96
+ >
97
+ <view
98
+ slot="append"
99
+ class="verification-btn {{ isCountingDown ? 'disabled' : '' }}"
100
+ bind:tap="sendVerificationCode"
101
+ >
102
+ {{ verificationText }}
103
+ </view>
104
+ </g-input>
105
+ </view>
106
+ <!-- 收不到验证码 -->
107
+ <view class="form-item-wrap" wx:if="{{source_type != 2}}">
108
+ <view class="not_get_verification_code" bind:tap="handleNotVerificationTipModal">
109
+ 收不到验证码?
110
+ </view>
111
+ </view>
112
+ <view class="describe-box" style="margin-top: 10rpx">
85
113
  <view class="special-describe-box" >
86
114
  <view>特别说明:</view>
87
115
  <view>您提供的银行卡号及其绑定手机号仅用于您的身份认证,北京市大数据中心不会留存你的银行卡信息</view>
@@ -117,4 +145,15 @@
117
145
  bind:cancel="handleModalOk"
118
146
  desc1="1、如果您在公安局变更了您的姓名或证件号码等信息,请您填写变更后的身份信息进行登录。"
119
147
  desc2="2、如果当前显示为他人信息(亲属/朋友等),请您删除后使用本人身份信息进行登录。"
148
+ ></tip-modal>
149
+
150
+ <!-- 收不到验证码弹窗 -->
151
+ <tip-modal
152
+ visible="{{ showNotGetVerificationCodeTipModal }}"
153
+ bind:cancel="handleNotGetVerificationCodeTipModalCancel"
154
+ xAlign="left"
155
+ desc1="1、短信验证码会发送至您银行卡绑定的手机号。"
156
+ desc2="2、请确认当前手机信号良好并已关闭飞行模式。"
157
+ desc3="3、请检查短信是否被手机安全软件拦截。"
158
+ desc4="4、如仍收不到短信验证码,请尝试使用人脸识别方式验证。"
120
159
  ></tip-modal>
@@ -214,4 +214,45 @@
214
214
  /* 在现有样式中添加隐藏选择文字 */
215
215
  .readonly-picker .picker__action {
216
216
  display: none !important;
217
+ }/* 短信验证码 */
218
+
219
+ /* 收不到验证码 */
220
+ .not_get_verification_code{
221
+ padding:40rpx; color: #ce0022;
222
+ font-family: "PingFang SC";
223
+ font-size: 34rpx;
224
+ font-style: normal;
225
+ font-weight: 500;
226
+ line-height: normal;
227
+ letter-spacing: -0.3px;
228
+ padding: 40rpx;
229
+ }
230
+ /* 验证码按钮样式 */
231
+ .verification-btn {
232
+ display: inline-flex;
233
+ align-items: center;
234
+ justify-content: center;
235
+ height: 64rpx; /* 胶囊高度 */
236
+ padding: 0 28rpx; /* 左右内边距 */
237
+ background: #ce0022; /* 红底 */
238
+ color: #ffffff; /* 白字 */
239
+ font-size: 28rpx;
240
+ white-space: nowrap;
241
+ border-radius: 40rpx; /* 圆角形成胶囊 */
242
+ transition: opacity 0.2s ease;
243
+ cursor: pointer;
244
+ box-shadow: 0 4rpx 12rpx rgba(206, 0, 34, 0.18);
245
+ }
246
+
247
+ /* 倒计时状态样式 */
248
+ .verification-btn.disabled {
249
+ background: #E6E6E6; /* 灰底 */
250
+ color: #999999; /* 灰字 */
251
+ box-shadow: none;
252
+ cursor: not-allowed;
253
+ }
254
+
255
+ /* 点击效果 */
256
+ .verification-btn:active:not(.disabled) {
257
+ opacity: 0.85;
217
258
  }
@@ -192,7 +192,8 @@ Page({
192
192
  customTipsMsg: '',
193
193
  submitMode: '',
194
194
  // 防重复点击标记 - 基于接口返回状态
195
- isSubmitting: false
195
+ isSubmitting: false,
196
+ checkType: 1, // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
196
197
  },
197
198
 
198
199
  /**
@@ -1585,19 +1586,121 @@ Page({
1585
1586
  async toBankCardLogin() {
1586
1587
  // 判断是否是PC端登录
1587
1588
  await this.getDevice()
1589
+ wx.showLoading({
1590
+ title: '验证中…',
1591
+ mask: true
1592
+ })
1593
+ // 身份二要素校验
1594
+ const { name, id_card_number } = this.data.formData
1595
+ const verifyIdCardParams = {
1596
+ "id_card_number": id_card_number,
1597
+ "name": name,
1598
+ "verify_type": "101",
1599
+ "support_type": "0x40"
1600
+ }
1601
+ jingtongVerifyRequest.verifyIdcard(verifyIdCardParams).then(res => {
1602
+ console.log('获取身份证二要素核验结果')
1603
+ console.log(res)
1604
+ if(res.errcode === 0){
1605
+ // 可进行
1606
+ } else {
1607
+ wx.showToast({
1608
+ title: res.errmsg,
1609
+ icon: 'none',
1610
+ duration: 2000
1611
+ })
1612
+ this.data.submitMode = ''
1613
+ this.data.isSubmitting = false
1614
+ return
1615
+ }
1616
+ wx.hideLoading()
1617
+ }).catch(error => {
1618
+ this.data.submitMode = ''
1619
+ this.data.isSubmitting = false
1620
+ return
1621
+ })
1622
+ // 验证手机号
1623
+ const infoCheckParam = {
1624
+ "id_card_number": id_card_number,
1625
+ "phone_number": ''
1626
+ }
1627
+
1628
+ let isPhoneNumber = false
1629
+ jingtongVerifyRequest.getInfoCheck(infoCheckParam).then(res =>{
1630
+ const { errmsg, errcode } = res
1631
+ console.log(res)
1632
+ if(errcode === 0){
1633
+ if(res.data.phone_suffix){
1634
+ isPhoneNumber = false
1635
+ // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
1636
+ this.setData({
1637
+ checkType:2
1638
+ })
1639
+ } else {
1640
+ isPhoneNumber = true
1641
+ // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
1642
+ this.setData({
1643
+ checkType:3
1644
+ })
1645
+ }
1646
+ } else{
1647
+ isPhoneNumber = true
1648
+ }
1649
+ }).catch(error => {
1650
+ this.data.submitMode = ''
1651
+ this.data.isSubmitting = false
1652
+ return
1653
+ })
1588
1654
  jingtongVerifyRequest.checkPhonePwd(this.data.formData.id_card_number).then(res => {
1589
1655
  console.log(res)
1656
+ wx.hideLoading()
1590
1657
  const { errmsg, errcode } = res
1658
+ console.log(isPhoneNumber)
1659
+ console.log(!res.data.is_new)
1591
1660
  if (errcode === 0) {
1592
- if(res.data.is_new){
1661
+ // isPhoneNumber 为true,即系没有手机号,res.data.is_new为true即系无密码
1662
+ if(isPhoneNumber && res.data.is_new){
1663
+ // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
1664
+ this.setData({
1665
+ checkType: 1
1666
+ })
1593
1667
  wx.navigateTo({
1594
1668
  url: '/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify?id_card_number='+ this.data.formData.id_card_number
1595
1669
  + '&cid_type=' + this.data.formData.cid_type
1596
1670
  + '&name=' + this.data.formData.name
1597
1671
  + '&strCid=' + this.data.formData.strCid
1598
1672
  + '&verify_expire_time=' + this.data.formData.verify_expire_time
1673
+ + '&checkType=' + this.data.checkType
1599
1674
  })
1600
- } else {
1675
+ } else if(isPhoneNumber && !res.data.is_new){
1676
+ // isPhoneNumber 为true,即系没有手机号,res.data.is_new为true即系无密码
1677
+ // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
1678
+ this.setData({
1679
+ checkType: 3
1680
+ })
1681
+ wx.navigateTo({
1682
+ url: '/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify?id_card_number='+ this.data.formData.id_card_number
1683
+ + '&cid_type=' + this.data.formData.cid_type
1684
+ + '&name=' + this.data.formData.name
1685
+ + '&strCid=' + this.data.formData.strCid
1686
+ + '&verify_expire_time=' + this.data.formData.verify_expire_time
1687
+ + '&checkType=' + this.data.checkType
1688
+ })
1689
+ } else if(!isPhoneNumber && res.data.is_new){
1690
+ // isPhoneNumber 为true,即系没有手机号,res.data.is_new为true即系无密码
1691
+ // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
1692
+ this.setData({
1693
+ checkType: 2
1694
+ })
1695
+ wx.navigateTo({
1696
+ url: '/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify?id_card_number='+ this.data.formData.id_card_number
1697
+ + '&cid_type=' + this.data.formData.cid_type
1698
+ + '&name=' + this.data.formData.name
1699
+ + '&strCid=' + this.data.formData.strCid
1700
+ + '&verify_expire_time=' + this.data.formData.verify_expire_time
1701
+ + '&checkType=' + this.data.checkType
1702
+ })
1703
+ } else {
1601
1704
  wx.navigateTo({
1602
1705
  url: '/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login?cardNumber='
1603
1706
  + this.data.formData.id_card_number
@@ -97,7 +97,7 @@
97
97
  }
98
98
 
99
99
  .accordion-content.show {
100
- max-height: 2000rpx; /* 放宽以容纳长内容 */
100
+ max-height: 3000rpx; /* 放宽以容纳长内容 */
101
101
  }
102
102
 
103
103
  /* 答案列表 */
@@ -107,7 +107,7 @@
107
107
 
108
108
  .answer-item {
109
109
  display: block;
110
- font-size: 26rpx;
110
+ font-size: 32rpx;
111
111
  color: #62667A;
112
112
  line-height: 1.6;
113
113
  margin-bottom: 15rpx;
@@ -1426,6 +1426,36 @@ function _checkPhonePwd(options) {
1426
1426
  });
1427
1427
  })
1428
1428
  }
1429
+
1430
+ // 根据证件号获取手机号后四位及根据证件号及手机号核验用户是否匹配
1431
+ function _infoCheck(options) {
1432
+ console.log(options)
1433
+ const paramsFull = {
1434
+ 'id_card_number': options.id_card_number,
1435
+ 'mobile': options.phone_number
1436
+ }
1437
+ return new Promise((resolve, reject) => {
1438
+ const [tifhost] = getOptions(['tifhost'])
1439
+ _request({
1440
+ url: tifhost + '/api/info_check',
1441
+ method: 'POST',
1442
+ data: paramsFull,
1443
+ success: res => {
1444
+ console.log('接口返回结果')
1445
+ let { errcode, data } = res.data
1446
+ console.log(errcode)
1447
+ if (errcode !== 0) {
1448
+ console.log(JSON.stringify(res.data))
1449
+ return resolve(res.data)
1450
+ }
1451
+ return resolve(res.data)
1452
+ },
1453
+ fail: err => {
1454
+ return reject(JSON.stringify(err.data))
1455
+ }
1456
+ });
1457
+ })
1458
+ }
1429
1459
  /**
1430
1460
  * 获取核验次数限制
1431
1461
  * id_card_number 证件号码
@@ -1755,9 +1785,9 @@ function _sendSmsCode(options) {
1755
1785
  success: res => {
1756
1786
  let { errcode, data } = res.data
1757
1787
  if (errcode !== 0) {
1758
- return reject(JSON.stringify(res.data))
1788
+ return resolve(res.data)
1759
1789
  }
1760
- return resolve(res)
1790
+ return resolve(res.data)
1761
1791
  },
1762
1792
  fail: err => {
1763
1793
  return reject(JSON.stringify(err.data))
@@ -1954,6 +1984,36 @@ function _setNewPwdToBankCardVerifyWithIdCard(options) {
1954
1984
  })
1955
1985
  }
1956
1986
 
1987
+ /**
1988
+ * 验证码核验
1989
+ * @param {*} options
1990
+ */
1991
+ function _verifySmsCode(options) {
1992
+ console.log(options)
1993
+ const paramsFull = {
1994
+ 'mobile': options.mobile,
1995
+ 'code': options.mobileCode
1996
+ }
1997
+ return new Promise((resolve, reject) => {
1998
+ const [tifhost] = getOptions(['tifhost'])
1999
+ _request({
2000
+ url: tifhost + '/api/verify_sms_code',
2001
+ method: 'POST',
2002
+ data: paramsFull,
2003
+ success: res => {
2004
+ let { errcode, data } = res.data
2005
+ if (errcode !== 0) {
2006
+ return resolve(res.data)
2007
+ }
2008
+ return resolve(res.data)
2009
+ },
2010
+ fail: err => {
2011
+ return reject(JSON.stringify(err.data))
2012
+ }
2013
+ });
2014
+ })
2015
+ }
2016
+
1957
2017
 
1958
2018
  module.exports = {
1959
2019
  init,
@@ -2035,6 +2095,9 @@ module.exports = {
2035
2095
  // 检查用户是否注册有密码
2036
2096
  checkPhonePwd:_checkPhonePwd,
2037
2097
 
2098
+ // 根据证件号获取手机号后四位及根据证件号及手机号核验用户是否匹配
2099
+ getInfoCheck:_infoCheck,
2100
+
2038
2101
  // 获取核验次数限制
2039
2102
  getVerifyLimit:_getVerifyLimit,
2040
2103
 
@@ -2069,5 +2132,8 @@ module.exports = {
2069
2132
  setNewPwdToFaceVerifyWithIdCard:_setNewPwdToFaceVerifyWithIdCard,
2070
2133
 
2071
2134
  // 忘记密码 - 身份证 - 银行卡核验
2072
- setNewPwdToBankCardVerifyWithIdCard:_setNewPwdToBankCardVerifyWithIdCard
2135
+ setNewPwdToBankCardVerifyWithIdCard:_setNewPwdToBankCardVerifyWithIdCard,
2136
+
2137
+ // 短信验证码核验
2138
+ verifySmsCode:_verifySmsCode
2073
2139
  }
@@ -290,7 +290,7 @@ const ForeignPassortRules = (language) => {
290
290
  // }
291
291
  // 银行卡
292
292
  const bankCardRules = (language) => {
293
- const { cardholder_name, id_card_number, bank_card_account, bank_phone } = dict.rules.bankCardRules
293
+ const { cardholder_name, id_card_number, bank_card_account, bank_phone,verification_code } = dict.rules.bankCardRules
294
294
  return {
295
295
  id_card_number: [
296
296
  { type: 'required', message: `${id_card_number.required[language]}` },
@@ -307,6 +307,9 @@ const bankCardRules = (language) => {
307
307
  bank_phone: [
308
308
  { type: 'required', message: `${bank_phone.required[language]}` },
309
309
  { type: 'bank_phone', message: `${bank_phone.validate[language]}` }
310
+ ],
311
+ verification_code: [
312
+ { type: 'required', message: `${verification_code.required[language]}` }
310
313
  ]
311
314
  }
312
315
  }
@@ -875,6 +875,21 @@ function checkSpecialChar(value) {
875
875
  }
876
876
  return false;
877
877
  }
878
+ function checkVerificationCode(value){
879
+ console.log('验证验证码')
880
+ console.log(value)
881
+ if (!value || value.trim() === '') {
882
+ return {
883
+ data: false,
884
+ msg: '请输入验证码'
885
+ };
886
+ }
887
+ return {
888
+ data: true,
889
+ msg: ''
890
+ };
891
+ }
892
+
878
893
 
879
894
  export {
880
895
  checkAccount,
@@ -891,5 +906,6 @@ export {
891
906
  checkEmail,
892
907
  checkIDCard,
893
908
  removeSpaceFun,
894
- checkHmtPassport
909
+ checkHmtPassport,
910
+ checkVerificationCode
895
911
  }