weapps-plugin-jingtong-verify 1.4.6 → 1.4.7

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 (222) hide show
  1. package/app.json +41 -33
  2. package/package.json +20 -20
  3. package/sdk.js +289 -289
  4. package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.js +31 -31
  5. package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.json +3 -3
  6. package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.wxml +9 -9
  7. package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.wxss +65 -65
  8. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.js +41 -0
  9. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.json +4 -0
  10. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.wxml +20 -0
  11. package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.wxss +112 -0
  12. package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.js +37 -37
  13. package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.json +3 -3
  14. package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.wxml +30 -30
  15. package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.wxss +79 -79
  16. package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.js +32 -32
  17. package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.json +3 -3
  18. package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.wxml +16 -16
  19. package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.wxss +57 -57
  20. package/weapps-plugin-jingtong-verify/components/gsd-lib/anim/anim.min.js +1 -1
  21. package/weapps-plugin-jingtong-verify/components/gsd-lib/crypto/crypto.js +37 -37
  22. package/weapps-plugin-jingtong-verify/components/gsd-lib/crypto/index.js +44 -44
  23. package/weapps-plugin-jingtong-verify/components/gsd-lib/dayjs/index.js +351 -351
  24. package/weapps-plugin-jingtong-verify/components/gsd-lib/event/index.js +117 -117
  25. package/weapps-plugin-jingtong-verify/components/gsd-lib/index.js +63 -63
  26. package/weapps-plugin-jingtong-verify/components/gsd-lib/map/index.js +10 -10
  27. package/weapps-plugin-jingtong-verify/components/gsd-lib/map/qmap.js +6 -6
  28. package/weapps-plugin-jingtong-verify/components/gsd-lib/storage/index.js +114 -114
  29. package/weapps-plugin-jingtong-verify/components/gsd-lib/utils/index.js +218 -218
  30. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/formCheck.js +72 -72
  31. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/formController.js +47 -47
  32. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/icon.js +11 -11
  33. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/list.js +16 -16
  34. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/navigator.js +33 -33
  35. package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/primarySecondButton.js +18 -18
  36. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-agree/index.js +12 -12
  37. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-agree/index.json +5 -5
  38. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-agree/index.wxml +15 -15
  39. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.js +47 -47
  40. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.json +3 -3
  41. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.wxml +13 -13
  42. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.js +44 -44
  43. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.json +5 -5
  44. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.wxml +28 -28
  45. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.js +30 -30
  46. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.json +6 -6
  47. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.wxml +42 -42
  48. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.wxss +1 -1
  49. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.js +418 -418
  50. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.json +5 -5
  51. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.wxml +29 -29
  52. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.js +11 -11
  53. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.json +3 -3
  54. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.wxml +4 -4
  55. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.js +182 -179
  56. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.json +6 -6
  57. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.wxml +16 -16
  58. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.js +92 -92
  59. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.json +6 -6
  60. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.wxml +12 -12
  61. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.wxss +2 -2
  62. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.js +49 -49
  63. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.json +3 -3
  64. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.wxml +14 -14
  65. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.js +33 -33
  66. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.json +3 -3
  67. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.wxml +2 -2
  68. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.js +108 -108
  69. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.json +6 -6
  70. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.wxml +53 -53
  71. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.js +241 -236
  72. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.json +8 -8
  73. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.wxml +49 -49
  74. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.js +328 -328
  75. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.json +6 -6
  76. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.wxml +26 -26
  77. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.js +159 -159
  78. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.json +3 -3
  79. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.wxml +10 -10
  80. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.js +112 -112
  81. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.json +5 -5
  82. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.wxml +21 -21
  83. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.js +21 -21
  84. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.json +7 -7
  85. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.wxml +16 -16
  86. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.js +50 -50
  87. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.json +5 -5
  88. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.wxml +27 -27
  89. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/add.svg +13 -13
  90. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/arrow.svg +14 -14
  91. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/delete.svg +16 -16
  92. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/preview.svg +21 -21
  93. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/user.svg +13 -13
  94. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-agree.wxss +147 -147
  95. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-badge.wxss +41 -41
  96. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-button-group.wxss +244 -244
  97. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-cell.wxss +220 -220
  98. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-dropdown.wxss +115 -115
  99. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form-cell.wxss +101 -101
  100. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form-item.wxss +174 -174
  101. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form.wxss +101 -101
  102. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-icon.wxss +268 -268
  103. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-index-list.wxss +206 -206
  104. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-input.wxss +214 -206
  105. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-picker.wxss +139 -139
  106. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-popover.wxss +129 -129
  107. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-search.wxss +171 -171
  108. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-switch.wxss +176 -176
  109. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-tips.wxss +173 -173
  110. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/icon/iconfont.wxss +160 -160
  111. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/main.wxss +283 -283
  112. package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/helper.js +55 -55
  113. package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/validType.js +117 -117
  114. package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/validator.js +106 -106
  115. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.js +32 -32
  116. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.json +3 -3
  117. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.wxml +8 -8
  118. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.wxss +57 -57
  119. package/weapps-plugin-jingtong-verify/components/modal/modal.js +32 -32
  120. package/weapps-plugin-jingtong-verify/components/modal/modal.json +3 -3
  121. package/weapps-plugin-jingtong-verify/components/modal/modal.wxml +28 -28
  122. package/weapps-plugin-jingtong-verify/components/modal/modal.wxss +84 -84
  123. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.js +82 -82
  124. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.json +3 -3
  125. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.wxml +18 -18
  126. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.wxss +72 -72
  127. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.js +47 -39
  128. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.json +3 -3
  129. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.wxml +11 -9
  130. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.wxss +51 -51
  131. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.js +73 -0
  132. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.json +4 -0
  133. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.wxml +19 -0
  134. package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.wxss +72 -0
  135. package/weapps-plugin-jingtong-verify/i18n/index.js +7 -7
  136. package/weapps-plugin-jingtong-verify/i18n/logout.js +10 -10
  137. package/weapps-plugin-jingtong-verify/i18n/rules.js +374 -262
  138. package/weapps-plugin-jingtong-verify/images/bank-card-verify.png +0 -0
  139. package/weapps-plugin-jingtong-verify/images/chek_right.png +0 -0
  140. package/weapps-plugin-jingtong-verify/images/chevron-down.png +0 -0
  141. package/weapps-plugin-jingtong-verify/images/chevron-up.png +0 -0
  142. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.js +488 -0
  143. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.json +7 -0
  144. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.wxml +73 -0
  145. package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.wxss +205 -0
  146. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.js +1218 -0
  147. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.json +10 -0
  148. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.wxml +254 -0
  149. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.wxss +389 -0
  150. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-sms-setting/bank-card-login-forgot-sms-setting.js +66 -0
  151. package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-sms-setting/bank-card-login-forgot-sms-setting.wxml +2 -0
  152. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.js +461 -0
  153. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.json +8 -0
  154. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.wxml +67 -0
  155. package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.wxss +231 -0
  156. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.js +477 -0
  157. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.json +12 -0
  158. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.wxml +120 -0
  159. package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.wxss +217 -0
  160. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.js +86 -86
  161. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.json +6 -6
  162. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.wxml +20 -20
  163. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.wxss +51 -51
  164. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.js +167 -167
  165. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.json +3 -3
  166. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.wxml +30 -30
  167. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.wxss +91 -91
  168. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.js +79 -79
  169. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.json +5 -5
  170. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.wxml +19 -19
  171. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.wxss +44 -44
  172. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.js +1687 -1548
  173. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.json +17 -17
  174. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.wxml +516 -504
  175. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.wxss +185 -133
  176. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.js +127 -127
  177. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.json +5 -5
  178. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.wxml +36 -36
  179. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.wxss +60 -60
  180. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.js +147 -0
  181. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.json +4 -0
  182. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.wxml +48 -0
  183. package/weapps-plugin-jingtong-verify/pages/login-help/login-help.wxss +166 -0
  184. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.js +106 -106
  185. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.json +3 -3
  186. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.wxml +29 -29
  187. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.wxss +68 -68
  188. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.js +156 -0
  189. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.json +4 -0
  190. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.wxml +19 -0
  191. package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.wxss +69 -0
  192. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.js +24 -24
  193. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.json +3 -3
  194. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.wxml +12 -12
  195. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.wxss +33 -33
  196. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.js +110 -110
  197. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.json +6 -6
  198. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.wxml +9 -9
  199. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.wxss +1 -1
  200. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.js +854 -854
  201. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.json +11 -11
  202. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.wxml +162 -162
  203. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.wxss +64 -64
  204. package/weapps-plugin-jingtong-verify/pages/setting/setting.js +331 -328
  205. package/weapps-plugin-jingtong-verify/pages/setting/setting.json +5 -5
  206. package/weapps-plugin-jingtong-verify/pages/setting/setting.wxml +91 -91
  207. package/weapps-plugin-jingtong-verify/pages/setting/setting.wxss +69 -69
  208. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.js +306 -306
  209. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.json +7 -7
  210. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.wxml +142 -142
  211. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.wxss +110 -110
  212. package/weapps-plugin-jingtong-verify/style/page.wxss +13 -13
  213. package/weapps-plugin-jingtong-verify/utils/QDTrackerNew/QDTracker.js +15 -15
  214. package/weapps-plugin-jingtong-verify/utils/QDTrackerNew/QDTrackerMain.js +59 -59
  215. package/weapps-plugin-jingtong-verify/utils/constantVal.js +75 -0
  216. package/weapps-plugin-jingtong-verify/utils/country.js +209 -209
  217. package/weapps-plugin-jingtong-verify/utils/index.js +306 -306
  218. package/weapps-plugin-jingtong-verify/utils/jsencrypt.min.js +1 -1
  219. package/weapps-plugin-jingtong-verify/utils/request.js +604 -1
  220. package/weapps-plugin-jingtong-verify/utils/rules.js +387 -301
  221. package/weapps-plugin-jingtong-verify/utils/tifadmin_config.js +61 -61
  222. package/weapps-plugin-jingtong-verify/utils/validate.js +894 -772
