@gmcb/uv-ui 0.2.26
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/CHANGELOG.md +295 -0
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/components/uv-action-sheet/props.js +50 -0
- package/components/uv-action-sheet/uv-action-sheet.vue +280 -0
- package/components/uv-album/uv-album.vue +312 -0
- package/components/uv-alert/props.js +45 -0
- package/components/uv-alert/uv-alert.vue +246 -0
- package/components/uv-avatar/props.js +85 -0
- package/components/uv-avatar/uv-avatar.vue +182 -0
- package/components/uv-avatar-group/props.js +53 -0
- package/components/uv-avatar-group/uv-avatar-group.vue +106 -0
- package/components/uv-back-top/props.js +58 -0
- package/components/uv-back-top/uv-back-top.vue +116 -0
- package/components/uv-badge/props.js +73 -0
- package/components/uv-badge/uv-badge.vue +176 -0
- package/components/uv-button/nvue.scss +46 -0
- package/components/uv-button/props.js +163 -0
- package/components/uv-button/uv-button.vue +529 -0
- package/components/uv-button/vue.scss +93 -0
- package/components/uv-calendar/calendar.js +546 -0
- package/components/uv-calendar/header.vue +104 -0
- package/components/uv-calendar/month.vue +616 -0
- package/components/uv-calendar/props.js +145 -0
- package/components/uv-calendar/uv-calendar.vue +390 -0
- package/components/uv-calendars/calendar-body.vue +376 -0
- package/components/uv-calendars/calendar-item.vue +248 -0
- package/components/uv-calendars/calendar.js +546 -0
- package/components/uv-calendars/i18n/en.json +12 -0
- package/components/uv-calendars/i18n/index.js +8 -0
- package/components/uv-calendars/i18n/zh-Hans.json +12 -0
- package/components/uv-calendars/i18n/zh-Hant.json +12 -0
- package/components/uv-calendars/util.js +435 -0
- package/components/uv-calendars/uv-calendars.vue +452 -0
- package/components/uv-cell/props.js +116 -0
- package/components/uv-cell/uv-cell.vue +209 -0
- package/components/uv-cell-group/props.js +15 -0
- package/components/uv-cell-group/uv-cell-group.vue +63 -0
- package/components/uv-checkbox/props.js +70 -0
- package/components/uv-checkbox/uv-checkbox.vue +371 -0
- package/components/uv-checkbox-group/props.js +84 -0
- package/components/uv-checkbox-group/uv-checkbox-group.vue +119 -0
- package/components/uv-code/props.js +35 -0
- package/components/uv-code/uv-code.vue +136 -0
- package/components/uv-code-input/props.js +83 -0
- package/components/uv-code-input/uv-code-input.vue +272 -0
- package/components/uv-col/props.js +30 -0
- package/components/uv-col/uv-col.vue +165 -0
- package/components/uv-collapse/props.js +20 -0
- package/components/uv-collapse/uv-collapse.vue +86 -0
- package/components/uv-collapse-item/props.js +60 -0
- package/components/uv-collapse-item/uv-collapse-item.vue +228 -0
- package/components/uv-column-notice/props.js +61 -0
- package/components/uv-column-notice/uv-column-notice.vue +176 -0
- package/components/uv-count-down/props.js +25 -0
- package/components/uv-count-down/utils.js +62 -0
- package/components/uv-count-down/uv-count-down.vue +169 -0
- package/components/uv-count-to/props.js +60 -0
- package/components/uv-count-to/uv-count-to.vue +187 -0
- package/components/uv-datetime-picker/props.js +130 -0
- package/components/uv-datetime-picker/uv-datetime-picker.vue +355 -0
- package/components/uv-divider/props.js +45 -0
- package/components/uv-divider/uv-divider.vue +113 -0
- package/components/uv-drop-down/uv-drop-down.vue +135 -0
- package/components/uv-drop-down-item/uv-drop-down-item.vue +169 -0
- package/components/uv-drop-down-popup/uv-drop-down-popup.vue +242 -0
- package/components/uv-empty/props.js +60 -0
- package/components/uv-empty/uv-empty.vue +126 -0
- package/components/uv-form/props.js +46 -0
- package/components/uv-form/uv-form.vue +209 -0
- package/components/uv-form/valid.js +1343 -0
- package/components/uv-form-item/props.js +49 -0
- package/components/uv-form-item/uv-form-item.vue +226 -0
- package/components/uv-gap/props.js +25 -0
- package/components/uv-gap/uv-gap.vue +36 -0
- package/components/uv-grid/props.js +20 -0
- package/components/uv-grid/uv-grid.vue +100 -0
- package/components/uv-grid-item/props.js +15 -0
- package/components/uv-grid-item/uv-grid-item.vue +223 -0
- package/components/uv-icon/icons.js +160 -0
- package/components/uv-icon/props.js +90 -0
- package/components/uv-icon/uv-icon.vue +226 -0
- package/components/uv-icon/uvicons.ttf +0 -0
- package/components/uv-image/props.js +100 -0
- package/components/uv-image/uv-image.vue +296 -0
- package/components/uv-index-anchor/props.js +30 -0
- package/components/uv-index-anchor/uv-index-anchor.vue +98 -0
- package/components/uv-index-item/uv-index-item.vue +87 -0
- package/components/uv-index-list/props.js +30 -0
- package/components/uv-index-list/uv-index-list.vue +461 -0
- package/components/uv-input/props.js +175 -0
- package/components/uv-input/uv-input.vue +348 -0
- package/components/uv-keyboard/props.js +95 -0
- package/components/uv-keyboard/uv-keyboard.vue +180 -0
- package/components/uv-keyboard-car/props.js +24 -0
- package/components/uv-keyboard-car/uv-keyboard-car.vue +347 -0
- package/components/uv-keyboard-number/props.js +19 -0
- package/components/uv-keyboard-number/uv-keyboard-number.vue +201 -0
- package/components/uv-line/props.js +34 -0
- package/components/uv-line/uv-line.vue +60 -0
- package/components/uv-line-progress/props.js +29 -0
- package/components/uv-line-progress/uv-line-progress.vue +146 -0
- package/components/uv-link/props.js +40 -0
- package/components/uv-link/uv-link.vue +83 -0
- package/components/uv-list/uv-list.vue +147 -0
- package/components/uv-list-item/uv-list-item.vue +535 -0
- package/components/uv-load-more/props.js +95 -0
- package/components/uv-load-more/uv-load-more.vue +152 -0
- package/components/uv-loading-icon/props.js +67 -0
- package/components/uv-loading-icon/uv-loading-icon.vue +347 -0
- package/components/uv-loading-page/props.js +55 -0
- package/components/uv-loading-page/uv-loading-page.vue +96 -0
- package/components/uv-modal/props.js +90 -0
- package/components/uv-modal/uv-modal.vue +245 -0
- package/components/uv-navbar/props.js +89 -0
- package/components/uv-navbar/uv-navbar.vue +245 -0
- package/components/uv-no-network/props.js +20 -0
- package/components/uv-no-network/uv-no-network.vue +222 -0
- package/components/uv-notice-bar/props.js +76 -0
- package/components/uv-notice-bar/uv-notice-bar.vue +110 -0
- package/components/uv-notify/props.js +45 -0
- package/components/uv-notify/uv-notify.vue +220 -0
- package/components/uv-number-box/props.js +118 -0
- package/components/uv-number-box/uv-number-box.vue +397 -0
- package/components/uv-overlay/props.js +25 -0
- package/components/uv-overlay/uv-overlay.vue +85 -0
- package/components/uv-parse/node/node.vue +576 -0
- package/components/uv-parse/parser.js +1335 -0
- package/components/uv-parse/uv-parse.vue +498 -0
- package/components/uv-pick-color/colors.js +217 -0
- package/components/uv-pick-color/props.js +47 -0
- package/components/uv-pick-color/uv-pick-color.vue +551 -0
- package/components/uv-picker/props.js +95 -0
- package/components/uv-picker/uv-picker.vue +329 -0
- package/components/uv-popup/keypress.js +45 -0
- package/components/uv-popup/uv-popup.vue +537 -0
- package/components/uv-preview-video/uv-preview-video.vue +52 -0
- package/components/uv-qrcode/cache.js +1 -0
- package/components/uv-qrcode/gcanvas/bridge/bridge-weex.js +241 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js +8 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
- package/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js +666 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Buffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Framebuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLenum.js +298 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js +142 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLtype.js +23 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Program.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Renderbuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js +1191 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Shader.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Texture.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/classUtils.js +3 -0
- package/components/uv-qrcode/gcanvas/env/canvas.js +74 -0
- package/components/uv-qrcode/gcanvas/env/image.js +96 -0
- package/components/uv-qrcode/gcanvas/env/tool.js +24 -0
- package/components/uv-qrcode/gcanvas/index.js +39 -0
- package/components/uv-qrcode/props.js +85 -0
- package/components/uv-qrcode/qrcode.js +34 -0
- package/components/uv-qrcode/queue.js +41 -0
- package/components/uv-qrcode/uv-qrcode.vue +1038 -0
- package/components/uv-radio/props.js +65 -0
- package/components/uv-radio/uv-radio.vue +349 -0
- package/components/uv-radio-group/props.js +89 -0
- package/components/uv-radio-group/uv-radio-group.vue +115 -0
- package/components/uv-rate/props.js +73 -0
- package/components/uv-rate/uv-rate.vue +274 -0
- package/components/uv-read-more/props.js +62 -0
- package/components/uv-read-more/uv-read-more.vue +162 -0
- package/components/uv-row/props.js +20 -0
- package/components/uv-row/uv-row.vue +95 -0
- package/components/uv-row-notice/props.js +40 -0
- package/components/uv-row-notice/uv-row-notice.vue +341 -0
- package/components/uv-safe-bottom/uv-safe-bottom.vue +67 -0
- package/components/uv-scroll-list/nvue.js +29 -0
- package/components/uv-scroll-list/props.js +35 -0
- package/components/uv-scroll-list/scrollWxs.wxs +51 -0
- package/components/uv-scroll-list/uv-scroll-list.vue +218 -0
- package/components/uv-search/props.js +127 -0
- package/components/uv-search/uv-search.vue +311 -0
- package/components/uv-skeleton/props.js +65 -0
- package/components/uv-skeleton/uv-skeleton.vue +250 -0
- package/components/uv-skeletons/uv-skeletons.vue +247 -0
- package/components/uv-slider/props.js +58 -0
- package/components/uv-slider/uv-slider.vue +58 -0
- package/components/uv-status-bar/props.js +8 -0
- package/components/uv-status-bar/uv-status-bar.vue +54 -0
- package/components/uv-steps/props.js +40 -0
- package/components/uv-steps/uv-steps.vue +83 -0
- package/components/uv-steps-item/props.js +25 -0
- package/components/uv-steps-item/uv-steps-item.vue +347 -0
- package/components/uv-sticky/props.js +41 -0
- package/components/uv-sticky/uv-sticky.vue +223 -0
- package/components/uv-subsection/props.js +54 -0
- package/components/uv-subsection/uv-subsection.vue +269 -0
- package/components/uv-swipe-action/props.js +10 -0
- package/components/uv-swipe-action/uv-swipe-action.vue +65 -0
- package/components/uv-swipe-action-item/index - backup.wxs +256 -0
- package/components/uv-swipe-action-item/index.wxs +225 -0
- package/components/uv-swipe-action-item/nvue - backup.js +264 -0
- package/components/uv-swipe-action-item/nvue.js +182 -0
- package/components/uv-swipe-action-item/props.js +40 -0
- package/components/uv-swipe-action-item/uv-swipe-action-item.vue +200 -0
- package/components/uv-swipe-action-item/wxs.js +15 -0
- package/components/uv-swiper/props.js +136 -0
- package/components/uv-swiper/uv-swiper.vue +263 -0
- package/components/uv-swiper-indicator/props.js +30 -0
- package/components/uv-swiper-indicator/uv-swiper-indicator.vue +112 -0
- package/components/uv-switch/props.js +58 -0
- package/components/uv-switch/uv-switch.vue +182 -0
- package/components/uv-tabbar/props.js +50 -0
- package/components/uv-tabbar/uv-tabbar.vue +146 -0
- package/components/uv-tabbar-item/props.js +40 -0
- package/components/uv-tabbar-item/uv-tabbar-item.vue +146 -0
- package/components/uv-tabs/props.js +71 -0
- package/components/uv-tabs/uv-tabs.vue +391 -0
- package/components/uv-tags/props.js +104 -0
- package/components/uv-tags/uv-tags.vue +379 -0
- package/components/uv-text/props.js +113 -0
- package/components/uv-text/uv-text.vue +218 -0
- package/components/uv-text/value.js +87 -0
- package/components/uv-textarea/props.js +138 -0
- package/components/uv-textarea/uv-textarea.vue +238 -0
- package/components/uv-toast/uv-toast.vue +292 -0
- package/components/uv-toolbar/props.js +40 -0
- package/components/uv-toolbar/uv-toolbar.vue +109 -0
- package/components/uv-tooltip/props.js +60 -0
- package/components/uv-tooltip/uv-tooltip.vue +372 -0
- package/components/uv-transition/createAnimation.js +131 -0
- package/components/uv-transition/props.js +31 -0
- package/components/uv-transition/uv-transition.vue +320 -0
- package/components/uv-upload/mixin.js +22 -0
- package/components/uv-upload/props.js +130 -0
- package/components/uv-upload/utils.js +151 -0
- package/components/uv-upload/uv-upload.vue +488 -0
- package/components/uv-vtabs/props.js +79 -0
- package/components/uv-vtabs/uv-vtabs.vue +438 -0
- package/components/uv-vtabs-item/uv-vtabs-item.vue +68 -0
- package/components/uv-waterfall/props.js +69 -0
- package/components/uv-waterfall/uv-waterfall.vue +265 -0
- package/index.js +82 -0
- package/index.scss +7 -0
- package/libs/config/config.js +34 -0
- package/libs/css/color.scss +32 -0
- package/libs/css/common.scss +100 -0
- package/libs/css/components.scss +23 -0
- package/libs/css/variable.scss +111 -0
- package/libs/css/vue.scss +40 -0
- package/libs/function/colorGradient.js +134 -0
- package/libs/function/compress.js +27 -0
- package/libs/function/debounce.js +29 -0
- package/libs/function/digit.js +167 -0
- package/libs/function/index.js +734 -0
- package/libs/function/platform.js +75 -0
- package/libs/function/test.js +287 -0
- package/libs/function/throttle.js +30 -0
- package/libs/luch-request/adapters/index.js +132 -0
- package/libs/luch-request/core/InterceptorManager.js +51 -0
- package/libs/luch-request/core/Request.js +201 -0
- package/libs/luch-request/core/buildFullPath.js +20 -0
- package/libs/luch-request/core/defaults.js +33 -0
- package/libs/luch-request/core/dispatchRequest.js +6 -0
- package/libs/luch-request/core/mergeConfig.js +126 -0
- package/libs/luch-request/core/settle.js +16 -0
- package/libs/luch-request/helpers/buildURL.js +64 -0
- package/libs/luch-request/helpers/combineURLs.js +14 -0
- package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
- package/libs/luch-request/index.d.ts +197 -0
- package/libs/luch-request/index.js +2 -0
- package/libs/luch-request/utils/clone.js +264 -0
- package/libs/luch-request/utils.js +135 -0
- package/libs/mixin/button.js +13 -0
- package/libs/mixin/mixin.js +172 -0
- package/libs/mixin/mpMixin.js +8 -0
- package/libs/mixin/mpShare.js +13 -0
- package/libs/mixin/openType.js +47 -0
- package/libs/mixin/touch.js +59 -0
- package/libs/util/dayjs.js +216 -0
- package/libs/util/route.js +126 -0
- package/package.json +28 -0
- package/theme.scss +43 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 日历顶部标题
|
|
4
|
+
title: {
|
|
5
|
+
type: String,
|
|
6
|
+
default: '日期选择'
|
|
7
|
+
},
|
|
8
|
+
// 是否显示标题
|
|
9
|
+
showTitle: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: true
|
|
12
|
+
},
|
|
13
|
+
// 是否显示副标题
|
|
14
|
+
showSubtitle: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: true
|
|
17
|
+
},
|
|
18
|
+
// 日期类型选择,single-选择单个日期,multiple-可以选择多个日期,range-选择日期范围
|
|
19
|
+
mode: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: 'single'
|
|
22
|
+
},
|
|
23
|
+
// mode=range时,第一个日期底部的提示文字
|
|
24
|
+
startText: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: '开始'
|
|
27
|
+
},
|
|
28
|
+
// mode=range时,最后一个日期底部的提示文字
|
|
29
|
+
endText: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: '结束'
|
|
32
|
+
},
|
|
33
|
+
// 自定义列表
|
|
34
|
+
customList: {
|
|
35
|
+
type: Array,
|
|
36
|
+
default: () => []
|
|
37
|
+
},
|
|
38
|
+
// 主题色,对底部按钮和选中日期有效
|
|
39
|
+
color: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: '#3c9cff'
|
|
42
|
+
},
|
|
43
|
+
// 最小的可选日期
|
|
44
|
+
minDate: {
|
|
45
|
+
type: [String, Number],
|
|
46
|
+
default: 0
|
|
47
|
+
},
|
|
48
|
+
// 最大可选日期
|
|
49
|
+
maxDate: {
|
|
50
|
+
type: [String, Number],
|
|
51
|
+
default: 0
|
|
52
|
+
},
|
|
53
|
+
// 默认选中的日期,mode为multiple或range是必须为数组格式
|
|
54
|
+
defaultDate: {
|
|
55
|
+
type: [Array, String, Date, null],
|
|
56
|
+
default: null
|
|
57
|
+
},
|
|
58
|
+
// mode=multiple时,最多可选多少个日期
|
|
59
|
+
maxCount: {
|
|
60
|
+
type: [String, Number],
|
|
61
|
+
default: Number.MAX_SAFE_INTEGER
|
|
62
|
+
},
|
|
63
|
+
// 日期行高
|
|
64
|
+
rowHeight: {
|
|
65
|
+
type: [String, Number],
|
|
66
|
+
default: 56
|
|
67
|
+
},
|
|
68
|
+
// 日期格式化函数
|
|
69
|
+
formatter: {
|
|
70
|
+
type: [Function, null],
|
|
71
|
+
default: null
|
|
72
|
+
},
|
|
73
|
+
// 是否显示农历
|
|
74
|
+
showLunar: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: false
|
|
77
|
+
},
|
|
78
|
+
// 是否显示月份背景色
|
|
79
|
+
showMark: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: true
|
|
82
|
+
},
|
|
83
|
+
// 确定按钮的文字
|
|
84
|
+
confirmText: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: '确定'
|
|
87
|
+
},
|
|
88
|
+
// 确认按钮处于禁用状态时的文字
|
|
89
|
+
confirmDisabledText: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: '确定'
|
|
92
|
+
},
|
|
93
|
+
// 是否允许点击遮罩关闭日历
|
|
94
|
+
closeOnClickOverlay: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: false
|
|
97
|
+
},
|
|
98
|
+
// 是否允许点击确认按钮关闭日历
|
|
99
|
+
closeOnClickConfirm: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: true
|
|
102
|
+
},
|
|
103
|
+
// 是否为只读状态,只读状态下禁止选择日期
|
|
104
|
+
readonly: {
|
|
105
|
+
type: Boolean,
|
|
106
|
+
default: false
|
|
107
|
+
},
|
|
108
|
+
// 是否展示确认按钮
|
|
109
|
+
showConfirm: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
default: true
|
|
112
|
+
},
|
|
113
|
+
// 日期区间最多可选天数,默认无限制,mode = range时有效 Infinity
|
|
114
|
+
maxRange: {
|
|
115
|
+
type: [Number, String],
|
|
116
|
+
default: Number.MAX_SAFE_INTEGER
|
|
117
|
+
},
|
|
118
|
+
// 范围选择超过最多可选天数时的提示文案,mode = range时有效
|
|
119
|
+
rangePrompt: {
|
|
120
|
+
type: String,
|
|
121
|
+
default: ''
|
|
122
|
+
},
|
|
123
|
+
// 范围选择超过最多可选天数时,是否展示提示文案,mode = range时有效
|
|
124
|
+
showRangePrompt: {
|
|
125
|
+
type: Boolean,
|
|
126
|
+
default: true
|
|
127
|
+
},
|
|
128
|
+
// 是否允许日期范围的起止时间为同一天,mode = range时有效
|
|
129
|
+
allowSameDay: {
|
|
130
|
+
type: Boolean,
|
|
131
|
+
default: false
|
|
132
|
+
},
|
|
133
|
+
// 圆角值
|
|
134
|
+
round: {
|
|
135
|
+
type: [Boolean, String, Number],
|
|
136
|
+
default: 0
|
|
137
|
+
},
|
|
138
|
+
// 最多展示月份数量
|
|
139
|
+
monthNum: {
|
|
140
|
+
type: [Number, String],
|
|
141
|
+
default: 3
|
|
142
|
+
},
|
|
143
|
+
...uni.$uv?.props?.calendar
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<uv-popup
|
|
3
|
+
ref="calendarPopup"
|
|
4
|
+
mode="bottom"
|
|
5
|
+
closeable
|
|
6
|
+
:round="round"
|
|
7
|
+
:closeOnClickOverlay="closeOnClickOverlay"
|
|
8
|
+
@change="popupChange"
|
|
9
|
+
>
|
|
10
|
+
<view class="uv-calendar">
|
|
11
|
+
<uvHeader
|
|
12
|
+
:title="title"
|
|
13
|
+
:subtitle="subtitle"
|
|
14
|
+
:showSubtitle="showSubtitle"
|
|
15
|
+
:showTitle="showTitle"
|
|
16
|
+
></uvHeader>
|
|
17
|
+
<scroll-view
|
|
18
|
+
:style="{ height: $uv.addUnit(listHeight) }"
|
|
19
|
+
scroll-y
|
|
20
|
+
@scroll="onScroll"
|
|
21
|
+
:scroll-top="scrollTop"
|
|
22
|
+
:scrollIntoView="scrollIntoView"
|
|
23
|
+
>
|
|
24
|
+
<uvMonth
|
|
25
|
+
:color="color"
|
|
26
|
+
:rowHeight="rowHeight"
|
|
27
|
+
:showMark="showMark"
|
|
28
|
+
:months="months"
|
|
29
|
+
:mode="mode"
|
|
30
|
+
:maxCount="maxCount"
|
|
31
|
+
:startText="startText"
|
|
32
|
+
:endText="endText"
|
|
33
|
+
:defaultDate="defaultDate"
|
|
34
|
+
:minDate="innerMinDate"
|
|
35
|
+
:maxDate="innerMaxDate"
|
|
36
|
+
:maxMonth="monthNum"
|
|
37
|
+
:readonly="readonly"
|
|
38
|
+
:maxRange="maxRange"
|
|
39
|
+
:rangePrompt="rangePrompt"
|
|
40
|
+
:showRangePrompt="showRangePrompt"
|
|
41
|
+
:allowSameDay="allowSameDay"
|
|
42
|
+
ref="month"
|
|
43
|
+
@monthSelected="monthSelected"
|
|
44
|
+
@updateMonthTop="updateMonthTop"
|
|
45
|
+
@change="changeDay"
|
|
46
|
+
></uvMonth>
|
|
47
|
+
</scroll-view>
|
|
48
|
+
<slot name="footer" v-if="showConfirm">
|
|
49
|
+
<view class="uv-calendar__confirm">
|
|
50
|
+
<uv-button
|
|
51
|
+
shape="circle"
|
|
52
|
+
:text="buttonDisabled ? confirmDisabledText : confirmText"
|
|
53
|
+
:color="color"
|
|
54
|
+
@click="confirm"
|
|
55
|
+
:disabled="buttonDisabled"
|
|
56
|
+
></uv-button>
|
|
57
|
+
</view>
|
|
58
|
+
</slot>
|
|
59
|
+
</view>
|
|
60
|
+
</uv-popup>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<script>
|
|
64
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
65
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
66
|
+
import uvHeader from './header.vue'
|
|
67
|
+
import uvMonth from './month.vue'
|
|
68
|
+
import props from './props.js'
|
|
69
|
+
import dayjs from '../../libs/util/dayjs.js'
|
|
70
|
+
import Calendar from './calendar.js'
|
|
71
|
+
/**
|
|
72
|
+
* Calendar 日历
|
|
73
|
+
* @description 此组件用于单个选择日期,范围选择日期等,日历被包裹在底部弹起的容器中.
|
|
74
|
+
* @tutorial https://www.uvui.cn/components/calendar.html
|
|
75
|
+
*
|
|
76
|
+
* @property {String} title 标题内容 (默认 日期选择 )
|
|
77
|
+
* @property {Boolean} showTitle 是否显示标题 (默认 true )
|
|
78
|
+
* @property {Boolean} showSubtitle 是否显示副标题 (默认 true )
|
|
79
|
+
* @property {String} mode 日期类型选择 single-选择单个日期,multiple-可以选择多个日期,range-选择日期范围 ( 默认 'single' )
|
|
80
|
+
* @property {String} startText mode=range时,第一个日期底部的提示文字 (默认 '开始' )
|
|
81
|
+
* @property {String} endText mode=range时,最后一个日期底部的提示文字 (默认 '结束' )
|
|
82
|
+
* @property {Array} customList 自定义列表
|
|
83
|
+
* @property {String} color 主题色,对底部按钮和选中日期有效 (默认 ‘#3c9cff' )
|
|
84
|
+
* @property {String | Number} minDate 最小的可选日期 (默认 0 )
|
|
85
|
+
* @property {String | Number} maxDate 最大可选日期 (默认 0 )
|
|
86
|
+
* @property {Array | String| Date} defaultDate 默认选中的日期,mode为multiple或range是必须为数组格式
|
|
87
|
+
* @property {String | Number} maxCount mode=multiple时,最多可选多少个日期 (默认 Number.MAX_SAFE_INTEGER )
|
|
88
|
+
* @property {String | Number} rowHeight 日期行高 (默认 56 )
|
|
89
|
+
* @property {Function} formatter 日期格式化函数
|
|
90
|
+
* @property {Boolean} showLunar 是否显示农历 (默认 false )
|
|
91
|
+
* @property {Boolean} showMark 是否显示月份背景色 (默认 true )
|
|
92
|
+
* @property {String} confirmText 确定按钮的文字 (默认 '确定' )
|
|
93
|
+
* @property {String} confirmDisabledText 确认按钮处于禁用状态时的文字 (默认 '确定' )
|
|
94
|
+
* @property {Boolean} show 是否显示日历弹窗 (默认 false )
|
|
95
|
+
* @property {Boolean} closeOnClickOverlay 是否允许点击遮罩关闭日历 (默认 false )
|
|
96
|
+
* @property {Boolean} closeOnClickConfirm 是否允许点击确认按钮关闭日历,设置为false不影响confirm事件返回 (默认 true )
|
|
97
|
+
* @property {Boolean} readonly 是否为只读状态,只读状态下禁止选择日期 (默认 false )
|
|
98
|
+
* @property {String | Number} maxRange 日期区间最多可选天数,默认无限制,mode = range时有效
|
|
99
|
+
* @property {String} rangePrompt 范围选择超过最多可选天数时的提示文案,mode = range时有效
|
|
100
|
+
* @property {Boolean} showRangePrompt 范围选择超过最多可选天数时,是否展示提示文案,mode = range时有效 (默认 true )
|
|
101
|
+
* @property {Boolean} allowSameDay 是否允许日期范围的起止时间为同一天,mode = range时有效 (默认 false )
|
|
102
|
+
* @property {Number|String} round 圆角值,默认无圆角 (默认 0 )
|
|
103
|
+
* @property {Number|String} monthNum 最多展示的月份数量 (默认 3 )
|
|
104
|
+
*
|
|
105
|
+
* @event {Function()} confirm 点击确定按钮时触发 选择日期相关的返回参数
|
|
106
|
+
* @event {Function()} close 日历关闭时触发 可定义页面关闭时的回调事件
|
|
107
|
+
* @example <uv-calendar ref="calendar" :defaultDate="defaultDateMultiple" mode="multiple" @confirm="confirm">
|
|
108
|
+
</uv-calendar>
|
|
109
|
+
* */
|
|
110
|
+
export default {
|
|
111
|
+
name: 'uv-calendar',
|
|
112
|
+
emits:['confirm','close','change'],
|
|
113
|
+
mixins: [mpMixin, mixin, props],
|
|
114
|
+
components: {
|
|
115
|
+
uvHeader,
|
|
116
|
+
uvMonth
|
|
117
|
+
},
|
|
118
|
+
data() {
|
|
119
|
+
return {
|
|
120
|
+
// 需要显示的月份的数组
|
|
121
|
+
months: [],
|
|
122
|
+
// 在月份滚动区域中,当前视图中月份的index索引
|
|
123
|
+
monthIndex: 0,
|
|
124
|
+
// 月份滚动区域的高度
|
|
125
|
+
listHeight: 0,
|
|
126
|
+
// month组件中选择的日期数组
|
|
127
|
+
selected: [],
|
|
128
|
+
scrollIntoView: '',
|
|
129
|
+
scrollTop:0,
|
|
130
|
+
// 过滤处理方法
|
|
131
|
+
innerFormatter: (value) => value
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
watch: {
|
|
135
|
+
selectedChange: {
|
|
136
|
+
immediate: true,
|
|
137
|
+
handler(n) {
|
|
138
|
+
this.setMonth()
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
computed: {
|
|
143
|
+
// 由于maxDate和minDate可以为字符串(2021-10-10),或者数值(时间戳),但是dayjs如果接受字符串形式的时间戳会有问题,这里进行处理
|
|
144
|
+
innerMaxDate() {
|
|
145
|
+
return this.$uv.test.number(this.maxDate)
|
|
146
|
+
? Number(this.maxDate)
|
|
147
|
+
: this.maxDate
|
|
148
|
+
},
|
|
149
|
+
innerMinDate() {
|
|
150
|
+
return this.$uv.test.number(this.minDate)
|
|
151
|
+
? Number(this.minDate)
|
|
152
|
+
: this.minDate
|
|
153
|
+
},
|
|
154
|
+
// 多个条件的变化,会引起选中日期的变化,这里统一管理监听
|
|
155
|
+
selectedChange() {
|
|
156
|
+
return [this.innerMinDate, this.innerMaxDate, this.defaultDate]
|
|
157
|
+
},
|
|
158
|
+
subtitle() {
|
|
159
|
+
// 初始化时,this.months为空数组,所以需要特别判断处理
|
|
160
|
+
if (this.months.length) {
|
|
161
|
+
return `${this.months[this.monthIndex].year}年${
|
|
162
|
+
this.months[this.monthIndex].month
|
|
163
|
+
}月`
|
|
164
|
+
} else {
|
|
165
|
+
return ''
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
buttonDisabled() {
|
|
169
|
+
// 如果为range类型,且选择的日期个数不足1个时,让底部的按钮出于disabled状态
|
|
170
|
+
if (this.mode === 'range') {
|
|
171
|
+
if (this.selected.length <= 1) {
|
|
172
|
+
return true
|
|
173
|
+
} else {
|
|
174
|
+
return false
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
return false
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
mounted() {
|
|
182
|
+
this.start = Date.now()
|
|
183
|
+
this.init()
|
|
184
|
+
},
|
|
185
|
+
methods: {
|
|
186
|
+
// 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
|
|
187
|
+
setFormatter(e) {
|
|
188
|
+
this.innerFormatter = e
|
|
189
|
+
},
|
|
190
|
+
// 点击日期框触发
|
|
191
|
+
changeDay(e) {
|
|
192
|
+
this.$emit('change',e);
|
|
193
|
+
},
|
|
194
|
+
// month组件内部选择日期后,通过事件通知给父组件
|
|
195
|
+
monthSelected(e) {
|
|
196
|
+
this.selected = e
|
|
197
|
+
if (!this.showConfirm) {
|
|
198
|
+
// 在不需要确认按钮的情况下,如果为单选,或者范围多选且已选长度大于2,则直接进行返还
|
|
199
|
+
if (
|
|
200
|
+
this.mode === 'multiple' ||
|
|
201
|
+
this.mode === 'single' ||
|
|
202
|
+
(this.mode === 'range' && this.selected.length >= 2)
|
|
203
|
+
) {
|
|
204
|
+
this.$emit('confirm', this.selected)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
init() {
|
|
209
|
+
// 校验maxDate,不能小于minDate
|
|
210
|
+
if (
|
|
211
|
+
this.innerMaxDate &&
|
|
212
|
+
this.innerMinDate &&
|
|
213
|
+
new Date(this.innerMaxDate).getTime() < new Date(this.innerMinDate).getTime()
|
|
214
|
+
) {
|
|
215
|
+
return this.$uv.error('maxDate不能小于minDate')
|
|
216
|
+
}
|
|
217
|
+
// 滚动区域的高度
|
|
218
|
+
this.listHeight = this.rowHeight * 5 + 30
|
|
219
|
+
this.setMonth()
|
|
220
|
+
},
|
|
221
|
+
open() {
|
|
222
|
+
this.setMonth()
|
|
223
|
+
this.$refs.calendarPopup.open();
|
|
224
|
+
},
|
|
225
|
+
popupChange(e) {
|
|
226
|
+
if(!e.show) {
|
|
227
|
+
this.$emit('close');
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
// 点击确定按钮
|
|
231
|
+
confirm() {
|
|
232
|
+
if (!this.buttonDisabled) {
|
|
233
|
+
this.$emit('confirm', this.selected)
|
|
234
|
+
}
|
|
235
|
+
if (this.closeOnClickConfirm) {
|
|
236
|
+
this.$refs.calendarPopup.close();
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
// 获得两个日期之间的月份数
|
|
240
|
+
getMonths(minDate, maxDate) {
|
|
241
|
+
const minYear = dayjs(minDate).year()
|
|
242
|
+
const minMonth = dayjs(minDate).month() + 1
|
|
243
|
+
const maxYear = dayjs(maxDate).year()
|
|
244
|
+
const maxMonth = dayjs(maxDate).month() + 1
|
|
245
|
+
return (maxYear - minYear) * 12 + (maxMonth - minMonth) + 1
|
|
246
|
+
},
|
|
247
|
+
// 设置月份数据
|
|
248
|
+
setMonth() {
|
|
249
|
+
// 最小日期的毫秒数
|
|
250
|
+
const minDate = this.innerMinDate || dayjs().valueOf()
|
|
251
|
+
// 如果没有指定最大日期,则往后推3个月
|
|
252
|
+
const maxDate =
|
|
253
|
+
this.innerMaxDate ||
|
|
254
|
+
dayjs(minDate)
|
|
255
|
+
.add(this.monthNum - 1, 'month')
|
|
256
|
+
.valueOf()
|
|
257
|
+
// 最大最小月份之间的共有多少个月份,
|
|
258
|
+
const months = this.$uv.range(
|
|
259
|
+
1,
|
|
260
|
+
this.monthNum,
|
|
261
|
+
this.getMonths(minDate, maxDate)
|
|
262
|
+
)
|
|
263
|
+
// 先清空数组
|
|
264
|
+
this.months = []
|
|
265
|
+
for (let i = 0; i < months; i++) {
|
|
266
|
+
this.months.push({
|
|
267
|
+
date: new Array(
|
|
268
|
+
dayjs(minDate).add(i, 'month').daysInMonth()
|
|
269
|
+
)
|
|
270
|
+
.fill(1)
|
|
271
|
+
.map((item, index) => {
|
|
272
|
+
// 日期,取值1-31
|
|
273
|
+
let day = index + 1
|
|
274
|
+
// 星期,0-6,0为周日
|
|
275
|
+
const week = dayjs(minDate)
|
|
276
|
+
.add(i, 'month')
|
|
277
|
+
.date(day)
|
|
278
|
+
.day()
|
|
279
|
+
const date = dayjs(minDate)
|
|
280
|
+
.add(i, 'month')
|
|
281
|
+
.date(day)
|
|
282
|
+
.format('YYYY-MM-DD')
|
|
283
|
+
let topInfo = ''
|
|
284
|
+
let bottomInfo = ''
|
|
285
|
+
if (this.showLunar) {
|
|
286
|
+
// 将日期转为农历格式
|
|
287
|
+
const lunar = Calendar.solar2lunar(
|
|
288
|
+
dayjs(date).year(),
|
|
289
|
+
dayjs(date).month() + 1,
|
|
290
|
+
dayjs(date).date()
|
|
291
|
+
)
|
|
292
|
+
bottomInfo = lunar.IDayCn
|
|
293
|
+
}
|
|
294
|
+
let config = {
|
|
295
|
+
day,
|
|
296
|
+
week,
|
|
297
|
+
// 小于最小允许的日期,或者大于最大的日期,则设置为disabled状态
|
|
298
|
+
disabled:
|
|
299
|
+
dayjs(date).isBefore(
|
|
300
|
+
dayjs(minDate).format('YYYY-MM-DD')
|
|
301
|
+
) ||
|
|
302
|
+
dayjs(date).isAfter(
|
|
303
|
+
dayjs(maxDate).format('YYYY-MM-DD')
|
|
304
|
+
),
|
|
305
|
+
// 返回一个日期对象,供外部的formatter获取当前日期的年月日等信息,进行加工处理
|
|
306
|
+
date: new Date(date),
|
|
307
|
+
topInfo,
|
|
308
|
+
bottomInfo,
|
|
309
|
+
dot: false,
|
|
310
|
+
month:
|
|
311
|
+
dayjs(minDate).add(i, 'month').month() + 1
|
|
312
|
+
}
|
|
313
|
+
const formatter =
|
|
314
|
+
this.formatter || this.innerFormatter
|
|
315
|
+
return formatter(config)
|
|
316
|
+
}),
|
|
317
|
+
// 当前所属的月份
|
|
318
|
+
month: dayjs(minDate).add(i, 'month').month() + 1,
|
|
319
|
+
// 当前年份
|
|
320
|
+
year: dayjs(minDate).add(i, 'month').year()
|
|
321
|
+
})
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
},
|
|
325
|
+
// 滚动到默认设置的月份
|
|
326
|
+
scrollIntoDefaultMonth(selected) {
|
|
327
|
+
// 查询默认日期在可选列表的下标
|
|
328
|
+
const _index = this.months.findIndex(({
|
|
329
|
+
year,
|
|
330
|
+
month
|
|
331
|
+
}) => {
|
|
332
|
+
month = this.$uv.padZero(month)
|
|
333
|
+
return `${year}-${month}` === selected
|
|
334
|
+
})
|
|
335
|
+
if (_index !== -1) {
|
|
336
|
+
// #ifndef MP-WEIXIN
|
|
337
|
+
this.$nextTick(() => {
|
|
338
|
+
this.scrollIntoView = `month-${_index}`
|
|
339
|
+
})
|
|
340
|
+
// #endif
|
|
341
|
+
// #ifdef MP-WEIXIN
|
|
342
|
+
this.scrollTop = this.months[_index].top || 0;
|
|
343
|
+
// #endif
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
// scroll-view滚动监听
|
|
347
|
+
onScroll(event) {
|
|
348
|
+
// 不允许小于0的滚动值,如果scroll-view到顶了,继续下拉,会出现负数值
|
|
349
|
+
const scrollTop = Math.max(0, event.detail.scrollTop)
|
|
350
|
+
// 将当前滚动条数值,除以滚动区域的高度,可以得出当前滚动到了哪一个月份的索引
|
|
351
|
+
for (let i = 0; i < this.months.length; i++) {
|
|
352
|
+
if (scrollTop >= (this.months[i].top || this.listHeight)) {
|
|
353
|
+
this.monthIndex = i
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
// 更新月份的top值
|
|
358
|
+
updateMonthTop(topArr = []) {
|
|
359
|
+
// 设置对应月份的top值,用于onScroll方法更新月份
|
|
360
|
+
topArr.map((item, index) => {
|
|
361
|
+
this.months[index].top = item
|
|
362
|
+
})
|
|
363
|
+
|
|
364
|
+
// 获取默认日期的下标
|
|
365
|
+
if (!this.defaultDate) {
|
|
366
|
+
// 如果没有设置默认日期,则将当天日期设置为默认选中的日期
|
|
367
|
+
const selected = dayjs().format("YYYY-MM")
|
|
368
|
+
this.scrollIntoDefaultMonth(selected)
|
|
369
|
+
return
|
|
370
|
+
}
|
|
371
|
+
let selected = dayjs().format("YYYY-MM");
|
|
372
|
+
// 单选模式,可以是字符串或数组,Date对象等
|
|
373
|
+
if (!this.$uv.test.array(this.defaultDate)) {
|
|
374
|
+
selected = dayjs(this.defaultDate).format("YYYY-MM")
|
|
375
|
+
} else {
|
|
376
|
+
selected = dayjs(this.defaultDate[0]).format("YYYY-MM");
|
|
377
|
+
}
|
|
378
|
+
this.scrollIntoDefaultMonth(selected)
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
</script>
|
|
383
|
+
|
|
384
|
+
<style lang="scss" scoped>
|
|
385
|
+
.uv-calendar {
|
|
386
|
+
&__confirm {
|
|
387
|
+
padding: 7px 18px;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
</style>
|