weapps-plugin-jingtong-verify 1.5.9 → 1.6.0

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 CHANGED
@@ -1,2 +1,2 @@
1
1
  # SDK #
2
- 1.5.9
2
+ 1.6.0
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.9",
5
+ "version": "1.6.0",
6
6
  "description": "",
7
7
  "main": "sdk.js",
8
8
  "author": "tongyirenzheng",
@@ -732,7 +732,8 @@ Page({
732
732
 
733
733
  this.setData({
734
734
  submitSafeMode: 'other',
735
- formSafeData: tempFormSafeData
735
+ formSafeData: tempFormSafeData,
736
+ _tempVerificationCode: tempCode // 临时保存验证码
736
737
  })
737
738
 
738
739
  const form = this.selectComponent('#formSafe')
@@ -742,14 +743,16 @@ Page({
742
743
  // 恢复 verification_code
743
744
  this.setData({
744
745
  formSafeData: { ...this.data.formSafeData, verification_code: tempCode },
745
- submitSafeMode: ''
746
+ submitSafeMode: '',
747
+ _tempVerificationCode: '' // 清空临时验证码
746
748
  })
747
749
  }
748
750
  } catch (error) {
749
751
  // 恢复 verification_code
750
752
  this.setData({
751
753
  formSafeData: { ...this.data.formSafeData, verification_code: tempCode },
752
- submitSafeMode: ''
754
+ submitSafeMode: '',
755
+ _tempVerificationCode: '' // 清空临时保存验证码
753
756
  })
754
757
  }
755
758
  },
@@ -927,15 +930,31 @@ Page({
927
930
  const formErrList = e.detail.value
928
931
  // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
929
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
+ })
930
938
  return
931
939
  }
932
940
  // 如果表单校验没有问题,自定义校验有问题,则显示自定义校验错误提示
933
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
+ })
934
947
  return
935
948
  }
936
949
  return
937
950
  }