@@ -1,855 +1,855 @@
1
- // weapps-plugin-jingtong-verify/pages/face-verify/index.js
2
- const jingtongVerifyRequest = require('../../utils/request')
3
- const utils = require("../../utils/index")
4
- const {
5
- flow
6
- } = require("@wecity/weda-plugin-utils");
7
- const rulesConfig = require("../../utils/rules")
8
- import {
9
- SDKTrack,
10
- setAccountInfo
11
- } from '../../utils/QDTrackerNew/QDTrackerMain'
12
- let cidType = '700'
13
-
14
- Page({
15
- /**
16
- * 页面的初始数据
17
- */
18
- data: {
19
- language: 'en', // 语言环境:英文
20
- formData: {
21
- cid_type: '700', // 证件类型
22
- id_card_number: '',
23
- nation: '', // 国籍
24
- nation_name: '',
25
- sur_name: '', // 姓
26
- first_name: '', // 名
27
- sex: '', // 性别
28
- birthday: '', // 出生日期
29
- cid_expire_date: '', // 护照有效期
30
- phone: '',
31
- verify_expire_time: '', // 登录有效期
32
- agree: false,
33
- isbind: 1
34
- },
35
- needUnite: '', // 是否需要串联起来
36
- cidTypeRange: [{
37
- name: 'International passport',
38
- value: '700'
39
- } // 外国护照
40
- ],
41
- sexRange: [{
42
- name: 'Male',
43
- value: 1
44
- },
45
- {
46
- name: 'Female',
47
- value: 2
48
- }
49
- ],
50
- loginTimeRangeEn: [{
51
- name: 'Keep me logged in for 1 day',
52
- value: 24
53
- },
54
- {
55
- name: 'Keep me logged in for 7 days',
56
- value: 168
57
- },
58
- {
59
- name: 'Keep me logged in for 30 days',
60
- value: 720
61
- }
62
- ],
63
- validateType: {
64
- id_card_number(value) {
65
- return utils.validate.checkCid(value, cidType).data
66
- },
67
- // surName(value) {
68
- // return utils.validate.checkName(value, cidType).data
69
- // },
70
- // firstName(value) {
71
- // return utils.validate.checkName(value, cidType).data
72
- // }
73
- },
74
- rules: rulesConfig.ForeignPassortRules('en'),
75
- // 打开文档的防抖操作
76
- canOpenPdf: true,
77
- // 外国人护照核验状态 '1'(通过) '4'(审核中) ''(无审核单) 其它值(审核失败)
78
- passportAuthStatus: '',
79
- passportAuthPersonCode: '',
80
- // 核验单数据
81
- passportOldData: {},
82
- // 弹窗
83
- showModal: false,
84
- modalStatus: 'info',
85
- // 定义日期边界值
86
- birthdayMaxDate: [new Date().getFullYear(), (new Date().getMonth() + 1), new Date().getDate()],
87
- cidExpireMinDate: [new Date().getFullYear(), (new Date().getMonth() + 1), new Date().getDate()],
88
- // cidType转化为certType
89
- certTypeMap: {
90
- '111': 1,
91
- '516': 78,
92
- '511': 4,
93
- '17': 5,
94
- '18': 6,
95
- '414': 2,
96
- '553': 9,
97
- '700': 3
98
- },
99
- // 记录是否已经登录成功
100
- hadSuccessLogin: false,
101
- // 该操作会触发小程序的销毁回调
102
- exitedState: true,
103
- // surname自定义校验状态,傻逼数广傻逼组件逼的
104
- sur_name_state: {
105
- valid: true,
106
- msg: ''
107
- },
108
- // givenName自定义校验状态,傻逼数广傻逼组件逼的
109
- first_name_state: {
110
- valid: true,
111
- msg: ''
112
- },
113
- showCustomTips: false,
114
- customTipsMsg: ''
115
- },
116
-
117
- // 验证sur_name和first_name
118
- validateFullname() {
119
- const {
120
- sur_name,
121
- first_name
122
- } = this.data.formData
123
- // 两个都没填
124
- if ((sur_name == null || sur_name === '') && (first_name == null || first_name === '')) {
125
- const msgEmpty = 'Please fill in surname or given name.';
126
- this.setData({
127
- sur_name_state: {
128
- valid: false,
129
- msg: msgEmpty
130
- },
131
- first_name_state: {
132
- valid: false,
133
- msg: msgEmpty
134
- }
135
- })
136
- return {
137
- valid: false,
138
- msg: msgEmpty
139
- }
140
- }
141
- this.setData({
142
- sur_name_state: {
143
- valid: true,
144
- msg: ''
145
- },
146
- first_name_state: {
147
- valid: false,
148
- msg: ''
149
- }
150
- })
151
- // 其中一个填了,或者两个都填了
152
- let sur_name_flag = true
153
- let msg = 'Please enter capital letters'
154
- if (sur_name != null && sur_name !== '') {
155
- const valid = utils.validate.checkName(sur_name, cidType)
156
- if (valid.data) {
157
- sur_name_flag = true
158
- } else {
159
- this.setData({
160
- sur_name_state: {
161
- valid: false,
162
- msg
163
- }
164
- })
165
- sur_name_flag = false
166
- }
167
- }
168
- let first_name_flag = true
169
- if (first_name != null && first_name !== '') {
170
- const valid = utils.validate.checkName(first_name, cidType)
171
- if (valid.data) {
172
- first_name_flag = true
173
- } else {
174
- this.setData({
175
- first_name_state: {
176
- valid: false,
177
- msg
178
- }
179
- })
180
- first_name_flag = false
181
- }
182
- }
183
- if (sur_name_flag && first_name_flag) {
184
- this.setData({
185
- sur_name_state: {
186
- valid: true,
187
- msg: ''
188
- },
189
- first_name_state: {
190
- valid: false,
191
- msg: ''
192
- }
193
- })
194
- }
195
- const valid = sur_name_flag && first_name_flag
196
- return {
197
- valid,
198
- msg: valid ? '' : msg
199
- }
200
- },
201
-
202
- // 自定义change事件,sur_name和first_name专用
203
- handleCustomChange(e) {
204
- let value = e.detail.value
205
- let field = e.target.id
206
- // 删除前后空格
207
- if (typeof value === 'string') {
208
- value = value.trim()
209
- }
210
- this.setData({
211
- [`formData.${field}`]: value,
212
- })
213
- // 临时存储表单数据
214
- this.saveFormDataTemp()
215
- this.validateFullname()
216
- },
217
-
218
- // 关闭提示条
219
- handleTipsClose(e) {
220
- this.setData({
221
- showCustomTips: e.detail.isShow
222
- });
223
- },
224
-
225
- /**
226
- * 生命周期函数--监听页面加载
227
- */
228
- onLoad(options) {
229
- console.log('onLoad', options)
230
- // 设置用户账号信息
231
- setAccountInfo(wx.getStorageSync('tif.openid'))
232
-
233
- this.setData({
234
- needUnite: options.needUnite || 'true'
235
- })
236
-
237
- // 清空本地Temp数据
238
- wx.setStorageSync('tif.formDataTemp', '')
239
-
240
- // 获取外国护照核验结果
241
- this.fetchPassortAuthResult()
242
- },
243
-
244
- // 生命周期函数--监听页面显示
245
- onShow: function () {
246
- wx.hideShareMenu()
247
-
248
- // 获取国籍
249
- let pages = getCurrentPages()
250
- let currentPage = pages[pages.length - 1]
251
- let hadChoseNation = currentPage.data.hadChoseNation || false
252
-
253
- if (hadChoseNation) {
254
- let cid_type = currentPage.data.formData.cid_type
255
- // 回传数据
256
- this.reFullFormDataTemp(cid_type)
257
- }
258
- },
259
-
260
- // 选择完国籍或认证失败后回传 -- 回传本地临时存储用户表单信息
261
- reFullFormDataTemp(cid_type) {
262
- const formDataTemp = wx.getStorageSync('tif.formDataTemp') || {}
263
- let formDataOld = this.data.formData
264
-
265
- if (formDataTemp && formDataTemp[cid_type]) {
266
- console.log('存在可回填的temp数据', formDataTemp[cid_type])
267
- let formData = Object.assign(formDataOld, formDataTemp[cid_type])
268
- this.setData({
269
- formData
270
- }, () => {
271
- wx.hideLoading()
272
- })
273
- }
274
- },
275
-
276
- // 同意协议和隐私政策
277
- viewPrivacy(e) {
278
- // 错误触发销毁回调函数处理
279
- this.handleExitedState()
280
-
281
- // 临时存储表单数据
282
- this.saveFormDataTemp()
283
-
284
- let canOpenPdf = this.data.canOpenPdf
285
- if (canOpenPdf) {
286
- this.setData({
287
- canOpenPdf: false
288
- })
289
- let {
290
- name,
291
- file
292
- } = e.currentTarget.dataset
293
- console.log('文件地址', `https://js.jt.beijing.gov.cn/jt/tiffile/${file}.pdf`)
294
- utils.openDoc({
295
- url: `https://js.jt.beijing.gov.cn/jt/tiffile/${file}.pdf`,
296
- fileType: 'pdf',
297
- name,
298
- successFn: () => {
299
- console.log('文档打开成功回调')
300
- setTimeout(() => {
301
- this.setData({
302
- canOpenPdf: true
303
- })
304
- }, 500)
305
- }
306
- })
307
- } else {
308
- setTimeout(() => {
309
- this.setData({
310
- canOpenPdf: true
311
- })
312
- }, 3500)
313
- }
314
- },
315
-
316
- // 选择事件
317
- handleChange(e) {
318
- let value = e.detail.value
319
- let formId = e.target.id
320
-
321
- // 删除前后空格
322
- if (typeof value === 'string' && formId !== 'cid_type') {
323
- value = value.trim()
324
- }
325
-
326
- this.setData({
327
- [`formData.${formId}`]: value,
328
- })
329
- // 临时存储表单数据
330
- this.saveFormDataTemp()
331
- },
332
-
333
- // 临时存储用户填写的表单信息
334
- saveFormDataTemp() {
335
- let {
336
- formData
337
- } = this.data
338
-
339
- let formDataTemp = wx.getStorageSync('tif.formDataTemp') || {}
340
- formDataTemp['700'] = formData
341
- wx.setStorageSync('tif.formDataTemp', formDataTemp)
342
- },
343
-
344
- // 获取外国人护照核验结果、是否需要返回状态
345
- fetchPassortAuthResult(needStatus = false) {
346
- let formData = this.data.formData
347
-
348
- return new Promise((resolve) => {
349
- jingtongVerifyRequest.getPassportInfo({
350
- success: res => {
351
- console.log('外国人护照核验接口获取成功', res)
352
- this.setData({
353
- passportAuthStatus: res.status,
354
- passportAuthPersonCode: res.person_code
355
- })
356
-
357
- if (needStatus) {
358
- // 需要返回状态
359
- resolve(res.status)
360
- } else {
361
- let {
362
- id_card_number,
363
- nation,
364
- sur_name,
365
- first_name,
366
- sex,
367
- birthday,
368
- cid_expire_date,
369
- phone,
370
- verify_expire_time,
371
- nation_name
372
- } = res
373
- let passportOldData = {
374
- id_card_number,
375
- nation,
376
- nation_name,
377
- sur_name,
378
- first_name,
379
- sex: sex ? sex : '',
380
- birthday,
381
- cid_expire_date,
382
- phone,
383
- verify_expire_time: verify_expire_time && Number(verify_expire_time) || ''
384
- }
385
- formData = Object.assign(formData, res, passportOldData)
386
- this.setData({
387
- formData,
388
- passportOldData
389
- })
390
- }
391
- },
392
- fail: err => {
393
- console.log('外国人护照核验接口获取失败', err)
394
- let {
395
- errmsg
396
- } = JSON.parse(err)
397
- wx.showToast({
398
- title: errmsg || '获取核验信息接口失败',
399
- icon: 'none',
400
- duration: 3000
401
- })
402
- }
403
- })
404
- })
405
- },
406
-
407
- // 选择国籍
408
- handleNationTap() {
409
- // 临时存储表单数据
410
- this.saveFormDataTemp()
411
- flow.navigateTo({
412
- url: `../nation-list/nation-list?cid_type=700`,
413
- })
414
- },
415
-
416
- // 显示自定义校验错误提示
417
- showCuntomErrTip(msg) {
418
- this.setData({
419
- showCustomTips: true,
420
- customTipsMsg: msg
421
- }, () => {
422
- // 3秒后关闭
423
- setTimeout(() => {
424
- this.setData({
425
- showCustomTips: false,
426
- customTipsMsg: ''
427
- });
428
- }, 3500);
429
- })
430
- },
431
-
432
- async handleFormSubmit(e) {
433
- const formValid = e.detail.validStatus
434
- const customValid = this.validateFullname()
435
- if (!e.detail.validStatus || !customValid.valid) {
436
- // 自定义校验字段有问题,获取表单错误列表
437
- const formErrList = e.detail.value
438
- // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
439
- if (!formValid && customValid.valid) {
440
- this.showCuntomErrTip(formErrList[0].message)
441
- return
442
- }
443
- // 如果表单校验没有问题,自定义校验有问题,则显示自定义校验错误提示
444
- if (formValid && !customValid.valid) {
445
- this.showCuntomErrTip(customValid.msg)
446
- return
447
- }
448
- // 如果两者都有问题,则判断显示谁
449
- let lastMsg = ''
450
- if (formErrList.some(i => ["id_card_number", "nation"].includes(i.name))) {
451
- lastMsg = formErrList[0].message
452
- } else {
453
- lastMsg = customValid.msg
454
- }
455
- this.showCuntomErrTip(lastMsg)
456
- return
457
- }
458
- this.setData({
459
- showCustomTips: false,
460
- customTipsMsg: ''
461
- })
462
- wx.showLoading({
463
- title: '加载中…',
464
- mask: true
465
- })
466
-
467
- console.log('删除“姓名、证件号码、护照号码、手机号码”的前后空格')
468
- let {
469
- id_card_number,
470
- sur_name,
471
- first_name,
472
- phone,
473
- cid_type
474
- } = this.data.formData
475
- // sur_name值为空,增加空格
476
- if (sur_name == null || sur_name === '') {
477
- sur_name = ' '
478
- } else {
479
- sur_name = sur_name.trim()
480
- }
481
- // first_name值为空,增加空格
482
- if (first_name == null || first_name === '') {
483
- first_name = ' '
484
- } else {
485
- first_name = first_name.trim()
486
- }
487
- this.setData({
488
- ['formData.sur_name']: sur_name,
489
- ['formData.first_name']: first_name,
490
- ['formData.phone']: phone.trim()
491
- })
492
-
493
- if (cid_type === '700') {
494
- console.log('删除“外国人护照号码”中间空格')
495
- this.setData({
496
- ['formData.id_card_number']: id_card_number.replace(/\s+/g, '')
497
- })
498
- }
499
- console.log('入参', this.data.formData)
500
-
501
- console.log('外国人护照核验')
502
- // 外国人护照核验
503
- this.handlePassortAuth()
504
- },
505
-
506
- // 外国人护照核验处理逻辑
507
- handlePassortAuth() {
508
- let authStatus = this.data.passportAuthStatus
509
- let newData = this.data.formData
510
- let oldData = this.data.passportOldData
511
- console.log('当前核验单状态', authStatus)
512
-
513
- if (!authStatus) {
514
- console.log('无审核单', authStatus)
515
- // 外国人护照核验,提交核验单
516
- this.passportAuth()
517
- } else {
518
- // 查上一单的状态
519
- this.fetchPassortAuthResult(true).then(status => {
520
- console.log('====查上一单的状态====', status)
521
- if (status === '1') {
522
- // 核验通过,弹窗提示
523
- console.log('外国人护照核验通过')
524
- this.passportAuthSuccess()
525
- } else {
526
- // 比对表单数据是否有修改
527
- console.log('新旧表单数据比对', newData, oldData)
528
- if (utils.objIsEqual(newData, oldData)) {
529
- console.log('表单数据没有修改')
530
- if (status === '4') {
531
- // 核验中
532
- this.fetchPassortAuthResult(true).then(status => {
533
- console.log('再次获取外国人护照核验状态', status)
534
- if (status === '1') {
535
- console.log('外国人护照核验通过')
536
- this.passportAuthSuccess()
537
- } else if (status === '4') {
538
- console.log('外国人护照核验中,弹窗提示')
539
- this.handleShowModal(status)
540
- } else {
541
- // 核验不通过,弹窗提示
542
- this.passportAuthFail(status)
543
- }
544
- })
545
- } else {
546
- // 核验不通过,弹窗提示
547
- this.passportAuthFail(status)
548
- }
549
- } else {
550
- console.log('表单数据存在修改')
551
- // 外国人护照核验,提交核验单
552
- this.passportAuth()
553
- }
554
- }
555
- })
556
- }
557
- },
558
-
559
- // 外国人护照核验不通过逻辑
560
- passportAuthFail(status) {
561
- console.log('===外国人护照核验不通过,弹窗提示===')
562
- // 判断当前person_code是否已失效
563
- const personCode = this.data.passportAuthPersonCode
564
- const localPersonCode = wx.getStorageSync('tif.fail.person_code') || ''
565
- if (personCode === localPersonCode) {
566
- // 提交核验单
567
- this.passportAuth()
568
- } else {
569
- // 埋点上报事件:自然人登录
570
- this.loginTracker(2, this.data.formData.cid_type)
571
-
572
- this.handleShowModal(status)
573
- // 记录这个person_code是失效的
574
- wx.setStorageSync('tif.fail.person_code', this.data.passportAuthPersonCode)
575
- }
576
- },
577
-
578
- // 外国人护照核验接口
579
- async passportAuth() {
580
- console.log('===========提交核验单============')
581
- let formData = this.data.formData
582
-
583
- const isLegalDate = utils.greaterCurrentTime(formData.cid_expire_date)
584
- console.log('isLegalDate', isLegalDate)
585
- if (!isLegalDate) {
586
- console.log('护照有效期日期不合法')
587
- wx.showToast({
588
- title: 'Please select the passport expiration date',
589
- icon: 'none',
590
- duration: 3000
591
- })
592
- this.setData({
593
- 'formData.cid_expire_date': ''
594
- })
595
- return
596
- }
597
-
598
- const [err, res] = await utils.awaitTo(jingtongVerifyRequest.passportAuth(formData))
599
- if (err) {
600
- console.log('外国人护照核验接口认证失败', err)
601
- let {
602
- errmsg
603
- } = JSON.parse(err)
604
- wx.showToast({
605
- title: errmsg || '认证失败',
606
- icon: 'none',
607
- duration: 3000
608
- })
609
- return
610
- }
611
- console.log('弹窗提示等待1分钟', res)
612
- this.setData({
613
- passportAuthStatus: '4',
614
- passportOldData: JSON.parse(JSON.stringify(formData)),
615
- passportAuthPersonCode: ''
616
- })
617
- wx.setStorageSync('tif.fail.person_code', '')
618
- this.handleShowModal('4')
619
- },
620
-
621
- // 外国人护照核验通过
622
- passportAuthSuccess() {
623
- // 调用删除接口/静默登录并返回session信息
624
- jingtongVerifyRequest.deletePassportAuth({
625
- success: session => {
626
- console.log('返回session信息', session)
627
-
628
- // 删除缓存信息
629
- console.log('删除缓存信息')
630
- let formDataTemp = wx.getStorageSync('tif.formDataTemp')
631
- formDataTemp['700'] = {}
632
- wx.setStorageSync('tif.formDataTemp', formDataTemp)
633
- this.setData({
634
- passportOldData: {}
635
- })
636
-
637
- this.authSuccess(session, true)
638
- },
639
- fail: err => {
640
- // 埋点上报事件:自然人登录
641
- this.loginTracker(2, this.data.formData.cid_type)
642
-
643
- let {
644
- errmsg
645
- } = JSON.parse(err)
646
- wx.showToast({
647
- title: errmsg || 'auth fail',
648
- icon: 'none',
649
- duration: 3000
650
- })
651
- }
652
- })
653
- },
654
-
655
- // 认证成功后续操作
656
- authSuccess(session, isEn = false) {
657
- console.log('====判断是否真的登录成功=====')
658
- if (!session) {
659
- wx.showToast({
660
- title: 'Login has expired, please log in again',
661
- icon: 'none',
662
- duration: 3000
663
- })
664
- return
665
- }
666
-
667
- const {
668
- face_time,
669
- realname_time,
670
- cid,
671
- has_phone,
672
- certType
673
- } = session
674
- if ((!face_time && !realname_time) || !cid) {
675
- wx.showToast({
676
- title: `Login has expired, please log in again: ${this.data.formData.cid_type}`,
677
- icon: 'none',
678
- duration: 2000
679
- })
680
- return
681
- }
682
-
683
- wx.showToast({
684
- title: isEn ? 'Verification successful, redirecting...' : '验证成功, 跳转中…',
685
- icon: 'none',
686
- duration: 5000,
687
- mask: true
688
- })
689
-
690
- const cidType = session.cid_type
691
-
692
- // 本地存储表单核验成功数据
693
- wx.setStorageSync('tif.formDataSuccess', this.data.formData)
694
-
695
- // 将弹窗标识设置为不需要弹窗
696
- jingtongVerifyRequest.setUserReadStatus(false).then(() => {
697
- console.log('设置弹窗标识成功')
698
- }).catch(err => {
699
- console.log('设置弹窗标识失败', err)
700
- })
701
-
702
- setTimeout(() => {
703
- if (this.data.needUnite === "true") {
704
- console.log('进入业务总入口, 判断是否有手机号码', has_phone)
705
- // this.setData({
706
- // needUnite: ''
707
- // })
708
-
709
- // 登录成功回调 => 业务侧操作事项
710
- wx.$_ServiceConfiguration && wx.$_ServiceConfiguration.methods && wx.$_ServiceConfiguration.methods._loginSuccessCallBack && wx.$_ServiceConfiguration.methods._loginSuccessCallBack(session)
711
-
712
- if (has_phone) {
713
- const realPhone = wx.getStorageSync('tif.realPhone') || ''
714
- const caPhone = wx.getStorageSync('tif.caPhone') || ''
715
- const confirmTime = wx.getStorageSync('tif.tel_confirm_time') || ''
716
-
717
- console.log('realPhone', realPhone)
718
- console.log('caPhone', caPhone)
719
- console.log('confirmTime', confirmTime)
720
-
721
- if (realPhone !== caPhone && confirmTime && (!utils.completeDate(new Date(Number(confirmTime + '000')), 6))) {
722
- // 埋点上报事件:自然人登录
723
- this.loginTracker(1, cidType)
724
-
725
- this.setData({
726
- hadSuccessLogin: true
727
- })
728
-
729
- // 【phone与caPhone不同】且【tel_confirm_time大于6个月】
730
- // 数据库手机号码有效期大于6个月
731
- flow.redirectTo({
732
- url: '../confirm-phone/confirm-phone'
733
- })
734
- } else {
735
- jingtongVerifyRequest.personToken({
736
- source: '12'
737
- }).then(async data => {
738
- // 设置用户账号信息
739
- setAccountInfo(session.openid)
740
-
741
- // 埋点上报事件:自然人登录
742
- this.loginTracker(1, cidType)
743
-
744
- this.setData({
745
- hadSuccessLogin: true
746
- })
747
-
748
- // 埋点 - 个人用户实体全属性上报
749
- let last_login_time = utils.getCurrentTime()
750
- wx.setStorageSync('tif.lastLoginTime', last_login_time)
751
- const userEntityReportData = Object.assign(session, {
752
- user_status: '1',
753
- last_login_time,
754
- user_date_of_birth: session.cid_type === '111' ? utils.getBirthByIDCard(session.cid) : ''
755
- })
756
- await utils.awaitTo(jingtongVerifyRequest.userEntityReport(userEntityReportData))
757
-
758
- setTimeout(() => {
759
- flow.resolve({
760
- token: data
761
- })
762
- }, 1200)
763
- })
764
- }
765
- } else {
766
- // 埋点上报事件:自然人登录
767
- this.loginTracker(1, cidType)
768
-
769
- this.setData({
770
- hadSuccessLogin: true
771
- })
772
-
773
- flow.redirectTo({
774
- url: '../bind-phone/bind-phone?source=4'
775
- })
776
- }
777
- } else {
778
- console.log('返回主包')
779
- flow.resolve()
780
- }
781
- }, 800)
782
- },
783
-
784
- // 埋点上报事件:自然人登录
785
- loginTracker(login_status = 1, cidType) {
786
- SDKTrack('nature_person_login', {
787
- // 1 登录成功;2 登录失败-身份信息核验失败;3 登录失败-人脸核验失败
788
- // 4 登录失败-电子营业执照核验失败;5 登录失败-账号密码输入错误
789
- // 6 取消登录(包含点击温馨提示的“取消”,点击请法人登录的×,在登录页面点击左上角返回按钮退出登录)
790
- // 7 退出小程序终止登录;old_1 历史数据:除登录成功之外的所有情况
791
- login_status,
792
- login_certificate: this.data.certTypeMap[cidType] || 1, // 证件类型
793
- invoke_location: '', // 调起位置
794
- login_validity_period: this.data.formData.verify_expire_time / 24 || '' // 免登录时间
795
- })
796
- },
797
-
798
- // 显示弹窗
799
- handleShowModal(status) {
800
- let modalStatus = ''
801
- if (status === '3') {
802
- // 未找到信息
803
- modalStatus = 'warning'
804
- } else if (status === '4') {
805
- // 核验中
806
- modalStatus = 'info'
807
- } else {
808
- // 信息有误
809
- modalStatus = 'error'
810
- }
811
- this.setData({
812
- modalStatus,
813
- showModal: true
814
- }, () => {
815
- wx.hideLoading()
816
- })
817
- },
818
-
819
- // modal确认事件
820
- handleModalOk() {
821
- this.setData({
822
- showModal: false
823
- })
824
- },
825
-
826
- onUnload: function () {
827
- // 页面卸载时的逻辑处理
828
- console.log('======页面即将卸载======', this.data.hadSuccessLogin);
829
- if (!this.data.hadSuccessLogin) {
830
- // 埋点上报事件:自然人登录
831
- this.loginTracker(6, this.data.formData.cid_type)
832
- }
833
- },
834
-
835
- // 有些操作程序会触发销毁回调函数,该操作不是真正的小程序销毁操作
836
- handleExitedState() {
837
- this.setData({
838
- exitedState: false
839
- })
840
- setTimeout(() => {
841
- this.setData({
842
- exitedState: true
843
- })
844
- }, 2000)
845
- },
846
-
847
- onSaveExitState: function () {
848
- // 小程序可能被销毁之前的逻辑处理
849
- if (!this.data.hadSuccessLogin && this.data.exitedState) {
850
- console.log('======小程序可能被销毁======')
851
- // 埋点上报事件:自然人登录
852
- this.loginTracker(7, this.data.formData.cid_type)
853
- }
854
- }
1
+ // weapps-plugin-jingtong-verify/pages/face-verify/index.js
2
+ const jingtongVerifyRequest = require('../../utils/request')
3
+ const utils = require("../../utils/index")
4
+ const {
5
+ flow
6
+ } = require("@wecity/weda-plugin-utils");
7
+ const rulesConfig = require("../../utils/rules")
8
+ import {
9
+ SDKTrack,
10
+ setAccountInfo
11
+ } from '../../utils/QDTrackerNew/QDTrackerMain'
12
+ let cidType = '700'
13
+
14
+ Page({
15
+ /**
16
+ * 页面的初始数据
17
+ */
18
+ data: {
19
+ language: 'en', // 语言环境:英文
20
+ formData: {
21
+ cid_type: '700', // 证件类型
22
+ id_card_number: '',
23
+ nation: '', // 国籍
24
+ nation_name: '',
25
+ sur_name: '', // 姓
26
+ first_name: '', // 名
27
+ sex: '', // 性别
28
+ birthday: '', // 出生日期
29
+ cid_expire_date: '', // 护照有效期
30
+ phone: '',
31
+ verify_expire_time: '', // 登录有效期
32
+ agree: false,
33
+ isbind: 1
34
+ },
35
+ needUnite: '', // 是否需要串联起来
36
+ cidTypeRange: [{
37
+ name: 'International passport',
38
+ value: '700'
39
+ } // 外国护照
40
+ ],
41
+ sexRange: [{
42
+ name: 'Male',
43
+ value: 1
44
+ },
45
+ {
46
+ name: 'Female',
47
+ value: 2
48
+ }
49
+ ],
50
+ loginTimeRangeEn: [{
51
+ name: 'Keep me logged in for 1 day',
52
+ value: 24
53
+ },
54
+ {
55
+ name: 'Keep me logged in for 7 days',
56
+ value: 168
57
+ },
58
+ {
59
+ name: 'Keep me logged in for 30 days',
60
+ value: 720
61
+ }
62
+ ],
63
+ validateType: {
64
+ id_card_number(value) {
65
+ return utils.validate.checkCid(value, cidType).data
66
+ },
67
+ // surName(value) {
68
+ // return utils.validate.checkName(value, cidType).data
69
+ // },
70
+ // firstName(value) {
71
+ // return utils.validate.checkName(value, cidType).data
72
+ // }
73
+ },
74
+ rules: rulesConfig.ForeignPassortRules('en'),
75
+ // 打开文档的防抖操作
76
+ canOpenPdf: true,
77
+ // 外国人护照核验状态 '1'(通过) '4'(审核中) ''(无审核单) 其它值(审核失败)
78
+ passportAuthStatus: '',
79
+ passportAuthPersonCode: '',
80
+ // 核验单数据
81
+ passportOldData: {},
82
+ // 弹窗
83
+ showModal: false,
84
+ modalStatus: 'info',
85
+ // 定义日期边界值
86
+ birthdayMaxDate: [new Date().getFullYear(), (new Date().getMonth() + 1), new Date().getDate()],
87
+ cidExpireMinDate: [new Date().getFullYear(), (new Date().getMonth() + 1), new Date().getDate()],
88
+ // cidType转化为certType
89
+ certTypeMap: {
90
+ '111': 1,
91
+ '516': 78,
92
+ '511': 4,
93
+ '17': 5,
94
+ '18': 6,
95
+ '414': 2,
96
+ '553': 9,
97
+ '700': 3
98
+ },
99
+ // 记录是否已经登录成功
100
+ hadSuccessLogin: false,
101
+ // 该操作会触发小程序的销毁回调
102
+ exitedState: true,
103
+ // surname自定义校验状态,傻逼数广傻逼组件逼的
104
+ sur_name_state: {
105
+ valid: true,
106
+ msg: ''
107
+ },
108
+ // givenName自定义校验状态,傻逼数广傻逼组件逼的
109
+ first_name_state: {
110
+ valid: true,
111
+ msg: ''
112
+ },
113
+ showCustomTips: false,
114
+ customTipsMsg: ''
115
+ },
116
+
117
+ // 验证sur_name和first_name
118
+ validateFullname() {
119
+ const {
120
+ sur_name,
121
+ first_name
122
+ } = this.data.formData
123
+ // 两个都没填
124
+ if ((sur_name == null || sur_name === '') && (first_name == null || first_name === '')) {
125
+ const msgEmpty = 'Please fill in surname or given name.';
126
+ this.setData({
127
+ sur_name_state: {
128
+ valid: false,
129
+ msg: msgEmpty
130
+ },
131
+ first_name_state: {
132
+ valid: false,
133
+ msg: msgEmpty
134
+ }
135
+ })
136
+ return {
137
+ valid: false,
138
+ msg: msgEmpty
139
+ }
140
+ }
141
+ this.setData({
142
+ sur_name_state: {
143
+ valid: true,
144
+ msg: ''
145
+ },
146
+ first_name_state: {
147
+ valid: false,
148
+ msg: ''
149
+ }
150
+ })
151
+ // 其中一个填了,或者两个都填了
152
+ let sur_name_flag = true
153
+ let msg = 'Please enter capital letters'
154
+ if (sur_name != null && sur_name !== '') {
155
+ const valid = utils.validate.checkName(sur_name, cidType)
156
+ if (valid.data) {
157
+ sur_name_flag = true
158
+ } else {
159
+ this.setData({
160
+ sur_name_state: {
161
+ valid: false,
162
+ msg
163
+ }
164
+ })
165
+ sur_name_flag = false
166
+ }
167
+ }
168
+ let first_name_flag = true
169
+ if (first_name != null && first_name !== '') {
170
+ const valid = utils.validate.checkName(first_name, cidType)
171
+ if (valid.data) {
172
+ first_name_flag = true
173
+ } else {
174
+ this.setData({
175
+ first_name_state: {
176
+ valid: false,
177
+ msg
178
+ }
179
+ })
180
+ first_name_flag = false
181
+ }
182
+ }
183
+ if (sur_name_flag && first_name_flag) {
184
+ this.setData({
185
+ sur_name_state: {
186
+ valid: true,
187
+ msg: ''
188
+ },
189
+ first_name_state: {
190
+ valid: false,
191
+ msg: ''
192
+ }
193
+ })
194
+ }
195
+ const valid = sur_name_flag && first_name_flag
196
+ return {
197
+ valid,
198
+ msg: valid ? '' : msg
199
+ }
200
+ },
201
+
202
+ // 自定义change事件,sur_name和first_name专用
203
+ handleCustomChange(e) {
204
+ let value = e.detail.value
205
+ let field = e.target.id
206
+ // 删除前后空格
207
+ if (typeof value === 'string') {
208
+ value = value.trim()
209
+ }
210
+ this.setData({
211
+ [`formData.${field}`]: value,
212
+ })
213
+ // 临时存储表单数据
214
+ this.saveFormDataTemp()
215
+ this.validateFullname()
216
+ },
217
+
218
+ // 关闭提示条
219
+ handleTipsClose(e) {
220
+ this.setData({
221
+ showCustomTips: e.detail.isShow
222
+ });
223
+ },
224
+
225
+ /**
226
+ * 生命周期函数--监听页面加载
227
+ */
228
+ onLoad(options) {
229
+ console.log('onLoad', options)
230
+ // 设置用户账号信息
231
+ setAccountInfo(wx.getStorageSync('tif.openid'))
232
+
233
+ this.setData({
234
+ needUnite: options.needUnite || 'true'
235
+ })
236
+
237
+ // 清空本地Temp数据
238
+ wx.setStorageSync('tif.formDataTemp', '')
239
+
240
+ // 获取外国护照核验结果
241
+ this.fetchPassortAuthResult()
242
+ },
243
+
244
+ // 生命周期函数--监听页面显示
245
+ onShow: function () {
246
+ wx.hideShareMenu()
247
+
248
+ // 获取国籍
249
+ let pages = getCurrentPages()
250
+ let currentPage = pages[pages.length - 1]
251
+ let hadChoseNation = currentPage.data.hadChoseNation || false
252
+
253
+ if (hadChoseNation) {
254
+ let cid_type = currentPage.data.formData.cid_type
255
+ // 回传数据
256
+ this.reFullFormDataTemp(cid_type)
257
+ }
258
+ },
259
+
260
+ // 选择完国籍或认证失败后回传 -- 回传本地临时存储用户表单信息
261
+ reFullFormDataTemp(cid_type) {
262
+ const formDataTemp = wx.getStorageSync('tif.formDataTemp') || {}
263
+ let formDataOld = this.data.formData
264
+
265
+ if (formDataTemp && formDataTemp[cid_type]) {
266
+ console.log('存在可回填的temp数据', formDataTemp[cid_type])
267
+ let formData = Object.assign(formDataOld, formDataTemp[cid_type])
268
+ this.setData({
269
+ formData
270
+ }, () => {
271
+ wx.hideLoading()
272
+ })
273
+ }
274
+ },
275
+
276
+ // 同意协议和隐私政策
277
+ viewPrivacy(e) {
278
+ // 错误触发销毁回调函数处理
279
+ this.handleExitedState()
280
+
281
+ // 临时存储表单数据
282
+ this.saveFormDataTemp()
283
+
284
+ let canOpenPdf = this.data.canOpenPdf
285
+ if (canOpenPdf) {
286
+ this.setData({
287
+ canOpenPdf: false
288
+ })
289
+ let {
290
+ name,
291
+ file
292
+ } = e.currentTarget.dataset
293
+ console.log('文件地址', `https://js.jt.beijing.gov.cn/jt/tiffile/${file}.pdf`)
294
+ utils.openDoc({
295
+ url: `https://js.jt.beijing.gov.cn/jt/tiffile/${file}.pdf`,
296
+ fileType: 'pdf',
297
+ name,
298
+ successFn: () => {
299
+ console.log('文档打开成功回调')
300
+ setTimeout(() => {
301
+ this.setData({
302
+ canOpenPdf: true
303
+ })
304
+ }, 500)
305
+ }
306
+ })
307
+ } else {
308
+ setTimeout(() => {
309
+ this.setData({
310
+ canOpenPdf: true
311
+ })
312
+ }, 3500)
313
+ }
314
+ },
315
+
316
+ // 选择事件
317
+ handleChange(e) {
318
+ let value = e.detail.value
319
+ let formId = e.target.id
320
+
321
+ // 删除前后空格
322
+ if (typeof value === 'string' && formId !== 'cid_type') {
323
+ value = value.trim()
324
+ }
325
+
326
+ this.setData({
327
+ [`formData.${formId}`]: value,
328
+ })
329
+ // 临时存储表单数据
330
+ this.saveFormDataTemp()
331
+ },
332
+
333
+ // 临时存储用户填写的表单信息
334
+ saveFormDataTemp() {
335
+ let {
336
+ formData
337
+ } = this.data
338
+
339
+ let formDataTemp = wx.getStorageSync('tif.formDataTemp') || {}
340
+ formDataTemp['700'] = formData
341
+ wx.setStorageSync('tif.formDataTemp', formDataTemp)
342
+ },
343
+
344
+ // 获取外国人护照核验结果、是否需要返回状态
345
+ fetchPassortAuthResult(needStatus = false) {
346
+ let formData = this.data.formData
347
+
348
+ return new Promise((resolve) => {
349
+ jingtongVerifyRequest.getPassportInfo({
350
+ success: res => {
351
+ console.log('外国人护照核验接口获取成功', res)
352
+ this.setData({
353
+ passportAuthStatus: res.status,
354
+ passportAuthPersonCode: res.person_code
355
+ })
356
+
357
+ if (needStatus) {
358
+ // 需要返回状态
359
+ resolve(res.status)
360
+ } else {
361
+ let {
362
+ id_card_number,
363
+ nation,
364
+ sur_name,
365
+ first_name,
366
+ sex,
367
+ birthday,
368
+ cid_expire_date,
369
+ phone,
370
+ verify_expire_time,
371
+ nation_name
372
+ } = res
373
+ let passportOldData = {
374
+ id_card_number,
375
+ nation,
376
+ nation_name,
377
+ sur_name,
378
+ first_name,
379
+ sex: sex ? sex : '',
380
+ birthday,
381
+ cid_expire_date,
382
+ phone,
383
+ verify_expire_time: verify_expire_time && Number(verify_expire_time) || ''
384
+ }
385
+ formData = Object.assign(formData, res, passportOldData)
386
+ this.setData({
387
+ formData,
388
+ passportOldData
389
+ })
390
+ }
391
+ },
392
+ fail: err => {
393
+ console.log('外国人护照核验接口获取失败', err)
394
+ let {
395
+ errmsg
396
+ } = JSON.parse(err)
397
+ wx.showToast({
398
+ title: errmsg || '获取核验信息接口失败',
399
+ icon: 'none',
400
+ duration: 3000
401
+ })
402
+ }
403
+ })
404
+ })
405
+ },
406
+
407
+ // 选择国籍
408
+ handleNationTap() {
409
+ // 临时存储表单数据
410
+ this.saveFormDataTemp()
411
+ flow.navigateTo({
412
+ url: `../nation-list/nation-list?cid_type=700`,
413
+ })
414
+ },
415
+
416
+ // 显示自定义校验错误提示
417
+ showCuntomErrTip(msg) {
418
+ this.setData({
419
+ showCustomTips: true,
420
+ customTipsMsg: msg
421
+ }, () => {
422
+ // 3秒后关闭
423
+ setTimeout(() => {
424
+ this.setData({
425
+ showCustomTips: false,
426
+ customTipsMsg: ''
427
+ });
428
+ }, 3500);
429
+ })
430
+ },
431
+
432
+ async handleFormSubmit(e) {
433
+ const formValid = e.detail.validStatus
434
+ const customValid = this.validateFullname()
435
+ if (!e.detail.validStatus || !customValid.valid) {
436
+ // 自定义校验字段有问题,获取表单错误列表
437
+ const formErrList = e.detail.value
438
+ // 如果表单校验有问题,自定义校验没问题,则显示表单校验错误提示
439
+ if (!formValid && customValid.valid) {
440
+ this.showCuntomErrTip(formErrList[0].message)
441
+ return
442
+ }
443
+ // 如果表单校验没有问题,自定义校验有问题,则显示自定义校验错误提示
444
+ if (formValid && !customValid.valid) {
445
+ this.showCuntomErrTip(customValid.msg)
446
+ return
447
+ }
448
+ // 如果两者都有问题,则判断显示谁
449
+ let lastMsg = ''
450
+ if (formErrList.some(i => ["id_card_number", "nation"].includes(i.name))) {
451
+ lastMsg = formErrList[0].message
452
+ } else {
453
+ lastMsg = customValid.msg
454
+ }
455
+ this.showCuntomErrTip(lastMsg)
456
+ return
457
+ }
458
+ this.setData({
459
+ showCustomTips: false,
460
+ customTipsMsg: ''
461
+ })
462
+ wx.showLoading({
463
+ title: '加载中…',
464
+ mask: true
465
+ })
466
+
467
+ console.log('删除“姓名、证件号码、护照号码、手机号码”的前后空格')
468
+ let {
469
+ id_card_number,
470
+ sur_name,
471
+ first_name,
472
+ phone,
473
+ cid_type
474
+ } = this.data.formData
475
+ // sur_name值为空,增加空格
476
+ if (sur_name == null || sur_name === '') {
477
+ sur_name = ' '
478
+ } else {
479
+ sur_name = sur_name.trim()
480
+ }
481
+ // first_name值为空,增加空格
482
+ if (first_name == null || first_name === '') {
483
+ first_name = ' '
484
+ } else {
485
+ first_name = first_name.trim()
486
+ }
487
+ this.setData({
488
+ ['formData.sur_name']: sur_name,
489
+ ['formData.first_name']: first_name,
490
+ ['formData.phone']: phone.trim()
491
+ })
492
+
493
+ if (cid_type === '700') {
494
+ console.log('删除“外国人护照号码”中间空格')
495
+ this.setData({
496
+ ['formData.id_card_number']: id_card_number.replace(/\s+/g, '')
497
+ })
498
+ }
499
+ console.log('入参', this.data.formData)
500
+
501
+ console.log('外国人护照核验')
502
+ // 外国人护照核验
503
+ this.handlePassortAuth()
504
+ },
505
+
506
+ // 外国人护照核验处理逻辑
507
+ handlePassortAuth() {
508
+ let authStatus = this.data.passportAuthStatus
509
+ let newData = this.data.formData
510
+ let oldData = this.data.passportOldData
511
+ console.log('当前核验单状态', authStatus)
512
+
513
+ if (!authStatus) {
514
+ console.log('无审核单', authStatus)
515
+ // 外国人护照核验,提交核验单
516
+ this.passportAuth()
517
+ } else {
518
+ // 查上一单的状态
519
+ this.fetchPassortAuthResult(true).then(status => {
520
+ console.log('====查上一单的状态====', status)
521
+ if (status === '1') {
522
+ // 核验通过,弹窗提示
523
+ console.log('外国人护照核验通过')
524
+ this.passportAuthSuccess()
525
+ } else {
526
+ // 比对表单数据是否有修改
527
+ console.log('新旧表单数据比对', newData, oldData)
528
+ if (utils.objIsEqual(newData, oldData)) {
529
+ console.log('表单数据没有修改')
530
+ if (status === '4') {
531
+ // 核验中
532
+ this.fetchPassortAuthResult(true).then(status => {
533
+ console.log('再次获取外国人护照核验状态', status)
534
+ if (status === '1') {
535
+ console.log('外国人护照核验通过')
536
+ this.passportAuthSuccess()
537
+ } else if (status === '4') {
538
+ console.log('外国人护照核验中,弹窗提示')
539
+ this.handleShowModal(status)
540
+ } else {
541
+ // 核验不通过,弹窗提示
542
+ this.passportAuthFail(status)
543
+ }
544
+ })
545
+ } else {
546
+ // 核验不通过,弹窗提示
547
+ this.passportAuthFail(status)
548
+ }
549
+ } else {
550
+ console.log('表单数据存在修改')
551
+ // 外国人护照核验,提交核验单
552
+ this.passportAuth()
553
+ }
554
+ }
555
+ })
556
+ }
557
+ },
558
+
559
+ // 外国人护照核验不通过逻辑
560
+ passportAuthFail(status) {
561
+ console.log('===外国人护照核验不通过,弹窗提示===')
562
+ // 判断当前person_code是否已失效
563
+ const personCode = this.data.passportAuthPersonCode
564
+ const localPersonCode = wx.getStorageSync('tif.fail.person_code') || ''
565
+ if (personCode === localPersonCode) {
566
+ // 提交核验单
567
+ this.passportAuth()
568
+ } else {
569
+ // 埋点上报事件:自然人登录
570
+ this.loginTracker(2, this.data.formData.cid_type)
571
+
572
+ this.handleShowModal(status)
573
+ // 记录这个person_code是失效的
574
+ wx.setStorageSync('tif.fail.person_code', this.data.passportAuthPersonCode)
575
+ }
576
+ },
577
+
578
+ // 外国人护照核验接口
579
+ async passportAuth() {
580
+ console.log('===========提交核验单============')
581
+ let formData = this.data.formData
582
+
583
+ const isLegalDate = utils.greaterCurrentTime(formData.cid_expire_date)
584
+ console.log('isLegalDate', isLegalDate)
585
+ if (!isLegalDate) {
586
+ console.log('护照有效期日期不合法')
587
+ wx.showToast({
588
+ title: 'Please select the passport expiration date',
589
+ icon: 'none',
590
+ duration: 3000
591
+ })
592
+ this.setData({
593
+ 'formData.cid_expire_date': ''
594
+ })
595
+ return
596
+ }
597
+
598
+ const [err, res] = await utils.awaitTo(jingtongVerifyRequest.passportAuth(formData))
599
+ if (err) {
600
+ console.log('外国人护照核验接口认证失败', err)
601
+ let {
602
+ errmsg
603
+ } = JSON.parse(err)
604
+ wx.showToast({
605
+ title: errmsg || '认证失败',
606
+ icon: 'none',
607
+ duration: 3000
608
+ })
609
+ return
610
+ }
611
+ console.log('弹窗提示等待1分钟', res)
612
+ this.setData({
613
+ passportAuthStatus: '4',
614
+ passportOldData: JSON.parse(JSON.stringify(formData)),
615
+ passportAuthPersonCode: ''
616
+ })
617
+ wx.setStorageSync('tif.fail.person_code', '')
618
+ this.handleShowModal('4')
619
+ },
620
+
621
+ // 外国人护照核验通过
622
+ passportAuthSuccess() {
623
+ // 调用删除接口/静默登录并返回session信息
624
+ jingtongVerifyRequest.deletePassportAuth({
625
+ success: session => {
626
+ console.log('返回session信息', session)
627
+
628
+ // 删除缓存信息
629
+ console.log('删除缓存信息')
630
+ let formDataTemp = wx.getStorageSync('tif.formDataTemp')
631
+ formDataTemp['700'] = {}
632
+ wx.setStorageSync('tif.formDataTemp', formDataTemp)
633
+ this.setData({
634
+ passportOldData: {}
635
+ })
636
+
637
+ this.authSuccess(session, true)
638
+ },
639
+ fail: err => {
640
+ // 埋点上报事件:自然人登录
641
+ this.loginTracker(2, this.data.formData.cid_type)
642
+
643
+ let {
644
+ errmsg
645
+ } = JSON.parse(err)
646
+ wx.showToast({
647
+ title: errmsg || 'auth fail',
648
+ icon: 'none',
649
+ duration: 3000
650
+ })
651
+ }
652
+ })
653
+ },
654
+
655
+ // 认证成功后续操作
656
+ authSuccess(session, isEn = false) {
657
+ console.log('====判断是否真的登录成功=====')
658
+ if (!session) {
659
+ wx.showToast({
660
+ title: 'Login has expired, please log in again',
661
+ icon: 'none',
662
+ duration: 3000
663
+ })
664
+ return
665
+ }
666
+
667
+ const {
668
+ face_time,
669
+ realname_time,
670
+ cid,
671
+ has_phone,
672
+ certType
673
+ } = session
674
+ if ((!face_time && !realname_time) || !cid) {
675
+ wx.showToast({
676
+ title: `Login has expired, please log in again: ${this.data.formData.cid_type}`,
677
+ icon: 'none',
678
+ duration: 2000
679
+ })
680
+ return
681
+ }
682
+
683
+ wx.showToast({
684
+ title: isEn ? 'Verification successful, redirecting...' : '验证成功, 跳转中…',
685
+ icon: 'none',
686
+ duration: 5000,
687
+ mask: true
688
+ })
689
+
690
+ const cidType = session.cid_type
691
+
692
+ // 本地存储表单核验成功数据
693
+ wx.setStorageSync('tif.formDataSuccess', this.data.formData)
694
+
695
+ // 将弹窗标识设置为不需要弹窗
696
+ jingtongVerifyRequest.setUserReadStatus(false).then(() => {
697
+ console.log('设置弹窗标识成功')
698
+ }).catch(err => {
699
+ console.log('设置弹窗标识失败', err)
700
+ })
701
+
702
+ setTimeout(() => {
703
+ if (this.data.needUnite === "true") {
704
+ console.log('进入业务总入口, 判断是否有手机号码', has_phone)
705
+ // this.setData({
706
+ // needUnite: ''
707
+ // })
708
+
709
+ // 登录成功回调 => 业务侧操作事项
710
+ wx.$_ServiceConfiguration && wx.$_ServiceConfiguration.methods && wx.$_ServiceConfiguration.methods._loginSuccessCallBack && wx.$_ServiceConfiguration.methods._loginSuccessCallBack(session)
711
+
712
+ if (has_phone) {
713
+ const realPhone = wx.getStorageSync('tif.realPhone') || ''
714
+ const caPhone = wx.getStorageSync('tif.caPhone') || ''
715
+ const confirmTime = wx.getStorageSync('tif.tel_confirm_time') || ''
716
+
717
+ console.log('realPhone', realPhone)
718
+ console.log('caPhone', caPhone)
719
+ console.log('confirmTime', confirmTime)
720
+
721
+ if (realPhone !== caPhone && confirmTime && (!utils.completeDate(new Date(Number(confirmTime + '000')), 6))) {
722
+ // 埋点上报事件:自然人登录
723
+ this.loginTracker(1, cidType)
724
+
725
+ this.setData({
726
+ hadSuccessLogin: true
727
+ })
728
+
729
+ // 【phone与caPhone不同】且【tel_confirm_time大于6个月】
730
+ // 数据库手机号码有效期大于6个月
731
+ flow.redirectTo({
732
+ url: '../confirm-phone/confirm-phone'
733
+ })
734
+ } else {
735
+ jingtongVerifyRequest.personToken({
736
+ source: '12'
737
+ }).then(async data => {
738
+ // 设置用户账号信息
739
+ setAccountInfo(session.openid)
740
+
741
+ // 埋点上报事件:自然人登录
742
+ this.loginTracker(1, cidType)
743
+
744
+ this.setData({
745
+ hadSuccessLogin: true
746
+ })
747
+
748
+ // 埋点 - 个人用户实体全属性上报
749
+ let last_login_time = utils.getCurrentTime()
750
+ wx.setStorageSync('tif.lastLoginTime', last_login_time)
751
+ const userEntityReportData = Object.assign(session, {
752
+ user_status: '1',
753
+ last_login_time,
754
+ user_date_of_birth: session.cid_type === '111' ? utils.getBirthByIDCard(session.cid) : ''
755
+ })
756
+ await utils.awaitTo(jingtongVerifyRequest.userEntityReport(userEntityReportData))
757
+
758
+ setTimeout(() => {
759
+ flow.resolve({
760
+ token: data
761
+ })
762
+ }, 1200)
763
+ })
764
+ }
765
+ } else {
766
+ // 埋点上报事件:自然人登录
767
+ this.loginTracker(1, cidType)
768
+
769
+ this.setData({
770
+ hadSuccessLogin: true
771
+ })
772
+
773
+ flow.redirectTo({
774
+ url: '../bind-phone/bind-phone?source=4'
775
+ })
776
+ }
777
+ } else {
778
+ console.log('返回主包')
779
+ flow.resolve()
780
+ }
781
+ }, 800)
782
+ },
783
+
784
+ // 埋点上报事件:自然人登录
785
+ loginTracker(login_status = 1, cidType) {
786
+ SDKTrack('nature_person_login', {
787
+ // 1 登录成功;2 登录失败-身份信息核验失败;3 登录失败-人脸核验失败
788
+ // 4 登录失败-电子营业执照核验失败;5 登录失败-账号密码输入错误
789
+ // 6 取消登录(包含点击温馨提示的“取消”,点击请法人登录的×,在登录页面点击左上角返回按钮退出登录)
790
+ // 7 退出小程序终止登录;old_1 历史数据:除登录成功之外的所有情况
791
+ login_status,
792
+ login_certificate: this.data.certTypeMap[cidType] || 1, // 证件类型
793
+ invoke_location: '', // 调起位置
794
+ login_validity_period: this.data.formData.verify_expire_time / 24 || '' // 免登录时间
795
+ })
796
+ },
797
+
798
+ // 显示弹窗
799
+ handleShowModal(status) {
800
+ let modalStatus = ''
801
+ if (status === '3') {
802
+ // 未找到信息
803
+ modalStatus = 'warning'
804
+ } else if (status === '4') {
805
+ // 核验中
806
+ modalStatus = 'info'
807
+ } else {
808
+ // 信息有误
809
+ modalStatus = 'error'
810
+ }
811
+ this.setData({
812
+ modalStatus,
813
+ showModal: true
814
+ }, () => {
815
+ wx.hideLoading()
816
+ })
817
+ },
818
+
819
+ // modal确认事件
820
+ handleModalOk() {
821
+ this.setData({
822
+ showModal: false
823
+ })
824
+ },
825
+
826
+ onUnload: function () {
827
+ // 页面卸载时的逻辑处理
828
+ console.log('======页面即将卸载======', this.data.hadSuccessLogin);
829
+ if (!this.data.hadSuccessLogin) {
830
+ // 埋点上报事件:自然人登录
831
+ this.loginTracker(6, this.data.formData.cid_type)
832
+ }
833
+ },
834
+
835
+ // 有些操作程序会触发销毁回调函数,该操作不是真正的小程序销毁操作
836
+ handleExitedState() {
837
+ this.setData({
838
+ exitedState: false
839
+ })
840
+ setTimeout(() => {
841
+ this.setData({
842
+ exitedState: true
843
+ })
844
+ }, 2000)
845
+ },
846
+
847
+ onSaveExitState: function () {
848
+ // 小程序可能被销毁之前的逻辑处理
849
+ if (!this.data.hadSuccessLogin && this.data.exitedState) {
850
+ console.log('======小程序可能被销毁======')
851
+ // 埋点上报事件:自然人登录
852
+ this.loginTracker(7, this.data.formData.cid_type)
853
+ }
854
+ }
855
855
  })