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,415 +1,419 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- const formControllerBehavior = require("../behaviors/formController")
6
-
7
- Component({
8
- behaviors: [formControllerBehavior],
9
- relations: {
10
- '../g-form-item/index': {
11
- type: 'child'
12
- },
13
- '../g-form/index': {
14
- type: 'ancestor'
15
- }
16
- },
17
- properties: {
18
- value: {
19
- type: String,
20
- observer(newValue) {
21
- this.setValueStatus(newValue)
22
- this.initValue(newValue)
23
- }
24
- },
25
- label: String,
26
- actionText: {
27
- type: String,
28
- value: 'select'
29
- },
30
- disabled: {
31
- type: Boolean
32
- },
33
- placeholder: {
34
- type: String,
35
- value: 'Please select',
36
- observer(newVal) {
37
- if (!this.properties.value) {
38
- this.setData({
39
- _displayName: newVal
40
- });
41
- }
42
- }
43
- },
44
- dateSplitKey: {
45
- type: String,
46
- value: '-',
47
- },
48
- minDate: {
49
- type: Array,
50
- value: null
51
- },
52
- maxDate: {
53
- type: Array,
54
- value: null
55
- }
56
- },
57
-
58
- /**
59
- * 页面的初始数据
60
- */
61
- data: {
62
- _readonly: false,
63
- _rangeKey: 'name',
64
- _displayName: 'Please select',
65
- _status: '',
66
- _statusMessage: '',
67
- _isEmpty: true,
68
- pickerDateshow: false,
69
- years: [],
70
- months: [],
71
- days: [],
72
- year: '',
73
- month: '',
74
- day: '',
75
- pickerValue: [0, 0, 0], //选中值的下标
76
- okText: '确定',
77
- cancelText: '取消'
78
- },
79
- lifetimes: {
80
- ready() {
81
- const that = this
82
- wx.getSystemInfo({
83
- success (res) {
84
- const lang = res.language
85
- if (lang === 'zh_CN') {
86
- that.setData({
87
- okText: '确定',
88
- cancelText: '取消'
89
- })
90
- } else {
91
- that.setData({
92
- okText: 'OK',
93
- cancelText: 'Cancel'
94
- })
95
- }
96
- }
97
- })
98
- this.setValueStatus(this.properties.value)
99
- this.updateYear()
100
- this.initValue(this.properties.value)
101
- }
102
- },
103
- methods: {
104
- // 初始化状态,包括 placeholder, _status
105
- setValueStatus(value) {
106
- const {
107
- placeholder
108
- } = this.properties;
109
- if (value == null || value === '') {
110
- this.setData({
111
- _status: '',
112
- _statusMessage: '',
113
- _isEmpty: true,
114
- _displayName: placeholder
115
- });
116
- } else {
117
- this.setData({
118
- _isEmpty: false,
119
- _status: '',
120
- _statusMessage: '',
121
- _displayName: value
122
- });
123
- }
124
- this.triggerEvent('change', { value })
125
- },
126
- // 更新年份
127
- updateYear () {
128
- const y = new Date().getFullYear()
129
- const { minDate, maxDate } = this.properties
130
- const years = []
131
- const limit = 100
132
- if (!minDate && !maxDate) {
133
- for (let i = y - limit; i <= y + limit; i++) {
134
- years.push(i.toString())
135
- }
136
- } else if (Array.isArray(minDate) && !maxDate) {
137
- const end = minDate[0] >= y ? (minDate[0] + limit) : (y + limit)
138
- for (let i = minDate[0]; i <= end; i++) {
139
- years.push(i.toString())
140
- }
141
- } else if (!minDate && Array.isArray(maxDate)) {
142
- const start = maxDate[0] <= y ? (maxDate[0] - limit) : (y - limit)
143
- for (let i = start; i <= maxDate[0]; i++) {
144
- years.push(i.toString())
145
- }
146
- } else {
147
- for (let i = minDate[0]; i <= maxDate[0]; i++) {
148
- years.push(i.toString())
149
- }
150
- }
151
- this.setData({
152
- years
153
- })
154
- },
155
- // 根据年份更新月份
156
- updateMonth (year) {
157
- const { minDate, maxDate } = this.properties
158
- const months = []
159
- if (!minDate && !maxDate) {
160
- for (let i = 0; i < 12; i++) {
161
- months.push((i + 1).toString().padStart(2, '0'))
162
- }
163
- } else if (Array.isArray(minDate) && !maxDate) {
164
- if (Number(year) === minDate[0]) {
165
- for (let i = minDate[1]; i <= 12; i++) {
166
- months.push(i.toString().padStart(2, '0'))
167
- }
168
- } else {
169
- for (let i = 1; i <= 12; i++) {
170
- months.push(i.toString().padStart(2, '0'))
171
- }
172
- }
173
- } else if (!minDate && Array.isArray(maxDate)) {
174
- if (Number(year) === maxDate[0]) {
175
- for (let i = 1; i <= maxDate[1]; i++) {
176
- months.push(i.toString().padStart(2, '0'))
177
- }
178
- } else {
179
- for (let i = 1; i <= 12; i++) {
180
- months.push(i.toString().padStart(2, '0'))
181
- }
182
- }
183
- } else {
184
- if (Number(year) === minDate[0]) {
185
- for (let i = minDate[1]; i <= 12; i++) {
186
- months.push(i.toString().padStart(2, '0'))
187
- }
188
- } else if (Number(year) === maxDate[0]) {
189
- for (let i = 1; i <= maxDate[1]; i++) {
190
- months.push(i.toString().padStart(2, '0'))
191
- }
192
- } else {
193
- for (let i = 1; i <= 12; i++) {
194
- months.push(i.toString().padStart(2, '0'))
195
- }
196
- }
197
- }
198
- this.setData({
199
- months
200
- })
201
- },
202
- // 更新日期
203
- updateDate (year, month) {
204
- const { minDate, maxDate } = this.properties
205
- const days = []
206
- const daysNum = this.calcDaysByYearMonth(year, month)
207
- if (!minDate && !maxDate) {
208
- for (let i = 1; i <= daysNum; i++) {
209
- days.push(i.toString().padStart(2, '0'))
210
- }
211
- } else if (Array.isArray(minDate) && !maxDate) {
212
- if (Number(year) === minDate[0] && month === minDate[1].toString().padStart(2, '0')) {
213
- for (let i = minDate[2]; i <= daysNum; i++) {
214
- days.push(i.toString().padStart(2, '0'))
215
- }
216
- } else {
217
- for (let i = 1; i <= daysNum; i++) {
218
- days.push(i.toString().padStart(2, '0'))
219
- }
220
- }
221
- } else if (!minDate && Array.isArray(maxDate)) {
222
- if (Number(year) === maxDate[0] && month === maxDate[1].toString().padStart(2, '0')) {
223
- for (let i = 1; i <= maxDate[2]; i++) {
224
- days.push(i.toString().padStart(2, '0'))
225
- }
226
- } else {
227
- for (let i = 1; i <= daysNum; i++) {
228
- days.push(i.toString().padStart(2, '0'))
229
- }
230
- }
231
- } else {
232
- if (Number(year) === minDate[0] && month === minDate[1].toString().padStart(2, '0')) {
233
- for (let i = minDate[2]; i <= daysNum; i++) {
234
- days.push(i.toString().padStart(2, '0'))
235
- }
236
- } else if (Number(year) === maxDate[0] && month === maxDate[1].toString().padStart(2, '0')) {
237
- for (let i = 1; i <= maxDate[2]; i++) {
238
- days.push(i.toString().padStart(2, '0'))
239
- }
240
- } else {
241
- for (let i = 1; i <= daysNum; i++) {
242
- days.push(i.toString().padStart(2, '0'))
243
- }
244
- }
245
- }
246
- this.setData({
247
- days
248
- })
249
- },
250
- // 设置年月份
251
- setYearMonth () {
252
- const y = new Date().getFullYear()
253
- const years = []
254
- const len = y
255
- for (let i = 1900; i <= len; i++) {
256
- years.push(i.toString())
257
- }
258
- const months = []
259
- for (let i = 0; i < 12; i++) {
260
- months.push((i + 1).toString().padStart(2, '0'))
261
- }
262
- this.setData({
263
- years,
264
- months
265
- })
266
- },
267
- // 根据年份月份计算天数
268
- calcDaysByYearMonth(year, month) {
269
- if (month === '02') {
270
- year = Number(year)
271
- return ((year % 4 === 0) && ((year % 100) !== 0)) || (year % 400 === 0) ? 29 : 28
272
- }
273
- let daysInMonth = {
274
- '01': 31,
275
- '02': 28,
276
- '03': 31,
277
- '04': 30,
278
- '05': 31,
279
- '06': 30,
280
- '07': 31,
281
- '08': 31,
282
- '09': 30,
283
- '10': 31,
284
- '11': 30,
285
- '12': 31,
286
- }
287
- return daysInMonth[month]
288
- },
289
- // 根据year和month更新days
290
- setDays (year, month) {
291
- const daysNum = this.calcDaysByYearMonth(year, month)
292
- const days = []
293
- for (let i = 1; i <= daysNum; i++) {
294
- days.push(i.toString().padStart(2, '0'))
295
- }
296
- this.setData({ days })
297
- },
298
- // 对比时间,对比第一个是否大于第二个
299
- contrastDate(dateArr1, dateArr2) {
300
- if (dateArr1[0] > dateArr2[0]) {
301
- return true
302
- } else if (dateArr1[0] === dateArr2[0]) {
303
- if (dateArr1[1] > dateArr2[1]) {
304
- return true
305
- } else if (dateArr1[1] === dateArr2[1]) {
306
- return dateArr1[2] > dateArr2[2]
307
- } else {
308
- return false
309
- }
310
- } else {
311
- return false
312
- }
313
- },
314
- // 根据不同的值更新
315
- updateValue: function(valueArr, valueNumArr) {
316
- const { minDate, maxDate } = this.properties
317
- // 超下限
318
- if (Array.isArray(minDate) && this.contrastDate(minDate, valueNumArr)) {
319
- this.updateMonth(this.data.years[0])
320
- this.updateDate(this.data.years[0],this.data.months[0])
321
- this.setData({
322
- year: this.data.years[0],
323
- month: this.data.months[0],
324
- day: this.data.days[0],
325
- pickerValue: [0, 0, 0]
326
- })
327
- return
328
- }
329
- // 超上限
330
- if (Array.isArray(maxDate) && this.contrastDate(valueNumArr, maxDate)) {
331
- this.updateMonth(this.data.years[this.data.years.length - 1])
332
- this.updateDate(this.data.years[this.data.years.length - 1], this.data.months[this.data.months.length - 1])
333
- this.setData({
334
- year: this.data.years[this.data.years.length - 1],
335
- month: this.data.months[this.data.months.length - 1],
336
- day: this.data.days[this.data.days.length - 1],
337
- pickerValue: [this.data.years.length - 1, this.data.months.length - 1, this.data.days.length - 1]
338
- })
339
- return
340
- }
341
- // 范围内
342
- const yearIdx = this.data.years.findIndex(item => item === valueArr[0])
343
- // 是否超限
344
- const isLimited = yearIdx === -1
345
- this.updateMonth(isLimited ? this.data.years[0] : valueArr[0])
346
- isLimited ? this.updateDate(this.data.years[0], this.data.months[0]) : this.updateDate(valueArr[0], valueArr[1])
347
- const monthIdx = this.data.months.findIndex(item => item === valueArr[1])
348
- const dayIdx = this.data.days.findIndex(item => item === valueArr[2])
349
- this.setData({
350
- year: isLimited ? this.data.years[0] : valueArr[0],
351
- month: isLimited ? this.data.months[0] : valueArr[1],
352
- day: isLimited ? this.data.days[0] : valueArr[2],
353
- pickerValue: [
354
- isLimited ? 0 : yearIdx,
355
- isLimited ? 0 : (monthIdx === -1 ? 0 : monthIdx),
356
- isLimited ? 0 : (dayIdx === -1 ? 0 : dayIdx)
357
- ]
358
- })
359
- },
360
- // 根据初始的value初始化数据
361
- initValue: function (value) {
362
- const { dateSplitKey } = this.properties
363
- if (value != null && value !== '' && value.split(dateSplitKey).length === 3) {
364
- const valueArr = value.split(dateSplitKey)
365
- const valueNumArr = valueArr.map(i => Number(i))
366
- this.updateValue(valueArr, valueNumArr)
367
- } else {
368
- const d = new Date()
369
- const valueArr = [d.getFullYear().toString(), (d.getMonth() + 1).toString().padStart(2, '0'), d.getDate().toString().padStart(2, '0')]
370
- const valueNumArr = [d.getFullYear(), d.getMonth() + 1, d.getDate()]
371
- this.updateValue(valueArr, valueNumArr)
372
- }
373
- },
374
- // 打开选框
375
- open: function () {
376
- this.initValue(this.properties.value)
377
- this.setData({
378
- pickerDateshow: true
379
- })
380
- },
381
- // 关闭选框
382
- close: function () {
383
- this.setData({
384
- pickerDateshow: false
385
- })
386
- },
387
- // 处理选择
388
- handleSelect: function (e) {
389
- const {
390
- dateSplitKey
391
- } = this.properties
392
- const newVal = `${this.data.year}${dateSplitKey}${this.data.month}${dateSplitKey}${this.data.day}`
393
- this.setValueStatus(newVal)
394
- this.setData({
395
- pickerValue: this.tempVal,
396
- pickerDateshow: false
397
- })
398
- },
399
- bindChange: function (e) {
400
- // 临时日期,记录picker-view触发的change事件返回的值
401
- let tempVal = e.detail.value;
402
- this.tempVal = tempVal; // 记录改变后的日期
403
- const year = this.data.years[tempVal[0]]
404
- this.updateMonth(year)
405
- const month = this.data.months[tempVal[1]]
406
- this.updateDate(year, month)
407
- const day = this.data.days[tempVal[2]]
408
- this.setData({
409
- year,
410
- month,
411
- day
412
- })
413
- },
414
- },
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const formControllerBehavior = require("../behaviors/formController")
6
+
7
+ Component({
8
+ behaviors: [formControllerBehavior],
9
+ relations: {
10
+ '../g-form-item/index': {
11
+ type: 'child'
12
+ },
13
+ '../g-form/index': {
14
+ type: 'ancestor'
15
+ }
16
+ },
17
+ properties: {
18
+ value: {
19
+ type: String,
20
+ observer(newValue) {
21
+ this.setValueStatus(newValue)
22
+ this.initValue(newValue)
23
+ }
24
+ },
25
+ label: String,
26
+ _required: {
27
+ type: Boolean,
28
+ value: true
29
+ },
30
+ actionText: {
31
+ type: String,
32
+ value: 'select'
33
+ },
34
+ disabled: {
35
+ type: Boolean
36
+ },
37
+ placeholder: {
38
+ type: String,
39
+ value: 'Please select',
40
+ observer(newVal) {
41
+ if (!this.properties.value) {
42
+ this.setData({
43
+ _displayName: newVal
44
+ });
45
+ }
46
+ }
47
+ },
48
+ dateSplitKey: {
49
+ type: String,
50
+ value: '-',
51
+ },
52
+ minDate: {
53
+ type: Array,
54
+ value: null
55
+ },
56
+ maxDate: {
57
+ type: Array,
58
+ value: null
59
+ }
60
+ },
61
+
62
+ /**
63
+ * 页面的初始数据
64
+ */
65
+ data: {
66
+ _readonly: false,
67
+ _rangeKey: 'name',
68
+ _displayName: 'Please select',
69
+ _status: '',
70
+ _statusMessage: '',
71
+ _isEmpty: true,
72
+ pickerDateshow: false,
73
+ years: [],
74
+ months: [],
75
+ days: [],
76
+ year: '',
77
+ month: '',
78
+ day: '',
79
+ pickerValue: [0, 0, 0], //选中值的下标
80
+ okText: '确定',
81
+ cancelText: '取消'
82
+ },
83
+ lifetimes: {
84
+ ready() {
85
+ const that = this
86
+ wx.getSystemInfo({
87
+ success (res) {
88
+ const lang = res.language
89
+ if (lang === 'zh_CN') {
90
+ that.setData({
91
+ okText: '确定',
92
+ cancelText: '取消'
93
+ })
94
+ } else {
95
+ that.setData({
96
+ okText: 'OK',
97
+ cancelText: 'Cancel'
98
+ })
99
+ }
100
+ }
101
+ })
102
+ this.setValueStatus(this.properties.value)
103
+ this.updateYear()
104
+ this.initValue(this.properties.value)
105
+ }
106
+ },
107
+ methods: {
108
+ // 初始化状态,包括 placeholder, _status
109
+ setValueStatus(value) {
110
+ const {
111
+ placeholder
112
+ } = this.properties;
113
+ if (value == null || value === '') {
114
+ this.setData({
115
+ _status: '',
116
+ _statusMessage: '',
117
+ _isEmpty: true,
118
+ _displayName: placeholder
119
+ });
120
+ } else {
121
+ this.setData({
122
+ _isEmpty: false,
123
+ _status: '',
124
+ _statusMessage: '',
125
+ _displayName: value
126
+ });
127
+ }
128
+ this.triggerEvent('change', { value })
129
+ },
130
+ // 更新年份
131
+ updateYear () {
132
+ const y = new Date().getFullYear()
133
+ const { minDate, maxDate } = this.properties
134
+ const years = []
135
+ const limit = 100
136
+ if (!minDate && !maxDate) {
137
+ for (let i = y - limit; i <= y + limit; i++) {
138
+ years.push(i.toString())
139
+ }
140
+ } else if (Array.isArray(minDate) && !maxDate) {
141
+ const end = minDate[0] >= y ? (minDate[0] + limit) : (y + limit)
142
+ for (let i = minDate[0]; i <= end; i++) {
143
+ years.push(i.toString())
144
+ }
145
+ } else if (!minDate && Array.isArray(maxDate)) {
146
+ const start = maxDate[0] <= y ? (maxDate[0] - limit) : (y - limit)
147
+ for (let i = start; i <= maxDate[0]; i++) {
148
+ years.push(i.toString())
149
+ }
150
+ } else {
151
+ for (let i = minDate[0]; i <= maxDate[0]; i++) {
152
+ years.push(i.toString())
153
+ }
154
+ }
155
+ this.setData({
156
+ years
157
+ })
158
+ },
159
+ // 根据年份更新月份
160
+ updateMonth (year) {
161
+ const { minDate, maxDate } = this.properties
162
+ const months = []
163
+ if (!minDate && !maxDate) {
164
+ for (let i = 0; i < 12; i++) {
165
+ months.push((i + 1).toString().padStart(2, '0'))
166
+ }
167
+ } else if (Array.isArray(minDate) && !maxDate) {
168
+ if (Number(year) === minDate[0]) {
169
+ for (let i = minDate[1]; i <= 12; i++) {
170
+ months.push(i.toString().padStart(2, '0'))
171
+ }
172
+ } else {
173
+ for (let i = 1; i <= 12; i++) {
174
+ months.push(i.toString().padStart(2, '0'))
175
+ }
176
+ }
177
+ } else if (!minDate && Array.isArray(maxDate)) {
178
+ if (Number(year) === maxDate[0]) {
179
+ for (let i = 1; i <= maxDate[1]; i++) {
180
+ months.push(i.toString().padStart(2, '0'))
181
+ }
182
+ } else {
183
+ for (let i = 1; i <= 12; i++) {
184
+ months.push(i.toString().padStart(2, '0'))
185
+ }
186
+ }
187
+ } else {
188
+ if (Number(year) === minDate[0]) {
189
+ for (let i = minDate[1]; i <= 12; i++) {
190
+ months.push(i.toString().padStart(2, '0'))
191
+ }
192
+ } else if (Number(year) === maxDate[0]) {
193
+ for (let i = 1; i <= maxDate[1]; i++) {
194
+ months.push(i.toString().padStart(2, '0'))
195
+ }
196
+ } else {
197
+ for (let i = 1; i <= 12; i++) {
198
+ months.push(i.toString().padStart(2, '0'))
199
+ }
200
+ }
201
+ }
202
+ this.setData({
203
+ months
204
+ })
205
+ },
206
+ // 更新日期
207
+ updateDate (year, month) {
208
+ const { minDate, maxDate } = this.properties
209
+ const days = []
210
+ const daysNum = this.calcDaysByYearMonth(year, month)
211
+ if (!minDate && !maxDate) {
212
+ for (let i = 1; i <= daysNum; i++) {
213
+ days.push(i.toString().padStart(2, '0'))
214
+ }
215
+ } else if (Array.isArray(minDate) && !maxDate) {
216
+ if (Number(year) === minDate[0] && month === minDate[1].toString().padStart(2, '0')) {
217
+ for (let i = minDate[2]; i <= daysNum; i++) {
218
+ days.push(i.toString().padStart(2, '0'))
219
+ }
220
+ } else {
221
+ for (let i = 1; i <= daysNum; i++) {
222
+ days.push(i.toString().padStart(2, '0'))
223
+ }
224
+ }
225
+ } else if (!minDate && Array.isArray(maxDate)) {
226
+ if (Number(year) === maxDate[0] && month === maxDate[1].toString().padStart(2, '0')) {
227
+ for (let i = 1; i <= maxDate[2]; i++) {
228
+ days.push(i.toString().padStart(2, '0'))
229
+ }
230
+ } else {
231
+ for (let i = 1; i <= daysNum; i++) {
232
+ days.push(i.toString().padStart(2, '0'))
233
+ }
234
+ }
235
+ } else {
236
+ if (Number(year) === minDate[0] && month === minDate[1].toString().padStart(2, '0')) {
237
+ for (let i = minDate[2]; i <= daysNum; i++) {
238
+ days.push(i.toString().padStart(2, '0'))
239
+ }
240
+ } else if (Number(year) === maxDate[0] && month === maxDate[1].toString().padStart(2, '0')) {
241
+ for (let i = 1; i <= maxDate[2]; i++) {
242
+ days.push(i.toString().padStart(2, '0'))
243
+ }
244
+ } else {
245
+ for (let i = 1; i <= daysNum; i++) {
246
+ days.push(i.toString().padStart(2, '0'))
247
+ }
248
+ }
249
+ }
250
+ this.setData({
251
+ days
252
+ })
253
+ },
254
+ // 设置年月份
255
+ setYearMonth () {
256
+ const y = new Date().getFullYear()
257
+ const years = []
258
+ const len = y
259
+ for (let i = 1900; i <= len; i++) {
260
+ years.push(i.toString())
261
+ }
262
+ const months = []
263
+ for (let i = 0; i < 12; i++) {
264
+ months.push((i + 1).toString().padStart(2, '0'))
265
+ }
266
+ this.setData({
267
+ years,
268
+ months
269
+ })
270
+ },
271
+ // 根据年份月份计算天数
272
+ calcDaysByYearMonth(year, month) {
273
+ if (month === '02') {
274
+ year = Number(year)
275
+ return ((year % 4 === 0) && ((year % 100) !== 0)) || (year % 400 === 0) ? 29 : 28
276
+ }
277
+ let daysInMonth = {
278
+ '01': 31,
279
+ '02': 28,
280
+ '03': 31,
281
+ '04': 30,
282
+ '05': 31,
283
+ '06': 30,
284
+ '07': 31,
285
+ '08': 31,
286
+ '09': 30,
287
+ '10': 31,
288
+ '11': 30,
289
+ '12': 31,
290
+ }
291
+ return daysInMonth[month]
292
+ },
293
+ // 根据year和month更新days
294
+ setDays (year, month) {
295
+ const daysNum = this.calcDaysByYearMonth(year, month)
296
+ const days = []
297
+ for (let i = 1; i <= daysNum; i++) {
298
+ days.push(i.toString().padStart(2, '0'))
299
+ }
300
+ this.setData({ days })
301
+ },
302
+ // 对比时间,对比第一个是否大于第二个
303
+ contrastDate(dateArr1, dateArr2) {
304
+ if (dateArr1[0] > dateArr2[0]) {
305
+ return true
306
+ } else if (dateArr1[0] === dateArr2[0]) {
307
+ if (dateArr1[1] > dateArr2[1]) {
308
+ return true
309
+ } else if (dateArr1[1] === dateArr2[1]) {
310
+ return dateArr1[2] > dateArr2[2]
311
+ } else {
312
+ return false
313
+ }
314
+ } else {
315
+ return false
316
+ }
317
+ },
318
+ // 根据不同的值更新
319
+ updateValue: function(valueArr, valueNumArr) {
320
+ const { minDate, maxDate } = this.properties
321
+ // 超下限
322
+ if (Array.isArray(minDate) && this.contrastDate(minDate, valueNumArr)) {
323
+ this.updateMonth(this.data.years[0])
324
+ this.updateDate(this.data.years[0],this.data.months[0])
325
+ this.setData({
326
+ year: this.data.years[0],
327
+ month: this.data.months[0],
328
+ day: this.data.days[0],
329
+ pickerValue: [0, 0, 0]
330
+ })
331
+ return
332
+ }
333
+ // 超上限
334
+ if (Array.isArray(maxDate) && this.contrastDate(valueNumArr, maxDate)) {
335
+ this.updateMonth(this.data.years[this.data.years.length - 1])
336
+ this.updateDate(this.data.years[this.data.years.length - 1], this.data.months[this.data.months.length - 1])
337
+ this.setData({
338
+ year: this.data.years[this.data.years.length - 1],
339
+ month: this.data.months[this.data.months.length - 1],
340
+ day: this.data.days[this.data.days.length - 1],
341
+ pickerValue: [this.data.years.length - 1, this.data.months.length - 1, this.data.days.length - 1]
342
+ })
343
+ return
344
+ }
345
+ // 范围内
346
+ const yearIdx = this.data.years.findIndex(item => item === valueArr[0])
347
+ // 是否超限
348
+ const isLimited = yearIdx === -1
349
+ this.updateMonth(isLimited ? this.data.years[0] : valueArr[0])
350
+ isLimited ? this.updateDate(this.data.years[0], this.data.months[0]) : this.updateDate(valueArr[0], valueArr[1])
351
+ const monthIdx = this.data.months.findIndex(item => item === valueArr[1])
352
+ const dayIdx = this.data.days.findIndex(item => item === valueArr[2])
353
+ this.setData({
354
+ year: isLimited ? this.data.years[0] : valueArr[0],
355
+ month: isLimited ? this.data.months[0] : valueArr[1],
356
+ day: isLimited ? this.data.days[0] : valueArr[2],
357
+ pickerValue: [
358
+ isLimited ? 0 : yearIdx,
359
+ isLimited ? 0 : (monthIdx === -1 ? 0 : monthIdx),
360
+ isLimited ? 0 : (dayIdx === -1 ? 0 : dayIdx)
361
+ ]
362
+ })
363
+ },
364
+ // 根据初始的value初始化数据
365
+ initValue: function (value) {
366
+ const { dateSplitKey } = this.properties
367
+ if (value != null && value !== '' && value.split(dateSplitKey).length === 3) {
368
+ const valueArr = value.split(dateSplitKey)
369
+ const valueNumArr = valueArr.map(i => Number(i))
370
+ this.updateValue(valueArr, valueNumArr)
371
+ } else {
372
+ const d = new Date()
373
+ const valueArr = [d.getFullYear().toString(), (d.getMonth() + 1).toString().padStart(2, '0'), d.getDate().toString().padStart(2, '0')]
374
+ const valueNumArr = [d.getFullYear(), d.getMonth() + 1, d.getDate()]
375
+ this.updateValue(valueArr, valueNumArr)
376
+ }
377
+ },
378
+ // 打开选框
379
+ open: function () {
380
+ this.initValue(this.properties.value)
381
+ this.setData({
382
+ pickerDateshow: true
383
+ })
384
+ },
385
+ // 关闭选框
386
+ close: function () {
387
+ this.setData({
388
+ pickerDateshow: false
389
+ })
390
+ },
391
+ // 处理选择
392
+ handleSelect: function (e) {
393
+ const {
394
+ dateSplitKey
395
+ } = this.properties
396
+ const newVal = `${this.data.year}${dateSplitKey}${this.data.month}${dateSplitKey}${this.data.day}`
397
+ this.setValueStatus(newVal)
398
+ this.setData({
399
+ pickerValue: this.tempVal,
400
+ pickerDateshow: false
401
+ })
402
+ },
403
+ bindChange: function (e) {
404
+ // 临时日期,记录picker-view触发的change事件返回的值
405
+ let tempVal = e.detail.value;
406
+ this.tempVal = tempVal; // 记录改变后的日期
407
+ const year = this.data.years[tempVal[0]]
408
+ this.updateMonth(year)
409
+ const month = this.data.months[tempVal[1]]
410
+ this.updateDate(year, month)
411
+ const day = this.data.days[tempVal[2]]
412
+ this.setData({
413
+ year,
414
+ month,
415
+ day
416
+ })
417
+ },
418
+ },
415
419
  })