938
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
+ })
939
958
  let params = {
940
959
  'id_card_number': formSafeData.id_card_number, // 证件号码
941
960
  'name': formData.name,
@@ -1014,7 +1033,7 @@ Page({
1014
1033
  if (errcode === 0) {
1015
1034
  if(!res.data.success){
1016
1035
  wx.showToast({
1017
- title: errmsg || '验证码校验失败,请重新输入。',
1036
+ title: '验证码校验失败,请重新输入。',
1018
1037
  icon: 'none',
1019
1038
  duration: 2000
1020
1039
  })
@@ -44,9 +44,9 @@ Page({
44
44
  // 新增验证码验证
45
45
  verification_code(value) {
46
46
  // 如果 source_type 为 2,跳过验证
47
- if (this.data.source_type === '2') {
48
- return true
49
- }
47
+ // if (this.data.source_type === '2') {
48
+ // return true
49
+ // }
50
50
  // 验证码不能为空
51
51
  if (!value || value.trim() === '') {
52
52
  return false
@@ -106,7 +106,8 @@ Page({
106
106
  showNotGetVerificationCodeTipModal: false,
107
107
  submitMode: '',
108
108
  // 防重复点击标记 - 基于接口返回状态
109
- isSubmitting: false
109
+ isSubmitting: false,
110
+ _tempVerificationCode: '', // 临时存储验证码
110
111
  },
111
112
 
112
113
  /**
@@ -132,6 +133,29 @@ Page({
132
133
  source_type: options.source_type
133
134
  })
134
135
  }
136
+ // 修复 validateType.verification_code 中的 this 指向
137
+ const that = this
138
+ this.setData({
139
+ 'validateType.verification_code': function(value, formData) {
140
+ // 通过闭包访问 Page 实例的 source_type
141
+ // if (that.data.source_type === '2') {
142
+ // return true
143
+ // }
144
+ if (!value || value.trim() === '') {
145
+ return false
146
+ }
147
+ return utils.validate.checkVerificationCode(value).data
148
+ }
149
+ })
150
+
151
+ // 如果 source_type === '2',从 rules 中移除 verification_code
152
+ if (this.data.source_type === '2') {
153
+ // const tempRules = { ...this.data.rules }
154
+ // delete tempRules.verification_code
155
+ // this.setData({
156
+ // rules: tempRules
157
+ // })
158
+ }
135
159
  },
136
160
  // 在 bank-card-verify.js 中添加
137
161
  preventInput: function(e) {
@@ -197,7 +221,10 @@ Page({
197
221
  // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
198
222
  if (!formValid && customValid.valid) {
199
223
  this.showCuntomErrTip(formErrList[0].message)
224
+ // 恢复 verification_code
225
+ const tempCode = this.data._tempVerificationCode || ''
200
226
  this.setData({
227
+ formData: { ...this.data.formData, verification_code: tempCode },
201
228
  isSubmitting: false
202
229
  })
203
230
  return
@@ -205,7 +232,10 @@ Page({
205
232
  // 如果表单校验没有问题,自定义校验有问题,则显示自定义校验错误提示
206
233
  if (formValid && !customValid.valid) {
207
234
  this.showCuntomErrTip(customValid.msg)
235
+ // 恢复 verification_code
236
+ const tempCode = this.data._tempVerificationCode || ''
208
237
  this.setData({
238
+ formData: { ...this.data.formData, verification_code: tempCode },
209
239
  isSubmitting: false
210
240
  })
211
241
  return
@@ -217,21 +247,41 @@ Page({
217
247
  } else {
218
248
  lastMsg = customValid.msg
219
249
  }
250
+ // 恢复 verification_code
251
+ const tempCode = this.data._tempVerificationCode || ''
220
252
  this.setData({
253
+ formData: { ...this.data.formData, verification_code: tempCode },
221
254
  submitMode: '',
222
255
  isSubmitting: false
223
256
  })
224
257
  this.showCuntomErrTip(lastMsg)
225
258
  wx.hideLoading()
226
259
  return
227
- }
260
+ }
261
+ // 校验通过,恢复 verification_code 并发送验证码
262
+ const tempCode = this.data._tempVerificationCode || ''
228
263
  this.setData({
264
+ formData: { ...this.data.formData, verification_code: tempCode },
229
265
  submitMode: '',
230
266
  isSubmitting: false
231
267
  })
232
268
  this.sendVerificationCode()
233
269
  return
234
270
  }
271
+ // if(this.data.source_type === 2){
272
+ // // 临时保存并移除 verification_code
273
+ // const tempCode = this.data.formData.verification_code
274
+ // const tempFormData = { ...this.data.formData }
275
+ // delete tempFormData.verification_code
276
+ // // 同时从 rules 中移除 verification_code 的校验规则
277
+ // const tempRules = { ...this.data.rules }
278
+ // delete tempRules.verification_code
279
+ // this.setData({
280
+ // formData: tempFormData,
281
+ // rules: tempRules, // 使用不包含 verification_code 的 rules
282
+ // _tempVerificationCode: tempCode // 临时保存验证码
283
+ // })
284
+ // }
235
285
  const customValid = this.data.language !== 'en' ? { valid: true, msg: '' } : this.validateFullname()
236
286
  if (!formValid || !customValid.valid) {
237
287
  // 自定义校验字段有问题,获取表单错误列表
@@ -297,10 +347,11 @@ Page({
297
347
  // }
298
348
  // 接口验证短信验证码
299
349
  let isVerifySmsCode = false
300
- if(source_type !== '2'){
350
+ console.log('验证码参数')
351
+ console.log(formData)
301
352
  const verSmsCodeParam = {
302
353
  "mobile": formData.bank_phone,
303
- "monbileCode": formData.verification_code
354
+ "mobileCode": formData.verification_code
304
355
  }
305
356
  jingtongVerifyRequest.verifySmsCode(verSmsCodeParam).then(res => {
306
357
  const { errcode, errmsg } = res
@@ -317,7 +368,7 @@ Page({
317
368
  } else{
318
369
  if(!res.data.success) {
319
370
  wx.showToast({
320
- title: errmsg || '验证码校验失败,请重新输入。',
371
+ title: '验证码校验失败,请重新输入。',
321
372
  icon: 'none',
322
373
  duration: 2000
323
374
  })
@@ -329,7 +380,45 @@ Page({
329
380
  }
330
381
  console.log('没有返回')
331
382
  })
332
- }
383
+ // if(source_type !== '2'){
384
+ // console.log('验证码参数')
385
+ // console.log(formData)
386
+ // const verSmsCodeParam = {
387
+ // "mobile": formData.bank_phone,
388
+ // "mobileCode": formData.verification_code
389
+ // }
390
+ // jingtongVerifyRequest.verifySmsCode(verSmsCodeParam).then(res => {
391
+ // const { errcode, errmsg } = res
392
+ // console.log('返回状态码')
393
+ // console.log(errcode)
394
+ // if(errcode !== 0){
395
+ // console.log('进入了')
396
+ // wx.showToast({
397
+ // title: errmsg,
398
+ // icon: 'none',
399
+ // duration: 2000
400
+ // })
401
+ // isVerifySmsCode = true
402
+ // } else{
403
+ // if(!res.data.success) {
404
+ // wx.showToast({
405
+ // title: '验证码校验失败,请重新输入。',
406
+ // icon: 'none',
407
+ // duration: 2000
408
+ // })
409
+ // isVerifySmsCode = true
410
+ // return
411
+ // } else {
412
+ // this.toOpera()
413
+ // }
414
+ // }
415
+ // console.log('没有返回')
416
+ // })
417
+ // } else {
418
+ // setTimeout(() => {
419
+ // this.toOpera()
420
+ // }, 1200)
421
+ // }
333
422
  },
334
423
  toOpera() {
335
424
  const { formData, idCardType, source_type } = this.data
@@ -476,7 +565,7 @@ Page({
476
565
 
477
566
  console.log('银行卡校验')
478
567
  console.log(res)
479
- wx.hideLoading()
568
+ // wx.hideLoading()
480
569
  if(res.errcode === 0){
481
570
  // 保存银行卡核验成功时间戳
482
571
  let timeStamp = new Date().getTime()
@@ -635,7 +724,8 @@ Page({
635
724
 
636
725
  this.setData({
637
726
  submitMode: 'other',
638
- formData: tempFormData
727
+ formData: tempFormData,
728
+ _tempVerificationCode: tempCode // 临时保存验证码
639
729
  })
640
730
 
641
731
  const form = this.selectComponent('#form')
@@ -646,7 +736,8 @@ Page({
646
736
  this.setData({
647
737
  formData: { ...this.data.formData, verification_code: tempCode },
648
738
  submitMode: '',
649
- isSubmitting: false
739
+ isSubmitting: false,
740
+ _tempVerificationCode: '' // 清空临时值
650
741
  })
651
742
  }
652
743
  } catch (error) {
@@ -654,7 +745,8 @@ Page({
654
745
  this.setData({
655
746
  formData: { ...this.data.formData, verification_code: tempCode },
656
747
  submitMode: '',
657
- isSubmitting: false
748
+ isSubmitting: false,
749
+ _tempVerificationCode: '' // 清空临时值
658
750
  })
659
751
  }
660
752
  },
@@ -82,7 +82,7 @@
82
82
  />
83
83
  </view>
84
84
  <!-- 验证码 -->
85
- <view class="form-item-wrap" wx:if="{{source_type != 2}}">
85
+ <view class="form-item-wrap">
86
86
  <g-input
87
87
  id="verification_code"
88
88
  label="验证码"