weapps-plugin-jingtong-verify 1.6.0 → 1.6.2-beta

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 (224) hide show
  1. package/README.md +1 -1
  2. package/app.json +33 -41
  3. package/package.json +21 -21
  4. package/sdk.js +309 -320
  5. package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.js +31 -31
  6. package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.json +3 -3
  7. package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.wxml +9 -9
  8. package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.wxss +65 -65
  9. package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.js +37 -37
  10. package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.json +3 -3
  11. package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.wxml +30 -30
  12. package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.wxss +79 -79
  13. package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.js +32 -32
  14. package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.json +3 -3
  15. package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.wxml +16 -16
  16. package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.wxss +57 -57
  17. package/weapps-plugin-jingtong-verify/components/gsd-lib/anim/anim.min.js +1 -1
  18. package/weapps-plugin-jingtong-verify/components/gsd-lib/crypto/crypto.js +37 -37
  19. package/weapps-plugin-jingtong-verify/components/gsd-lib/crypto/index.js +44 -44
  20. package/weapps-plugin-jingtong-verify/components/gsd-lib/dayjs/index.js +351 -351
  21. package/weapps-plugin-jingtong-verify/components/gsd-lib/event/index.js +117 -117
  22. package/weapps-plugin-jingtong-verify/components/gsd-lib/index.js +63 -63
  23. package/weapps-plugin-jingtong-verify/components/gsd-lib/map/index.js +10 -10
  24. package/weapps-plugin-jingtong-verify/components/gsd-lib/map/qmap.js +6 -6
  25. package/weapps-plugin-jingtong-verify/components/gsd-lib/storage/index.js +114 -114
  26. package/weapps-plugin-jingtong-verify/components/gsd-lib/utils/index.js +218 -218
  27. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/formCheck.js +72 -72
  28. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/formController.js +47 -47
  29. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/icon.js +11 -11
  30. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/list.js +16 -16
  31. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/navigator.js +33 -33
  32. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/primarySecondButton.js +18 -18
  33. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-agree/index.js +12 -12
  34. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-agree/index.json +5 -5
  35. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-agree/index.wxml +15 -15
  36. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.js +47 -47
  37. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.json +3 -3
  38. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.wxml +13 -13
  39. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.js +44 -44
  40. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.json +5 -5
  41. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.wxml +28 -28
  42. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.js +30 -30
  43. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.json +6 -6
  44. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.wxml +42 -42
  45. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.wxss +1 -1
  46. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.js +418 -418
  47. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.json +5 -5
  48. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.wxml +29 -29
  49. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.js +11 -11
  50. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.json +3 -3
  51. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.wxml +4 -4
  52. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.js +179 -182
  53. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.json +6 -6
  54. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.wxml +16 -16
  55. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.js +92 -92
  56. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.json +6 -6
  57. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.wxml +12 -12
  58. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.wxss +2 -2
  59. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.js +49 -49
  60. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.json +3 -3
  61. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.wxml +14 -14
  62. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.js +33 -33
  63. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.json +3 -3
  64. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.wxml +2 -2
  65. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.js +108 -108
  66. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.json +6 -6
  67. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.wxml +53 -53
  68. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.js +236 -241
  69. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.json +8 -8
  70. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.wxml +49 -49
  71. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.js +328 -328
  72. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.json +6 -6
  73. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.wxml +26 -26
  74. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.js +159 -159
  75. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.json +3 -3
  76. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.wxml +10 -10
  77. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.js +112 -112
  78. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.json +5 -5
  79. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.wxml +21 -21
  80. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.js +21 -21
  81. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.json +7 -7
  82. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.wxml +16 -16
  83. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.js +50 -50
  84. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.json +5 -5
  85. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.wxml +27 -27
  86. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/add.svg +13 -13
  87. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/arrow.svg +14 -14
  88. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/delete.svg +16 -16
  89. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/preview.svg +21 -21
  90. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/user.svg +13 -13
  91. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-agree.wxss +147 -147
  92. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-badge.wxss +41 -41
  93. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-button-group.wxss +244 -244
  94. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-cell.wxss +220 -220
  95. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-dropdown.wxss +115 -115
  96. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form-cell.wxss +101 -101
  97. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form-item.wxss +174 -174
  98. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form.wxss +101 -101
  99. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-icon.wxss +268 -268
  100. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-index-list.wxss +206 -206
  101. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-input.wxss +206 -214
  102. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-picker.wxss +139 -139
  103. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-popover.wxss +129 -129
  104. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-search.wxss +171 -171
  105. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-switch.wxss +176 -176
  106. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-tips.wxss +173 -173
  107. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/icon/iconfont.wxss +160 -160
  108. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/main.wxss +283 -283
  109. package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/helper.js +55 -55
  110. package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/validType.js +117 -117
  111. package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/validator.js +106 -106
  112. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.js +32 -32
  113. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.json +3 -3
  114. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.wxml +8 -8
  115. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.wxss +57 -57
  116. package/weapps-plugin-jingtong-verify/components/modal/modal.js +32 -32
  117. package/weapps-plugin-jingtong-verify/components/modal/modal.json +3 -3
  118. package/weapps-plugin-jingtong-verify/components/modal/modal.wxml +28 -28
  119. package/weapps-plugin-jingtong-verify/components/modal/modal.wxss +84 -84
  120. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.js +82 -82
  121. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.json +3 -3
  122. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.wxml +18 -18
  123. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.wxss +72 -72
  124. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.js +39 -47
  125. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.json +3 -3
  126. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.wxml +9 -11
  127. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.wxss +51 -51
  128. package/weapps-plugin-jingtong-verify/i18n/index.js +7 -7
  129. package/weapps-plugin-jingtong-verify/i18n/logout.js +10 -10
  130. package/weapps-plugin-jingtong-verify/i18n/rules.js +262 -403
  131. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.js +86 -86
  132. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.json +6 -6
  133. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.wxml +20 -20
  134. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.wxss +51 -51
  135. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.js +167 -167
  136. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.json +3 -3
  137. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.wxml +30 -30
  138. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.wxss +91 -91
  139. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.js +79 -79
  140. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.json +5 -5
  141. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.wxml +19 -19
  142. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.wxss +44 -44
  143. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.js +1558 -1812
  144. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.json +17 -17
  145. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.wxml +504 -522
  146. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.wxss +133 -185
  147. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.js +127 -127
  148. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.json +5 -5
  149. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.wxml +36 -36
  150. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.wxss +60 -60
  151. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.js +106 -106
  152. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.json +3 -3
  153. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.wxml +29 -29
  154. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.wxss +68 -68
  155. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.js +24 -24
  156. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.json +3 -3
  157. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.wxml +12 -12
  158. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.wxss +33 -33
  159. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.js +120 -110
  160. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.json +6 -6
  161. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.wxml +9 -9
  162. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.wxss +1 -1
  163. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.js +864 -854
  164. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.json +11 -11
  165. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.wxml +162 -162
  166. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.wxss +64 -64
  167. package/weapps-plugin-jingtong-verify/pages/setting/setting.js +328 -331
  168. package/weapps-plugin-jingtong-verify/pages/setting/setting.json +5 -5
  169. package/weapps-plugin-jingtong-verify/pages/setting/setting.wxml +91 -91
  170. package/weapps-plugin-jingtong-verify/pages/setting/setting.wxss +69 -69
  171. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.js +306 -306
  172. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.json +7 -7
  173. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.wxml +142 -142
  174. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.wxss +110 -110
  175. package/weapps-plugin-jingtong-verify/style/page.wxss +13 -13
  176. package/weapps-plugin-jingtong-verify/utils/QDTrackerNew/QDTracker.js +15 -15
  177. package/weapps-plugin-jingtong-verify/utils/QDTrackerNew/QDTrackerMain.js +59 -59
  178. package/weapps-plugin-jingtong-verify/utils/country.js +209 -209
  179. package/weapps-plugin-jingtong-verify/utils/index.js +306 -306
  180. package/weapps-plugin-jingtong-verify/utils/jsencrypt.min.js +1 -1
  181. package/weapps-plugin-jingtong-verify/utils/request.js +1 -670
  182. package/weapps-plugin-jingtong-verify/utils/rules.js +301 -405
  183. package/weapps-plugin-jingtong-verify/utils/tifadmin_config.js +61 -61
  184. package/weapps-plugin-jingtong-verify/utils/validate.js +772 -910
  185. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.js +0 -41
  186. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.json +0 -4
  187. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.wxml +0 -20
  188. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.wxss +0 -112
  189. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.js +0 -73
  190. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.json +0 -4
  191. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.wxml +0 -19
  192. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.wxss +0 -72
  193. package/weapps-plugin-jingtong-verify/images/bank-card-verify.png +0 -0
  194. package/weapps-plugin-jingtong-verify/images/chek_right.png +0 -0
  195. package/weapps-plugin-jingtong-verify/images/chevron-down.png +0 -0
  196. package/weapps-plugin-jingtong-verify/images/chevron-up.png +0 -0
  197. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.js +0 -506
  198. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.json +0 -8
  199. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.wxml +0 -79
  200. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.wxss +0 -212
  201. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.js +0 -1392
  202. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.json +0 -10
  203. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.wxml +0 -247
  204. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.wxss +0 -397
  205. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-sms-setting/bank-card-login-forgot-sms-setting.js +0 -66
  206. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-sms-setting/bank-card-login-forgot-sms-setting.wxml +0 -2
  207. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.js +0 -463
  208. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.json +0 -8
  209. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.wxml +0 -69
  210. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.wxss +0 -232
  211. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.js +0 -984
  212. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.json +0 -12
  213. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.wxml +0 -157
  214. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.wxss +0 -258
  215. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.js +0 -147
  216. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.json +0 -4
  217. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.wxml +0 -48
  218. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.wxss +0 -166
  219. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.js +0 -189
  220. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.json +0 -4
  221. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.wxml +0 -19
  222. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.wxss +0 -69
  223. package/weapps-plugin-jingtong-verify/utils/constantVal.js +0 -75
  224. package/weapps-plugin-jingtong-verify/utils/md5.js +0 -184
