weapps-plugin-jingtong-verify 1.4.4 → 1.4.5

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.4.4
2
+ 1.4.5
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.4.4",
5
+ "version": "1.4.5",
6
6
  "description": "",
7
7
  "main": "sdk.js",
8
8
  "author": "tongyirenzheng",
@@ -690,39 +690,46 @@ Page({
690
690
  })
691
691
  },
692
692
 
693
+ // 显示自定义校验错误提示
694
+ showCuntomErrTip(msg) {
695
+ this.setData({
696
+ showCustomTips: true,
697
+ customTipsMsg: msg
698
+ }, () => {
699
+ // 3秒后关闭
700
+ setTimeout(() => {
701
+ this.setData({
702
+ showCustomTips: false,
703
+ customTipsMsg: ''
704
+ });
705
+ }, 3500);
706
+ })
707
+ },
708
+
693
709
  async handleFormSubmit(e) {
694
- // 自定义校验结果
695
710
  const formValid = e.detail.validStatus
696
- let customValid = this.data.language !== 'en' ? { valid: true, msg: '' } : this.validateFullname()
711
+ const customValid = this.data.language !== 'en' ? { valid: true, msg: '' } : this.validateFullname()
697
712
  if (!formValid || !customValid.valid) {
698
- // 如果自定义校验字段没问题,则跳过
699
- if (customValid.valid) {
700
- return
701
- }
702
713
  // 自定义校验字段有问题,获取表单错误列表
703
714
  const formErrList = e.detail.value
704
- // 计算是否单独弹出错误提示
705
- let showCustomTips = false
706
- if (formErrList && formErrList.length) {
707
- showCustomTips = !formErrList.some(i => ["id_card_number", "nation"].includes(i.name))
708
- } else {
709
- showCustomTips = true
715
+ // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
716
+ if (!formValid && customValid.valid) {
717
+ this.showCuntomErrTip(formErrList[0].message)
718
+ return
710
719
  }
711
- // 如果需要弹出,则弹出
712
- if (showCustomTips) {
713
- this.setData({
714
- showCustomTips: true,
715
- customTipsMsg: customValid.msg
716
- }, () => {
717
- // 3秒后关闭
718
- setTimeout(() => {
719
- this.setData({
720
- showCustomTips: false,
721
- customTipsMsg: ''
722
- });
723
- }, 3500);
724
- })
720
+ // 如果表单校验没有问题,自定义校验有问题,则显示自定义校验错误提示
721
+ if (formValid && !customValid.valid) {
722
+ this.showCuntomErrTip(customValid.msg)
723
+ return
724
+ }
725
+ // 如果两者都有问题,则判断显示谁
726
+ let lastMsg = ''
727
+ if (formErrList.some(i => ["id_card_number", "nation"].includes(i.name))) {
728
+ lastMsg = formErrList[0].message
729
+ } else {
730
+ lastMsg = customValid.msg
725
731
  }
732
+ this.showCuntomErrTip(lastMsg)
726
733
  return
727
734
  }
728
735
  wx.showLoading({
@@ -324,6 +324,7 @@
324
324
  id="form"
325
325
  model="{{ formData }}"
326
326
  rules="{{ rules }}"
327
+ showTips="{{ false }}"
327
328
  validateType="{{ validateType }}"
328
329
  primary-text="Submit"
329
330
  bind:submit="handleFormSubmit"
@@ -413,37 +413,46 @@ Page({
413
413
  })
414
414
  },
415
415
 
416
+ // 显示自定义校验错误提示
417
+ showCuntomErrTip(msg) {
418
+ this.setData({
419
+ showCustomTips: true,
420
+ customTipsMsg: msg
421
+ }, () => {
422
+ // 3秒后关闭
423
+ setTimeout(() => {
424
+ this.setData({
425
+ showCustomTips: false,
426
+ customTipsMsg: ''
427
+ });
428
+ }, 3500);
429
+ })
430
+ },
431
+
416
432
  async handleFormSubmit(e) {
417
- const vid1 = this.validateFullname()
418
- if (!e.detail.validStatus || !vid1.valid) {
419
- // 如果自定义校验字段没问题,则跳过
420
- if (vid1.valid) {
421
- return
422
- }
433
+ const formValid = e.detail.validStatus
434
+ const customValid = this.validateFullname()
435
+ if (!e.detail.validStatus || !customValid.valid) {
423
436
  // 自定义校验字段有问题,获取表单错误列表
424
437
  const formErrList = e.detail.value
425
- // 计算是否单独弹出错误提示
426
- let showCustomTips = false
427
- if (formErrList && formErrList.length) {
428
- showCustomTips = !formErrList.some(i => ["id_card_number", "nation"].includes(i.name))
429
- } else {
430
- showCustomTips = true
438
+ // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
439
+ if (!formValid && customValid.valid) {
440
+ this.showCuntomErrTip(formErrList[0].message)
441
+ return
431
442
  }
432
- // 如果需要弹出,则弹出
433
- if (showCustomTips) {
434
- this.setData({
435
- showCustomTips: true,
436
- customTipsMsg: vid1.msg
437
- }, () => {
438
- // 3秒后关闭
439
- setTimeout(() => {
440
- this.setData({
441
- showCustomTips: false,
442
- customTipsMsg: ''
443
- });
444
- }, 3500);
445
- })
443
+ // 如果表单校验没有问题,自定义校验有问题,则显示自定义校验错误提示
444
+ if (formValid && !customValid.valid) {
445
+ this.showCuntomErrTip(customValid.msg)
446
+ return
447
+ }
448
+ // 如果两者都有问题,则判断显示谁
449
+ let lastMsg = ''
450
+ if (formErrList.some(i => ["id_card_number", "nation"].includes(i.name))) {
451
+ lastMsg = formErrList[0].message
452
+ } else {
453
+ lastMsg = customValid.msg
446
454
  }
455
+ this.showCuntomErrTip(lastMsg)
447
456
  return
448
457
  }
449
458
  this.setData({
@@ -17,6 +17,7 @@
17
17
  id="form"
18
18
  model="{{ formData }}"
19
19
  rules="{{ rules }}"
20
+ showTips="{{ false }}"
20
21
  validateType="{{ validateType }}"
21
22
  primary-text="Submit"
22
23
  bind:submit="handleFormSubmit"