weapps-plugin-jingtong-verify 1.3.9 → 1.4.1-dev

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 (187) hide show
  1. package/README.md +2 -1
  2. package/app.json +33 -33
  3. package/package.json +20 -20
  4. package/sdk.js +289 -289
  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 -0
  37. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.json +4 -0
  38. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.wxml +13 -0
  39. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.wxss +1 -0
  40. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.js +44 -44
  41. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.json +5 -5
  42. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.wxml +28 -28
  43. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.js +30 -0
  44. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.json +7 -0
  45. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.wxml +42 -0
  46. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.wxss +1 -0
  47. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.js +418 -414
  48. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.json +5 -5
  49. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.wxml +29 -29
  50. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.js +11 -11
  51. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.json +3 -3
  52. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.wxml +4 -4
  53. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.js +179 -179
  54. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.json +6 -6
  55. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.wxml +16 -16
  56. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.js +92 -92
  57. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.json +6 -6
  58. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.wxml +12 -12
  59. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.wxss +2 -2
  60. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.js +49 -48
  61. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.json +3 -3
  62. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.wxml +14 -13
  63. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.js +33 -33
  64. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.json +3 -3
  65. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.wxml +2 -2
  66. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.js +108 -108
  67. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.json +6 -6
  68. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.wxml +53 -53
  69. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.js +237 -233
  70. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.json +8 -8
  71. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.wxml +49 -49
  72. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.js +328 -324
  73. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.json +6 -6
  74. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.wxml +26 -26
  75. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.js +159 -159
  76. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.json +3 -3
  77. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.wxml +10 -10
  78. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.js +112 -112
  79. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.json +5 -5
  80. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.wxml +21 -21
  81. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.js +21 -0
  82. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.json +7 -0
  83. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.wxml +16 -0
  84. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.wxss +1 -0
  85. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.js +50 -50
  86. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.json +5 -5
  87. package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.wxml +27 -27
  88. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/add.svg +13 -13
  89. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/arrow.svg +14 -14
  90. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/delete.svg +16 -16
  91. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/preview.svg +21 -21
  92. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/user.svg +13 -13
  93. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-agree.wxss +147 -147
  94. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-badge.wxss +41 -0
  95. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-button-group.wxss +244 -244
  96. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-cell.wxss +220 -0
  97. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-dropdown.wxss +115 -115
  98. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form-cell.wxss +101 -101
  99. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form-item.wxss +174 -167
  100. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form.wxss +101 -101
  101. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-icon.wxss +268 -268
  102. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-index-list.wxss +206 -206
  103. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-input.wxss +206 -206
  104. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-picker.wxss +139 -139
  105. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-popover.wxss +129 -129
  106. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-search.wxss +171 -171
  107. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-switch.wxss +176 -0
  108. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-tips.wxss +173 -173
  109. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/icon/iconfont.wxss +160 -160
  110. package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/main.wxss +283 -283
  111. package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/helper.js +55 -55
  112. package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/validType.js +117 -117
  113. package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/validator.js +106 -106
  114. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.js +32 -32
  115. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.json +3 -3
  116. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.wxml +8 -8
  117. package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.wxss +57 -57
  118. package/weapps-plugin-jingtong-verify/components/modal/modal.js +32 -32
  119. package/weapps-plugin-jingtong-verify/components/modal/modal.json +3 -3
  120. package/weapps-plugin-jingtong-verify/components/modal/modal.wxml +28 -28
  121. package/weapps-plugin-jingtong-verify/components/modal/modal.wxss +84 -84
  122. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.js +82 -82
  123. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.json +3 -3
  124. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.wxml +18 -18
  125. package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.wxss +72 -71
  126. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.js +39 -35
  127. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.json +3 -3
  128. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.wxml +9 -9
  129. package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.wxss +51 -51
  130. package/weapps-plugin-jingtong-verify/i18n/index.js +7 -7
  131. package/weapps-plugin-jingtong-verify/i18n/logout.js +10 -10
  132. package/weapps-plugin-jingtong-verify/i18n/rules.js +202 -189
  133. package/weapps-plugin-jingtong-verify/images/close-circle.png +0 -0
  134. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.js +86 -86
  135. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.json +6 -6
  136. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.wxml +20 -17
  137. package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.wxss +51 -38
  138. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.js +167 -167
  139. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.json +3 -3
  140. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.wxml +30 -30
  141. package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.wxss +91 -91
  142. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.js +79 -79
  143. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.json +5 -5
  144. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.wxml +19 -19
  145. package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.wxss +44 -44
  146. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.js +1382 -1286
  147. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.json +16 -15
  148. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.wxml +494 -410
  149. package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.wxss +116 -76
  150. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.js +127 -126
  151. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.json +5 -5
  152. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.wxml +36 -36
  153. package/weapps-plugin-jingtong-verify/pages/log-off/log-off.wxss +60 -60
  154. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.js +106 -106
  155. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.json +3 -3
  156. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.wxml +29 -29
  157. package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.wxss +68 -68
  158. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.js +24 -24
  159. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.json +3 -3
  160. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.wxml +12 -12
  161. package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.wxss +33 -33
  162. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.js +110 -97
  163. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.json +6 -6
  164. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.wxml +9 -9
  165. package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.wxss +1 -1
  166. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.js +641 -641
  167. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.json +10 -10
  168. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.wxml +152 -152
  169. package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.wxss +47 -47
  170. package/weapps-plugin-jingtong-verify/pages/setting/setting.js +328 -328
  171. package/weapps-plugin-jingtong-verify/pages/setting/setting.json +5 -5
  172. package/weapps-plugin-jingtong-verify/pages/setting/setting.wxml +91 -91
  173. package/weapps-plugin-jingtong-verify/pages/setting/setting.wxss +69 -69
  174. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.js +306 -159
  175. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.json +7 -6
  176. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.wxml +142 -61
  177. package/weapps-plugin-jingtong-verify/pages/user-info/user-info.wxss +110 -64
  178. package/weapps-plugin-jingtong-verify/style/page.wxss +13 -13
  179. package/weapps-plugin-jingtong-verify/utils/QDTrackerNew/QDTracker.js +15 -15
  180. package/weapps-plugin-jingtong-verify/utils/QDTrackerNew/QDTrackerMain.js +59 -59
  181. package/weapps-plugin-jingtong-verify/utils/country.js +209 -203
  182. package/weapps-plugin-jingtong-verify/utils/index.js +306 -306
  183. package/weapps-plugin-jingtong-verify/utils/jsencrypt.min.js +1 -1
  184. package/weapps-plugin-jingtong-verify/utils/request.js +89 -24
  185. package/weapps-plugin-jingtong-verify/utils/rules.js +258 -162
  186. package/weapps-plugin-jingtong-verify/utils/tifadmin_config.js +61 -61
  187. package/weapps-plugin-jingtong-verify/utils/validate.js +772 -754