@@ -1,1812 +1,1558 @@
1
- // weapps-plugin-jingtong-verify/pages/face-verify/index.js
2
- const jingtongVerifyRequest = require('../../utils/request')
3
- const utils = require("../../utils/index")
4
- const { flow } = require("@wecity/weda-plugin-utils");
5
- const rulesConfig = require("../../utils/rules")
6
- import { SDKTrack, setAccountInfo } from '../../utils/QDTrackerNew/QDTrackerMain'
7
- const validator = require('../../components/gsd-ui/utils/validator')
8
- const constantVal = require("../../utils/constantVal")
9
- let cidType = '111'
10
- let Nation = 'CHN'
11
-
12
- Page({
13
- /**
14
- * 页面的初始数据
15
- */
16
- data: {
17
- language: 'zh_CN', // 语言环境:默认中文
18
- formData: {
19
- cid_type: '111', // 证件类型
20
- strName: '', // 身份证姓名(脱敏)
21
- name: '',
22
- strCid: '', // 身份证号码(脱敏)
23
- id_card_number: '', // 证件号码
24
- strBankCount: '', // 银行卡卡号(脱敏)
25
- bank_account: '',
26
- nation: 'CHN', // 国籍
27
- nation_name: '中国',
28
- sur_name: '', //
29
- first_name: '', //
30
- sur_name_en: '', // 姓(国外护照)
31
- first_name_en: '', // 名(国外护照)
32
- sex: '', // 性别
33
- birthday: '', // 出生日期
34
- cid_expire_date: '', // 护照有效期
35
- validity_period: '', // 证件生效日期
36
- passport_number: '', // 通行证号码
37
- phone: '',
38
- verify_expire_time: '', // 登录有效期
39
- agree: false,
40
- isbind: 1,
41
- sbSwitch: true
42
- },
43
- needUnite: '', // 是否需要串联起来
44
- agreeInfo: '我同意北京市大数据中心使用我所提交的信息注册京通小程序,以及登录北京市统一身份认证平台,以便使用京通相关服务。',
45
- cidTypeRange: [
46
- // 微信人脸识别
47
- { name: '中华人民共和国居民身份证', value: '111' },
48
- // 移民局接口
49
- { name: '港澳居民来往内地通行证', value: '516' },
50
- { name: '台湾居民来往大陆通行证', value: '511' },
51
- { name: '外国人永久居留身份证', value: '553' },
52
- { name: '华侨护照(国内签发)', value: '414' },
53
- // 银行卡接口
54
- { name: '港澳居民居住证', value: '17' },
55
- { name: '台湾居民居住证', value: '18' },
56
- // 外国护照
57
- { name: 'International passport', value: '700' }
58
- ],
59
- sexRange: [
60
- { name: 'Male', value: 1 },
61
- { name: 'Female', value: 2 }
62
- ],
63
- sexRangeZH: [
64
- { name: '男', value: 1 },
65
- { name: '女', value: 2 }
66
- ],
67
- loginTimeRangeEn: [
68
- { name: 'Keep me logged in for 1 day', value: 24 },
69
- { name: 'Keep me logged in for 7 days', value: 168 },
70
- { name: 'Keep me logged in for 30 days', value: 720 }
71
- ],
72
- loginTimeRange: [
73
- { name: '1天免登录', value: 24 },
74
- { name: '7天免登录', value: 168 },
75
- { name: '30天免登录', value: 720 }
76
- ],
77
- validateType: {
78
- id_card_number(value) {
79
- return utils.validate.checkCid(value, cidType, Nation).data
80
- },
81
- name(value) {
82
- return utils.validate.checkName(value, cidType).data
83
- },
84
- sur_name(value) {
85
- return utils.validate.checkName(value, cidType).data
86
- },
87
- first_name(value) {
88
- return utils.validate.checkName(value, cidType).data
89
- },
90
- passport_number(value) {
91
- return utils.validate.checkHmtPassport(value, cidType, Nation).data
92
- },
93
- },
94
- rulesMap: {
95
- '111': {
96
- currentAuthType: 'wxFace',
97
- rules: rulesConfig.chinaRules('zh_CN')
98
- },
99
- '516': {
100
- currentAuthType: 'faceReceptionAuth',
101
- rules: rulesConfig.HMORules('zh_CN')
102
- },
103
- '511': {
104
- currentAuthType: 'faceReceptionAuth',
105
- rules: rulesConfig.HMORules('zh_CN')
106
- },
107
- '553': {
108
- currentAuthType: 'faceReceptionAuth',
109
- rules: rulesConfig.residenceRules('zh_CN')
110
- },
111
- '414': {
112
- currentAuthType: 'faceReceptionAuth',
113
- rules: rulesConfig.HMORules('zh_CN')
114
- },
115
- '17': {
116
- currentAuthType: 'faceReceptionAuth',
117
- // rules: rulesConfig.cardRules('zh_CN'),
118
- rules: rulesConfig.residenceAuthRules('zh_CN'),
119
- tip: '请填写本人在办理银联银行卡时登记的姓名、港澳居民居住证证件号、手机号、银行卡号。'
120
- },
121
- '18': {
122
- currentAuthType: 'faceReceptionAuth',
123
- // rules: rulesConfig.cardRules('zh_CN'),
124
- rules: rulesConfig.residenceAuthRules('zh_CN'),
125
- tip: '请填写本人在办理银联银行卡时登记的姓名、台湾居民居住证证件号、手机号、银行卡号。'
126
- },
127
- '700': {
128
- currentAuthType: 'ForeignPassortAuth',
129
- rules: rulesConfig.ForeignPassortRules('en')
130
- }
131
- },
132
- rules: rulesConfig.chinaRules('zh_CN'),
133
- // 核验类别
134
- currentAuthType: 'wxFace',
135
- // 打开文档的防抖操作
136
- canOpenPdf: true,
137
- // 外国人护照核验状态 '1'(通过) '4'(审核中) ''(无审核单) 其它值(审核失败)
138
- passportAuthStatus: '',
139
- passportAuthPersonCode: '',
140
- // 核验单数据
141
- passportOldData: {},
142
- // 弹窗
143
- showModal: false,
144
- modalStatus: 'info',
145
- // 定义日期边界值
146
- birthdayMaxDate: [new Date().getFullYear(), (new Date().getMonth() + 1), new Date().getDate()],
147
- cidExpireMinDate: [new Date().getFullYear(), (new Date().getMonth() + 1), new Date().getDate()],
148
- // 老/小6次、成人3次 人脸报错提示弹窗
149
- showFaceModal: false,
150
- isKidsOrOld: false,
151
- // 老/小18次、成人6次 人脸报错提示弹窗
152
- showLockFaceModal: false,
153
- // 银行卡认证弹窗
154
- showCardModal: false,
155
- // 姓名和证件号码弹窗
156
- showTipModal: false,
157
- // cidType转化为certType
158
- certTypeMap: {
159
- '111': 1,
160
- '516': 78,
161
- '511': 4,
162
- '17': 5,
163
- '18': 6,
164
- '414': 2,
165
- '553': 9,
166
- '700': 3
167
- },
168
- // 记录是否已经登录成功
169
- hadSuccessLogin: false,
170
- // 该操作会触发小程序的销毁回调
171
- exitedState: true,
172
- // 扫脸失败温馨提示弹窗
173
- faceErrorModal: false,
174
- // 扫脸失败原因
175
- faceErrorType: '2',
176
- // 标记港澳居民来往内地通行证存在回显的session信息
177
- // exitHmSession: false,
178
- // HmSession: {}
179
- showForeignTip: false,
180
- // (国外)surname自定义校验状态,傻逼数广傻逼组件逼的
181
- sur_name_state: {
182
- valid: true,
183
- msg: ''
184
- },
185
- // (国外)givenName自定义校验状态,傻逼数广傻逼组件逼的
186
- first_name_state: {
187
- valid: true,
188
- msg: ''
189
- },
190
- // 是否显示自定义校验提示
191
- showCustomTips: false,
192
- // 自定义校验提示文本
193
- customTipsMsg: '',
194
- submitMode: '',
195
- // 防重复点击标记 - 基于接口返回状态
196
- isSubmitting: false,
197
- checkType: 1, // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
198
- showOtherWayTipModal: false, // 提示
199
- },
200
-
201
- /**
202
- * 生命周期函数--监听页面加载
203
- */
204
- onLoad(options) {
205
- console.log('onLoad', options)
206
- this.setData({
207
- needUnite: options.needUnite || 'true'
208
- })
209
-
210
- // 初始化操作,回填证件类型为身份证的身份信息
211
- this.initUserInfo()
212
- },
213
-
214
- // 初始化操作,回填证件类型为身份证的身份信息
215
- initUserInfo() {
216
- // 默认身份证号码
217
- cidType = '111'
218
-
219
- wx.showLoading({
220
- title: '加载中…',
221
- })
222
- // 清空本地Temp数据
223
- wx.setStorageSync('tif.formDataTemp', '')
224
-
225
- jingtongVerifyRequest.getSession({
226
- success: res => {
227
- let { cid_type, cid, name, star_name, star_cid, verify_expire_time } = res
228
-
229
- // 设置用户账号信息
230
- setAccountInfo(res.openid)
231
-
232
- const hideForeignTip = wx.getStorageSync('tif.hideForeignTip') || 0
233
- console.log('hideForeignTip', hideForeignTip)
234
- if (!cid && hideForeignTip !== '1') {
235
- this.setData({
236
- showForeignTip: true
237
- })
238
- }
239
-
240
- if (cid_type === '111' && cid && name) {
241
- // 回填身份证类型
242
- this.setData({
243
- 'formData.strName': star_name,
244
- 'formData.name': name,
245
- 'formData.strCid': star_cid,
246
- 'formData.id_card_number': cid,
247
- 'formData.cid_type': cid_type,
248
- 'formData.verify_expire_time': verify_expire_time || ''
249
- })
250
- }
251
- // if (cid_type === '516') {
252
- // this.setData({
253
- // exitHmSession: true,
254
- // HmSession: res
255
- // })
256
- // console.log('HmSession', this.data.HmSession)
257
- // } else {
258
- // this.setData({
259
- // exitHmSession: false
260
- // })
261
- // }
262
- wx.hideLoading()
263
- },
264
- fail: fail => {
265
- console.log('getSession-fail', fail)
266
- wx.hideLoading()
267
- }
268
- })
269
- },
270
-
271
- // 生命周期函数--监听页面显示
272
- onShow: function () {
273
- wx.hideShareMenu()
274
-
275
- // 获取国籍
276
- let pages = getCurrentPages()
277
- let currentPage = pages[pages.length - 1]
278
- let hadChoseNation = currentPage.data.hadChoseNation || false
279
-
280
- if (hadChoseNation) {
281
- let cid_type = currentPage.data.formData.cid_type
282
- // 回传数据
283
- this.reFullFormDataTemp(cid_type)
284
- }
285
- },
286
-
287
- // 三证照:港澳通行证、台湾通行证、华侨护照
288
- matchOptionsRule () {
289
- let { cid_type, nation, sbSwitch } = this.data.formData
290
- Nation = nation
291
-
292
- if (cid_type === '516' || cid_type === '511' || cid_type === '414') {
293
- if (nation !== 'CHN' && cid_type === '516') {
294
- // 港澳通行证-外籍
295
- this.setData({
296
- rules: rulesConfig.HMPassRulesForeign('zh_CN')
297
- })
298
- } else if (sbSwitch) {
299
- // 姓名、出生日期必填
300
- this.setData({
301
- rules: rulesConfig.HMORulesMore('zh_CN')
302
- })
303
- } else {
304
- // 姓名、出生日期非必填
305
- this.setData({
306
- rules: rulesConfig.HMORules('zh_CN')
307
- })
308
- }
309
- console.log('三证照正则', this.data.rules)
310
- }
311
- },
312
-
313
- // 年龄≤18岁或年龄≥60岁的用户
314
- isCarePeople(age) {
315
- return age <= 18 || age >= 60
316
- },
317
-
318
- /**
319
- * 获取/设置人脸失败次数
320
- * @param {*} count
321
- * count:true 设置次数+1
322
- * count:false 获取次数
323
- */
324
- fetchFaceFailCount(count, errCode) {
325
- const { id_card_number: cid } = this.data.formData
326
- const age = utils.parseIDCard(cid).age
327
- const isKidsOrOld = this.isCarePeople(age) || false
328
- console.log('获取/设置人脸失败', count)
329
- console.log('年龄', age)
330
- console.log('是否是老人/小孩', isKidsOrOld)
331
-
332
- this.setData({
333
- isKidsOrOld
334
- })
335
-
336
- return new Promise((resolve, reject) => {
337
- jingtongVerifyRequest.operateFaceFailCount({
338
- count,
339
- cid,
340
- age
341
- }).then(res => {
342
- console.log('获取人脸失败次数res', res)
343
- const times = Number(res.times) || 0
344
-
345
- // 老人/小孩:累计刷脸失败6次后,弹长窗提示
346
- if (count && isKidsOrOld && times === 6) {
347
- console.log('==============老人/小孩 -- 累计刷脸失败6次:弹长窗===============')
348
- this.setData({
349
- showFaceModal: true
350
- })
351
- }
352
-
353
- // 成人:累计刷脸失败3次后,弹长窗提示
354
- if (count && !isKidsOrOld && times === 3) {
355
- console.log('==============成人 -- 累计刷脸失败3次:弹长窗===============')
356
- this.setData({
357
- showFaceModal: true
358
- })
359
- }
360
-
361
- // 老/小18次、成人6次 锁定人脸
362
- if (isKidsOrOld && times >= 18) {
363
- console.log('==============老人/小孩 -- 累计刷脸失败18次:弹短窗===============')
364
- wx.hideLoading()
365
- this.setData({
366
- showLockFaceModal: true
367
- })
368
- // 人脸识别异常温馨提示弹窗
369
- count && this.handleFaceError(errCode)
370
- return
371
- } else if (!isKidsOrOld && times >= 6) {
372
- console.log('==============成人 -- 累计刷脸失败6次:弹短窗===============')
373
- wx.hideLoading()
374
- this.setData({
375
- showLockFaceModal: true
376
- })
377
- // 人脸识别异常温馨提示弹窗
378
- count && this.handleFaceError(errCode)
379
- return
380
- }
381
- resolve()
382
- }).catch(err => {
383
- console.log(err, '获取人脸失败次数err')
384
- wx.showToast({
385
- title: '初始化有误,请稍后再试',
386
- icon: 'none'
387
- })
388
- reject()
389
- })
390
- })
391
- },
392
-
393
- // 判断是否是PC端登录
394
- getDevice() {
395
- return new Promise((resolve, reject) => {
396
- const systemInfo = wx.getDeviceInfo();
397
- console.log('systemInfo', systemInfo)
398
- if (['windows', 'mac'].includes(systemInfo.platform)) {
399
- console.log('当前为电脑端微信');
400
- wx.showToast({
401
- title: '请您使用移动端京通小程序',
402
- icon: 'none',
403
- duration: 3000
404
- })
405
- return
406
- } else {
407
- console.log('当前为手机端');
408
- resolve()
409
- }
410
- })
411
- },
412
-
413
- // 根据证件类型匹配校验正则和校验类型
414
- toMatchRules() {
415
- let { cid_type, nation, nation_name } = this.data.formData
416
- let { rules, currentAuthType } = this.data.rulesMap[cid_type]
417
- console.log('核验源', currentAuthType)
418
- Nation = nation
419
- // 默认【中国】
420
- if (cid_type === '516' || cid_type === '511' || cid_type === '414') {
421
- nation = 'CHN'
422
- nation_name = 'CHN-中国'
423
- }
424
- this.setData({
425
- rules,
426
- currentAuthType,
427
- 'formData.nation': nation,
428
- 'formData.nation_name': nation_name,
429
- }, () => {
430
- wx.hideLoading()
431
- })
432
- console.log('匹配到的正则', rules, currentAuthType)
433
- },
434
-
435
- // 选择完国籍或认证失败后回传 -- 回传本地临时存储用户表单信息
436
- reFullFormDataTemp(cid_type) {
437
- const formDataTemp = wx.getStorageSync('tif.formDataTemp') || {}
438
- let formDataOld = this.data.formData
439
-
440
- if (formDataTemp && formDataTemp[cid_type]) {
441
- console.log('存在可回填的temp数据', formDataTemp[cid_type])
442
- let formData = Object.assign(formDataOld, formDataTemp[cid_type])
443
- Nation = formData.nation
444
- // 国外护照,回填名字
445
- if (cid_type === '700') {
446
- formData.sur_name_en = formData.sur_name
447
- formData.first_name_en = formData.first_name
448
- }
449
- this.setData({
450
- formData
451
- })
452
- }
453
- // else if (cid_type === '516' && this.data.exitHmSession) {
454
- // console.log('存在可回显的HM数据', this.data.HmSession)
455
- // const { star_name, name, star_cid, cid, verify_expire_time, nation } = this.data.HmSession
456
- // this.setData({
457
- // 'formData.strName': star_name,
458
- // 'formData.name': name,
459
- // 'formData.strCid': star_cid,
460
- // 'formData.id_card_number': cid,
461
- // 'formData.verify_expire_time': verify_expire_time || '',
462
- // 'formData.nation': nation
463
- // })
464
- // }
465
- // 处理三证照的正则问题
466
- this.matchOptionsRule()
467
- },
468
-
469
- // 同意协议和隐私政策
470
- viewPrivacy(e) {
471
- // 临时存储表单数据
472
- this.saveFormDataTemp()
473
- // 错误触发销毁回调函数处理
474
- this.handleExitedState()
475
-
476
- let canOpenPdf = this.data.canOpenPdf
477
- if (canOpenPdf) {
478
- this.setData({
479
- canOpenPdf: false
480
- })
481
- let { name, file } = e.currentTarget.dataset
482
- console.log('文件地址', `https://js.jt.beijing.gov.cn/jt/tiffile/${file}.pdf`)
483
- utils.openDoc({
484
- url: `https://js.jt.beijing.gov.cn/jt/tiffile/${file}.pdf`,
485
- fileType: 'pdf',
486
- name,
487
- successFn: () => {
488
- console.log('文档打开成功回调')
489
- setTimeout(() => {
490
- this.setData({
491
- canOpenPdf: true
492
- })
493
- }, 500)
494
- }
495
- })
496
- } else {
497
- setTimeout(() => {
498
- this.setData({
499
- canOpenPdf: true
500
- })
501
- }, 3500)
502
- }
503
- },
504
-
505
- // 选择事件
506
- handleChange(e) {
507
- let value = e.detail.value
508
- let formId = e.target.id
509
-
510
- // 删除前后空格
511
- if (typeof value === 'string' && formId !== 'cid_type') {
512
- value = value.trim()
513
- console.log('==删除前后空格==', value, '==删除前后空格==')
514
- }
515
-
516
- let starId = e.target.dataset.star
517
- // 切换“证件类型”
518
- let oldCidType = this.data.formData.cid_type
519
- if (formId === 'cid_type' && oldCidType !== value) {
520
- cidType = value
521
- wx.showLoading({
522
- title: '加载中…',
523
- })
524
-
525
- // 若是港澳台,则证件类别默认为居住证核验
526
- if (value == 17 || value == 18) {
527
- this.setData({
528
- currentAuthType: 'faceReceptionAuth',
529
- rules: rulesConfig.residenceAuthRules('zh_CN')
530
- })
531
- }
532
-
533
- // 语言环境
534
- this.setData({
535
- language: value === '700' ? 'en' : 'zh_CN'
536
- })
537
-
538
- // 临时存储用户填写的表单信息、是否需要回显
539
- this.saveFormDataTemp(true, value, oldCidType)
540
- } else {
541
- // 临时存储表单数据
542
- this.saveFormDataTemp()
543
-
544
- this.setData({
545
- [`formData.${formId}`]: value
546
- })
547
- if (starId) {
548
- this.setData({
549
- [`formData.${starId}`]: ''
550
- })
551
- }
552
- if (['sur_name_en', 'first_name_en'].includes(formId)) {
553
- this.validateFullname()
554
- }
555
- }
556
- },
557
-
558
- // 临时存储用户填写的表单信息
559
- saveFormDataTemp(needFull = false, newCidType = '', oldCidType = '') {
560
- console.log('临时存储用户填写的表单信息', needFull, newCidType, oldCidType)
561
- let {
562
- formData
563
- } = this.data
564
-
565
- let formDataTemp = wx.getStorageSync('tif.formDataTemp') || {}
566
- formDataTemp[formData.cid_type] = formData
567
- wx.setStorageSync('tif.formDataTemp', formDataTemp)
568
- if (needFull) {
569
- // 是否需要回传
570
- Nation = ''
571
- this.setData({
572
- formData: {
573
- cid_type: newCidType,
574
- name: '',
575
- id_card_number: '',
576
- bank_account: '',
577
- nation: '',
578
- nation_name: '',
579
- sur_name: '',
580
- first_name: '',
581
- sur_name_en: '',
582
- first_name_en: '',
583
- sex: '',
584
- birthday: '',
585
- cid_expire_date: '',
586
- validity_period: '',
587
- passport_number: '',
588
- phone: '',
589
- verify_expire_time: '',
590
- sbSwitch: true,
591
- agree: false,
592
- isbind: 1
593
- }
594
- })
595
- if (newCidType === '700') {
596
- // 获取外国护照核验结果
597
- this.fetchPassortAuthResult()
598
- } else {
599
- // 回传 Temp => Success => 空
600
- this.restartInitChange(newCidType)
601
- }
602
- wx.hideLoading()
603
- }
604
- },
605
-
606
- // 回传 Temp => Success => 空
607
- restartInitChange(cid_type) {
608
- console.log('根据证件类型匹配校验正则,回填本地Temp数据')
609
- wx.showLoading({
610
- title: '加载中…',
611
- })
612
- // 根据证件类型匹配校验正则
613
- this.toMatchRules()
614
- // 数据回传
615
- this.reFullFormDataTemp(cid_type)
616
- },
617
-
618
- // 获取外国人护照核验结果、是否需要返回状态
619
- fetchPassortAuthResult(needStatus = false) {
620
- // 根据证件类型匹配校验正则
621
- !needStatus && this.toMatchRules()
622
- let formData = this.data.formData
623
-
624
- return new Promise((resolve) => {
625
- jingtongVerifyRequest.getPassportInfo({
626
- success: res => {
627
- console.log('外国人护照核验接口获取成功', res)
628
-
629
- this.setData({
630
- passportAuthStatus: res.status,
631
- passportAuthPersonCode: res.person_code
632
- })
633
-
634
- if (needStatus) {
635
- // 需要返回状态
636
- resolve(res.status)
637
- } else {
638
- let {
639
- id_card_number,
640
- nation,
641
- sur_name,
642
- first_name,
643
- sex,
644
- birthday,
645
- cid_expire_date,
646
- phone,
647
- verify_expire_time,
648
- nation_name
649
- } = res
650
- let passportOldData = {
651
- id_card_number,
652
- nation,
653
- nation_name,
654
- sur_name,
655
- sur_name_en: sur_name,
656
- first_name,
657
- first_name_en: first_name,
658
- sex: sex ? sex : '',
659
- birthday,
660
- cid_expire_date,
661
- phone,
662
- verify_expire_time: verify_expire_time && Number(verify_expire_time) || ''
663
- }
664
- formData = Object.assign(formData, res, passportOldData)
665
- Nation = nation
666
- this.setData({
667
- formData,
668
- passportOldData
669
- })
670
- }
671
- },
672
- fail: err => {
673
- console.log('外国人护照核验接口获取失败', err)
674
- let { errmsg } = JSON.parse(err)
675
- wx.showToast({
676
- title: errmsg || '获取核验信息接口失败',
677
- icon: 'none',
678
- duration: 3000
679
- })
680
- }
681
- })
682
- })
683
- },
684
-
685
- // 选择国籍
686
- handleNationTap() {
687
- const cid_type = this.data.formData.cid_type
688
- if (cid_type === '414') {
689
- // 华侨护照
690
- return
691
- }
692
- // 临时存储表单数据
693
- this.saveFormDataTemp()
694
-
695
- flow.navigateTo({
696
- url: `../nation-list/nation-list?cid_type=${cid_type}`,
697
- })
698
- },
699
-
700
- // 显示自定义校验错误提示
701
- showCuntomErrTip(msg) {
702
- this.setData({
703
- showCustomTips: true,
704
- customTipsMsg: msg
705
- }, () => {
706
- // 3秒后关闭
707
- setTimeout(() => {
708
- this.setData({
709
- showCustomTips: false,
710
- customTipsMsg: ''
711
- });
712
- }, 3500);
713
- })
714
- },
715
-
716
- async handleFormSubmit(e) {
717
- const isOther = this.data.submitMode === 'other'
718
- const formValid = e.detail.validStatus
719
- if (isOther) {
720
- wx.showLoading({
721
- title: '加载中…',
722
- mask: true
723
- })
724
- // 自定义英文名校验(与现有一致)
725
- const customValid = this.data.language !== 'en' ? { valid: true, msg: '' } : this.validateFullname()
726
-
727
- if (!formValid || !customValid.valid) {
728
- // 与现有提示优先级一致
729
- const formErrList = e.detail.value || []
730
- if (!formValid && customValid.valid) {
731
- this.showCuntomErrTip(formErrList[0].message)
732
- } else if (formValid && !customValid.valid) {
733
- this.showCuntomErrTip(customValid.msg)
734
- } else {
735
- const needPrior = formErrList.find(i => ["id_card_number", "nation"].includes(i.name))
736
- const lastMsg = needPrior ? needPrior.message : customValid.msg
737
- this.showCuntomErrTip(lastMsg)
738
- }
739
- this.data.submitMode = ''
740
- this.data.isSubmitting = false
741
- wx.hideLoading()
742
- return
743
- }
744
-
745
- // 通过后再跳"其他方式"业务(可按需补入参清洗,沿用 handleFormSubmit 的清洗逻辑)
746
- this.toBankCardLogin()
747
- // 注意:isSubmitting 状态在 toBankCardLogin 方法中重置
748
- return
749
- }
750
- // const formValid = e.detail.validStatus
751
- const customValid = this.data.language !== 'en' ? { valid: true, msg: '' } : this.validateFullname()
752
- if (!formValid || !customValid.valid) {
753
- // 自定义校验字段有问题,获取表单错误列表
754
- const formErrList = e.detail.value
755
- // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
756
- if (!formValid && customValid.valid) {
757
- this.showCuntomErrTip(formErrList[0].message)
758
- return
759
- }
760
- // 如果表单校验没有问题,自定义校验有问题,则显示自定义校验错误提示
761
- if (formValid && !customValid.valid) {
762
- this.showCuntomErrTip(customValid.msg)
763
- return
764
- }
765
- // 如果两者都有问题,则判断显示谁
766
- let lastMsg = ''
767
- if (formErrList.some(i => ["id_card_number", "nation"].includes(i.name))) {
768
- lastMsg = formErrList[0].message
769
- } else {
770
- lastMsg = customValid.msg
771
- }
772
- this.showCuntomErrTip(lastMsg)
773
- return
774
- }
775
- wx.showLoading({
776
- title: '加载中…',
777
- mask: true
778
- })
779
- // 处理参数
780
- console.log('删除“姓名、证件号码、护照号码、手机号码”的前后空格')
781
- let { name, id_card_number, sur_name, first_name, passport_number, phone, cid_type } = this.data.formData
782
- this.setData({
783
- ['formData.name']: name.trim(),
784
- ['formData.passport_number']: passport_number.trim(),
785
- ['formData.phone']: phone.trim()
786
- })
787
- if (cid_type === '700') {
788
- // 外国护照,sur_name和first_name需要特殊处理
789
- let { sur_name_en, first_name_en } = this.data.formData
790
- if (sur_name_en == null || sur_name_en === '') {
791
- sur_name_en = ' '
792
- } else {
793
- sur_name = sur_name_en.trim()
794
- }
795
- if (first_name_en == null || first_name_en === '') {
796
- first_name_en = ' '
797
- } else {
798
- first_name_en = first_name_en.trim()
799
- }
800
- this.setData({
801
- ['formData.sur_name']: sur_name_en,
802
- ['formData.first_name']: first_name_en,
803
- // 删除“外国人护照号码”中间空格
804
- ['formData.id_card_number']: id_card_number.replace(/\s+/g, '').trim()
805
- })
806
- } else {
807
- this.setData({
808
- ['formData.sur_name']: sur_name.trim(),
809
- ['formData.first_name']: first_name.trim(),
810
- ['formData.id_card_number']: id_card_number.trim()
811
- })
812
- }
813
- console.log('入参', this.data.formData)
814
-
815
- let currentAuthType = this.data.currentAuthType
816
- console.log('当前认证类型', currentAuthType)
817
-
818
- if (currentAuthType === 'wxFace') {
819
- console.log('微信人脸识别认证')
820
-
821
- // 判断是否是PC端登录
822
- await this.getDevice()
823
-
824
- // 判断人脸失败次数
825
- await this.fetchFaceFailCount(false)
826
-
827
- // 错误触发销毁回调函数处理
828
- this.handleExitedState()
829
-
830
- // 开启人脸识别认证
831
- this.toFaceVerify()
832
- } else if (currentAuthType === 'faceReceptionAuth') {
833
- console.log('出入境微信人脸识别接口认证')
834
- // 错误触发销毁回调函数处理
835
- this.handleExitedState()
836
-
837
- // 判断是否是PC端登录
838
- await this.getDevice()
839
-
840
- // 出入境微信人脸识别接口
841
- this.toFaceReceptionAuth()
842
- } else if(currentAuthType === 'cardAuth') {
843
- console.log('银行卡接口认证')
844
- // 银行卡身份核验接口
845
- this.bankCardAuth()
846
- } else if(currentAuthType === 'ForeignPassortAuth') {
847
- console.log('外国人护照核验')
848
- // 外国人护照核验
849
- this.handlePassortAuth()
850
- }
851
- },
852
-
853
- // 开启人脸识别认证
854
- async toFaceVerify() {
855
- const [err, session] = await utils.awaitTo(jingtongVerifyRequest.faceVerifyWithIdCard(this.data.formData))
856
-
857
- const cidType = this.data.formData.cid_type
858
-
859
- if (err) {
860
- // 埋点上报事件:刷脸认证
861
- this.faceTracker(2, cidType)
862
-
863
- // 埋点上报事件:自然人登录
864
- this.loginTracker(3, cidType)
865
-
866
- console.log('微信人脸识别失败', err)
867
- let { errmsg, errMsg, errCode } = JSON.parse(err)
868
- if (errCode) {
869
- let errCodeArr = [10002, 10003, 10004, 10005, 10012, 10057, 90002, 90003, 90004, 90005, 90006, 90100, 90023, 90024, 90025]
870
- if (errCodeArr.indexOf(errCode) >= 0) {
871
- console.log('在指定的错误码范围内,人脸失败次数+1')
872
- // 设置人脸失败次数
873
- await this.fetchFaceFailCount(true, errCode)
874
- }
875
- // 人脸识别异常温馨提示弹窗
876
- this.handleFaceError(errCode)
877
- }
878
-
879
- if (errCode && errCode === 90100) {
880
- wx.showToast({
881
- title: '您已取消人脸识别',
882
- icon: 'none',
883
- duration: 3000
884
- })
885
- } else if (errCode && errCode === 10004) {
886
- wx.showToast({
887
- title: '人脸与身份信息不匹配',
888
- icon: 'none',
889
- duration: 3000
890
- })
891
- } else if (errCode && errCode === 10003) {
892
- wx.showToast({
893
- title: '姓名或证件号码有误',
894
- icon: 'none',
895
- duration: 3000
896
- })
897
- } else {
898
- wx.showToast({
899
- title: errmsg || errMsg || '认证失败,请稍后再试',
900
- icon: 'none',
901
- duration: 3000
902
- })
903
- }
904
- } else {
905
- // 埋点上报事件:刷脸认证
906
- this.faceTracker(1, cidType)
907
-
908
- console.log('认证成功返回页面数据:', session)
909
- // 保存刷脸成功时间戳
910
- let timeStamp = new Date().getTime()
911
- wx.setStorageSync('tif.faceTimeStamp', timeStamp)
912
-
913
- this.authSuccess(session)
914
- }
915
- },
916
-
917
- // 人脸识别异常温馨提示弹窗
918
- handleFaceError(code) {
919
- let errCode1 = [10009, 10026, 10032, 10072, 10076, 10084, 10086, 10089, 10092, 10049, 10107, 10095]
920
- let errCode2 = [10002, 10004, 10005, 10010, 10012, 10027, 10028, 10057]
921
- if (errCode1.indexOf(code) >= 0) {
922
- // 1: 未办理过身份证/新办理身份证的
923
- this.setData({
924
- faceErrorModal: true,
925
- faceErrorType: '1'
926
- })
927
- } else if (errCode2.indexOf(code) >= 0) {
928
- const age = utils.parseIDCard(this.data.formData.id_card_number).age
929
- console.log('年龄', age)
930
- if (age >= 60) {
931
- // 3: 刷脸没刷过,60岁以上的
932
- this.setData({
933
- faceErrorModal: true,
934
- faceErrorType: '3'
935
- })
936
- } else {
937
- // 2: 刷脸没刷过,60岁以下的
938
- this.setData({
939
- faceErrorModal: true,
940
- faceErrorType: '2'
941
- })
942
- }
943
- }
944
- },
945
-
946
- // 出入境微信人脸识别接口
947
- async toFaceReceptionAuth() {
948
- // 临时存储表单数据
949
- this.saveFormDataTemp()
950
-
951
- // 数据加密
952
- const [err, res] = await utils.awaitTo(jingtongVerifyRequest.caEncrypt(this.data.formData))
953
- if (err) {
954
- console.log('CA加密失败', err)
955
- let { errmsg } = JSON.parse(err)
956
- wx.showToast({
957
- title: errmsg || 'CA加密失败,请重试',
958
- icon: 'none',
959
- duration: 3500
960
- })
961
- } else {
962
- wx.hideLoading()
963
- console.log('CA加密成功:', res)
964
- this.toFaceReceptionVerify(res.user_id_key)
965
- }
966
- },
967
-
968
- // 开启出入境微信人脸识别认证
969
- async toFaceReceptionVerify(userIdKey) {
970
- const params = Object.assign(this.data.formData, {
971
- userIdKey
972
- })
973
- const { cid_type } = this.data.formData
974
- const [err, session] = await utils.awaitTo(jingtongVerifyRequest.faceVerifyWithUserIdKey(params))
975
- if (err) {
976
- console.log('出入境-微信人脸识别失败', err)
977
-
978
- // 埋点上报事件:刷脸认证
979
- this.faceTracker(2, cid_type)
980
-
981
- // 埋点上报事件:自然人登录
982
- this.loginTracker(3, cid_type)
983
-
984
- try {
985
- let { errmsg = '', errMsg = '', errCode = '' } = JSON.parse(err) || ''
986
- if (errCode && errCode === 90100) {
987
- wx.showToast({
988
- title: '您已取消人脸识别',
989
- icon: 'none',
990
- duration: 3000
991
- })
992
- } else if (errCode && errCode === 10004) {
993
- wx.showToast({
994
- title: '人脸与身份信息不匹配',
995
- icon: 'none',
996
- duration: 3000
997
- })
998
- } else if (errCode && errCode === 10003) {
999
- wx.showToast({
1000
- title: '姓名或证件号码有误',
1001
- icon: 'none',
1002
- duration: 3000
1003
- })
1004
- } else if (errCode && errCode === 10111 && (cid_type === '17' || cid_type === '18')) {
1005
- // 若是“港澳台居住证”且错误码是10111,则触发银行卡核验
1006
- this.setData({
1007
- showCardModal: true
1008
- })
1009
- } else {
1010
- wx.showToast({
1011
- title: errmsg || errMsg || '认证失败,请稍后再试',
1012
- icon: 'none',
1013
- duration: 3000
1014
- })
1015
- }
1016
- } catch {
1017
- wx.showToast({
1018
- title: '人脸识别不支持电脑端,请使用真机',
1019
- icon: 'none',
1020
- duration: 3000
1021
- })
1022
- }
1023
- } else {
1024
- // 埋点上报事件:刷脸认证
1025
- this.faceTracker(1, cid_type)
1026
-
1027
- console.log('认证成功返回页面数据:', session)
1028
- this.authSuccess(session)
1029
- }
1030
- },
1031
-
1032
- // 港澳台居住证核验接口
1033
- async HmtResidenceAuth() {
1034
- const [err, session] = await utils.awaitTo(jingtongVerifyRequest.residenceAuth(this.data.formData))
1035
- if (err) {
1036
- console.log('港澳台居住证核验接口认证失败', err)
1037
- let { errmsg, errcode } = JSON.parse(err)
1038
- if (errcode == 4048) {
1039
- this.setData({
1040
- showCardModal: true
1041
- })
1042
- } else {
1043
- wx.showToast({
1044
- title: errmsg || '认证失败',
1045
- icon: 'none',
1046
- duration: 3000
1047
- })
1048
- }
1049
- } else {
1050
- console.log('认证成功返回页面数据:', session)
1051
- this.authSuccess(session)
1052
- }
1053
- },
1054
-
1055
- // 银行卡身份核验接口
1056
- async bankCardAuth() {
1057
- const [err, session] = await utils.awaitTo(jingtongVerifyRequest.bankCardAuth(this.data.formData))
1058
- if (err) {
1059
- // 埋点上报事件:自然人登录
1060
- this.loginTracker(2, this.data.formData.cid_type)
1061
-
1062
- console.log('银行卡身份核验接口认证失败', err)
1063
- let { errmsg } = JSON.parse(err)
1064
- wx.showToast({
1065
- title: errmsg || '认证失败',
1066
- icon: 'none',
1067
- duration: 3000
1068
- })
1069
- } else {
1070
- console.log('认证成功返回页面数据:', session)
1071
- this.authSuccess(session)
1072
- }
1073
- },
1074
-
1075
- // 外国人护照核验处理逻辑
1076
- handlePassortAuth() {
1077
- let authStatus = this.data.passportAuthStatus
1078
- let newData = this.data.formData
1079
- let oldData = this.data.passportOldData
1080
-
1081
- console.log('当前核验单状态', authStatus)
1082
-
1083
- if (!authStatus) {
1084
- console.log('无审核单', authStatus)
1085
- // 外国人护照核验,提交核验单
1086
- this.passportAuth()
1087
- } else {
1088
- // 查上一单的状态
1089
- this.fetchPassortAuthResult(true).then(status => {
1090
- console.log('====查上一单的状态====', status)
1091
- if (status === '1') {
1092
- // 核验通过,弹窗提示
1093
- console.log('外国人护照核验通过')
1094
- this.passportAuthSuccess()
1095
- } else {
1096
- // 比对表单数据是否有修改
1097
- console.log('新旧表单数据比对', newData, oldData)
1098
- if (utils.objIsEqual(newData, oldData)) {
1099
- console.log('表单数据没有修改')
1100
- if (status === '4') {
1101
- // 核验中
1102
- this.fetchPassortAuthResult(true).then(status => {
1103
- console.log('再次获取外国人护照核验状态', status)
1104
- if (status === '1') {
1105
- console.log('外国人护照核验通过')
1106
- this.passportAuthSuccess()
1107
- } else if (status === '4') {
1108
- console.log('外国人护照核验中,弹窗提示')
1109
- this.handleShowModal(status)
1110
- } else {
1111
- // 核验不通过,弹窗提示
1112
- this.passportAuthFail(status)
1113
- }
1114
- })
1115
- } else {
1116
- // 核验不通过,弹窗提示
1117
- this.passportAuthFail(status)
1118
- }
1119
- } else {
1120
- console.log('表单数据存在修改')
1121
- // 外国人护照核验,提交核验单
1122
- this.passportAuth()
1123
- }
1124
- }
1125
- })
1126
- }
1127
- },
1128
-
1129
- // 外国人护照核验不通过逻辑
1130
- passportAuthFail(status) {
1131
- console.log('===外国人护照核验不通过,弹窗提示===')
1132
- // 判断当前person_code是否已失效
1133
- const personCode = this.data.passportAuthPersonCode
1134
- const localPersonCode = wx.getStorageSync('tif.fail.person_code') || ''
1135
- if (personCode === localPersonCode) {
1136
- // 提交核验单
1137
- this.passportAuth()
1138
- } else {
1139
- // 埋点上报事件:自然人登录
1140
- this.loginTracker(2, this.data.formData.cid_type)
1141
-
1142
- this.handleShowModal(status)
1143
- // 记录这个person_code是失效的
1144
- wx.setStorageSync('tif.fail.person_code', this.data.passportAuthPersonCode)
1145
- }
1146
- },
1147
-
1148
- // 外国人护照核验接口
1149
- async passportAuth() {
1150
- console.log('===========提交核验单============')
1151
- let formData = this.data.formData
1152
-
1153
- const isLegalDate = utils.greaterCurrentTime(formData.cid_expire_date)
1154
- console.log('isLegalDate', isLegalDate)
1155
- if (!isLegalDate) {
1156
- console.log('护照有效期日期不合法')
1157
- wx.showToast({
1158
- title: 'Please select the passport expiration date',
1159
- icon: 'none',
1160
- duration: 3000
1161
- })
1162
- this.setData({
1163
- 'formData.cid_expire_date': ''
1164
- })
1165
- return
1166
- }
1167
-
1168
- const [err, res] = await utils.awaitTo(jingtongVerifyRequest.passportAuth(formData))
1169
- if (err) {
1170
- console.log('外国人护照核验接口认证失败', err)
1171
- let { errmsg } = JSON.parse(err)
1172
- wx.showToast({
1173
- title: errmsg || '认证失败',
1174
- icon: 'none',
1175
- duration: 3000
1176
- })
1177
- return
1178
- }
1179
- console.log('弹窗提示等待10分钟', res)
1180
- this.setData({
1181
- passportAuthStatus: '4',
1182
- passportOldData: JSON.parse(JSON.stringify(formData)),
1183
- passportAuthPersonCode: ''
1184
- })
1185
- wx.setStorageSync('tif.fail.person_code', '')
1186
- this.handleShowModal('4')
1187
- },
1188
-
1189
- // 外国人护照核验通过
1190
- passportAuthSuccess() {
1191
- // 调用删除接口/静默登录并返回session信息
1192
- jingtongVerifyRequest.deletePassportAuth({
1193
- success: session => {
1194
- console.log('返回session信息', session)
1195
-
1196
- // 删除缓存信息
1197
- console.log('删除缓存信息')
1198
- let formDataTemp = wx.getStorageSync('tif.formDataTemp')
1199
- formDataTemp['700'] = {}
1200
- wx.setStorageSync('tif.formDataTemp', formDataTemp)
1201
- this.setData({
1202
- passportOldData: {}
1203
- })
1204
-
1205
- this.authSuccess(session, true)
1206
- },
1207
- fail: err => {
1208
- // 埋点上报事件:自然人登录
1209
- this.loginTracker(2, this.data.formData.cid_type)
1210
-
1211
- let { errmsg } = JSON.parse(err)
1212
- wx.showToast({
1213
- title: errmsg || 'auth fail',
1214
- icon: 'none',
1215
- duration: 3000
1216
- })
1217
- }
1218
- })
1219
- },
1220
-
1221
- // 认证成功后续操作
1222
- authSuccess(session, isEn = false) {
1223
- console.log('====判断是否真的登录成功=====')
1224
- if (!session) {
1225
- wx.showToast({
1226
- title: '登录态失效,请重试',
1227
- icon: 'none',
1228
- duration: 2000
1229
- })
1230
- return
1231
- }
1232
- const { face_time, realname_time, cid, has_phone, certType } = session
1233
- if ((!face_time && !realname_time) || !cid) {
1234
- wx.showToast({
1235
- title: `登录态失效请重试: ${this.data.formData.cid_type}`,
1236
- icon: 'none',
1237
- duration: 2000
1238
- })
1239
- return
1240
- }
1241
-
1242
- wx.showToast({
1243
- title: isEn ? 'Verification successful, redirecting...': '验证成功, 跳转中…',
1244
- icon: 'none',
1245
- duration: 5000,
1246
- mask: true
1247
- })
1248
-
1249
- const cidType = session.cid_type
1250
-
1251
- // 本地存储表单核验成功数据
1252
- wx.setStorageSync('tif.formDataSuccess', this.data.formData)
1253
-
1254
- // 将弹窗标识设置为不需要弹窗
1255
- jingtongVerifyRequest.setUserReadStatus(false).then(() => {
1256
- console.log('设置弹窗标识成功')
1257
- }).catch(err => {
1258
- console.log('设置弹窗标识失败', err)
1259
- })
1260
-
1261
- setTimeout(() => {
1262
- if (this.data.needUnite === "true") {
1263
- // this.setData({
1264
- // needUnite: ''
1265
- // })
1266
-
1267
- console.log('进入业务总入口, 判断是否有手机号码', has_phone)
1268
-
1269
- // 登录成功回调 => 业务侧操作事项
1270
- wx.$_ServiceConfiguration && wx.$_ServiceConfiguration.methods && wx.$_ServiceConfiguration.methods._loginSuccessCallBack && wx.$_ServiceConfiguration.methods._loginSuccessCallBack(session)
1271
-
1272
- if (has_phone) {
1273
- const realPhone = wx.getStorageSync('tif.realPhone') || ''
1274
- const caPhone = wx.getStorageSync('tif.caPhone') || ''
1275
- const confirmTime = wx.getStorageSync('tif.tel_confirm_time') || ''
1276
-
1277
- console.log('realPhone', realPhone)
1278
- console.log('caPhone', caPhone)
1279
- console.log('confirmTime', confirmTime)
1280
-
1281
- if (realPhone !== caPhone && confirmTime && (!utils.completeDate(new Date(Number(confirmTime + '000')), 6))) {
1282
- // 埋点上报事件:自然人登录
1283
- this.loginTracker(1, cidType)
1284
-
1285
- this.setData({
1286
- hadSuccessLogin: true
1287
- })
1288
-
1289
- // 【phone与caPhone不同】且【tel_confirm_time大于6个月】
1290
- // 数据库手机号码有效期大于6个月
1291
- flow.redirectTo({
1292
- url: '../confirm-phone/confirm-phone'
1293
- })
1294
- } else {
1295
- jingtongVerifyRequest.personToken({
1296
- source: '11'
1297
- }).then(async data => {
1298
- // 设置用户账号信息
1299
- setAccountInfo(session.openid)
1300
-
1301
- // 埋点上报事件:自然人登录
1302
- this.loginTracker(1, cidType)
1303
-
1304
- this.setData({
1305
- hadSuccessLogin: true
1306
- })
1307
-
1308
- // 埋点 - 个人用户实体全属性上报
1309
- let last_login_time = utils.getCurrentTime()
1310
- wx.setStorageSync('tif.lastLoginTime', last_login_time)
1311
- const userEntityReportData = Object.assign(session, {
1312
- user_status: '1',
1313
- last_login_time,
1314
- user_date_of_birth: session.cid_type === '111' ? utils.getBirthByIDCard(session.cid) : ''
1315
- })
1316
- await utils.awaitTo(jingtongVerifyRequest.userEntityReport(userEntityReportData))
1317
-
1318
- setTimeout(() => {
1319
- flow.resolve({
1320
- token: data
1321
- })
1322
- }, 1200)
1323
- })
1324
- }
1325
- } else {
1326
- // 埋点上报事件:自然人登录
1327
- this.loginTracker(1, cidType)
1328
-
1329
- this.setData({
1330
- hadSuccessLogin: true
1331
- })
1332
-
1333
- flow.redirectTo({
1334
- url: '../bind-phone/bind-phone?source=3'
1335
- })
1336
- }
1337
- } else {
1338
- console.log('返回主包')
1339
- flow.resolve()
1340
- }
1341
- }, 800)
1342
- },
1343
-
1344
- // 埋点上报事件:刷脸认证
1345
- faceTracker(recognition_status = 1, cidType) {
1346
- SDKTrack('face_recognition_login', {
1347
- recognition_status, // 1: 人脸识别成功 2:人脸识别失败
1348
- login_certificate: this.data.certTypeMap[cidType] || 1, // 证件类型
1349
- invoke_location: '' // 调起位置
1350
- })
1351
- },
1352
-
1353
- // 埋点上报事件:自然人登录
1354
- loginTracker(login_status = 1, cidType) {
1355
- SDKTrack('nature_person_login', {
1356
- // 1 登录成功;2 登录失败-身份信息核验失败;3 登录失败-人脸核验失败
1357
- // 4 登录失败-电子营业执照核验失败;5 登录失败-账号密码输入错误
1358
- // 6 取消登录(包含点击温馨提示的“取消”,点击请法人登录的×,在登录页面点击左上角返回按钮退出登录)
1359
- // 7 退出小程序终止登录;old_1 历史数据:除登录成功之外的所有情况
1360
- login_status,
1361
- login_certificate: this.data.certTypeMap[cidType] || 1, // 证件类型
1362
- invoke_location: '', // 调起位置
1363
- login_validity_period: this.data.formData.verify_expire_time / 24 || '' // 免登录时间
1364
- })
1365
- },
1366
-
1367
- // 显示弹窗
1368
- handleShowModal(status) {
1369
- let modalStatus = ''
1370
- if (status === '3') {
1371
- // 未找到信息
1372
- modalStatus = 'warning'
1373
- } else if (status === '4') {
1374
- // 核验中
1375
- modalStatus = 'info'
1376
- } else {
1377
- // 信息有误
1378
- modalStatus = 'error'
1379
- }
1380
- this.setData({
1381
- modalStatus,
1382
- showModal: true
1383
- },() => {
1384
- wx.hideLoading()
1385
- })
1386
- },
1387
-
1388
- // modal确认事件
1389
- handleModalOk() {
1390
- // this.fetchPassortAuthResult()
1391
- this.setData({
1392
- showModal: false,
1393
- showFaceModal: false,
1394
- showLockFaceModal: false,
1395
- showCardModal: false,
1396
- showTipModal: false,
1397
- showOtherWayTipModal: false
1398
- })
1399
- },
1400
-
1401
- // 调起银行卡认证
1402
- toCardAuth() {
1403
- console.log('====调起银行卡认证====')
1404
- this.setData({
1405
- currentAuthType: 'cardAuth',
1406
- rules: rulesConfig.cardRules('zh_CN'),
1407
- showCardModal: false
1408
- })
1409
- },
1410
-
1411
- // 触发问号弹出
1412
- showQuestionTip() {
1413
- this.setData({
1414
- showTipModal: true
1415
- })
1416
- },
1417
-
1418
- onUnload: function() {
1419
- // 页面卸载时的逻辑处理
1420
- console.log('======页面即将卸载======', this.data.hadSuccessLogin);
1421
- if (!this.data.hadSuccessLogin) {
1422
- // 埋点上报事件:自然人登录
1423
- this.loginTracker(6, this.data.formData.cid_type)
1424
- }
1425
- },
1426
-
1427
- // 有些操作程序会触发销毁回调函数,该操作不是真正的小程序销毁操作
1428
- handleExitedState() {
1429
- this.setData({
1430
- exitedState: false
1431
- })
1432
- setTimeout(() => {
1433
- this.setData({
1434
- exitedState: true
1435
- })
1436
- }, 2000)
1437
- },
1438
-
1439
- onSaveExitState: function() {
1440
- // 小程序可能被销毁之前的逻辑处理
1441
- if (!this.data.hadSuccessLogin && this.data.exitedState) {
1442
- console.log('======小程序可能被销毁======')
1443
- // 埋点上报事件:自然人登录
1444
- this.loginTracker(7, this.data.formData.cid_type)
1445
- }
1446
- },
1447
-
1448
- // 关闭 - 扫脸失败温馨提示弹窗
1449
- cancelFaceErrorModal() {
1450
- this.setData({
1451
- faceErrorModal: false
1452
- })
1453
- },
1454
-
1455
- // 扫脸失败温馨提示弹窗-跳转到失败原因
1456
- okFaceErrorModal() {
1457
- this.setData({
1458
- faceErrorModal: false
1459
- })
1460
- flow.navigateTo({
1461
- url: `../face-error-reason/face-error-reason?type=${this.data.faceErrorType}`,
1462
- })
1463
- },
1464
-
1465
- openEye(e) {
1466
- console.log(e)
1467
- const isOpen = e.detail.isOpen
1468
- const key = e.currentTarget.id
1469
- const strKey = e.currentTarget.dataset.star
1470
- console.log('isOpen', isOpen)
1471
- console.log('key', key)
1472
- console.log('strKey', strKey)
1473
- if (isOpen) {
1474
- console.log('显示脱敏')
1475
- const { name, id_card_number } = this.data.formData
1476
- const value = key === 'name' ? utils.hideName(name) : utils.hideIdCard(id_card_number, '111')
1477
- console.log('value', value)
1478
- this.setData({
1479
- [`formData.${strKey}`]: value
1480
- })
1481
- } else {
1482
- console.log('删除脱敏,显示明文')
1483
- this.setData({
1484
- [`formData.${strKey}`]: ''
1485
- })
1486
- }
1487
- },
1488
-
1489
- handleChangeSwtich(e) {
1490
- this.setData({
1491
- ['formData.sbSwitch']: e.detail.value
1492
- })
1493
- // 处理三证照的正则问题
1494
- this.matchOptionsRule()
1495
- },
1496
-
1497
- // 隐藏提示
1498
- closeForeignTip() {
1499
- wx.setStorageSync('tif.hideForeignTip', '1')
1500
- this.setData({
1501
- showForeignTip: false
1502
- })
1503
- },
1504
-
1505
- // 验证sur_name和first_name
1506
- validateFullname() {
1507
- const {
1508
- sur_name_en: sur_name,
1509
- first_name_en: first_name
1510
- } = this.data.formData
1511
- // 两个都没填
1512
- if ((sur_name == null || sur_name === '') && (first_name == null || first_name === '')) {
1513
- const msgEmpty = 'Please fill in surname or given name.';
1514
- this.setData({
1515
- sur_name_state: {
1516
- valid: false,
1517
- msg: msgEmpty
1518
- },
1519
- first_name_state: {
1520
- valid: false,
1521
- msg: msgEmpty
1522
- }
1523
- })
1524
- return {
1525
- valid: false,
1526
- msg: msgEmpty
1527
- }
1528
- }
1529
- this.setData({
1530
- sur_name_state: {
1531
- valid: true,
1532
- msg: ''
1533
- },
1534
- first_name_state: {
1535
- valid: false,
1536
- msg: ''
1537
- }
1538
- })
1539
- // 其中一个填了,或者两个都填了
1540
- let sur_name_flag = true
1541
- let msg = 'Please enter capital letters'
1542
- if (sur_name != null && sur_name !== '') {
1543
- const valid = utils.validate.checkName(sur_name, cidType)
1544
- if (valid.data) {
1545
- sur_name_flag = true
1546
- } else {
1547
- this.setData({
1548
- sur_name_state: {
1549
- valid: false,
1550
- msg
1551
- }
1552
- })
1553
- sur_name_flag = false
1554
- }
1555
- }
1556
- let first_name_flag = true
1557
- if (first_name != null && first_name !== '') {
1558
- const valid = utils.validate.checkName(first_name, cidType)
1559
- if (valid.data) {
1560
- first_name_flag = true
1561
- } else {
1562
- this.setData({
1563
- first_name_state: {
1564
- valid: false,
1565
- msg
1566
- }
1567
- })
1568
- first_name_flag = false
1569
- }
1570
- }
1571
- if (sur_name_flag && first_name_flag) {
1572
- this.setData({
1573
- sur_name_state: {
1574
- valid: true,
1575
- msg: ''
1576
- },
1577
- first_name_state: {
1578
- valid: false,
1579
- msg: ''
1580
- }
1581
- })
1582
- }
1583
- const valid = sur_name_flag && first_name_flag
1584
- return {
1585
- valid,
1586
- msg: valid ? '' : msg
1587
- }
1588
- },
1589
- async toBankCardLogin() {
1590
- // 判断是否是PC端登录
1591
- await this.getDevice()
1592
- wx.showLoading({
1593
- title: '验证中…',
1594
- mask: true
1595
- })
1596
- // 验证是否在锁定期内,在的话,直接弹窗提示,并返回
1597
- let bankCardFailTime = constantVal.getStorageWithExpire(constantVal.bank_card_verify_fail_time)
1598
- if(bankCardFailTime){
1599
- // 当前时间
1600
- const now = Date.now()
1601
-
1602
- // 判断是否在30分钟内(1小时 = 3600 * 1000 毫秒)
1603
- const isWithinOneHour = (now - bankCardFailTime) < (30 * 60 * 1000)
1604
- if(isWithinOneHour){
1605
- console.log('当前仍在10分钟限制内')
1606
- this.setData({
1607
- showOtherWayTipModal: true
1608
- })
1609
- wx.showToast({
1610
- title: '还存在银行卡验证失败锁定期内,请稍后再试',
1611
- })
1612
- return
1613
- }
1614
- }
1615
- // 身份二要素校验
1616
- const { name, id_card_number } = this.data.formData
1617
- const verifyIdCardParams = {
1618
- "id_card_number": id_card_number,
1619
- "name": name,
1620
- "verify_type": "101",
1621
- "support_type": "0x40"
1622
- }
1623
- jingtongVerifyRequest.verifyIdcard(verifyIdCardParams).then(res => {
1624
- console.log('获取身份证二要素核验结果')
1625
- console.log(res)
1626
- if(res.errcode === 0){
1627
- // 可进行
1628
- } else {
1629
- wx.showToast({
1630
- title: res.errmsg,
1631
- icon: 'none',
1632
- duration: 2000
1633
- })
1634
- this.data.submitMode = ''
1635
- this.data.isSubmitting = false
1636
- return
1637
- }
1638
- wx.hideLoading()
1639
- }).catch(error => {
1640
- this.data.submitMode = ''
1641
- this.data.isSubmitting = false
1642
- return
1643
- })
1644
- // 验证手机号
1645
- const infoCheckParam = {
1646
- "id_card_number": id_card_number,
1647
- "phone_number": ''
1648
- }
1649
-
1650
- let isPhoneNumber = false
1651
- jingtongVerifyRequest.getInfoCheck(infoCheckParam).then(res =>{
1652
- const { errmsg, errcode } = res
1653
- console.log(res)
1654
- if(errcode === 0){
1655
- if(res.data.phone_suffix){
1656
- isPhoneNumber = false
1657
- // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
1658
- this.setData({
1659
- checkType:2
1660
- })
1661
- } else {
1662
- isPhoneNumber = true
1663
- // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
1664
- this.setData({
1665
- checkType:3
1666
- })
1667
- }
1668
- } else{
1669
- isPhoneNumber = true
1670
- }
1671
- }).catch(error => {
1672
- this.data.submitMode = ''
1673
- this.data.isSubmitting = false
1674
- return
1675
- })
1676
- jingtongVerifyRequest.checkPhonePwd(this.data.formData.id_card_number).then(res => {
1677
- console.log(res)
1678
- wx.hideLoading()
1679
- const { errmsg, errcode } = res
1680
- console.log(isPhoneNumber)
1681
- console.log(!res.data.is_new)
1682
- if (errcode === 0) {
1683
- // isPhoneNumber 为true,即系没有手机号,res.data.is_new为true即系无密码
1684
- if(isPhoneNumber && res.data.is_new){
1685
- // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
1686
- this.setData({
1687
- checkType: 1
1688
- })
1689
- wx.navigateTo({
1690
- url: '/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify?id_card_number='+ this.data.formData.id_card_number
1691
- + '&cid_type=' + this.data.formData.cid_type
1692
- + '&name=' + this.data.formData.name
1693
- + '&strCid=' + this.data.formData.strCid
1694
- + '&verify_expire_time=' + this.data.formData.verify_expire_time
1695
- + '&checkType=' + this.data.checkType
1696
- })
1697
- } else if(isPhoneNumber && !res.data.is_new){
1698
- // isPhoneNumber 为true,即系没有手机号,res.data.is_new为true即系无密码
1699
- // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
1700
- this.setData({
1701
- checkType: 3
1702
- })
1703
- wx.navigateTo({
1704
- url: '/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify?id_card_number='+ this.data.formData.id_card_number
1705
- + '&cid_type=' + this.data.formData.cid_type
1706
- + '&name=' + this.data.formData.name
1707
- + '&strCid=' + this.data.formData.strCid
1708
- + '&verify_expire_time=' + this.data.formData.verify_expire_time
1709
- + '&checkType=' + this.data.checkType
1710
- })
1711
- } else if(!isPhoneNumber && res.data.is_new){
1712
- // isPhoneNumber 为true,即系没有手机号,res.data.is_new为true即系无密码
1713
- // 1:无密码和手机号,2:无密码有手机号,3:无手机号有密码
1714
- this.setData({
1715
- checkType: 2
1716
- })
1717
- wx.navigateTo({
1718
- url: '/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify?id_card_number='+ this.data.formData.id_card_number
1719
- + '&cid_type=' + this.data.formData.cid_type
1720
- + '&name=' + this.data.formData.name
1721
- + '&strCid=' + this.data.formData.strCid
1722
- + '&verify_expire_time=' + this.data.formData.verify_expire_time
1723
- + '&checkType=' + this.data.checkType
1724
- })
1725
- } else {
1726
- wx.navigateTo({
1727
- url: '/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login?cardNumber='
1728
- + this.data.formData.id_card_number
1729
- + '&cid_type=' + this.data.formData.cid_type
1730
- + '&name=' + this.data.formData.name
1731
- + '&strCid=' + this.data.formData.strCid
1732
- + '&verify_expire_time=' + this.data.formData.verify_expire_time
1733
- })
1734
- }
1735
- wx.hideLoading()
1736
- // 成功跳转后重置防重复点击标记
1737
- this.data.isSubmitting = false
1738
- } else {
1739
- wx.showToast({
1740
- title: errmsg,
1741
- icon: 'none',
1742
- duration: 2000,
1743
- })
1744
- // 出错时重置防重复点击标记
1745
- this.data.isSubmitting = false
1746
- }
1747
- }).catch(error => {
1748
- console.log('异常')
1749
- console.log(error)
1750
- const { errcode, errmsg } = error
1751
- wx.showToast({
1752
- title: errmsg,
1753
- icon: 'none',
1754
- duration: 2000,
1755
- })
1756
- // 出错时重置防重复点击标记
1757
- this.data.isSubmitting = false
1758
- })
1759
- this.data.submitMode = ''
1760
- this.data.isSubmitting = false
1761
- },
1762
- // 防重复点击的点击处理方法
1763
- async handletoOther() {
1764
- console.log('点击其他方式')
1765
-
1766
- // 检查是否正在处理中
1767
- if (this.data.isSubmitting) {
1768
- console.log('正在处理中,请勿重复点击')
1769
- wx.showToast({
1770
- title: '正在处理中,请稍候...',
1771
- icon: 'none',
1772
- duration: 1500
1773
- })
1774
- return
1775
- }
1776
-
1777
- // 立即设置处理状态,防止重复点击
1778
- this.data.isSubmitting = true
1779
-
1780
- try {
1781
- console.log('跳转其他页面')
1782
- // console.log(this.data.formData)
1783
- // console.log(this.data.formData.name)
1784
- // console.log(this.data.formData.id_card_number)
1785
- // console.log(this.data.formData.cid_type)
1786
-
1787
- // 方案B
1788
- this.data.submitMode = 'other' // 设置来源标记
1789
- const form = this.selectComponent('#form')
1790
- if (form && typeof form.handleSubmit === 'function') {
1791
- // 触发表单的内置校验流程,结果会回调到 handleFormSubmit
1792
- form.handleSubmit()
1793
- // 注意:这里不重置 isSubmitting,等待 handleFormSubmit 中的处理完成
1794
- } else {
1795
- wx.showToast({ title: '表单未就绪,请稍后再试', icon: 'none' })
1796
- // 表单未就绪时立即重置状态
1797
- this.data.isSubmitting = false
1798
- }
1799
- } catch (error) {
1800
- console.error('handletoOther 执行出错:', error)
1801
- // 出错时重置状态
1802
- this.data.isSubmitting = false
1803
- }
1804
- },
1805
- handletoLoginHelp () {
1806
- console.log('点击登录帮助')
1807
- console.log('跳转其他页面')
1808
- wx.navigateTo({
1809
- url: '/weapps-plugin-jingtong-verify/pages/login-help/login-help',
1810
- })
1811
- }
1812
- })
1
+ // weapps-plugin-jingtong-verify/pages/face-verify/index.js
2
+ const jingtongVerifyRequest = require('../../utils/request')
3
+ const utils = require("../../utils/index")
4
+ const { flow } = require("@wecity/weda-plugin-utils");
5
+ const rulesConfig = require("../../utils/rules")
6
+ import { SDKTrack, setAccountInfo } from '../../utils/QDTrackerNew/QDTrackerMain'
7
+ let cidType = '111'
8
+ let Nation = 'CHN'
9
+
10
+ Page({
11
+ /**
12
+ * 页面的初始数据
13
+ */
14
+ data: {
15
+ language: 'zh_CN', // 语言环境:默认中文
16
+ formData: {
17
+ cid_type: '111', // 证件类型
18
+ strName: '', // 身份证姓名(脱敏)
19
+ name: '',
20
+ strCid: '', // 身份证号码(脱敏)
21
+ id_card_number: '', // 证件号码
22
+ strBankCount: '', // 银行卡卡号(脱敏)
23
+ bank_account: '',
24
+ nation: 'CHN', // 国籍
25
+ nation_name: '中国',
26
+ sur_name: '', //
27
+ first_name: '', // 名
28
+ sur_name_en: '', // 姓(国外护照)
29
+ first_name_en: '', // 名(国外护照)
30
+ sex: '', // 性别
31
+ birthday: '', // 出生日期
32
+ cid_expire_date: '', // 护照有效期
33
+ validity_period: '', // 证件生效日期
34
+ passport_number: '', // 通行证号码
35
+ phone: '',
36
+ verify_expire_time: '', // 登录有效期
37
+ agree: false,
38
+ isbind: 1,
39
+ sbSwitch: true
40
+ },
41
+ needUnite: '', // 是否需要串联起来
42
+ agreeInfo: '我同意北京市大数据中心使用我所提交的信息注册京通小程序,以及登录北京市统一身份认证平台,以便使用京通相关服务。',
43
+ cidTypeRange: [
44
+ // 微信人脸识别
45
+ { name: '中华人民共和国居民身份证', value: '111' },
46
+ // 移民局接口
47
+ { name: '港澳居民来往内地通行证', value: '516' },
48
+ { name: '台湾居民来往大陆通行证', value: '511' },
49
+ { name: '外国人永久居留身份证', value: '553' },
50
+ { name: '华侨护照(国内签发)', value: '414' },
51
+ // 银行卡接口
52
+ { name: '港澳居民居住证', value: '17' },
53
+ { name: '台湾居民居住证', value: '18' },
54
+ // 外国护照
55
+ { name: 'International passport', value: '700' }
56
+ ],
57
+ sexRange: [
58
+ { name: 'Male', value: 1 },
59
+ { name: 'Female', value: 2 }
60
+ ],
61
+ sexRangeZH: [
62
+ { name: '男', value: 1 },
63
+ { name: '女', value: 2 }
64
+ ],
65
+ loginTimeRangeEn: [
66
+ { name: 'Keep me logged in for 1 day', value: 24 },
67
+ { name: 'Keep me logged in for 7 days', value: 168 },
68
+ { name: 'Keep me logged in for 30 days', value: 720 }
69
+ ],
70
+ loginTimeRange: [
71
+ { name: '1天免登录', value: 24 },
72
+ { name: '7天免登录', value: 168 },
73
+ { name: '30天免登录', value: 720 }
74
+ ],
75
+ validateType: {
76
+ id_card_number(value) {
77
+ return utils.validate.checkCid(value, cidType, Nation).data
78
+ },
79
+ name(value) {
80
+ return utils.validate.checkName(value, cidType).data
81
+ },
82
+ sur_name(value) {
83
+ return utils.validate.checkName(value, cidType).data
84
+ },
85
+ first_name(value) {
86
+ return utils.validate.checkName(value, cidType).data
87
+ },
88
+ passport_number(value) {
89
+ return utils.validate.checkHmtPassport(value, cidType, Nation).data
90
+ },
91
+ },
92
+ rulesMap: {
93
+ '111': {
94
+ currentAuthType: 'wxFace',
95
+ rules: rulesConfig.chinaRules('zh_CN')
96
+ },
97
+ '516': {
98
+ currentAuthType: 'faceReceptionAuth',
99
+ rules: rulesConfig.HMORules('zh_CN')
100
+ },
101
+ '511': {
102
+ currentAuthType: 'faceReceptionAuth',
103
+ rules: rulesConfig.HMORules('zh_CN')
104
+ },
105
+ '553': {
106
+ currentAuthType: 'faceReceptionAuth',
107
+ rules: rulesConfig.residenceRules('zh_CN')
108
+ },
109
+ '414': {
110
+ currentAuthType: 'faceReceptionAuth',
111
+ rules: rulesConfig.HMORules('zh_CN')
112
+ },
113
+ '17': {
114
+ currentAuthType: 'faceReceptionAuth',
115
+ // rules: rulesConfig.cardRules('zh_CN'),
116
+ rules: rulesConfig.residenceAuthRules('zh_CN'),
117
+ tip: '请填写本人在办理银联银行卡时登记的姓名、港澳居民居住证证件号、手机号、银行卡号。'
118
+ },
119
+ '18': {
120
+ currentAuthType: 'faceReceptionAuth',
121
+ // rules: rulesConfig.cardRules('zh_CN'),
122
+ rules: rulesConfig.residenceAuthRules('zh_CN'),
123
+ tip: '请填写本人在办理银联银行卡时登记的姓名、台湾居民居住证证件号、手机号、银行卡号。'
124
+ },
125
+ '700': {
126
+ currentAuthType: 'ForeignPassortAuth',
127
+ rules: rulesConfig.ForeignPassortRules('en')
128
+ }
129
+ },
130
+ rules: rulesConfig.chinaRules('zh_CN'),
131
+ // 核验类别
132
+ currentAuthType: 'wxFace',
133
+ // 打开文档的防抖操作
134
+ canOpenPdf: true,
135
+ // 外国人护照核验状态 '1'(通过) '4'(审核中) ''(无审核单) 其它值(审核失败)
136
+ passportAuthStatus: '',
137
+ passportAuthPersonCode: '',
138
+ // 核验单数据
139
+ passportOldData: {},
140
+ // 弹窗
141
+ showModal: false,
142
+ modalStatus: 'info',
143
+ // 定义日期边界值
144
+ birthdayMaxDate: [new Date().getFullYear(), (new Date().getMonth() + 1), new Date().getDate()],
145
+ cidExpireMinDate: [new Date().getFullYear(), (new Date().getMonth() + 1), new Date().getDate()],
146
+ // 老/小6次、成人3次 人脸报错提示弹窗
147
+ showFaceModal: false,
148
+ isKidsOrOld: false,
149
+ // 老/小18次、成人6次 人脸报错提示弹窗
150
+ showLockFaceModal: false,
151
+ // 银行卡认证弹窗
152
+ showCardModal: false,
153
+ // 姓名和证件号码弹窗
154
+ showTipModal: false,
155
+ // cidType转化为certType
156
+ certTypeMap: {
157
+ '111': 1,
158
+ '516': 78,
159
+ '511': 4,
160
+ '17': 5,
161
+ '18': 6,
162
+ '414': 2,
163
+ '553': 9,
164
+ '700': 3
165
+ },
166
+ // 记录是否已经登录成功
167
+ hadSuccessLogin: false,
168
+ // 该操作会触发小程序的销毁回调
169
+ exitedState: true,
170
+ // 扫脸失败温馨提示弹窗
171
+ faceErrorModal: false,
172
+ // 扫脸失败原因
173
+ faceErrorType: '2',
174
+ // 标记港澳居民来往内地通行证存在回显的session信息
175
+ // exitHmSession: false,
176
+ // HmSession: {}
177
+ showForeignTip: false,
178
+ // (国外)surname自定义校验状态,傻逼数广傻逼组件逼的
179
+ sur_name_state: {
180
+ valid: true,
181
+ msg: ''
182
+ },
183
+ // (国外)givenName自定义校验状态,傻逼数广傻逼组件逼的
184
+ first_name_state: {
185
+ valid: true,
186
+ msg: ''
187
+ },
188
+ // 是否显示自定义校验提示
189
+ showCustomTips: false,
190
+ // 自定义校验提示文本
191
+ customTipsMsg: ''
192
+ },
193
+
194
+ /**
195
+ * 生命周期函数--监听页面加载
196
+ */
197
+ onLoad(options) {
198
+ console.log('onLoad', options)
199
+ this.setData({
200
+ needUnite: options.needUnite || 'true'
201
+ })
202
+
203
+ // 初始化操作,回填证件类型为身份证的身份信息
204
+ this.initUserInfo()
205
+ },
206
+
207
+ // 初始化操作,回填证件类型为身份证的身份信息
208
+ initUserInfo() {
209
+ // 默认身份证号码
210
+ cidType = '111'
211
+
212
+ wx.showLoading({
213
+ title: '加载中…',
214
+ })
215
+ // 清空本地Temp数据
216
+ wx.setStorageSync('tif.formDataTemp', '')
217
+
218
+ jingtongVerifyRequest.getSession({
219
+ success: res => {
220
+ let { cid_type, cid, name, star_name, star_cid, verify_expire_time } = res
221
+
222
+ // 设置用户账号信息
223
+ setAccountInfo(res.openid)
224
+
225
+ const hideForeignTip = wx.getStorageSync('tif.hideForeignTip') || 0
226
+ console.log('hideForeignTip', hideForeignTip)
227
+ if (!cid && hideForeignTip !== '1') {
228
+ this.setData({
229
+ showForeignTip: true
230
+ })
231
+ }
232
+
233
+ if (cid_type === '111' && cid && name) {
234
+ // 回填身份证类型
235
+ this.setData({
236
+ 'formData.strName': star_name,
237
+ 'formData.name': name,
238
+ 'formData.strCid': star_cid,
239
+ 'formData.id_card_number': cid,
240
+ 'formData.cid_type': cid_type,
241
+ 'formData.verify_expire_time': verify_expire_time || ''
242
+ })
243
+ }
244
+ // if (cid_type === '516') {
245
+ // this.setData({
246
+ // exitHmSession: true,
247
+ // HmSession: res
248
+ // })
249
+ // console.log('HmSession', this.data.HmSession)
250
+ // } else {
251
+ // this.setData({
252
+ // exitHmSession: false
253
+ // })
254
+ // }
255
+ wx.hideLoading()
256
+ },
257
+ fail: fail => {
258
+ console.log('getSession-fail', fail)
259
+ wx.hideLoading()
260
+ }
261
+ })
262
+ },
263
+
264
+ // 生命周期函数--监听页面显示
265
+ onShow: function () {
266
+ wx.hideShareMenu()
267
+
268
+ // 获取国籍
269
+ let pages = getCurrentPages()
270
+ let currentPage = pages[pages.length - 1]
271
+ let hadChoseNation = currentPage.data.hadChoseNation || false
272
+
273
+ if (hadChoseNation) {
274
+ let cid_type = currentPage.data.formData.cid_type
275
+ // 回传数据
276
+ this.reFullFormDataTemp(cid_type)
277
+ }
278
+ },
279
+
280
+ // 三证照:港澳通行证、台湾通行证、华侨护照
281
+ matchOptionsRule () {
282
+ let { cid_type, nation, sbSwitch } = this.data.formData
283
+ Nation = nation
284
+
285
+ if (cid_type === '516' || cid_type === '511' || cid_type === '414') {
286
+ if (nation !== 'CHN' && cid_type === '516') {
287
+ // 港澳通行证-外籍
288
+ this.setData({
289
+ rules: rulesConfig.HMPassRulesForeign('zh_CN')
290
+ })
291
+ } else if (sbSwitch) {
292
+ // 姓名、出生日期必填
293
+ this.setData({
294
+ rules: rulesConfig.HMORulesMore('zh_CN')
295
+ })
296
+ } else {
297
+ // 姓名、出生日期非必填
298
+ this.setData({
299
+ rules: rulesConfig.HMORules('zh_CN')
300
+ })
301
+ }
302
+ console.log('三证照正则', this.data.rules)
303
+ }
304
+ },
305
+
306
+ // 年龄≤18岁或年龄≥60岁的用户
307
+ isCarePeople(age) {
308
+ return age <= 18 || age >= 60
309
+ },
310
+
311
+ /**
312
+ * 获取/设置人脸失败次数
313
+ * @param {*} count
314
+ * count:true 设置次数+1
315
+ * count:false 获取次数
316
+ */
317
+ fetchFaceFailCount(count, errCode) {
318
+ const { id_card_number: cid } = this.data.formData
319
+ const age = utils.parseIDCard(cid).age
320
+ const isKidsOrOld = this.isCarePeople(age) || false
321
+ console.log('获取/设置人脸失败', count)
322
+ console.log('年龄', age)
323
+ console.log('是否是老人/小孩', isKidsOrOld)
324
+
325
+ this.setData({
326
+ isKidsOrOld
327
+ })
328
+
329
+ return new Promise((resolve, reject) => {
330
+ jingtongVerifyRequest.operateFaceFailCount({
331
+ count,
332
+ cid,
333
+ age
334
+ }).then(res => {
335
+ console.log('获取人脸失败次数res', res)
336
+ const times = Number(res.times) || 0
337
+
338
+ // 老人/小孩:累计刷脸失败6次后,弹长窗提示
339
+ if (count && isKidsOrOld && times === 6) {
340
+ console.log('==============老人/小孩 -- 累计刷脸失败6次:弹长窗===============')
341
+ this.setData({
342
+ showFaceModal: true
343
+ })
344
+ }
345
+
346
+ // 成人:累计刷脸失败3次后,弹长窗提示
347
+ if (count && !isKidsOrOld && times === 3) {
348
+ console.log('==============成人 -- 累计刷脸失败3次:弹长窗===============')
349
+ this.setData({
350
+ showFaceModal: true
351
+ })
352
+ }
353
+
354
+ // 老/小18次、成人6次 锁定人脸
355
+ if (isKidsOrOld && times >= 18) {
356
+ console.log('==============老人/小孩 -- 累计刷脸失败18次:弹短窗===============')
357
+ wx.hideLoading()
358
+ this.setData({
359
+ showLockFaceModal: true
360
+ })
361
+ // 人脸识别异常温馨提示弹窗
362
+ count && this.handleFaceError(errCode)
363
+ return
364
+ } else if (!isKidsOrOld && times >= 6) {
365
+ console.log('==============成人 -- 累计刷脸失败6次:弹短窗===============')
366
+ wx.hideLoading()
367
+ this.setData({
368
+ showLockFaceModal: true
369
+ })
370
+ // 人脸识别异常温馨提示弹窗
371
+ count && this.handleFaceError(errCode)
372
+ return
373
+ }
374
+ resolve()
375
+ }).catch(err => {
376
+ console.log(err, '获取人脸失败次数err')
377
+ wx.showToast({
378
+ title: '初始化有误,请稍后再试',
379
+ icon: 'none'
380
+ })
381
+ reject()
382
+ })
383
+ })
384
+ },
385
+
386
+ // 判断是否是PC端登录
387
+ getDevice() {
388
+ return new Promise((resolve, reject) => {
389
+ const systemInfo = wx.getDeviceInfo();
390
+ console.log('systemInfo', systemInfo)
391
+ if (['windows', 'mac'].includes(systemInfo.platform)) {
392
+ console.log('当前为电脑端微信');
393
+ wx.showToast({
394
+ title: '请您使用移动端京通小程序',
395
+ icon: 'none',
396
+ duration: 3000
397
+ })
398
+ return
399
+ } else {
400
+ console.log('当前为手机端');
401
+ resolve()
402
+ }
403
+ })
404
+ },
405
+
406
+ // 根据证件类型匹配校验正则和校验类型
407
+ toMatchRules() {
408
+ let { cid_type, nation, nation_name } = this.data.formData
409
+ let { rules, currentAuthType } = this.data.rulesMap[cid_type]
410
+ console.log('核验源', currentAuthType)
411
+ Nation = nation
412
+ // 默认【中国】
413
+ if (cid_type === '516' || cid_type === '511' || cid_type === '414') {
414
+ nation = 'CHN'
415
+ nation_name = 'CHN-中国'
416
+ }
417
+ this.setData({
418
+ rules,
419
+ currentAuthType,
420
+ 'formData.nation': nation,
421
+ 'formData.nation_name': nation_name,
422
+ }, () => {
423
+ wx.hideLoading()
424
+ })
425
+ console.log('匹配到的正则', rules, currentAuthType)
426
+ },
427
+
428
+ // 选择完国籍或认证失败后回传 -- 回传本地临时存储用户表单信息
429
+ reFullFormDataTemp(cid_type) {
430
+ const formDataTemp = wx.getStorageSync('tif.formDataTemp') || {}
431
+ let formDataOld = this.data.formData
432
+
433
+ if (formDataTemp && formDataTemp[cid_type]) {
434
+ console.log('存在可回填的temp数据', formDataTemp[cid_type])
435
+ let formData = Object.assign(formDataOld, formDataTemp[cid_type])
436
+ Nation = formData.nation
437
+ // 国外护照,回填名字
438
+ if (cid_type === '700') {
439
+ formData.sur_name_en = formData.sur_name
440
+ formData.first_name_en = formData.first_name
441
+ }
442
+ this.setData({
443
+ formData
444
+ })
445
+ }
446
+ // else if (cid_type === '516' && this.data.exitHmSession) {
447
+ // console.log('存在可回显的HM数据', this.data.HmSession)
448
+ // const { star_name, name, star_cid, cid, verify_expire_time, nation } = this.data.HmSession
449
+ // this.setData({
450
+ // 'formData.strName': star_name,
451
+ // 'formData.name': name,
452
+ // 'formData.strCid': star_cid,
453
+ // 'formData.id_card_number': cid,
454
+ // 'formData.verify_expire_time': verify_expire_time || '',
455
+ // 'formData.nation': nation
456
+ // })
457
+ // }
458
+ // 处理三证照的正则问题
459
+ this.matchOptionsRule()
460
+ },
461
+
462
+ // 同意协议和隐私政策
463
+ viewPrivacy(e) {
464
+ // 临时存储表单数据
465
+ this.saveFormDataTemp()
466
+ // 错误触发销毁回调函数处理
467
+ this.handleExitedState()
468
+
469
+ let canOpenPdf = this.data.canOpenPdf
470
+ if (canOpenPdf) {
471
+ this.setData({
472
+ canOpenPdf: false
473
+ })
474
+ let { name, file } = e.currentTarget.dataset
475
+ console.log('文件地址', `https://js.jt.beijing.gov.cn/jt/tiffile/${file}.pdf`)
476
+ utils.openDoc({
477
+ url: `https://js.jt.beijing.gov.cn/jt/tiffile/${file}.pdf`,
478
+ fileType: 'pdf',
479
+ name,
480
+ successFn: () => {
481
+ console.log('文档打开成功回调')
482
+ setTimeout(() => {
483
+ this.setData({
484
+ canOpenPdf: true
485
+ })
486
+ }, 500)
487
+ }
488
+ })
489
+ } else {
490
+ setTimeout(() => {
491
+ this.setData({
492
+ canOpenPdf: true
493
+ })
494
+ }, 3500)
495
+ }
496
+ },
497
+
498
+ // 选择事件
499
+ handleChange(e) {
500
+ let value = e.detail.value
501
+ let formId = e.target.id
502
+
503
+ // 删除前后空格
504
+ if (typeof value === 'string' && formId !== 'cid_type') {
505
+ value = value.trim()
506
+ console.log('==删除前后空格==', value, '==删除前后空格==')
507
+ }
508
+
509
+ let starId = e.target.dataset.star
510
+ // 切换“证件类型”
511
+ let oldCidType = this.data.formData.cid_type
512
+ if (formId === 'cid_type' && oldCidType !== value) {
513
+ cidType = value
514
+ wx.showLoading({
515
+ title: '加载中…',
516
+ })
517
+
518
+ // 若是港澳台,则证件类别默认为居住证核验
519
+ if (value == 17 || value == 18) {
520
+ this.setData({
521
+ currentAuthType: 'faceReceptionAuth',
522
+ rules: rulesConfig.residenceAuthRules('zh_CN')
523
+ })
524
+ }
525
+
526
+ // 语言环境
527
+ this.setData({
528
+ language: value === '700' ? 'en' : 'zh_CN'
529
+ })
530
+
531
+ // 临时存储用户填写的表单信息、是否需要回显
532
+ this.saveFormDataTemp(true, value, oldCidType)
533
+ } else {
534
+ // 临时存储表单数据
535
+ this.saveFormDataTemp()
536
+
537
+ this.setData({
538
+ [`formData.${formId}`]: value
539
+ })
540
+ if (starId) {
541
+ this.setData({
542
+ [`formData.${starId}`]: ''
543
+ })
544
+ }
545
+ if (['sur_name_en', 'first_name_en'].includes(formId)) {
546
+ this.validateFullname()
547
+ }
548
+ }
549
+ },
550
+
551
+ // 临时存储用户填写的表单信息
552
+ saveFormDataTemp(needFull = false, newCidType = '', oldCidType = '') {
553
+ console.log('临时存储用户填写的表单信息', needFull, newCidType, oldCidType)
554
+ let {
555
+ formData
556
+ } = this.data
557
+
558
+ let formDataTemp = wx.getStorageSync('tif.formDataTemp') || {}
559
+ formDataTemp[formData.cid_type] = formData
560
+ wx.setStorageSync('tif.formDataTemp', formDataTemp)
561
+ if (needFull) {
562
+ // 是否需要回传
563
+ Nation = ''
564
+ this.setData({
565
+ formData: {
566
+ cid_type: newCidType,
567
+ name: '',
568
+ id_card_number: '',
569
+ bank_account: '',
570
+ nation: '',
571
+ nation_name: '',
572
+ sur_name: '',
573
+ first_name: '',
574
+ sur_name_en: '',
575
+ first_name_en: '',
576
+ sex: '',
577
+ birthday: '',
578
+ cid_expire_date: '',
579
+ validity_period: '',
580
+ passport_number: '',
581
+ phone: '',
582
+ verify_expire_time: '',
583
+ sbSwitch: true,
584
+ agree: false,
585
+ isbind: 1
586
+ }
587
+ })
588
+ if (newCidType === '700') {
589
+ // 获取外国护照核验结果
590
+ this.fetchPassortAuthResult()
591
+ } else {
592
+ // 回传 Temp => Success => 空
593
+ this.restartInitChange(newCidType)
594
+ }
595
+ wx.hideLoading()
596
+ }
597
+ },
598
+
599
+ // 回传 Temp => Success => 空
600
+ restartInitChange(cid_type) {
601
+ console.log('根据证件类型匹配校验正则,回填本地Temp数据')
602
+ wx.showLoading({
603
+ title: '加载中…',
604
+ })
605
+ // 根据证件类型匹配校验正则
606
+ this.toMatchRules()
607
+ // 数据回传
608
+ this.reFullFormDataTemp(cid_type)
609
+ },
610
+
611
+ // 获取外国人护照核验结果、是否需要返回状态
612
+ fetchPassortAuthResult(needStatus = false) {
613
+ // 根据证件类型匹配校验正则
614
+ !needStatus && this.toMatchRules()
615
+ let formData = this.data.formData
616
+
617
+ return new Promise((resolve) => {
618
+ jingtongVerifyRequest.getPassportInfo({
619
+ success: res => {
620
+ console.log('外国人护照核验接口获取成功', res)
621
+
622
+ this.setData({
623
+ passportAuthStatus: res.status,
624
+ passportAuthPersonCode: res.person_code
625
+ })
626
+
627
+ if (needStatus) {
628
+ // 需要返回状态
629
+ resolve(res.status)
630
+ } else {
631
+ let {
632
+ id_card_number,
633
+ nation,
634
+ sur_name,
635
+ first_name,
636
+ sex,
637
+ birthday,
638
+ cid_expire_date,
639
+ phone,
640
+ verify_expire_time,
641
+ nation_name
642
+ } = res
643
+ let passportOldData = {
644
+ id_card_number,
645
+ nation,
646
+ nation_name,
647
+ sur_name,
648
+ sur_name_en: sur_name,
649
+ first_name,
650
+ first_name_en: first_name,
651
+ sex: sex ? sex : '',
652
+ birthday,
653
+ cid_expire_date,
654
+ phone,
655
+ verify_expire_time: verify_expire_time && Number(verify_expire_time) || ''
656
+ }
657
+ formData = Object.assign(formData, res, passportOldData)
658
+ Nation = nation
659
+ this.setData({
660
+ formData,
661
+ passportOldData
662
+ })
663
+ }
664
+ },
665
+ fail: err => {
666
+ console.log('外国人护照核验接口获取失败', err)
667
+ let { errmsg } = JSON.parse(err)
668
+ wx.showToast({
669
+ title: errmsg || '获取核验信息接口失败',
670
+ icon: 'none',
671
+ duration: 3000
672
+ })
673
+ }
674
+ })
675
+ })
676
+ },
677
+
678
+ // 选择国籍
679
+ handleNationTap() {
680
+ const cid_type = this.data.formData.cid_type
681
+ if (cid_type === '414') {
682
+ // 华侨护照
683
+ return
684
+ }
685
+ // 临时存储表单数据
686
+ this.saveFormDataTemp()
687
+
688
+ flow.navigateTo({
689
+ url: `../nation-list/nation-list?cid_type=${cid_type}`,
690
+ })
691
+ },
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
+
709
+ async handleFormSubmit(e) {
710
+ const formValid = e.detail.validStatus
711
+ const customValid = this.data.language !== 'en' ? { valid: true, msg: '' } : this.validateFullname()
712
+ if (!formValid || !customValid.valid) {
713
+ // 自定义校验字段有问题,获取表单错误列表
714
+ const formErrList = e.detail.value
715
+ // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
716
+ if (!formValid && customValid.valid) {
717
+ this.showCuntomErrTip(formErrList[0].message)
718
+ return
719
+ }
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
731
+ }
732
+ this.showCuntomErrTip(lastMsg)
733
+ return
734
+ }
735
+ wx.showLoading({
736
+ title: '加载中…',
737
+ mask: true
738
+ })
739
+ // 处理参数
740
+ console.log('删除“姓名、证件号码、护照号码、手机号码”的前后空格')
741
+ let { name, id_card_number, sur_name, first_name, passport_number, phone, cid_type } = this.data.formData
742
+ this.setData({
743
+ ['formData.name']: name.trim(),
744
+ ['formData.passport_number']: passport_number.trim(),
745
+ ['formData.phone']: phone.trim()
746
+ })
747
+ if (cid_type === '700') {
748
+ // 外国护照,sur_name和first_name需要特殊处理
749
+ let { sur_name_en, first_name_en } = this.data.formData
750
+ if (sur_name_en == null || sur_name_en === '') {
751
+ sur_name_en = ' '
752
+ } else {
753
+ sur_name = sur_name_en.trim()
754
+ }
755
+ if (first_name_en == null || first_name_en === '') {
756
+ first_name_en = ' '
757
+ } else {
758
+ first_name_en = first_name_en.trim()
759
+ }
760
+ this.setData({
761
+ ['formData.sur_name']: sur_name_en,
762
+ ['formData.first_name']: first_name_en,
763
+ // 删除“外国人护照号码”中间空格
764
+ ['formData.id_card_number']: id_card_number.replace(/\s+/g, '').trim()
765
+ })
766
+ } else {
767
+ this.setData({
768
+ ['formData.sur_name']: sur_name.trim(),
769
+ ['formData.first_name']: first_name.trim(),
770
+ ['formData.id_card_number']: id_card_number.trim()
771
+ })
772
+ }
773
+ console.log('入参', this.data.formData)
774
+
775
+ let currentAuthType = this.data.currentAuthType
776
+ console.log('当前认证类型', currentAuthType)
777
+
778
+ if (currentAuthType === 'wxFace') {
779
+ console.log('微信人脸识别认证')
780
+
781
+ // 判断是否是PC端登录
782
+ await this.getDevice()
783
+
784
+ // 判断人脸失败次数
785
+ await this.fetchFaceFailCount(false)
786
+
787
+ // 错误触发销毁回调函数处理
788
+ this.handleExitedState()
789
+
790
+ // 开启人脸识别认证
791
+ this.toFaceVerify()
792
+ } else if (currentAuthType === 'faceReceptionAuth') {
793
+ console.log('出入境微信人脸识别接口认证')
794
+ // 错误触发销毁回调函数处理
795
+ this.handleExitedState()
796
+
797
+ // 判断是否是PC端登录
798
+ await this.getDevice()
799
+
800
+ // 出入境微信人脸识别接口
801
+ this.toFaceReceptionAuth()
802
+ } else if(currentAuthType === 'cardAuth') {
803
+ console.log('银行卡接口认证')
804
+ // 银行卡身份核验接口
805
+ this.bankCardAuth()
806
+ } else if(currentAuthType === 'ForeignPassortAuth') {
807
+ console.log('外国人护照核验')
808
+ // 外国人护照核验
809
+ this.handlePassortAuth()
810
+ }
811
+ },
812
+
813
+ // 开启人脸识别认证
814
+ async toFaceVerify() {
815
+ const [err, session] = await utils.awaitTo(jingtongVerifyRequest.faceVerifyWithIdCard(this.data.formData))
816
+
817
+ const cidType = this.data.formData.cid_type
818
+
819
+ if (err) {
820
+ // 埋点上报事件:刷脸认证
821
+ this.faceTracker(2, cidType)
822
+
823
+ // 埋点上报事件:自然人登录
824
+ this.loginTracker(3, cidType)
825
+
826
+ console.log('微信人脸识别失败', err)
827
+ let { errmsg, errMsg, errCode } = JSON.parse(err)
828
+ if (errCode) {
829
+ let errCodeArr = [10002, 10003, 10004, 10005, 10012, 10057, 90002, 90003, 90004, 90005, 90006, 90100, 90023, 90024, 90025]
830
+ if (errCodeArr.indexOf(errCode) >= 0) {
831
+ console.log('在指定的错误码范围内,人脸失败次数+1')
832
+ // 设置人脸失败次数
833
+ await this.fetchFaceFailCount(true, errCode)
834
+ }
835
+ // 人脸识别异常温馨提示弹窗
836
+ this.handleFaceError(errCode)
837
+ }
838
+
839
+ if (errCode && errCode === 90100) {
840
+ wx.showToast({
841
+ title: '您已取消人脸识别',
842
+ icon: 'none',
843
+ duration: 3000
844
+ })
845
+ } else if (errCode && errCode === 10004) {
846
+ wx.showToast({
847
+ title: '人脸与身份信息不匹配',
848
+ icon: 'none',
849
+ duration: 3000
850
+ })
851
+ } else if (errCode && errCode === 10003) {
852
+ wx.showToast({
853
+ title: '姓名或证件号码有误',
854
+ icon: 'none',
855
+ duration: 3000
856
+ })
857
+ } else {
858
+ wx.showToast({
859
+ title: errmsg || errMsg || '认证失败,请稍后再试',
860
+ icon: 'none',
861
+ duration: 3000
862
+ })
863
+ }
864
+ } else {
865
+ // 埋点上报事件:刷脸认证
866
+ this.faceTracker(1, cidType)
867
+
868
+ console.log('认证成功返回页面数据:', session)
869
+ // 保存刷脸成功时间戳
870
+ let timeStamp = new Date().getTime()
871
+ wx.setStorageSync('tif.faceTimeStamp', timeStamp)
872
+
873
+ this.authSuccess(session)
874
+ }
875
+ },
876
+
877
+ // 人脸识别异常温馨提示弹窗
878
+ handleFaceError(code) {
879
+ let errCode1 = [10009, 10026, 10032, 10072, 10076, 10084, 10086, 10089, 10092, 10049, 10107, 10095]
880
+ let errCode2 = [10002, 10004, 10005, 10010, 10012, 10027, 10028, 10057]
881
+ if (errCode1.indexOf(code) >= 0) {
882
+ // 1: 未办理过身份证/新办理身份证的
883
+ this.setData({
884
+ faceErrorModal: true,
885
+ faceErrorType: '1'
886
+ })
887
+ } else if (errCode2.indexOf(code) >= 0) {
888
+ const age = utils.parseIDCard(this.data.formData.id_card_number).age
889
+ console.log('年龄', age)
890
+ if (age >= 60) {
891
+ // 3: 刷脸没刷过,60岁以上的
892
+ this.setData({
893
+ faceErrorModal: true,
894
+ faceErrorType: '3'
895
+ })
896
+ } else {
897
+ // 2: 刷脸没刷过,60岁以下的
898
+ this.setData({
899
+ faceErrorModal: true,
900
+ faceErrorType: '2'
901
+ })
902
+ }
903
+ }
904
+ },
905
+
906
+ // 出入境微信人脸识别接口
907
+ async toFaceReceptionAuth() {
908
+ // 临时存储表单数据
909
+ this.saveFormDataTemp()
910
+
911
+ // 数据加密
912
+ const [err, res] = await utils.awaitTo(jingtongVerifyRequest.caEncrypt(this.data.formData))
913
+ if (err) {
914
+ console.log('CA加密失败', err)
915
+ let { errmsg } = JSON.parse(err)
916
+ wx.showToast({
917
+ title: errmsg || 'CA加密失败,请重试',
918
+ icon: 'none',
919
+ duration: 3500
920
+ })
921
+ } else {
922
+ wx.hideLoading()
923
+ console.log('CA加密成功:', res)
924
+ this.toFaceReceptionVerify(res.user_id_key)
925
+ }
926
+ },
927
+
928
+ // 开启出入境微信人脸识别认证
929
+ async toFaceReceptionVerify(userIdKey) {
930
+ const params = Object.assign(this.data.formData, {
931
+ userIdKey
932
+ })
933
+ const { cid_type } = this.data.formData
934
+ const [err, session] = await utils.awaitTo(jingtongVerifyRequest.faceVerifyWithUserIdKey(params))
935
+ if (err) {
936
+ console.log('出入境-微信人脸识别失败', err)
937
+
938
+ // 埋点上报事件:刷脸认证
939
+ this.faceTracker(2, cid_type)
940
+
941
+ // 埋点上报事件:自然人登录
942
+ this.loginTracker(3, cid_type)
943
+
944
+ try {
945
+ let { errmsg = '', errMsg = '', errCode = '' } = JSON.parse(err) || ''
946
+ if (errCode && errCode === 90100) {
947
+ wx.showToast({
948
+ title: '您已取消人脸识别',
949
+ icon: 'none',
950
+ duration: 3000
951
+ })
952
+ } else if (errCode && errCode === 10004) {
953
+ wx.showToast({
954
+ title: '人脸与身份信息不匹配',
955
+ icon: 'none',
956
+ duration: 3000
957
+ })
958
+ } else if (errCode && errCode === 10003) {
959
+ wx.showToast({
960
+ title: '姓名或证件号码有误',
961
+ icon: 'none',
962
+ duration: 3000
963
+ })
964
+ } else if (errCode && errCode === 10111 && (cid_type === '17' || cid_type === '18')) {
965
+ // 若是“港澳台居住证”且错误码是10111,则触发银行卡核验
966
+ this.setData({
967
+ showCardModal: true
968
+ })
969
+ } else {
970
+ wx.showToast({
971
+ title: errmsg || errMsg || '认证失败,请稍后再试',
972
+ icon: 'none',
973
+ duration: 3000
974
+ })
975
+ }
976
+ } catch {
977
+ wx.showToast({
978
+ title: '人脸识别不支持电脑端,请使用真机',
979
+ icon: 'none',
980
+ duration: 3000
981
+ })
982
+ }
983
+ } else {
984
+ // 埋点上报事件:刷脸认证
985
+ this.faceTracker(1, cid_type)
986
+
987
+ console.log('认证成功返回页面数据:', session)
988
+ this.authSuccess(session)
989
+ }
990
+ },
991
+
992
+ // 港澳台居住证核验接口
993
+ async HmtResidenceAuth() {
994
+ const [err, session] = await utils.awaitTo(jingtongVerifyRequest.residenceAuth(this.data.formData))
995
+ if (err) {
996
+ console.log('港澳台居住证核验接口认证失败', err)
997
+ let { errmsg, errcode } = JSON.parse(err)
998
+ if (errcode == 4048) {
999
+ this.setData({
1000
+ showCardModal: true
1001
+ })
1002
+ } else {
1003
+ wx.showToast({
1004
+ title: errmsg || '认证失败',
1005
+ icon: 'none',
1006
+ duration: 3000
1007
+ })
1008
+ }
1009
+ } else {
1010
+ console.log('认证成功返回页面数据:', session)
1011
+ this.authSuccess(session)
1012
+ }
1013
+ },
1014
+
1015
+ // 银行卡身份核验接口
1016
+ async bankCardAuth() {
1017
+ const [err, session] = await utils.awaitTo(jingtongVerifyRequest.bankCardAuth(this.data.formData))
1018
+ if (err) {
1019
+ // 埋点上报事件:自然人登录
1020
+ this.loginTracker(2, this.data.formData.cid_type)
1021
+
1022
+ console.log('银行卡身份核验接口认证失败', err)
1023
+ let { errmsg } = JSON.parse(err)
1024
+ wx.showToast({
1025
+ title: errmsg || '认证失败',
1026
+ icon: 'none',
1027
+ duration: 3000
1028
+ })
1029
+ } else {
1030
+ console.log('认证成功返回页面数据:', session)
1031
+ this.authSuccess(session)
1032
+ }
1033
+ },
1034
+
1035
+ // 外国人护照核验处理逻辑
1036
+ handlePassortAuth() {
1037
+ let authStatus = this.data.passportAuthStatus
1038
+ let newData = this.data.formData
1039
+ let oldData = this.data.passportOldData
1040
+
1041
+ console.log('当前核验单状态', authStatus)
1042
+
1043
+ if (!authStatus) {
1044
+ console.log('无审核单', authStatus)
1045
+ // 外国人护照核验,提交核验单
1046
+ this.passportAuth()
1047
+ } else {
1048
+ // 查上一单的状态
1049
+ this.fetchPassortAuthResult(true).then(status => {
1050
+ console.log('====查上一单的状态====', status)
1051
+ if (status === '1') {
1052
+ // 核验通过,弹窗提示
1053
+ console.log('外国人护照核验通过')
1054
+ this.passportAuthSuccess()
1055
+ } else {
1056
+ // 比对表单数据是否有修改
1057
+ console.log('新旧表单数据比对', newData, oldData)
1058
+ if (utils.objIsEqual(newData, oldData)) {
1059
+ console.log('表单数据没有修改')
1060
+ if (status === '4') {
1061
+ // 核验中
1062
+ this.fetchPassortAuthResult(true).then(status => {
1063
+ console.log('再次获取外国人护照核验状态', status)
1064
+ if (status === '1') {
1065
+ console.log('外国人护照核验通过')
1066
+ this.passportAuthSuccess()
1067
+ } else if (status === '4') {
1068
+ console.log('外国人护照核验中,弹窗提示')
1069
+ this.handleShowModal(status)
1070
+ } else {
1071
+ // 核验不通过,弹窗提示
1072
+ this.passportAuthFail(status)
1073
+ }
1074
+ })
1075
+ } else {
1076
+ // 核验不通过,弹窗提示
1077
+ this.passportAuthFail(status)
1078
+ }
1079
+ } else {
1080
+ console.log('表单数据存在修改')
1081
+ // 外国人护照核验,提交核验单
1082
+ this.passportAuth()
1083
+ }
1084
+ }
1085
+ })
1086
+ }
1087
+ },
1088
+
1089
+ // 外国人护照核验不通过逻辑
1090
+ passportAuthFail(status) {
1091
+ console.log('===外国人护照核验不通过,弹窗提示===')
1092
+ // 判断当前person_code是否已失效
1093
+ const personCode = this.data.passportAuthPersonCode
1094
+ const localPersonCode = wx.getStorageSync('tif.fail.person_code') || ''
1095
+ if (personCode === localPersonCode) {
1096
+ // 提交核验单
1097
+ this.passportAuth()
1098
+ } else {
1099
+ // 埋点上报事件:自然人登录
1100
+ this.loginTracker(2, this.data.formData.cid_type)
1101
+
1102
+ this.handleShowModal(status)
1103
+ // 记录这个person_code是失效的
1104
+ wx.setStorageSync('tif.fail.person_code', this.data.passportAuthPersonCode)
1105
+ }
1106
+ },
1107
+
1108
+ // 外国人护照核验接口
1109
+ async passportAuth() {
1110
+ console.log('===========提交核验单============')
1111
+ let formData = this.data.formData
1112
+
1113
+ const isLegalDate = utils.greaterCurrentTime(formData.cid_expire_date)
1114
+ console.log('isLegalDate', isLegalDate)
1115
+ if (!isLegalDate) {
1116
+ console.log('护照有效期日期不合法')
1117
+ wx.showToast({
1118
+ title: 'Please select the passport expiration date',
1119
+ icon: 'none',
1120
+ duration: 3000
1121
+ })
1122
+ this.setData({
1123
+ 'formData.cid_expire_date': ''
1124
+ })
1125
+ return
1126
+ }
1127
+
1128
+ const [err, res] = await utils.awaitTo(jingtongVerifyRequest.passportAuth(formData))
1129
+ if (err) {
1130
+ console.log('外国人护照核验接口认证失败', err)
1131
+ let { errmsg } = JSON.parse(err)
1132
+ wx.showToast({
1133
+ title: errmsg || '认证失败',
1134
+ icon: 'none',
1135
+ duration: 3000
1136
+ })
1137
+ return
1138
+ }
1139
+ console.log('弹窗提示等待10分钟', res)
1140
+ this.setData({
1141
+ passportAuthStatus: '4',
1142
+ passportOldData: JSON.parse(JSON.stringify(formData)),
1143
+ passportAuthPersonCode: ''
1144
+ })
1145
+ wx.setStorageSync('tif.fail.person_code', '')
1146
+ this.handleShowModal('4')
1147
+ },
1148
+
1149
+ // 外国人护照核验通过
1150
+ passportAuthSuccess() {
1151
+ // 调用删除接口/静默登录并返回session信息
1152
+ jingtongVerifyRequest.deletePassportAuth({
1153
+ success: session => {
1154
+ console.log('返回session信息', session)
1155
+
1156
+ // 删除缓存信息
1157
+ console.log('删除缓存信息')
1158
+ let formDataTemp = wx.getStorageSync('tif.formDataTemp')
1159
+ formDataTemp['700'] = {}
1160
+ wx.setStorageSync('tif.formDataTemp', formDataTemp)
1161
+ this.setData({
1162
+ passportOldData: {}
1163
+ })
1164
+
1165
+ this.authSuccess(session, true)
1166
+ },
1167
+ fail: err => {
1168
+ // 埋点上报事件:自然人登录
1169
+ this.loginTracker(2, this.data.formData.cid_type)
1170
+
1171
+ let { errmsg } = JSON.parse(err)
1172
+ wx.showToast({
1173
+ title: errmsg || 'auth fail',
1174
+ icon: 'none',
1175
+ duration: 3000
1176
+ })
1177
+ }
1178
+ })
1179
+ },
1180
+
1181
+ // 认证成功后续操作
1182
+ authSuccess(session, isEn = false) {
1183
+ console.log('====判断是否真的登录成功=====')
1184
+ if (!session) {
1185
+ wx.showToast({
1186
+ title: '登录态失效,请重试',
1187
+ icon: 'none',
1188
+ duration: 2000
1189
+ })
1190
+ return
1191
+ }
1192
+ const { face_time, realname_time, cid, has_phone, certType } = session
1193
+ if ((!face_time && !realname_time) || !cid) {
1194
+ wx.showToast({
1195
+ title: `登录态失效请重试: ${this.data.formData.cid_type}`,
1196
+ icon: 'none',
1197
+ duration: 2000
1198
+ })
1199
+ return
1200
+ }
1201
+
1202
+ wx.showToast({
1203
+ title: isEn ? 'Verification successful, redirecting...': '验证成功, 跳转中…',
1204
+ icon: 'none',
1205
+ duration: 5000,
1206
+ mask: true
1207
+ })
1208
+
1209
+ const cidType = session.cid_type
1210
+
1211
+ // 本地存储表单核验成功数据
1212
+ wx.setStorageSync('tif.formDataSuccess', this.data.formData)
1213
+
1214
+ // 将弹窗标识设置为不需要弹窗
1215
+ jingtongVerifyRequest.setUserReadStatus(false).then(() => {
1216
+ console.log('设置弹窗标识成功')
1217
+ }).catch(err => {
1218
+ console.log('设置弹窗标识失败', err)
1219
+ })
1220
+
1221
+ setTimeout(() => {
1222
+ if (this.data.needUnite === "true") {
1223
+ // this.setData({
1224
+ // needUnite: ''
1225
+ // })
1226
+
1227
+ console.log('进入业务总入口, 判断是否有手机号码', has_phone)
1228
+
1229
+ // 登录成功回调 => 业务侧操作事项
1230
+ wx.$_ServiceConfiguration && wx.$_ServiceConfiguration.methods && wx.$_ServiceConfiguration.methods._loginSuccessCallBack && wx.$_ServiceConfiguration.methods._loginSuccessCallBack(session)
1231
+
1232
+ if (has_phone) {
1233
+ const realPhone = wx.getStorageSync('tif.realPhone') || ''
1234
+ const caPhone = wx.getStorageSync('tif.caPhone') || ''
1235
+ const confirmTime = wx.getStorageSync('tif.tel_confirm_time') || ''
1236
+
1237
+ console.log('realPhone', realPhone)
1238
+ console.log('caPhone', caPhone)
1239
+ console.log('confirmTime', confirmTime)
1240
+
1241
+ if (realPhone !== caPhone && confirmTime && (!utils.completeDate(new Date(Number(confirmTime + '000')), 6))) {
1242
+ // 埋点上报事件:自然人登录
1243
+ this.loginTracker(1, cidType)
1244
+
1245
+ this.setData({
1246
+ hadSuccessLogin: true
1247
+ })
1248
+
1249
+ // 【phone与caPhone不同】且【tel_confirm_time大于6个月】
1250
+ // 数据库手机号码有效期大于6个月
1251
+ // flow.redirectTo({
1252
+ // url: '../confirm-phone/confirm-phone'
1253
+ // })
1254
+ // 新增逻辑:如果caPhone存在,则跳转原来的逻辑,即换绑手机号,否则跳转绑定手机号
1255
+ if (caPhone == null || caPhone === '') {
1256
+ flow.redirectTo({
1257
+ url: '../bind-phone/bind-phone?source=14'
1258
+ })
1259
+ } else {
1260
+ flow.redirectTo({
1261
+ url: '../confirm-phone/confirm-phone'
1262
+ })
1263
+ }
1264
+ } else {
1265
+ jingtongVerifyRequest.personToken({
1266
+ source: '11'
1267
+ }).then(async data => {
1268
+ // 设置用户账号信息
1269
+ setAccountInfo(session.openid)
1270
+
1271
+ // 埋点上报事件:自然人登录
1272
+ this.loginTracker(1, cidType)
1273
+
1274
+ this.setData({
1275
+ hadSuccessLogin: true
1276
+ })
1277
+
1278
+ // 埋点 - 个人用户实体全属性上报
1279
+ let last_login_time = utils.getCurrentTime()
1280
+ wx.setStorageSync('tif.lastLoginTime', last_login_time)
1281
+ const userEntityReportData = Object.assign(session, {
1282
+ user_status: '1',
1283
+ last_login_time,
1284
+ user_date_of_birth: session.cid_type === '111' ? utils.getBirthByIDCard(session.cid) : ''
1285
+ })
1286
+ await utils.awaitTo(jingtongVerifyRequest.userEntityReport(userEntityReportData))
1287
+
1288
+ setTimeout(() => {
1289
+ flow.resolve({
1290
+ token: data
1291
+ })
1292
+ }, 1200)
1293
+ })
1294
+ }
1295
+ } else {
1296
+ // 埋点上报事件:自然人登录
1297
+ this.loginTracker(1, cidType)
1298
+
1299
+ this.setData({
1300
+ hadSuccessLogin: true
1301
+ })
1302
+
1303
+ flow.redirectTo({
1304
+ url: '../bind-phone/bind-phone?source=3'
1305
+ })
1306
+ }
1307
+ } else {
1308
+ console.log('返回主包')
1309
+ flow.resolve()
1310
+ }
1311
+ }, 800)
1312
+ },
1313
+
1314
+ // 埋点上报事件:刷脸认证
1315
+ faceTracker(recognition_status = 1, cidType) {
1316
+ SDKTrack('face_recognition_login', {
1317
+ recognition_status, // 1: 人脸识别成功 2:人脸识别失败
1318
+ login_certificate: this.data.certTypeMap[cidType] || 1, // 证件类型
1319
+ invoke_location: '' // 调起位置
1320
+ })
1321
+ },
1322
+
1323
+ // 埋点上报事件:自然人登录
1324
+ loginTracker(login_status = 1, cidType) {
1325
+ SDKTrack('nature_person_login', {
1326
+ // 1 登录成功;2 登录失败-身份信息核验失败;3 登录失败-人脸核验失败
1327
+ // 4 登录失败-电子营业执照核验失败;5 登录失败-账号密码输入错误
1328
+ // 6 取消登录(包含点击温馨提示的“取消”,点击请法人登录的×,在登录页面点击左上角返回按钮退出登录)
1329
+ // 7 退出小程序终止登录;old_1 历史数据:除登录成功之外的所有情况
1330
+ login_status,
1331
+ login_certificate: this.data.certTypeMap[cidType] || 1, // 证件类型
1332
+ invoke_location: '', // 调起位置
1333
+ login_validity_period: this.data.formData.verify_expire_time / 24 || '' // 免登录时间
1334
+ })
1335
+ },
1336
+
1337
+ // 显示弹窗
1338
+ handleShowModal(status) {
1339
+ let modalStatus = ''
1340
+ if (status === '3') {
1341
+ // 未找到信息
1342
+ modalStatus = 'warning'
1343
+ } else if (status === '4') {
1344
+ // 核验中
1345
+ modalStatus = 'info'
1346
+ } else {
1347
+ // 信息有误
1348
+ modalStatus = 'error'
1349
+ }
1350
+ this.setData({
1351
+ modalStatus,
1352
+ showModal: true
1353
+ },() => {
1354
+ wx.hideLoading()
1355
+ })
1356
+ },
1357
+
1358
+ // modal确认事件
1359
+ handleModalOk() {
1360
+ // this.fetchPassortAuthResult()
1361
+ this.setData({
1362
+ showModal: false,
1363
+ showFaceModal: false,
1364
+ showLockFaceModal: false,
1365
+ showCardModal: false,
1366
+ showTipModal: false
1367
+ })
1368
+ },
1369
+
1370
+ // 调起银行卡认证
1371
+ toCardAuth() {
1372
+ console.log('====调起银行卡认证====')
1373
+ this.setData({
1374
+ currentAuthType: 'cardAuth',
1375
+ rules: rulesConfig.cardRules('zh_CN'),
1376
+ showCardModal: false
1377
+ })
1378
+ },
1379
+
1380
+ // 触发问号弹出
1381
+ showQuestionTip() {
1382
+ this.setData({
1383
+ showTipModal: true
1384
+ })
1385
+ },
1386
+
1387
+ onUnload: function() {
1388
+ // 页面卸载时的逻辑处理
1389
+ console.log('======页面即将卸载======', this.data.hadSuccessLogin);
1390
+ if (!this.data.hadSuccessLogin) {
1391
+ // 埋点上报事件:自然人登录
1392
+ this.loginTracker(6, this.data.formData.cid_type)
1393
+ }
1394
+ },
1395
+
1396
+ // 有些操作程序会触发销毁回调函数,该操作不是真正的小程序销毁操作
1397
+ handleExitedState() {
1398
+ this.setData({
1399
+ exitedState: false
1400
+ })
1401
+ setTimeout(() => {
1402
+ this.setData({
1403
+ exitedState: true
1404
+ })
1405
+ }, 2000)
1406
+ },
1407
+
1408
+ onSaveExitState: function() {
1409
+ // 小程序可能被销毁之前的逻辑处理
1410
+ if (!this.data.hadSuccessLogin && this.data.exitedState) {
1411
+ console.log('======小程序可能被销毁======')
1412
+ // 埋点上报事件:自然人登录
1413
+ this.loginTracker(7, this.data.formData.cid_type)
1414
+ }
1415
+ },
1416
+
1417
+ // 关闭 - 扫脸失败温馨提示弹窗
1418
+ cancelFaceErrorModal() {
1419
+ this.setData({
1420
+ faceErrorModal: false
1421
+ })
1422
+ },
1423
+
1424
+ // 扫脸失败温馨提示弹窗-跳转到失败原因
1425
+ okFaceErrorModal() {
1426
+ this.setData({
1427
+ faceErrorModal: false
1428
+ })
1429
+ flow.navigateTo({
1430
+ url: `../face-error-reason/face-error-reason?type=${this.data.faceErrorType}`,
1431
+ })
1432
+ },
1433
+
1434
+ openEye(e) {
1435
+ console.log(e)
1436
+ const isOpen = e.detail.isOpen
1437
+ const key = e.currentTarget.id
1438
+ const strKey = e.currentTarget.dataset.star
1439
+ console.log('isOpen', isOpen)
1440
+ console.log('key', key)
1441
+ console.log('strKey', strKey)
1442
+ if (isOpen) {
1443
+ console.log('显示脱敏')
1444
+ const { name, id_card_number } = this.data.formData
1445
+ const value = key === 'name' ? utils.hideName(name) : utils.hideIdCard(id_card_number, '111')
1446
+ console.log('value', value)
1447
+ this.setData({
1448
+ [`formData.${strKey}`]: value
1449
+ })
1450
+ } else {
1451
+ console.log('删除脱敏,显示明文')
1452
+ this.setData({
1453
+ [`formData.${strKey}`]: ''
1454
+ })
1455
+ }
1456
+ },
1457
+
1458
+ handleChangeSwtich(e) {
1459
+ this.setData({
1460
+ ['formData.sbSwitch']: e.detail.value
1461
+ })
1462
+ // 处理三证照的正则问题
1463
+ this.matchOptionsRule()
1464
+ },
1465
+
1466
+ // 隐藏提示
1467
+ closeForeignTip() {
1468
+ wx.setStorageSync('tif.hideForeignTip', '1')
1469
+ this.setData({
1470
+ showForeignTip: false
1471
+ })
1472
+ },
1473
+
1474
+ // 验证sur_name和first_name
1475
+ validateFullname() {
1476
+ const {
1477
+ sur_name_en: sur_name,
1478
+ first_name_en: first_name
1479
+ } = this.data.formData
1480
+ // 两个都没填
1481
+ if ((sur_name == null || sur_name === '') && (first_name == null || first_name === '')) {
1482
+ const msgEmpty = 'Please fill in surname or given name.';
1483
+ this.setData({
1484
+ sur_name_state: {
1485
+ valid: false,
1486
+ msg: msgEmpty
1487
+ },
1488
+ first_name_state: {
1489
+ valid: false,
1490
+ msg: msgEmpty
1491
+ }
1492
+ })
1493
+ return {
1494
+ valid: false,
1495
+ msg: msgEmpty
1496
+ }
1497
+ }
1498
+ this.setData({
1499
+ sur_name_state: {
1500
+ valid: true,
1501
+ msg: ''
1502
+ },
1503
+ first_name_state: {
1504
+ valid: false,
1505
+ msg: ''
1506
+ }
1507
+ })
1508
+ // 其中一个填了,或者两个都填了
1509
+ let sur_name_flag = true
1510
+ let msg = 'Please enter capital letters'
1511
+ if (sur_name != null && sur_name !== '') {
1512
+ const valid = utils.validate.checkName(sur_name, cidType)
1513
+ if (valid.data) {
1514
+ sur_name_flag = true
1515
+ } else {
1516
+ this.setData({
1517
+ sur_name_state: {
1518
+ valid: false,
1519
+ msg
1520
+ }
1521
+ })
1522
+ sur_name_flag = false
1523
+ }
1524
+ }
1525
+ let first_name_flag = true
1526
+ if (first_name != null && first_name !== '') {
1527
+ const valid = utils.validate.checkName(first_name, cidType)
1528
+ if (valid.data) {
1529
+ first_name_flag = true
1530
+ } else {
1531
+ this.setData({
1532
+ first_name_state: {
1533
+ valid: false,
1534
+ msg
1535
+ }
1536
+ })
1537
+ first_name_flag = false
1538
+ }
1539
+ }
1540
+ if (sur_name_flag && first_name_flag) {
1541
+ this.setData({
1542
+ sur_name_state: {
1543
+ valid: true,
1544
+ msg: ''
1545
+ },
1546
+ first_name_state: {
1547
+ valid: false,
1548
+ msg: ''
1549
+ }
1550
+ })
1551
+ }
1552
+ const valid = sur_name_flag && first_name_flag
1553
+ return {
1554
+ valid,
1555
+ msg: valid ? '' : msg
1556
+ }
1557
+ },
1558
+ })