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.
- package/README.md +1 -1
- package/app.json +33 -41
- package/package.json +21 -21
- package/sdk.js +309 -320
- package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.js +31 -31
- package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.json +3 -3
- package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.wxml +9 -9
- package/weapps-plugin-jingtong-verify/components/card-modal/card-modal.wxss +65 -65
- package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.js +37 -37
- package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.json +3 -3
- package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.wxml +30 -30
- package/weapps-plugin-jingtong-verify/components/face-error-modal/face-error-modal.wxss +79 -79
- package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.js +32 -32
- package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.json +3 -3
- package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.wxml +16 -16
- package/weapps-plugin-jingtong-verify/components/face-modal/face-modal.wxss +57 -57
- package/weapps-plugin-jingtong-verify/components/gsd-lib/anim/anim.min.js +1 -1
- package/weapps-plugin-jingtong-verify/components/gsd-lib/crypto/crypto.js +37 -37
- package/weapps-plugin-jingtong-verify/components/gsd-lib/crypto/index.js +44 -44
- package/weapps-plugin-jingtong-verify/components/gsd-lib/dayjs/index.js +351 -351
- package/weapps-plugin-jingtong-verify/components/gsd-lib/event/index.js +117 -117
- package/weapps-plugin-jingtong-verify/components/gsd-lib/index.js +63 -63
- package/weapps-plugin-jingtong-verify/components/gsd-lib/map/index.js +10 -10
- package/weapps-plugin-jingtong-verify/components/gsd-lib/map/qmap.js +6 -6
- package/weapps-plugin-jingtong-verify/components/gsd-lib/storage/index.js +114 -114
- package/weapps-plugin-jingtong-verify/components/gsd-lib/utils/index.js +218 -218
- package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/formCheck.js +72 -72
- package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/formController.js +47 -47
- package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/icon.js +11 -11
- package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/list.js +16 -16
- package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/navigator.js +33 -33
- package/weapps-plugin-jingtong-verify/components/gsd-ui/behaviors/primarySecondButton.js +18 -18
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-agree/index.js +12 -12
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-agree/index.json +5 -5
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-agree/index.wxml +15 -15
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.js +47 -47
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.json +3 -3
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-badge/index.wxml +13 -13
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.js +44 -44
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.json +5 -5
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-button-group/index.wxml +28 -28
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.js +30 -30
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.json +6 -6
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.wxml +42 -42
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-cell/index.wxss +1 -1
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.js +418 -418
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.json +5 -5
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-date-picker-en/index.wxml +29 -29
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.js +11 -11
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.json +3 -3
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-dropdown/index.wxml +4 -4
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.js +179 -182
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.json +6 -6
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form/index.wxml +16 -16
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.js +92 -92
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.json +6 -6
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.wxml +12 -12
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-cell/index.wxss +2 -2
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.js +49 -49
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.json +3 -3
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-form-item/index.wxml +14 -14
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.js +33 -33
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.json +3 -3
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-icon/index.wxml +2 -2
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.js +108 -108
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.json +6 -6
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-index-list/index.wxml +53 -53
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.js +236 -241
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.json +8 -8
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-input/index.wxml +49 -49
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.js +328 -328
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.json +6 -6
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-picker/index.wxml +26 -26
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.js +159 -159
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.json +3 -3
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-popover/index.wxml +10 -10
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.js +112 -112
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.json +5 -5
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-search/index.wxml +21 -21
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.js +21 -21
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.json +7 -7
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-switch/index.wxml +16 -16
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.js +50 -50
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.json +5 -5
- package/weapps-plugin-jingtong-verify/components/gsd-ui/g-tips/index.wxml +27 -27
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/add.svg +13 -13
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/arrow.svg +14 -14
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/delete.svg +16 -16
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/preview.svg +21 -21
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/image/user.svg +13 -13
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-agree.wxss +147 -147
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-badge.wxss +41 -41
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-button-group.wxss +244 -244
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-cell.wxss +220 -220
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-dropdown.wxss +115 -115
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form-cell.wxss +101 -101
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form-item.wxss +174 -174
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-form.wxss +101 -101
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-icon.wxss +268 -268
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-index-list.wxss +206 -206
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-input.wxss +206 -214
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-picker.wxss +139 -139
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-popover.wxss +129 -129
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-search.wxss +171 -171
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-switch.wxss +176 -176
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/components/g-tips.wxss +173 -173
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/icon/iconfont.wxss +160 -160
- package/weapps-plugin-jingtong-verify/components/gsd-ui/static/style/main.wxss +283 -283
- package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/helper.js +55 -55
- package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/validType.js +117 -117
- package/weapps-plugin-jingtong-verify/components/gsd-ui/utils/validator.js +106 -106
- package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.js +32 -32
- package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.json +3 -3
- package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.wxml +8 -8
- package/weapps-plugin-jingtong-verify/components/lock-face-modal/lock-face-modal.wxss +57 -57
- package/weapps-plugin-jingtong-verify/components/modal/modal.js +32 -32
- package/weapps-plugin-jingtong-verify/components/modal/modal.json +3 -3
- package/weapps-plugin-jingtong-verify/components/modal/modal.wxml +28 -28
- package/weapps-plugin-jingtong-verify/components/modal/modal.wxss +84 -84
- package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.js +82 -82
- package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.json +3 -3
- package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.wxml +18 -18
- package/weapps-plugin-jingtong-verify/components/my-modal/my-modal.wxss +72 -72
- package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.js +39 -47
- package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.json +3 -3
- package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.wxml +9 -11
- package/weapps-plugin-jingtong-verify/components/tip-modal/tip-modal.wxss +51 -51
- package/weapps-plugin-jingtong-verify/i18n/index.js +7 -7
- package/weapps-plugin-jingtong-verify/i18n/logout.js +10 -10
- package/weapps-plugin-jingtong-verify/i18n/rules.js +262 -403
- package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.js +86 -86
- package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.json +6 -6
- package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.wxml +20 -20
- package/weapps-plugin-jingtong-verify/pages/bind-phone/bind-phone.wxss +51 -51
- package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.js +167 -167
- package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.json +3 -3
- package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.wxml +30 -30
- package/weapps-plugin-jingtong-verify/pages/confirm-phone/confirm-phone.wxss +91 -91
- package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.js +79 -79
- package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.json +5 -5
- package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.wxml +19 -19
- package/weapps-plugin-jingtong-verify/pages/face-error-reason/face-error-reason.wxss +44 -44
- package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.js +1558 -1812
- package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.json +17 -17
- package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.wxml +504 -522
- package/weapps-plugin-jingtong-verify/pages/face-verify/face-verify.wxss +133 -185
- package/weapps-plugin-jingtong-verify/pages/log-off/log-off.js +127 -127
- package/weapps-plugin-jingtong-verify/pages/log-off/log-off.json +5 -5
- package/weapps-plugin-jingtong-verify/pages/log-off/log-off.wxml +36 -36
- package/weapps-plugin-jingtong-verify/pages/log-off/log-off.wxss +60 -60
- package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.js +106 -106
- package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.json +3 -3
- package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.wxml +29 -29
- package/weapps-plugin-jingtong-verify/pages/login-manage/login-manage.wxss +68 -68
- package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.js +24 -24
- package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.json +3 -3
- package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.wxml +12 -12
- package/weapps-plugin-jingtong-verify/pages/logoff-success/logoff-success.wxss +33 -33
- package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.js +120 -110
- package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.json +6 -6
- package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.wxml +9 -9
- package/weapps-plugin-jingtong-verify/pages/nation-list/nation-list.wxss +1 -1
- package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.js +864 -854
- package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.json +11 -11
- package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.wxml +162 -162
- package/weapps-plugin-jingtong-verify/pages/passport-verify/passport-verify.wxss +64 -64
- package/weapps-plugin-jingtong-verify/pages/setting/setting.js +328 -331
- package/weapps-plugin-jingtong-verify/pages/setting/setting.json +5 -5
- package/weapps-plugin-jingtong-verify/pages/setting/setting.wxml +91 -91
- package/weapps-plugin-jingtong-verify/pages/setting/setting.wxss +69 -69
- package/weapps-plugin-jingtong-verify/pages/user-info/user-info.js +306 -306
- package/weapps-plugin-jingtong-verify/pages/user-info/user-info.json +7 -7
- package/weapps-plugin-jingtong-verify/pages/user-info/user-info.wxml +142 -142
- package/weapps-plugin-jingtong-verify/pages/user-info/user-info.wxss +110 -110
- package/weapps-plugin-jingtong-verify/style/page.wxss +13 -13
- package/weapps-plugin-jingtong-verify/utils/QDTrackerNew/QDTracker.js +15 -15
- package/weapps-plugin-jingtong-verify/utils/QDTrackerNew/QDTrackerMain.js +59 -59
- package/weapps-plugin-jingtong-verify/utils/country.js +209 -209
- package/weapps-plugin-jingtong-verify/utils/index.js +306 -306
- package/weapps-plugin-jingtong-verify/utils/jsencrypt.min.js +1 -1
- package/weapps-plugin-jingtong-verify/utils/request.js +1 -670
- package/weapps-plugin-jingtong-verify/utils/rules.js +301 -405
- package/weapps-plugin-jingtong-verify/utils/tifadmin_config.js +61 -61
- package/weapps-plugin-jingtong-verify/utils/validate.js +772 -910
- package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.js +0 -41
- package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.json +0 -4
- package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.wxml +0 -20
- package/weapps-plugin-jingtong-verify/components/custom-steps/custom-steps.wxss +0 -112
- package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.js +0 -73
- package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.json +0 -4
- package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.wxml +0 -19
- package/weapps-plugin-jingtong-verify/components/to-other-modal/to-other-modal.wxss +0 -72
- package/weapps-plugin-jingtong-verify/images/bank-card-verify.png +0 -0
- package/weapps-plugin-jingtong-verify/images/chek_right.png +0 -0
- package/weapps-plugin-jingtong-verify/images/chevron-down.png +0 -0
- package/weapps-plugin-jingtong-verify/images/chevron-up.png +0 -0
- package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.js +0 -506
- package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.json +0 -8
- package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.wxml +0 -79
- package/weapps-plugin-jingtong-verify/pages/bank-card-login/bank-card-login.wxss +0 -212
- package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.js +0 -1392
- package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.json +0 -10
- package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.wxml +0 -247
- package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-face-setting/bank-card-login-forgot-face-setting.wxss +0 -397
- package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-sms-setting/bank-card-login-forgot-sms-setting.js +0 -66
- package/weapps-plugin-jingtong-verify/pages/bank-card-login-forgot-sms-setting/bank-card-login-forgot-sms-setting.wxml +0 -2
- package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.js +0 -463
- package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.json +0 -8
- package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.wxml +0 -69
- package/weapps-plugin-jingtong-verify/pages/bank-card-login-pwd-setting/bank-card-login-pwd-setting.wxss +0 -232
- package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.js +0 -984
- package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.json +0 -12
- package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.wxml +0 -157
- package/weapps-plugin-jingtong-verify/pages/bank-card-verify/bank-card-verify.wxss +0 -258
- package/weapps-plugin-jingtong-verify/pages/login-help/login-help.js +0 -147
- package/weapps-plugin-jingtong-verify/pages/login-help/login-help.json +0 -4
- package/weapps-plugin-jingtong-verify/pages/login-help/login-help.wxml +0 -48
- package/weapps-plugin-jingtong-verify/pages/login-help/login-help.wxss +0 -166
- package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.js +0 -189
- package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.json +0 -4
- package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.wxml +0 -19
- package/weapps-plugin-jingtong-verify/pages/login-manage-setting/login-manage-setting.wxss +0 -69
- package/weapps-plugin-jingtong-verify/utils/constantVal.js +0 -75
- package/weapps-plugin-jingtong-verify/utils/md5.js +0 -184
|
@@ -1,419 +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
|
-
_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
|
-
},
|
|
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
|
+
},
|
|
419
419
|
})
|