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,117 +1,117 @@
1
- /**
2
- * https://github.com/krasimir/EventBus
3
- * @constructor
4
- */
5
-
6
- const EventBusClass = function () {
7
- this.listeners = {}
8
- // 统计所有 event 数量,方便添加 id
9
- this.count = 0
10
- }
11
-
12
- EventBusClass.prototype = {
13
- getGuid(type) {
14
- const _guid = `${type}${this.count}`
15
- this.count++
16
- return _guid
17
- },
18
-
19
- addEventListener(type, callback, scope) {
20
- console.log('Event 监听事件:', type)
21
- // 给对应事件分配一个 id
22
- callback._guid = this.getGuid(type)
23
- let args = []
24
- const numOfArgs = arguments.length
25
- for (let i = 0; i < numOfArgs; i++) {
26
- args.push(arguments[i])
27
- }
28
- args = args.length > 3 ? args.splice(3, args.length - 1) : []
29
- if (typeof this.listeners[type] !== 'undefined') {
30
- this.listeners[type].push({scope, callback, args})
31
- } else {
32
- this.listeners[type] = [{scope, callback, args}]
33
- }
34
- },
35
-
36
- removeEventListener(type) {
37
- if (typeof this.listeners[type] !== 'undefined') {
38
- this.listeners[type] = []
39
- }
40
- },
41
-
42
- removeSingleEventListener(type, callback, scope) {
43
- const currentType = this.listeners[type]
44
- if (currentType && scope) {
45
- const findIndex = currentType.findIndex(item => {
46
- return item.scope === scope
47
- })
48
- findIndex !== -1 && this.listeners[type].splice(findIndex, 1);
49
- return;
50
- }
51
- if (currentType) {
52
- const findIndex = currentType.findIndex(item => {
53
- return item.callback._guid === callback._guid
54
- })
55
- findIndex !== -1 && this.listeners[type].splice(findIndex, 1)
56
- }
57
- },
58
-
59
- hasEventListener(type, callback, scope) {
60
- if (typeof this.listeners[type] !== 'undefined') {
61
- const numOfCallbacks = this.listeners[type].length
62
- if (callback === undefined && scope === undefined) {
63
- return numOfCallbacks > 0
64
- }
65
- for (let i = 0; i < numOfCallbacks; i++) {
66
- const listener = this.listeners[type][i]
67
- if ((scope ? listener.scope == scope : true) && listener.callback == callback) {
68
- return true
69
- }
70
- }
71
- }
72
- return false
73
- },
74
-
75
- dispatch(type, target) {
76
- console.log('Event 发布事件:', type, target)
77
-
78
- const event = {
79
- type,
80
- target
81
- }
82
- let args = []
83
- const numOfArgs = arguments.length
84
- for (let i = 0; i < numOfArgs; i++) {
85
- args.push(arguments[i])
86
- }
87
- args = args.length > 2 ? args.splice(2, args.length - 1) : []
88
- args = [event].concat(args)
89
-
90
- if (typeof this.listeners[type] !== 'undefined') {
91
- const listeners = this.listeners[type].slice()
92
- const numOfCallbacks = listeners.length
93
- for (let i = 0; i < numOfCallbacks; i++) {
94
- const listener = listeners[i]
95
- if (listener && listener.callback) {
96
- const concatArgs = args.concat(listener.args);
97
- listener.callback.apply(listener.scope, concatArgs)
98
- }
99
- }
100
- }
101
- },
102
-
103
- getEvents() {
104
- let str = ''
105
- for (const type in this.listeners) {
106
- const numOfCallbacks = this.listeners[type].length
107
- for (let i = 0; i < numOfCallbacks; i++) {
108
- const listener = this.listeners[type][i]
109
- str += listener.scope && listener.scope.className ? listener.scope.className : 'anonymous'
110
- str += ' listen for \'' + type + '\'\n'
111
- }
112
- }
113
- return str
114
- }
115
- }
116
-
117
- module.exports = new EventBusClass()
1
+ /**
2
+ * https://github.com/krasimir/EventBus
3
+ * @constructor
4
+ */
5
+
6
+ const EventBusClass = function () {
7
+ this.listeners = {}
8
+ // 统计所有 event 数量,方便添加 id
9
+ this.count = 0
10
+ }
11
+
12
+ EventBusClass.prototype = {
13
+ getGuid(type) {
14
+ const _guid = `${type}${this.count}`
15
+ this.count++
16
+ return _guid
17
+ },
18
+
19
+ addEventListener(type, callback, scope) {
20
+ console.log('Event 监听事件:', type)
21
+ // 给对应事件分配一个 id
22
+ callback._guid = this.getGuid(type)
23
+ let args = []
24
+ const numOfArgs = arguments.length
25
+ for (let i = 0; i < numOfArgs; i++) {
26
+ args.push(arguments[i])
27
+ }
28
+ args = args.length > 3 ? args.splice(3, args.length - 1) : []
29
+ if (typeof this.listeners[type] !== 'undefined') {
30
+ this.listeners[type].push({scope, callback, args})
31
+ } else {
32
+ this.listeners[type] = [{scope, callback, args}]
33
+ }
34
+ },
35
+
36
+ removeEventListener(type) {
37
+ if (typeof this.listeners[type] !== 'undefined') {
38
+ this.listeners[type] = []
39
+ }
40
+ },
41
+
42
+ removeSingleEventListener(type, callback, scope) {
43
+ const currentType = this.listeners[type]
44
+ if (currentType && scope) {
45
+ const findIndex = currentType.findIndex(item => {
46
+ return item.scope === scope
47
+ })
48
+ findIndex !== -1 && this.listeners[type].splice(findIndex, 1);
49
+ return;
50
+ }
51
+ if (currentType) {
52
+ const findIndex = currentType.findIndex(item => {
53
+ return item.callback._guid === callback._guid
54
+ })
55
+ findIndex !== -1 && this.listeners[type].splice(findIndex, 1)
56
+ }
57
+ },
58
+
59
+ hasEventListener(type, callback, scope) {
60
+ if (typeof this.listeners[type] !== 'undefined') {
61
+ const numOfCallbacks = this.listeners[type].length
62
+ if (callback === undefined && scope === undefined) {
63
+ return numOfCallbacks > 0
64
+ }
65
+ for (let i = 0; i < numOfCallbacks; i++) {
66
+ const listener = this.listeners[type][i]
67
+ if ((scope ? listener.scope == scope : true) && listener.callback == callback) {
68
+ return true
69
+ }
70
+ }
71
+ }
72
+ return false
73
+ },
74
+
75
+ dispatch(type, target) {
76
+ console.log('Event 发布事件:', type, target)
77
+
78
+ const event = {
79
+ type,
80
+ target
81
+ }
82
+ let args = []
83
+ const numOfArgs = arguments.length
84
+ for (let i = 0; i < numOfArgs; i++) {
85
+ args.push(arguments[i])
86
+ }
87
+ args = args.length > 2 ? args.splice(2, args.length - 1) : []
88
+ args = [event].concat(args)
89
+
90
+ if (typeof this.listeners[type] !== 'undefined') {
91
+ const listeners = this.listeners[type].slice()
92
+ const numOfCallbacks = listeners.length
93
+ for (let i = 0; i < numOfCallbacks; i++) {
94
+ const listener = listeners[i]
95
+ if (listener && listener.callback) {
96
+ const concatArgs = args.concat(listener.args);
97
+ listener.callback.apply(listener.scope, concatArgs)
98
+ }
99
+ }
100
+ }
101
+ },
102
+
103
+ getEvents() {
104
+ let str = ''
105
+ for (const type in this.listeners) {
106
+ const numOfCallbacks = this.listeners[type].length
107
+ for (let i = 0; i < numOfCallbacks; i++) {
108
+ const listener = this.listeners[type][i]
109
+ str += listener.scope && listener.scope.className ? listener.scope.className : 'anonymous'
110
+ str += ' listen for \'' + type + '\'\n'
111
+ }
112
+ }
113
+ return str
114
+ }
115
+ }
116
+
117
+ module.exports = new EventBusClass()
@@ -1,63 +1,63 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const Event = require('./event/index');
4
- const Map = require('./map/index');
5
- const CryptoJS = require('./crypto/index');
6
- const dayjs = require('./dayjs/index');
7
- const utils = require('./utils/index');
8
- const Storage = require('./storage/index');
9
- const Anim = require('./anim/anim.min.js');
10
- const wedux = Anim.wedux;
11
- const lib = Object.assign({
12
- // 事件驱动
13
- Event,
14
- // LBS能力
15
- Map,
16
- // 加密解密
17
- CryptoJS,
18
- // 时间处理
19
- dayjs,
20
- // 全局数据状态
21
- wedux,
22
- // 开发框架
23
- Anim,
24
- // 数据缓存
25
- Storage }, utils);
26
- const configList = [
27
- [[
28
- 'addEventListener',
29
- 'removeEventListener',
30
- 'removeSingleEventListener',
31
- 'hasEventListener',
32
- 'dispatch',
33
- 'getEvents'
34
- ], Event, lib],
35
- [[
36
- 'search',
37
- 'getSuggestion',
38
- 'reverseGeocoder',
39
- 'geocoder',
40
- 'getCityList',
41
- 'getDistrictByCityId',
42
- 'calculateDistance'
43
- ], Map, lib],
44
- [[
45
- 'encryptByAES',
46
- 'decryptByAES',
47
- ], CryptoJS, lib],
48
- [[
49
- 'mapToData',
50
- 'observe',
51
- ], wedux, lib],
52
- [[
53
- 'setStorageSync',
54
- 'getStorageSync',
55
- 'removeStorageSync',
56
- 'clearStorageSync',
57
- 'clearExpiredStorage'
58
- ], Storage, lib]
59
- ];
60
- configList.forEach(config => {
61
- utils.extendMethods(...config);
62
- });
63
- exports.default = lib;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Event = require('./event/index');
4
+ const Map = require('./map/index');
5
+ const CryptoJS = require('./crypto/index');
6
+ const dayjs = require('./dayjs/index');
7
+ const utils = require('./utils/index');
8
+ const Storage = require('./storage/index');
9
+ const Anim = require('./anim/anim.min.js');
10
+ const wedux = Anim.wedux;
11
+ const lib = Object.assign({
12
+ // 事件驱动
13
+ Event,
14
+ // LBS能力
15
+ Map,
16
+ // 加密解密
17
+ CryptoJS,
18
+ // 时间处理
19
+ dayjs,
20
+ // 全局数据状态
21
+ wedux,
22
+ // 开发框架
23
+ Anim,
24
+ // 数据缓存
25
+ Storage }, utils);
26
+ const configList = [
27
+ [[
28
+ 'addEventListener',
29
+ 'removeEventListener',
30
+ 'removeSingleEventListener',
31
+ 'hasEventListener',
32
+ 'dispatch',
33
+ 'getEvents'
34
+ ], Event, lib],
35
+ [[
36
+ 'search',
37
+ 'getSuggestion',
38
+ 'reverseGeocoder',
39
+ 'geocoder',
40
+ 'getCityList',
41
+ 'getDistrictByCityId',
42
+ 'calculateDistance'
43
+ ], Map, lib],
44
+ [[
45
+ 'encryptByAES',
46
+ 'decryptByAES',
47
+ ], CryptoJS, lib],
48
+ [[
49
+ 'mapToData',
50
+ 'observe',
51
+ ], wedux, lib],
52
+ [[
53
+ 'setStorageSync',
54
+ 'getStorageSync',
55
+ 'removeStorageSync',
56
+ 'clearStorageSync',
57
+ 'clearExpiredStorage'
58
+ ], Storage, lib]
59
+ ];
60
+ configList.forEach(config => {
61
+ utils.extendMethods(...config);
62
+ });
63
+ exports.default = lib;
@@ -1,10 +1,10 @@
1
- "use strict";
2
- const QQMapWX = require('./qmap');
3
-
4
- /**
5
- * Doc文档地址 https://lbs.qq.com/qqmap_wx_jssdk/method-reverseGeocoder.html
6
- * @type {b}
7
- */
8
- module.exports = new QQMapWX({
9
- key: 'ZFDBZ-43YKD-IHC4T-HGXTT-WEZJ6-DLB5G' // 必填
10
- });
1
+ "use strict";
2
+ const QQMapWX = require('./qmap');
3
+
4
+ /**
5
+ * Doc文档地址 https://lbs.qq.com/qqmap_wx_jssdk/method-reverseGeocoder.html
6
+ * @type {b}
7
+ */
8
+ module.exports = new QQMapWX({
9
+ key: 'ZFDBZ-43YKD-IHC4T-HGXTT-WEZJ6-DLB5G' // 必填
10
+ });
@@ -1,6 +1,6 @@
1
- const _createClass = (function (){ function a(e, c){ for(let b = 0;b < c.length;b++){ const d = c[b];d.enumerable = d.enumerable || false;d.configurable = true;if('value' in d){ d.writable = true }Object.defineProperty(e, d.key, d) } }return function (d, b, c){ if(b){ a(d.prototype, b) }if(c){ a(d, c) }return d } })();function _classCallCheck(a, b){ if(!(a instanceof b)){ throw new TypeError('Cannot call a class as a function') } }const ERROR_CONF = { KEY_ERR: 311, KEY_ERR_MSG: 'key格式错误', PARAM_ERR: 310, PARAM_ERR_MSG: '请求参数信息有误', SYSTEM_ERR: 600, SYSTEM_ERR_MSG: '系统错误', WX_ERR_CODE: 1000, WX_OK_CODE: 200 };const BASE_URL = 'https://apis.map.qq.com/ws/';const URL_SEARCH = BASE_URL + 'place/v1/search';const URL_SUGGESTION = BASE_URL + 'place/v1/suggestion';const URL_GET_GEOCODER = BASE_URL + 'geocoder/v1/';const URL_CITY_LIST = BASE_URL + 'district/v1/list';const URL_AREA_LIST = BASE_URL + 'district/v1/getchildren';const URL_DISTANCE = BASE_URL + 'distance/v1/';var Utils = { location2query: function location2query(c){ if(typeof c === 'string'){ return c }let b = '';for(let a = 0;a < c.length;a++){ const e = c[a];if(b){ b += ';' }if(e.location){ b = b + e.location.lat + ',' + e.location.lng }if(e.latitude && e.longitude){ b = b + e.latitude + ',' + e.longitude } }return b }, getWXLocation: function getWXLocation(c, b, a){ wx.getLocation({ type: 'gcj02', success: c, fail: b, complete: a }) }, getLocationParam: function getLocationParam(b){ if(typeof b === 'string'){ const a = b.split(',');if(a.length === 2){ b = { latitude: b.split(',')[0], longitude: b.split(',')[1] } }else{ b = {} } }return b }, polyfillParam: function polyfillParam(a){ a.success = a.success || function (){};a.fail = a.fail || function (){};a.complete = a.complete || function (){} }, checkParamKeyEmpty: function checkParamKeyEmpty(c, b){ if(!c[b]){ const a = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + b + '参数格式有误');c.fail(a);c.complete(a);return true }return false }, checkKeyword: function checkKeyword(a){ return !this.checkParamKeyEmpty(a, 'keyword') }, checkLocation: function checkLocation(c){ const a = this.getLocationParam(c.location);if(!a || !a.latitude || !a.longitude){ const b = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + ' location参数格式有误');c.fail(b);c.complete(b);return false }return true }, buildErrorConfig: function buildErrorConfig(a, b){ return{ status: a, message: b } }, buildWxRequestConfig: function buildWxRequestConfig(c, a){ const b = this;a.header = { 'content-type': 'application/json' };a.method = 'GET';a.success = function (d){ const e = d.data;if(e.status === 0){ c.success(e) }else{ c.fail(e) } };a.fail = function (d){ d.statusCode = ERROR_CONF.WX_ERR_CODE;c.fail(b.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, result.errMsg)) };a.complete = function (d){ const e = +d.statusCode;switch(e){ case ERROR_CONF.WX_ERR_CODE:c.complete(b.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, d.errMsg));break;case ERROR_CONF.WX_OK_CODE:var f = d.data;if(f.status === 0){ c.complete(f) }else{ c.complete(b.buildErrorConfig(f.status, f.message)) }break;default:c.complete(b.buildErrorConfig(ERROR_CONF.SYSTEM_ERR, ERROR_CONF.SYSTEM_ERR_MSG)) } };return a }, locationProcess: function locationProcess(f, e, c, a){ const d = this;c = c || function (g){ g.statusCode = ERROR_CONF.WX_ERR_CODE;f.fail(d.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, g.errMsg)) };a = a || function (g){ if(g.statusCode == ERROR_CONF.WX_ERR_CODE){ f.complete(d.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, g.errMsg)) } };if(!f.location){ d.getWXLocation(e, c, a) }else if(d.checkLocation(f)){ const b = Utils.getLocationParam(f.location);e(b) } } };const QQMapWX = (function (){
2
- function b(i){ _classCallCheck(this, b);if(!i.key){ throw Error('key值不能为空') }this.key = i.key }_createClass(b, [{ key: 'search', value: function f(i){ const l = this;i = i || {};Utils.polyfillParam(i);if(!Utils.checkKeyword(i)){ return }const k = { keyword: i.keyword, orderby: i.orderby || '_distance', page_size: i.page_size || 10, page_index: i.page_index || 1, output: 'json', key: l.key };if(i.address_format){ k.address_format = i.address_format }if(i.filter){ k.filter = i.filter }const n = i.distance || '1000';const j = i.auto_extend || 1;const m = function m(o){ k.boundary = 'nearby(' + o.latitude + ',' + o.longitude + ',' + n + ',' + j + ')';wx.request(Utils.buildWxRequestConfig(i, { url: URL_SEARCH, data: k })) };Utils.locationProcess(i, m) } }, { key: 'getSuggestion', value: function h(i){ const k = this;i = i || {};Utils.polyfillParam(i);if(!Utils.checkKeyword(i)){ return }const j = { keyword: i.keyword, region: i.region || '全国', region_fix: i.region_fix || 0, policy: i.policy || 0, output: 'json', key: k.key };wx.request(Utils.buildWxRequestConfig(i, { url: URL_SUGGESTION, data: j })) } }, { key: 'reverseGeocoder', value: function a(i){ const k = this;i = i || {};Utils.polyfillParam(i);const j = { coord_type: i.coord_type || 5, get_poi: i.get_poi || 0, output: 'json', key: k.key };if(i.poi_options){ j.poi_options = i.poi_options }const l = function l(m){ j.location = m.latitude + ',' + m.longitude;wx.request(Utils.buildWxRequestConfig(i, { url: URL_GET_GEOCODER, data: j })) };Utils.locationProcess(i, l) } }, { key: 'geocoder', value: function g(i){ const k = this;i = i || {};Utils.polyfillParam(i);if(Utils.checkParamKeyEmpty(i, 'address')){ return }const j = { address: i.address, output: 'json', key: k.key };wx.request(Utils.buildWxRequestConfig(i, { url: URL_GET_GEOCODER, data: j })) } }, { key: 'getCityList', value: function c(i){
3
- const k = this;i = i || {};Utils.polyfillParam(i);const j = { output: 'json', key: k.key }
4
- wx.request(Utils.buildWxRequestConfig(i, { url: URL_CITY_LIST, data: j }))
5
- } }, { key: 'getDistrictByCityId', value: function d(i){ const k = this;i = i || {};Utils.polyfillParam(i);if(Utils.checkParamKeyEmpty(i, 'id')){ return }const j = { id: i.id || '', output: 'json', key: k.key };wx.request(Utils.buildWxRequestConfig(i, { url: URL_AREA_LIST, data: j })) } }, { key: 'calculateDistance', value: function e(i){ const k = this;i = i || {};Utils.polyfillParam(i);if(Utils.checkParamKeyEmpty(i, 'to')){ return }const j = { mode: i.mode || 'walking', to: Utils.location2query(i.to), output: 'json', key: k.key };const l = function l(m){ j.from = m.latitude + ',' + m.longitude;wx.request(Utils.buildWxRequestConfig(i, { url: URL_DISTANCE, data: j })) };if(i.from){ i.location = i.from }Utils.locationProcess(i, l) } }]);return b
6
- })();module.exports = QQMapWX
1
+ const _createClass = (function (){ function a(e, c){ for(let b = 0;b < c.length;b++){ const d = c[b];d.enumerable = d.enumerable || false;d.configurable = true;if('value' in d){ d.writable = true }Object.defineProperty(e, d.key, d) } }return function (d, b, c){ if(b){ a(d.prototype, b) }if(c){ a(d, c) }return d } })();function _classCallCheck(a, b){ if(!(a instanceof b)){ throw new TypeError('Cannot call a class as a function') } }const ERROR_CONF = { KEY_ERR: 311, KEY_ERR_MSG: 'key格式错误', PARAM_ERR: 310, PARAM_ERR_MSG: '请求参数信息有误', SYSTEM_ERR: 600, SYSTEM_ERR_MSG: '系统错误', WX_ERR_CODE: 1000, WX_OK_CODE: 200 };const BASE_URL = 'https://apis.map.qq.com/ws/';const URL_SEARCH = BASE_URL + 'place/v1/search';const URL_SUGGESTION = BASE_URL + 'place/v1/suggestion';const URL_GET_GEOCODER = BASE_URL + 'geocoder/v1/';const URL_CITY_LIST = BASE_URL + 'district/v1/list';const URL_AREA_LIST = BASE_URL + 'district/v1/getchildren';const URL_DISTANCE = BASE_URL + 'distance/v1/';var Utils = { location2query: function location2query(c){ if(typeof c === 'string'){ return c }let b = '';for(let a = 0;a < c.length;a++){ const e = c[a];if(b){ b += ';' }if(e.location){ b = b + e.location.lat + ',' + e.location.lng }if(e.latitude && e.longitude){ b = b + e.latitude + ',' + e.longitude } }return b }, getWXLocation: function getWXLocation(c, b, a){ wx.getLocation({ type: 'gcj02', success: c, fail: b, complete: a }) }, getLocationParam: function getLocationParam(b){ if(typeof b === 'string'){ const a = b.split(',');if(a.length === 2){ b = { latitude: b.split(',')[0], longitude: b.split(',')[1] } }else{ b = {} } }return b }, polyfillParam: function polyfillParam(a){ a.success = a.success || function (){};a.fail = a.fail || function (){};a.complete = a.complete || function (){} }, checkParamKeyEmpty: function checkParamKeyEmpty(c, b){ if(!c[b]){ const a = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + b + '参数格式有误');c.fail(a);c.complete(a);return true }return false }, checkKeyword: function checkKeyword(a){ return !this.checkParamKeyEmpty(a, 'keyword') }, checkLocation: function checkLocation(c){ const a = this.getLocationParam(c.location);if(!a || !a.latitude || !a.longitude){ const b = this.buildErrorConfig(ERROR_CONF.PARAM_ERR, ERROR_CONF.PARAM_ERR_MSG + ' location参数格式有误');c.fail(b);c.complete(b);return false }return true }, buildErrorConfig: function buildErrorConfig(a, b){ return{ status: a, message: b } }, buildWxRequestConfig: function buildWxRequestConfig(c, a){ const b = this;a.header = { 'content-type': 'application/json' };a.method = 'GET';a.success = function (d){ const e = d.data;if(e.status === 0){ c.success(e) }else{ c.fail(e) } };a.fail = function (d){ d.statusCode = ERROR_CONF.WX_ERR_CODE;c.fail(b.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, result.errMsg)) };a.complete = function (d){ const e = +d.statusCode;switch(e){ case ERROR_CONF.WX_ERR_CODE:c.complete(b.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, d.errMsg));break;case ERROR_CONF.WX_OK_CODE:var f = d.data;if(f.status === 0){ c.complete(f) }else{ c.complete(b.buildErrorConfig(f.status, f.message)) }break;default:c.complete(b.buildErrorConfig(ERROR_CONF.SYSTEM_ERR, ERROR_CONF.SYSTEM_ERR_MSG)) } };return a }, locationProcess: function locationProcess(f, e, c, a){ const d = this;c = c || function (g){ g.statusCode = ERROR_CONF.WX_ERR_CODE;f.fail(d.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, g.errMsg)) };a = a || function (g){ if(g.statusCode == ERROR_CONF.WX_ERR_CODE){ f.complete(d.buildErrorConfig(ERROR_CONF.WX_ERR_CODE, g.errMsg)) } };if(!f.location){ d.getWXLocation(e, c, a) }else if(d.checkLocation(f)){ const b = Utils.getLocationParam(f.location);e(b) } } };const QQMapWX = (function (){
2
+ function b(i){ _classCallCheck(this, b);if(!i.key){ throw Error('key值不能为空') }this.key = i.key }_createClass(b, [{ key: 'search', value: function f(i){ const l = this;i = i || {};Utils.polyfillParam(i);if(!Utils.checkKeyword(i)){ return }const k = { keyword: i.keyword, orderby: i.orderby || '_distance', page_size: i.page_size || 10, page_index: i.page_index || 1, output: 'json', key: l.key };if(i.address_format){ k.address_format = i.address_format }if(i.filter){ k.filter = i.filter }const n = i.distance || '1000';const j = i.auto_extend || 1;const m = function m(o){ k.boundary = 'nearby(' + o.latitude + ',' + o.longitude + ',' + n + ',' + j + ')';wx.request(Utils.buildWxRequestConfig(i, { url: URL_SEARCH, data: k })) };Utils.locationProcess(i, m) } }, { key: 'getSuggestion', value: function h(i){ const k = this;i = i || {};Utils.polyfillParam(i);if(!Utils.checkKeyword(i)){ return }const j = { keyword: i.keyword, region: i.region || '全国', region_fix: i.region_fix || 0, policy: i.policy || 0, output: 'json', key: k.key };wx.request(Utils.buildWxRequestConfig(i, { url: URL_SUGGESTION, data: j })) } }, { key: 'reverseGeocoder', value: function a(i){ const k = this;i = i || {};Utils.polyfillParam(i);const j = { coord_type: i.coord_type || 5, get_poi: i.get_poi || 0, output: 'json', key: k.key };if(i.poi_options){ j.poi_options = i.poi_options }const l = function l(m){ j.location = m.latitude + ',' + m.longitude;wx.request(Utils.buildWxRequestConfig(i, { url: URL_GET_GEOCODER, data: j })) };Utils.locationProcess(i, l) } }, { key: 'geocoder', value: function g(i){ const k = this;i = i || {};Utils.polyfillParam(i);if(Utils.checkParamKeyEmpty(i, 'address')){ return }const j = { address: i.address, output: 'json', key: k.key };wx.request(Utils.buildWxRequestConfig(i, { url: URL_GET_GEOCODER, data: j })) } }, { key: 'getCityList', value: function c(i){
3
+ const k = this;i = i || {};Utils.polyfillParam(i);const j = { output: 'json', key: k.key }
4
+ wx.request(Utils.buildWxRequestConfig(i, { url: URL_CITY_LIST, data: j }))
5
+ } }, { key: 'getDistrictByCityId', value: function d(i){ const k = this;i = i || {};Utils.polyfillParam(i);if(Utils.checkParamKeyEmpty(i, 'id')){ return }const j = { id: i.id || '', output: 'json', key: k.key };wx.request(Utils.buildWxRequestConfig(i, { url: URL_AREA_LIST, data: j })) } }, { key: 'calculateDistance', value: function e(i){ const k = this;i = i || {};Utils.polyfillParam(i);if(Utils.checkParamKeyEmpty(i, 'to')){ return }const j = { mode: i.mode || 'walking', to: Utils.location2query(i.to), output: 'json', key: k.key };const l = function l(m){ j.from = m.latitude + ',' + m.longitude;wx.request(Utils.buildWxRequestConfig(i, { url: URL_DISTANCE, data: j })) };if(i.from){ i.location = i.from }Utils.locationProcess(i, l) } }]);return b
6
+ })();module.exports = QQMapWX
@@ -1,114 +1,114 @@
1
- const Storage = {
2
- _storage: wx,
3
-
4
- _expiration_key_prefix: '__expired___storage__',
5
-
6
- getTimestamp: function() {
7
- return Math.floor(((new Date()).getTime()) / 1000);
8
- },
9
-
10
- setStorageSync: function(key, value, expiration) {
11
- try {
12
- this._storage.setStorageSync(key, value);
13
- } catch (e) {
14
- // 1. 第一次失败,先清理过期的数据
15
- this.clearExpiredStorage();
16
-
17
- try {
18
- this._storage.setStorageSync(key, value);
19
- } catch (error) {
20
- // 2. 第二次失败,则抛出错误
21
- console.error(`当前存储的key为${key},其value已超出微信数据缓存限制:`)
22
- console.error('单个 key 允许存储的最大数据长度为 1MB')
23
- console.error('所有数据存储上限为 10MB。')
24
- return error
25
- }
26
- }
27
- // 默认过期时间为 7 天
28
- this.updateExpiration(key, expiration || 7 * 24 * 60 * 60);
29
- },
30
-
31
- getStorageSync: function(key) {
32
- if (this.isExpired(key)) {
33
- this.removeStorageSync(key);
34
- return null;
35
- }
36
- return this._storage.getStorageSync(key) || null;
37
- },
38
-
39
- peek: function(key) {
40
- let result = {
41
- value: this._storage.getStorageSync(key),
42
- timeLeft: this.getTimeLeft(key)
43
- };
44
- result.isExpired = result.timeLeft !== null && result.timeLeft <= 0;
45
- return result;
46
- },
47
-
48
- getTimeLeft: function(key) {
49
- let expireTime = parseInt(this._storage.getStorageSync(this._expiration_key_prefix + key), 10);
50
- if (expireTime && !isNaN(expireTime)) {
51
- return expireTime - this.getTimestamp();
52
- }
53
- return null;
54
- },
55
-
56
- isExpired: function(key) {
57
- let timeLeft = this.getTimeLeft(key);
58
- return timeLeft !== null && timeLeft <= 0;
59
- },
60
-
61
- updateExpiration: function(key, expiration) {
62
- return this._storage.setStorageSync(this._expiration_key_prefix + key, this.getTimestamp() + expiration);
63
- },
64
-
65
- removeStorageSync: function(key) {
66
- this._storage.removeStorageSync(key);
67
- this._storage.removeStorageSync(this._expiration_key_prefix + key);
68
- },
69
-
70
- keys: function(includeExpired) {
71
- let keyList = [];
72
- this._iterKeys(storageKey => {
73
- if (storageKey.indexOf(this._expiration_key_prefix) !== 0) {
74
- if (includeExpired || !this.isExpired(storageKey)) {
75
- keyList.push(storageKey);
76
- }
77
- }
78
- });
79
- return keyList;
80
- },
81
-
82
- _iterKeys: function(callback) {
83
- const storageInfo = wx.getStorageInfoSync();
84
- if (storageInfo.keys) {
85
- storageInfo.keys.forEach(key => {
86
- callback(key);
87
- });
88
- }
89
- },
90
-
91
- clearStorageSync: function() {
92
- try {
93
- this._storage.clearStorageSync();
94
- } catch (err) {
95
- console.log('Storage clear', err);
96
- }
97
- },
98
-
99
- clearExpiredStorage: function() {
100
- let resultList = [];
101
- this._iterKeys((storageKey) => {
102
- if (storageKey.indexOf(this._expiration_key_prefix) === 0) {
103
- let itemKey = storageKey.substr(this._expiration_key_prefix.length);
104
- if (this.isExpired(itemKey)) {
105
- this.removeStorageSync(itemKey);
106
- resultList.push(itemKey);
107
- }
108
- }
109
- });
110
- return resultList;
111
- }
112
- };
113
-
114
- module.exports = Storage;
1
+ const Storage = {
2
+ _storage: wx,
3
+
4
+ _expiration_key_prefix: '__expired___storage__',
5
+
6
+ getTimestamp: function() {
7
+ return Math.floor(((new Date()).getTime()) / 1000);
8
+ },
9
+
10
+ setStorageSync: function(key, value, expiration) {
11
+ try {
12
+ this._storage.setStorageSync(key, value);
13
+ } catch (e) {
14
+ // 1. 第一次失败,先清理过期的数据
15
+ this.clearExpiredStorage();
16
+
17
+ try {
18
+ this._storage.setStorageSync(key, value);
19
+ } catch (error) {
20
+ // 2. 第二次失败,则抛出错误
21
+ console.error(`当前存储的key为${key},其value已超出微信数据缓存限制:`)
22
+ console.error('单个 key 允许存储的最大数据长度为 1MB')
23
+ console.error('所有数据存储上限为 10MB。')
24
+ return error
25
+ }
26
+ }
27
+ // 默认过期时间为 7 天
28
+ this.updateExpiration(key, expiration || 7 * 24 * 60 * 60);
29
+ },
30
+
31
+ getStorageSync: function(key) {
32
+ if (this.isExpired(key)) {
33
+ this.removeStorageSync(key);
34
+ return null;
35
+ }
36
+ return this._storage.getStorageSync(key) || null;
37
+ },
38
+
39
+ peek: function(key) {
40
+ let result = {
41
+ value: this._storage.getStorageSync(key),
42
+ timeLeft: this.getTimeLeft(key)
43
+ };
44
+ result.isExpired = result.timeLeft !== null && result.timeLeft <= 0;
45
+ return result;
46
+ },
47
+
48
+ getTimeLeft: function(key) {
49
+ let expireTime = parseInt(this._storage.getStorageSync(this._expiration_key_prefix + key), 10);
50
+ if (expireTime && !isNaN(expireTime)) {
51
+ return expireTime - this.getTimestamp();
52
+ }
53
+ return null;
54
+ },
55
+
56
+ isExpired: function(key) {
57
+ let timeLeft = this.getTimeLeft(key);
58
+ return timeLeft !== null && timeLeft <= 0;
59
+ },
60
+
61
+ updateExpiration: function(key, expiration) {
62
+ return this._storage.setStorageSync(this._expiration_key_prefix + key, this.getTimestamp() + expiration);
63
+ },
64
+
65
+ removeStorageSync: function(key) {
66
+ this._storage.removeStorageSync(key);
67
+ this._storage.removeStorageSync(this._expiration_key_prefix + key);
68
+ },
69
+
70
+ keys: function(includeExpired) {
71
+ let keyList = [];
72
+ this._iterKeys(storageKey => {
73
+ if (storageKey.indexOf(this._expiration_key_prefix) !== 0) {
74
+ if (includeExpired || !this.isExpired(storageKey)) {
75
+ keyList.push(storageKey);
76
+ }
77
+ }
78
+ });
79
+ return keyList;
80
+ },
81
+
82
+ _iterKeys: function(callback) {
83
+ const storageInfo = wx.getStorageInfoSync();
84
+ if (storageInfo.keys) {
85
+ storageInfo.keys.forEach(key => {
86
+ callback(key);
87
+ });
88
+ }
89
+ },
90
+
91
+ clearStorageSync: function() {
92
+ try {
93
+ this._storage.clearStorageSync();
94
+ } catch (err) {
95
+ console.log('Storage clear', err);
96
+ }
97
+ },
98
+
99
+ clearExpiredStorage: function() {
100
+ let resultList = [];
101
+ this._iterKeys((storageKey) => {
102
+ if (storageKey.indexOf(this._expiration_key_prefix) === 0) {
103
+ let itemKey = storageKey.substr(this._expiration_key_prefix.length);
104
+ if (this.isExpired(itemKey)) {
105
+ this.removeStorageSync(itemKey);
106
+ resultList.push(itemKey);
107
+ }
108
+ }
109
+ });
110
+ return resultList;
111
+ }
112
+ };
113
+
114
+ module.exports = Storage;