@@ -1,218 +1,218 @@
1
- "use strict";
2
- function deepClone(src) {
3
- // 对于数字、字符串、布尔
4
- if (typeof src !== 'object') {
5
- return src;
6
- }
7
- // 对于Date
8
- if (src instanceof Date) {
9
- return new Date(src);
10
- }
11
- // 对于数组
12
- if (src instanceof Array) {
13
- const clone = [];
14
- for (let i = 0, len = src.length; i < len; i++) {
15
- clone[i] = deepClone(src[i]);
16
- }
17
- return clone;
18
- }
19
- // 对于Object对象
20
- if (typeof src === 'object') {
21
- const clone = {};
22
- for (const key in src) {
23
- if (src.hasOwnProperty(key)) {
24
- clone[key] = deepClone(src[key]);
25
- }
26
- }
27
- return clone;
28
- }
29
- }
30
- module.exports = {
31
- debounce(func, wait, immediate) {
32
- // immediate默认为false
33
- let timeout;
34
- let args;
35
- let context;
36
- let timestamp;
37
- let result;
38
- const later = () => {
39
- // 当wait指定的时间间隔期间多次调用_.debounce返回的函数,则会不断更新timestamp的值,导致last < wait && last >= 0一直为true,从而不断启动新的计时器延时执行func
40
- const last = Date.now() - timestamp;
41
- if (last < wait && last >= 0) {
42
- timeout = setTimeout(later, wait - last);
43
- }
44
- else {
45
- timeout = undefined;
46
- if (!immediate) {
47
- result = func.apply(context, args);
48
- if (!timeout) {
49
- context = args = undefined;
50
- }
51
- }
52
- }
53
- };
54
- return function () {
55
- context = this;
56
- args = arguments;
57
- timestamp = Date.now();
58
- // 第一次调用该方法时,且immediate为true,则调用func函数
59
- const callNow = immediate && !timeout;
60
- // 在wait指定的时间间隔内首次调用该方法,则启动计时器定时调用func函数
61
- if (!timeout) {
62
- timeout = setTimeout(later, wait);
63
- }
64
- if (callNow) {
65
- result = func.apply(context, args);
66
- context = args = undefined;
67
- }
68
- return result;
69
- };
70
- },
71
- throttle(fn, delay) {
72
- let timer;
73
- let t_start = Date.now();
74
- return function () {
75
- const context = this;
76
- const args = arguments;
77
- const t_curr = Date.now();
78
- clearTimeout(timer);
79
- if (t_curr - t_start >= delay) {
80
- fn.apply(context, args);
81
- t_start = t_curr;
82
- }
83
- else {
84
- timer = setTimeout(() => {
85
- fn.apply(context, args);
86
- }, delay);
87
- }
88
- };
89
- },
90
- deepClone,
91
- // 生成唯一的 GUID
92
- generateGUID() {
93
- let text = '';
94
- const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
95
- for (let i = 0; i < 10; i++) {
96
- text += possible.charAt(Math.floor(Math.random() * possible.length));
97
- }
98
- return text;
99
- },
100
- // 处理url链接,加入params参数
101
- urlJoinParams(url, params) {
102
- if (!url || !params || typeof params !== 'object') {
103
- return url;
104
- }
105
- const separate = url.indexOf('?') === -1 ? '?' : '&';
106
- const tempStr = Object.keys(params).map(key => {
107
- if (typeof params[key] === 'object') {
108
- params[key] = JSON.stringify(params[key]);
109
- }
110
- if (params[key] !== undefined) {
111
- return `${key}=${params[key]}`;
112
- }
113
- return '';
114
- }).filter(value => value).join('&');
115
- return `${url}${separate}${tempStr}`;
116
- },
117
- compareVersion(version1, version2) {
118
- const v1 = version1.split('.');
119
- const v2 = version2.split('.');
120
- const len = Math.max(v1.length, v2.length);
121
- while (v1.length < len) {
122
- v1.push('0');
123
- }
124
- while (v2.length < len) {
125
- v2.push('0');
126
- }
127
- for (let i = 0; i < len; i++) {
128
- const num1 = parseInt(v1[i], 10);
129
- const num2 = parseInt(v2[i], 10);
130
- if (num1 > num2) {
131
- return 1;
132
- }
133
- else if (num1 < num2) {
134
- return -1;
135
- }
136
- }
137
- return 0;
138
- },
139
- // 拓展方法
140
- extendMethods(methodKeys, src, target) {
141
- if (!methodKeys)
142
- return;
143
- methodKeys.forEach(key => {
144
- if (!src[key]) {
145
- console.warn('源对象的方法不存在:', key);
146
- return;
147
- }
148
- if (target[key]) {
149
- console.warn('目标对象已存在重复方法:', key);
150
- return;
151
- }
152
- target[key] = src[key].bind(src);
153
- });
154
- },
155
- hideIdCard(idCard, keepLength) {
156
- if (!idCard) {
157
- return idCard;
158
- }
159
- const digits = keepLength ? keepLength : 4;
160
- const reg = new RegExp(`(^\\w{${digits}})(\\w+)(\\w{${digits}}$)`, 'g');
161
- return idCard.replace(reg, (...args) => {
162
- let tempStr = '';
163
- if (args[2] && args[2].length) {
164
- for (let i = 0, len = args[2].length; i < len; i++) {
165
- tempStr += '*';
166
- }
167
- }
168
- return args[1] + tempStr + args[3];
169
- });
170
- },
171
- hideName(name) {
172
- if (!name) {
173
- return name;
174
- }
175
- return name.replace(/(^.{1})(.+)$/g, (...args) => {
176
- let tempStr = '';
177
- if (args[2] && args[2].length) {
178
- tempStr = Array.from({
179
- length: args[2].length + 1
180
- }).join('*');
181
- }
182
- return args[1] + tempStr;
183
- });
184
- },
185
- navigateBack(delta) {
186
- return new Promise((resolve) => {
187
- const startDelta = getCurrentPages().length - delta;
188
- wx.navigateBack({
189
- delta,
190
- success: () => {
191
- const checkSuccess = () => {
192
- setTimeout(() => {
193
- const currentPageLength = getCurrentPages().length;
194
- if (startDelta === currentPageLength || currentPageLength <= 1) {
195
- console.log('已回退到指定页面:', getCurrentPages());
196
- resolve();
197
- }
198
- else {
199
- checkSuccess();
200
- }
201
- }, 100);
202
- };
203
- checkSuccess();
204
- }
205
- });
206
- });
207
- },
208
- uniqBy(arr, fn) {
209
- const hashMap = arr.reduce((map, item) => {
210
- const key = fn(item);
211
- if (key && !map[key]) {
212
- map[key] = item;
213
- }
214
- return map;
215
- }, {});
216
- return Object.keys(hashMap).map(key => hashMap[key]);
217
- }
218
- };
1
+ "use strict";
2
+ function deepClone(src) {
3
+ // 对于数字、字符串、布尔
4
+ if (typeof src !== 'object') {
5
+ return src;
6
+ }
7
+ // 对于Date
8
+ if (src instanceof Date) {
9
+ return new Date(src);
10
+ }
11
+ // 对于数组
12
+ if (src instanceof Array) {
13
+ const clone = [];
14
+ for (let i = 0, len = src.length; i < len; i++) {
15
+ clone[i] = deepClone(src[i]);
16
+ }
17
+ return clone;
18
+ }
19
+ // 对于Object对象
20
+ if (typeof src === 'object') {
21
+ const clone = {};
22
+ for (const key in src) {
23
+ if (src.hasOwnProperty(key)) {
24
+ clone[key] = deepClone(src[key]);
25
+ }
26
+ }
27
+ return clone;
28
+ }
29
+ }
30
+ module.exports = {
31
+ debounce(func, wait, immediate) {
32
+ // immediate默认为false
33
+ let timeout;
34
+ let args;
35
+ let context;
36
+ let timestamp;
37
+ let result;
38
+ const later = () => {
39
+ // 当wait指定的时间间隔期间多次调用_.debounce返回的函数,则会不断更新timestamp的值,导致last < wait && last >= 0一直为true,从而不断启动新的计时器延时执行func
40
+ const last = Date.now() - timestamp;
41
+ if (last < wait && last >= 0) {
42
+ timeout = setTimeout(later, wait - last);
43
+ }
44
+ else {
45
+ timeout = undefined;
46
+ if (!immediate) {
47
+ result = func.apply(context, args);
48
+ if (!timeout) {
49
+ context = args = undefined;
50
+ }
51
+ }
52
+ }
53
+ };
54
+ return function () {
55
+ context = this;
56
+ args = arguments;
57
+ timestamp = Date.now();
58
+ // 第一次调用该方法时,且immediate为true,则调用func函数
59
+ const callNow = immediate && !timeout;
60
+ // 在wait指定的时间间隔内首次调用该方法,则启动计时器定时调用func函数
61
+ if (!timeout) {
62
+ timeout = setTimeout(later, wait);
63
+ }
64
+ if (callNow) {
65
+ result = func.apply(context, args);
66
+ context = args = undefined;
67
+ }
68
+ return result;
69
+ };
70
+ },
71
+ throttle(fn, delay) {
72
+ let timer;
73
+ let t_start = Date.now();
74
+ return function () {
75
+ const context = this;
76
+ const args = arguments;
77
+ const t_curr = Date.now();
78
+ clearTimeout(timer);
79
+ if (t_curr - t_start >= delay) {
80
+ fn.apply(context, args);
81
+ t_start = t_curr;
82
+ }
83
+ else {
84
+ timer = setTimeout(() => {
85
+ fn.apply(context, args);
86
+ }, delay);
87
+ }
88
+ };
89
+ },
90
+ deepClone,
91
+ // 生成唯一的 GUID
92
+ generateGUID() {
93
+ let text = '';
94
+ const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
95
+ for (let i = 0; i < 10; i++) {
96
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
97
+ }
98
+ return text;
99
+ },
100
+ // 处理url链接,加入params参数
101
+ urlJoinParams(url, params) {
102
+ if (!url || !params || typeof params !== 'object') {
103
+ return url;
104
+ }
105
+ const separate = url.indexOf('?') === -1 ? '?' : '&';
106
+ const tempStr = Object.keys(params).map(key => {
107
+ if (typeof params[key] === 'object') {
108
+ params[key] = JSON.stringify(params[key]);
109
+ }
110
+ if (params[key] !== undefined) {
111
+ return `${key}=${params[key]}`;
112
+ }
113
+ return '';
114
+ }).filter(value => value).join('&');
115
+ return `${url}${separate}${tempStr}`;
116
+ },
117
+ compareVersion(version1, version2) {
118
+ const v1 = version1.split('.');
119
+ const v2 = version2.split('.');
120
+ const len = Math.max(v1.length, v2.length);
121
+ while (v1.length < len) {
122
+ v1.push('0');
123
+ }
124
+ while (v2.length < len) {
125
+ v2.push('0');
126
+ }
127
+ for (let i = 0; i < len; i++) {
128
+ const num1 = parseInt(v1[i], 10);
129
+ const num2 = parseInt(v2[i], 10);
130
+ if (num1 > num2) {
131
+ return 1;
132
+ }
133
+ else if (num1 < num2) {
134
+ return -1;
135
+ }
136
+ }
137
+ return 0;
138
+ },
139
+ // 拓展方法
140
+ extendMethods(methodKeys, src, target) {
141
+ if (!methodKeys)
142
+ return;
143
+ methodKeys.forEach(key => {
144
+ if (!src[key]) {
145
+ console.warn('源对象的方法不存在:', key);
146
+ return;
147
+ }
148
+ if (target[key]) {
149
+ console.warn('目标对象已存在重复方法:', key);
150
+ return;
151
+ }
152
+ target[key] = src[key].bind(src);
153
+ });
154
+ },
155
+ hideIdCard(idCard, keepLength) {
156
+ if (!idCard) {
157
+ return idCard;
158
+ }
159
+ const digits = keepLength ? keepLength : 4;
160
+ const reg = new RegExp(`(^\\w{${digits}})(\\w+)(\\w{${digits}}$)`, 'g');
161
+ return idCard.replace(reg, (...args) => {
162
+ let tempStr = '';
163
+ if (args[2] && args[2].length) {
164
+ for (let i = 0, len = args[2].length; i < len; i++) {
165
+ tempStr += '*';
166
+ }
167
+ }
168
+ return args[1] + tempStr + args[3];
169
+ });
170
+ },
171
+ hideName(name) {
172
+ if (!name) {
173
+ return name;
174
+ }
175
+ return name.replace(/(^.{1})(.+)$/g, (...args) => {
176
+ let tempStr = '';
177
+ if (args[2] && args[2].length) {
178
+ tempStr = Array.from({
179
+ length: args[2].length + 1
180
+ }).join('*');
181
+ }
182
+ return args[1] + tempStr;
183
+ });
184
+ },
185
+ navigateBack(delta) {
186
+ return new Promise((resolve) => {
187
+ const startDelta = getCurrentPages().length - delta;
188
+ wx.navigateBack({
189
+ delta,
190
+ success: () => {
191
+ const checkSuccess = () => {
192
+ setTimeout(() => {
193
+ const currentPageLength = getCurrentPages().length;
194
+ if (startDelta === currentPageLength || currentPageLength <= 1) {
195
+ console.log('已回退到指定页面:', getCurrentPages());
196
+ resolve();
197
+ }
198
+ else {
199
+ checkSuccess();
200
+ }
201
+ }, 100);
202
+ };
203
+ checkSuccess();
204
+ }
205
+ });
206
+ });
207
+ },
208
+ uniqBy(arr, fn) {
209
+ const hashMap = arr.reduce((map, item) => {
210
+ const key = fn(item);
211
+ if (key && !map[key]) {
212
+ map[key] = item;
213
+ }
214
+ return map;
215
+ }, {});
216
+ return Object.keys(hashMap).map(key => hashMap[key]);
217
+ }
218
+ };
@@ -1,72 +1,72 @@
1
- "use strict";
2
- module.exports = Behavior({
3
- properties: {
4
- icon: String,
5
- disabled: Boolean,
6
- items: {
7
- type: Array,
8
- value: [],
9
- observer(items) {
10
- const { value } = this.properties;
11
- // items 修改时,重置 items 属性
12
- items = items.map(item => {
13
- // 处理 checked 属性
14
- item.checked = false;
15
- // checkbox 数组类
16
- if (Array.isArray(value) && -1 !== value.indexOf(String(item.value))) {
17
- item.checked = true;
18
- }
19
- else if (String(value) === String(item.value)) {
20
- // radio 字符串类
21
- item.checked = true;
22
- }
23
- // 处理 desc 属性
24
- if (typeof item.desc === 'string') {
25
- item.desc = item.desc.split('\n');
26
- }
27
- return item;
28
- });
29
- this.setData({ _items: items });
30
- }
31
- },
32
- value: {
33
- type: [Array, String],
34
- observer(value) {
35
- // value 修改时,统一内部改成 formItem 需要的格式
36
- const items = this.data._items.map(item => {
37
- item.checked = false;
38
- if (Array.isArray(value)) {
39
- if (-1 !== value.indexOf(item.value.toString())) {
40
- item.checked = true;
41
- }
42
- }
43
- else if (String(value) === String(item.value)) {
44
- item.checked = true;
45
- }
46
- return item;
47
- });
48
- this.setData({ _items: items });
49
- }
50
- }
51
- },
52
- /**
53
- * 组件的初始数据
54
- */
55
- data: {
56
- _items: []
57
- },
58
- /**
59
- * 组件的方法列表
60
- */
61
- methods: {
62
- // change 事件
63
- handleChange(e) {
64
- this.triggerEvent('change', e.detail);
65
- },
66
- // 点击 icon
67
- handleIconTap(e) {
68
- const { dataset } = e.currentTarget;
69
- this.triggerEvent('iconTap', dataset.item);
70
- }
71
- }
72
- });
1
+ "use strict";
2
+ module.exports = Behavior({
3
+ properties: {
4
+ icon: String,
5
+ disabled: Boolean,
6
+ items: {
7
+ type: Array,
8
+ value: [],
9
+ observer(items) {
10
+ const { value } = this.properties;
11
+ // items 修改时,重置 items 属性
12
+ items = items.map(item => {
13
+ // 处理 checked 属性
14
+ item.checked = false;
15
+ // checkbox 数组类
16
+ if (Array.isArray(value) && -1 !== value.indexOf(String(item.value))) {
17
+ item.checked = true;
18
+ }
19
+ else if (String(value) === String(item.value)) {
20
+ // radio 字符串类
21
+ item.checked = true;
22
+ }
23
+ // 处理 desc 属性
24
+ if (typeof item.desc === 'string') {
25
+ item.desc = item.desc.split('\n');
26
+ }
27
+ return item;
28
+ });
29
+ this.setData({ _items: items });
30
+ }
31
+ },
32
+ value: {
33
+ type: [Array, String],
34
+ observer(value) {
35
+ // value 修改时,统一内部改成 formItem 需要的格式
36
+ const items = this.data._items.map(item => {
37
+ item.checked = false;
38
+ if (Array.isArray(value)) {
39
+ if (-1 !== value.indexOf(item.value.toString())) {
40
+ item.checked = true;
41
+ }
42
+ }
43
+ else if (String(value) === String(item.value)) {
44
+ item.checked = true;
45
+ }
46
+ return item;
47
+ });
48
+ this.setData({ _items: items });
49
+ }
50
+ }
51
+ },
52
+ /**
53
+ * 组件的初始数据
54
+ */
55
+ data: {
56
+ _items: []
57
+ },
58
+ /**
59
+ * 组件的方法列表
60
+ */
61
+ methods: {
62
+ // change 事件
63
+ handleChange(e) {
64
+ this.triggerEvent('change', e.detail);
65
+ },
66
+ // 点击 icon
67
+ handleIconTap(e) {
68
+ const { dataset } = e.currentTarget;
69
+ this.triggerEvent('iconTap', dataset.item);
70
+ }
71
+ }
72
+ });
@@ -1,47 +1,47 @@
1
- "use strict";
2
- /**
3
- * 处理所有表单相关组件
4
- */
5
- module.exports = Behavior({
6
- relations: {
7
- '../g-form-item/index': {
8
- type: 'child'
9
- },
10
- '../g-form/index': {
11
- type: 'ancestor'
12
- }
13
- },
14
- properties: {
15
- disabled: Boolean,
16
- status: {
17
- type: String,
18
- observer(_status) {
19
- this.setData({ _status });
20
- }
21
- },
22
- statusMessage: {
23
- type: String,
24
- observer(_statusMessage) {
25
- this.setData({ _statusMessage });
26
- }
27
- }
28
- },
29
- data: {
30
- _status: '',
31
- _statusMessage: ''
32
- },
33
- methods: {
34
- // 获取 Form 节点
35
- getFormNode() {
36
- const form = this.getRelationNodes('../g-form/index');
37
- return form && form[0];
38
- },
39
- // 对外提供 warn 方法
40
- warn(errorConfig) {
41
- this.setData({
42
- _status: 'warn',
43
- _statusMessage: errorConfig.message || '填写有误'
44
- });
45
- }
46
- }
47
- });
1
+ "use strict";
2
+ /**
3
+ * 处理所有表单相关组件
4
+ */
5
+ module.exports = Behavior({
6
+ relations: {
7
+ '../g-form-item/index': {
8
+ type: 'child'
9
+ },
10
+ '../g-form/index': {
11
+ type: 'ancestor'
12
+ }
13
+ },
14
+ properties: {
15
+ disabled: Boolean,
16
+ status: {
17
+ type: String,
18
+ observer(_status) {
19
+ this.setData({ _status });
20
+ }
21
+ },
22
+ statusMessage: {
23
+ type: String,
24
+ observer(_statusMessage) {
25
+ this.setData({ _statusMessage });
26
+ }
27
+ }
28
+ },
29
+ data: {
30
+ _status: '',
31
+ _statusMessage: ''
32
+ },
33
+ methods: {
34
+ // 获取 Form 节点
35
+ getFormNode() {
36
+ const form = this.getRelationNodes('../g-form/index');
37
+ return form && form[0];
38
+ },
39
+ // 对外提供 warn 方法
40
+ warn(errorConfig) {
41
+ this.setData({
42
+ _status: 'warn',
43
+ _statusMessage: errorConfig.message || '填写有误'
44
+ });
45
+ }
46
+ }
47
+ });