@10yun/cv-mobile-ui 0.4.1 → 0.4.2
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/package.json +1 -1
- package/ui-cv/cv-badge/{uni-badge.vue → cv-badge.vue} +2 -2
- package/ui-cv/cv-calendar/calendar.js +762 -345
- package/ui-cv/cv-calendar/cv-calendar-item.vue +198 -0
- package/ui-cv/cv-calendar/cv-calendar.vue +508 -0
- package/ui-cv/cv-card/cv-card.vue +427 -0
- package/ui-cv/cv-col/cv-col.vue +2965 -0
- package/ui-cv/cv-collapse/cv-collapse.vue +146 -0
- package/ui-cv/cv-collapse-item/cv-collapse-item.vue +395 -0
- package/ui-cv/cv-combox/cv-combox.vue +250 -0
- package/ui-cv/cv-countdown/cv-countdown.vue +245 -0
- package/ui-cv/cv-data-checkbox/cv-data-checkbox.vue +841 -0
- package/ui-cv/cv-data-indexed-list/cv-data-indexed-list-item.vue +154 -0
- package/ui-cv/cv-data-indexed-list/cv-data-indexed-list.vue +376 -0
- package/ui-cv/cv-data-picker/cv-data-picker.vue +486 -0
- package/ui-cv/cv-data-pickerview/{uni-data-picker.js → cv-data-picker.js} +0 -0
- package/ui-cv/cv-data-pickerview/cv-data-pickerview.vue +304 -0
- package/ui-cv/cv-dateformat/cv-dateformat.vue +86 -0
- package/ui-cv/cv-datetime-picker/calendar.vue +752 -738
- package/ui-cv/cv-datetime-picker/cv-datetime-picker.vue +958 -0
- package/ui-cv/cv-datetime-picker/time-picker.vue +900 -892
- package/ui-cv/cv-easyinput/cv-easyinput.vue +514 -0
- package/ui-cv/cv-fab/cv-fab.vue +465 -0
- package/ui-cv/cv-fab/{uni-fab.vue.bak → cv-fab.vue.bak} +2 -2
- package/ui-cv/cv-fav/cv-fav.vue +150 -0
- package/ui-cv/cv-file-picker/cv-file-picker.vue +619 -0
- package/ui-cv/cv-form-item/cv-form-item.vue +1 -1
- package/ui-cv/cv-goods-nav/{uni-goods-nav.vue → cv-goods-nav.vue} +1 -1
- package/ui-cv/{cv-icons2/cv-icons2.vue → cv-icon2/cv-icon2.vue} +3 -3
- package/ui-cv/{cv-icons2 → cv-icon2}/icons.js +0 -0
- package/ui-cv/{cv-icons2 → cv-icon2}/uni.ttf +0 -0
- package/ui-cv/cv-indexed-list/cv-indexed-list-item.vue +154 -0
- package/ui-cv/cv-indexed-list/cv-indexed-list.vue +371 -0
- package/ui-cv/cv-input-password/cv-input-password.vue +2 -2
- package/ui-cv/{cv-link/uni-link.vue → cv-link2/cv-link2.vue} +1 -1
- package/ui-cv/cv-list/cv-list.vue +107 -0
- package/ui-cv/cv-list/cv-refresh.vue +65 -0
- package/ui-cv/cv-list-ad/cv-list-ad.vue +113 -0
- package/ui-cv/cv-list-chat/{uni-list-chat.scss → cv-list-chat.scss} +0 -0
- package/ui-cv/cv-list-chat/{uni-list-chat.vue → cv-list-chat.vue} +0 -0
- package/ui-cv/cv-list-item/cv-list-item.vue +449 -0
- package/ui-cv/cv-nav-bar/cv-nav-bar.vue +256 -0
- package/ui-cv/cv-nav-bar/{uni-status-bar.vue → cv-status-bar.vue} +0 -0
- package/ui-cv/cv-notice-bar/cv-notice-bar.vue +453 -0
- package/ui-cv/cv-number-box/cv-number-box.vue +223 -0
- package/ui-cv/cv-pagination/cv-pagination.vue +397 -0
- package/ui-cv/cv-popup/cv-popup.vue +429 -0
- package/ui-cv/cv-popup-dialog/{uni-popup-dialog.vue → cv-popup-dialog.vue} +0 -0
- package/ui-cv/cv-popup-message/cv-popup-message.vue +143 -0
- package/ui-cv/cv-popup-share/{uni-popup-share.vue → cv-popup-share.vue} +0 -0
- package/ui-cv/cv-row/{uni-row.vue → cv-row.vue} +1 -1
- package/ui-cv/cv-search-bar/cv-search-bar.vue +280 -0
- package/ui-cv/cv-section/{uni-section.vue → cv-section.vue} +0 -0
- package/ui-cv/cv-segmented-control/{uni-segmented-control.vue → cv-segmented-control.vue} +0 -0
- package/ui-cv/cv-status-bar/{uni-status-bar.vue → cv-status-bar.vue} +0 -0
- package/ui-cv/cv-steps/cv-steps.vue +293 -0
- package/ui-cv/cv-swipe-action/{uni-swipe-action.vue → cv-swipe-action.vue} +0 -0
- package/ui-cv/cv-swipe-action-item/{uni-swipe-action-item.vue → cv-swipe-action-item.vue} +0 -0
- package/ui-cv/cv-swiper-dot/cv-swiper-dot.vue +255 -0
- package/ui-cv/cv-table/cv-table.vue +460 -0
- package/ui-cv/cv-tag/cv-tag.vue +276 -0
- package/ui-cv/cv-tbody/cv-tbody.vue +28 -0
- package/ui-cv/cv-td/cv-td.vue +93 -0
- package/ui-cv/cv-test/{uni-test.vue → cv-test.vue} +0 -0
- package/ui-cv/cv-th/cv-th.vue +270 -0
- package/ui-cv/cv-thead/cv-thead.vue +114 -0
- package/ui-cv/cv-title/cv-title.vue +168 -0
- package/ui-cv/cv-tr/cv-tr.vue +166 -0
- package/ui-cv/cv-transition/cv-transition.vue +279 -0
- package/ui-cv/cv-calendar/uni-calendar-item.vue +0 -171
- package/ui-cv/cv-calendar/uni-calendar.vue +0 -504
- package/ui-cv/cv-card/uni-card.vue +0 -420
- package/ui-cv/cv-col/uni-col.vue +0 -2968
- package/ui-cv/cv-collapse/uni-collapse.vue +0 -146
- package/ui-cv/cv-collapse-item/uni-collapse-item.vue +0 -378
- package/ui-cv/cv-combox/uni-combox.vue +0 -237
- package/ui-cv/cv-countdown/uni-countdown.vue +0 -234
- package/ui-cv/cv-data-checkbox/uni-data-checkbox.vue +0 -792
- package/ui-cv/cv-data-indexed-list/uni-data-indexed-list-item.vue +0 -142
- package/ui-cv/cv-data-indexed-list/uni-data-indexed-list.vue +0 -364
- package/ui-cv/cv-data-picker/uni-data-picker.vue +0 -468
- package/ui-cv/cv-data-pickerview/uni-data-pickerview.vue +0 -298
- package/ui-cv/cv-dateformat/uni-dateformat.vue +0 -88
- package/ui-cv/cv-datetime-picker/uni-datetime-picker.vue +0 -874
- package/ui-cv/cv-easyinput/uni-easyinput.vue +0 -438
- package/ui-cv/cv-fab/uni-fab.vue +0 -443
- package/ui-cv/cv-fav/uni-fav.vue +0 -136
- package/ui-cv/cv-file-picker/uni-file-picker.vue +0 -614
- package/ui-cv/cv-indexed-list/uni-indexed-list-item.vue +0 -142
- package/ui-cv/cv-indexed-list/uni-indexed-list.vue +0 -357
- package/ui-cv/cv-list/uni-list.vue +0 -107
- package/ui-cv/cv-list/uni-refresh.vue +0 -65
- package/ui-cv/cv-list-ad/uni-list-ad.vue +0 -106
- package/ui-cv/cv-list-item/uni-list-item.vue +0 -428
- package/ui-cv/cv-nav-bar/uni-nav-bar.vue +0 -244
- package/ui-cv/cv-notice-bar/uni-notice-bar.vue +0 -394
- package/ui-cv/cv-number-box/uni-number-box.vue +0 -224
- package/ui-cv/cv-pagination/uni-pagination.vue +0 -376
- package/ui-cv/cv-popup/uni-popup.vue +0 -412
- package/ui-cv/cv-popup-message/uni-popup-message.vue +0 -143
- package/ui-cv/cv-search-bar/uni-search-bar.vue +0 -262
- package/ui-cv/cv-steps/uni-steps.vue +0 -250
- package/ui-cv/cv-swiper-dot/uni-swiper-dot.vue +0 -205
- package/ui-cv/cv-table/uni-table.vue +0 -455
- package/ui-cv/cv-tag/uni-tag.vue +0 -283
- package/ui-cv/cv-tbody/uni-tbody.vue +0 -30
- package/ui-cv/cv-td/uni-td.vue +0 -88
- package/ui-cv/cv-th/uni-th.vue +0 -259
- package/ui-cv/cv-thead/uni-thead.vue +0 -114
- package/ui-cv/cv-title/uni-title.vue +0 -171
- package/ui-cv/cv-tr/uni-tr.vue +0 -156
- package/ui-cv/cv-transition/uni-transition.vue +0 -287
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="uni-calendar-item__weeks-box"
|
|
4
|
+
:class="{
|
|
5
|
+
'uni-calendar-item--disable': weeks.disable,
|
|
6
|
+
'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
|
|
7
|
+
'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
|
|
8
|
+
'uni-calendar-item--before-checked': weeks.beforeMultiple,
|
|
9
|
+
'uni-calendar-item--multiple': weeks.multiple,
|
|
10
|
+
'uni-calendar-item--after-checked': weeks.afterMultiple
|
|
11
|
+
}"
|
|
12
|
+
@click="choiceDate(weeks)"
|
|
13
|
+
>
|
|
14
|
+
<view class="uni-calendar-item__weeks-box-item">
|
|
15
|
+
<text v-if="selected && weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
|
|
16
|
+
<text
|
|
17
|
+
class="uni-calendar-item__weeks-box-text"
|
|
18
|
+
:class="{
|
|
19
|
+
'uni-calendar-item--isDay-text': weeks.isDay,
|
|
20
|
+
'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
|
|
21
|
+
'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
|
|
22
|
+
'uni-calendar-item--before-checked': weeks.beforeMultiple,
|
|
23
|
+
'uni-calendar-item--multiple': weeks.multiple,
|
|
24
|
+
'uni-calendar-item--after-checked': weeks.afterMultiple,
|
|
25
|
+
'uni-calendar-item--disable': weeks.disable
|
|
26
|
+
}"
|
|
27
|
+
>
|
|
28
|
+
{{ weeks.date }}
|
|
29
|
+
</text>
|
|
30
|
+
<text
|
|
31
|
+
v-if="!lunar && !weeks.extraInfo && weeks.isDay"
|
|
32
|
+
class="uni-calendar-item__weeks-lunar-text"
|
|
33
|
+
:class="{
|
|
34
|
+
'uni-calendar-item--isDay-text': weeks.isDay,
|
|
35
|
+
'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
|
|
36
|
+
'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
|
|
37
|
+
'uni-calendar-item--before-checked': weeks.beforeMultiple,
|
|
38
|
+
'uni-calendar-item--multiple': weeks.multiple,
|
|
39
|
+
'uni-calendar-item--after-checked': weeks.afterMultiple
|
|
40
|
+
}"
|
|
41
|
+
>
|
|
42
|
+
今天
|
|
43
|
+
</text>
|
|
44
|
+
<text
|
|
45
|
+
v-if="lunar && !weeks.extraInfo"
|
|
46
|
+
class="uni-calendar-item__weeks-lunar-text"
|
|
47
|
+
:class="{
|
|
48
|
+
'uni-calendar-item--isDay-text': weeks.isDay,
|
|
49
|
+
'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
|
|
50
|
+
'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
|
|
51
|
+
'uni-calendar-item--before-checked': weeks.beforeMultiple,
|
|
52
|
+
'uni-calendar-item--multiple': weeks.multiple,
|
|
53
|
+
'uni-calendar-item--after-checked': weeks.afterMultiple,
|
|
54
|
+
'uni-calendar-item--disable': weeks.disable
|
|
55
|
+
}"
|
|
56
|
+
>
|
|
57
|
+
{{ weeks.isDay ? '今天' : weeks.lunar.IDayCn === '初一' ? weeks.lunar.IMonthCn : weeks.lunar.IDayCn }}
|
|
58
|
+
</text>
|
|
59
|
+
<text
|
|
60
|
+
v-if="weeks.extraInfo && weeks.extraInfo.info"
|
|
61
|
+
class="uni-calendar-item__weeks-lunar-text"
|
|
62
|
+
:class="{
|
|
63
|
+
'uni-calendar-item--extra': weeks.extraInfo.info,
|
|
64
|
+
'uni-calendar-item--isDay-text': weeks.isDay,
|
|
65
|
+
'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
|
|
66
|
+
'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
|
|
67
|
+
'uni-calendar-item--before-checked': weeks.beforeMultiple,
|
|
68
|
+
'uni-calendar-item--multiple': weeks.multiple,
|
|
69
|
+
'uni-calendar-item--after-checked': weeks.afterMultiple,
|
|
70
|
+
'uni-calendar-item--disable': weeks.disable
|
|
71
|
+
}"
|
|
72
|
+
>
|
|
73
|
+
{{ weeks.extraInfo.info }}
|
|
74
|
+
</text>
|
|
75
|
+
</view>
|
|
76
|
+
</view>
|
|
77
|
+
</template>
|
|
78
|
+
|
|
79
|
+
<script>
|
|
80
|
+
export default {
|
|
81
|
+
emits: ['change'],
|
|
82
|
+
props: {
|
|
83
|
+
weeks: {
|
|
84
|
+
type: Object,
|
|
85
|
+
default() {
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
calendar: {
|
|
90
|
+
type: Object,
|
|
91
|
+
default: () => {
|
|
92
|
+
return {};
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
selected: {
|
|
96
|
+
type: Array,
|
|
97
|
+
default: () => {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
lunar: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
default: false
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
methods: {
|
|
107
|
+
choiceDate(weeks) {
|
|
108
|
+
this.$emit('change', weeks);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<style scoped>
|
|
115
|
+
.uni-calendar-item__weeks-box {
|
|
116
|
+
flex: 1;
|
|
117
|
+
/* #ifndef APP-NVUE */
|
|
118
|
+
display: flex;
|
|
119
|
+
/* #endif */
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
justify-content: center;
|
|
122
|
+
align-items: center;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.uni-calendar-item__weeks-box-text {
|
|
126
|
+
font-size: 14px;
|
|
127
|
+
color: #333;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.uni-calendar-item__weeks-lunar-text {
|
|
131
|
+
font-size: 12px;
|
|
132
|
+
color: #333;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.uni-calendar-item__weeks-box-item {
|
|
136
|
+
position: relative;
|
|
137
|
+
/* #ifndef APP-NVUE */
|
|
138
|
+
display: flex;
|
|
139
|
+
/* #endif */
|
|
140
|
+
flex-direction: column;
|
|
141
|
+
justify-content: center;
|
|
142
|
+
align-items: center;
|
|
143
|
+
width: 100rpx;
|
|
144
|
+
height: 100rpx;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.uni-calendar-item__weeks-box-circle {
|
|
148
|
+
position: absolute;
|
|
149
|
+
top: 5px;
|
|
150
|
+
right: 5px;
|
|
151
|
+
width: 8px;
|
|
152
|
+
height: 8px;
|
|
153
|
+
border-radius: 8px;
|
|
154
|
+
background-color: #dd524d;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.uni-calendar-item--disable {
|
|
158
|
+
background-color: rgba(249, 249, 249, 0.3);
|
|
159
|
+
color: #c0c0c0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.uni-calendar-item--isDay-text {
|
|
163
|
+
color: #007aff;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.uni-calendar-item--isDay {
|
|
167
|
+
background-color: #007aff;
|
|
168
|
+
opacity: 0.8;
|
|
169
|
+
color: #fff;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.uni-calendar-item--extra {
|
|
173
|
+
color: #dd524d;
|
|
174
|
+
opacity: 0.8;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.uni-calendar-item--checked {
|
|
178
|
+
background-color: #007aff;
|
|
179
|
+
color: #fff;
|
|
180
|
+
opacity: 0.8;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.uni-calendar-item--multiple {
|
|
184
|
+
background-color: #007aff;
|
|
185
|
+
color: #fff;
|
|
186
|
+
opacity: 0.8;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.uni-calendar-item--before-checked {
|
|
190
|
+
background-color: #ff5a5f;
|
|
191
|
+
color: #fff;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.uni-calendar-item--after-checked {
|
|
195
|
+
background-color: #ff5a5f;
|
|
196
|
+
color: #fff;
|
|
197
|
+
}
|
|
198
|
+
</style>
|
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uni-calendar">
|
|
3
|
+
<view
|
|
4
|
+
v-if="!insert && show"
|
|
5
|
+
class="uni-calendar__mask"
|
|
6
|
+
:class="{ 'uni-calendar--mask-show': aniMaskShow }"
|
|
7
|
+
@click="clean"
|
|
8
|
+
></view>
|
|
9
|
+
<view
|
|
10
|
+
v-if="insert || show"
|
|
11
|
+
class="uni-calendar__content"
|
|
12
|
+
:class="{ 'uni-calendar--fixed': !insert, 'uni-calendar--ani-show': aniMaskShow }"
|
|
13
|
+
>
|
|
14
|
+
<view v-if="!insert" class="uni-calendar__header uni-calendar--fixed-top">
|
|
15
|
+
<view class="uni-calendar__header-btn-box" @click="close">
|
|
16
|
+
<text class="uni-calendar__header-text uni-calendar--fixed-width">取消</text>
|
|
17
|
+
</view>
|
|
18
|
+
<view class="uni-calendar__header-btn-box" @click="confirm">
|
|
19
|
+
<text class="uni-calendar__header-text uni-calendar--fixed-width">确定</text>
|
|
20
|
+
</view>
|
|
21
|
+
</view>
|
|
22
|
+
<view class="uni-calendar__header">
|
|
23
|
+
<view class="uni-calendar__header-btn-box" @click.stop="pre">
|
|
24
|
+
<view class="uni-calendar__header-btn uni-calendar--left"></view>
|
|
25
|
+
</view>
|
|
26
|
+
<picker mode="date" :value="date" fields="month" @change="bindDateChange">
|
|
27
|
+
<text class="uni-calendar__header-text">{{ (nowDate.year || '') + '年' + (nowDate.month || '') + '月' }}</text>
|
|
28
|
+
</picker>
|
|
29
|
+
<view class="uni-calendar__header-btn-box" @click.stop="next">
|
|
30
|
+
<view class="uni-calendar__header-btn uni-calendar--right"></view>
|
|
31
|
+
</view>
|
|
32
|
+
<text class="uni-calendar__backtoday" @click="backtoday">回到今天</text>
|
|
33
|
+
</view>
|
|
34
|
+
<view class="uni-calendar__box">
|
|
35
|
+
<view v-if="showMonth" class="uni-calendar__box-bg">
|
|
36
|
+
<text class="uni-calendar__box-bg-text">{{ nowDate.month }}</text>
|
|
37
|
+
</view>
|
|
38
|
+
<view class="uni-calendar__weeks">
|
|
39
|
+
<view class="uni-calendar__weeks-day">
|
|
40
|
+
<text class="uni-calendar__weeks-day-text">日</text>
|
|
41
|
+
</view>
|
|
42
|
+
<view class="uni-calendar__weeks-day">
|
|
43
|
+
<text class="uni-calendar__weeks-day-text">一</text>
|
|
44
|
+
</view>
|
|
45
|
+
<view class="uni-calendar__weeks-day">
|
|
46
|
+
<text class="uni-calendar__weeks-day-text">二</text>
|
|
47
|
+
</view>
|
|
48
|
+
<view class="uni-calendar__weeks-day">
|
|
49
|
+
<text class="uni-calendar__weeks-day-text">三</text>
|
|
50
|
+
</view>
|
|
51
|
+
<view class="uni-calendar__weeks-day">
|
|
52
|
+
<text class="uni-calendar__weeks-day-text">四</text>
|
|
53
|
+
</view>
|
|
54
|
+
<view class="uni-calendar__weeks-day">
|
|
55
|
+
<text class="uni-calendar__weeks-day-text">五</text>
|
|
56
|
+
</view>
|
|
57
|
+
<view class="uni-calendar__weeks-day">
|
|
58
|
+
<text class="uni-calendar__weeks-day-text">六</text>
|
|
59
|
+
</view>
|
|
60
|
+
</view>
|
|
61
|
+
<view class="uni-calendar__weeks" v-for="(item, weekIndex) in weeks" :key="weekIndex">
|
|
62
|
+
<view class="uni-calendar__weeks-item" v-for="(weeks, weeksIndex) in item" :key="weeksIndex">
|
|
63
|
+
<calendar-item
|
|
64
|
+
class="uni-calendar-item--hook"
|
|
65
|
+
:weeks="weeks"
|
|
66
|
+
:calendar="calendar"
|
|
67
|
+
:selected="selected"
|
|
68
|
+
:lunar="lunar"
|
|
69
|
+
@change="choiceDate"
|
|
70
|
+
></calendar-item>
|
|
71
|
+
</view>
|
|
72
|
+
</view>
|
|
73
|
+
</view>
|
|
74
|
+
</view>
|
|
75
|
+
</view>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<script>
|
|
79
|
+
import Calendar from './util.js';
|
|
80
|
+
import calendarItem from './cv-calendar-item.vue';
|
|
81
|
+
/**
|
|
82
|
+
* Calendar 日历
|
|
83
|
+
* @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
|
|
84
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=56
|
|
85
|
+
* @property {String} date 自定义当前时间,默认为今天
|
|
86
|
+
* @property {Boolean} lunar 显示农历
|
|
87
|
+
* @property {String} startDate 日期选择范围-开始日期
|
|
88
|
+
* @property {String} endDate 日期选择范围-结束日期
|
|
89
|
+
* @property {Boolean} range 范围选择
|
|
90
|
+
* @property {Boolean} insert = [true|false] 插入模式,默认为false
|
|
91
|
+
* @value true 弹窗模式
|
|
92
|
+
* @value false 插入模式
|
|
93
|
+
* @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
|
|
94
|
+
* @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
|
|
95
|
+
* @property {Boolean} showMonth 是否选择月份为背景
|
|
96
|
+
* @event {Function} change 日期改变,`insert :ture` 时生效
|
|
97
|
+
* @event {Function} confirm 确认选择`insert :false` 时生效
|
|
98
|
+
* @event {Function} monthSwitch 切换月份时触发
|
|
99
|
+
* @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
|
|
100
|
+
*/
|
|
101
|
+
export default {
|
|
102
|
+
components: {
|
|
103
|
+
calendarItem
|
|
104
|
+
},
|
|
105
|
+
emits: ['close', 'confirm', 'change', 'monthSwitch'],
|
|
106
|
+
props: {
|
|
107
|
+
date: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: ''
|
|
110
|
+
},
|
|
111
|
+
selected: {
|
|
112
|
+
type: Array,
|
|
113
|
+
default() {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
lunar: {
|
|
118
|
+
type: Boolean,
|
|
119
|
+
default: false
|
|
120
|
+
},
|
|
121
|
+
startDate: {
|
|
122
|
+
type: String,
|
|
123
|
+
default: ''
|
|
124
|
+
},
|
|
125
|
+
endDate: {
|
|
126
|
+
type: String,
|
|
127
|
+
default: ''
|
|
128
|
+
},
|
|
129
|
+
range: {
|
|
130
|
+
type: Boolean,
|
|
131
|
+
default: false
|
|
132
|
+
},
|
|
133
|
+
insert: {
|
|
134
|
+
type: Boolean,
|
|
135
|
+
default: true
|
|
136
|
+
},
|
|
137
|
+
showMonth: {
|
|
138
|
+
type: Boolean,
|
|
139
|
+
default: true
|
|
140
|
+
},
|
|
141
|
+
clearDate: {
|
|
142
|
+
type: Boolean,
|
|
143
|
+
default: true
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
data() {
|
|
147
|
+
return {
|
|
148
|
+
show: false,
|
|
149
|
+
weeks: [],
|
|
150
|
+
calendar: {},
|
|
151
|
+
nowDate: '',
|
|
152
|
+
aniMaskShow: false
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
watch: {
|
|
156
|
+
date(newVal) {
|
|
157
|
+
// this.cale.setDate(newVal)
|
|
158
|
+
this.init(newVal);
|
|
159
|
+
},
|
|
160
|
+
startDate(val) {
|
|
161
|
+
this.cale.resetSatrtDate(val);
|
|
162
|
+
},
|
|
163
|
+
endDate(val) {
|
|
164
|
+
this.cale.resetEndDate(val);
|
|
165
|
+
},
|
|
166
|
+
selected(newVal) {
|
|
167
|
+
this.cale.setSelectInfo(this.nowDate.fullDate, newVal);
|
|
168
|
+
this.weeks = this.cale.weeks;
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
created() {
|
|
172
|
+
// 获取日历方法实例
|
|
173
|
+
this.cale = new Calendar({
|
|
174
|
+
// date: new Date(),
|
|
175
|
+
selected: this.selected,
|
|
176
|
+
startDate: this.startDate,
|
|
177
|
+
endDate: this.endDate,
|
|
178
|
+
range: this.range
|
|
179
|
+
});
|
|
180
|
+
// 选中某一天
|
|
181
|
+
// this.cale.setDate(this.date)
|
|
182
|
+
this.init(this.date);
|
|
183
|
+
// this.setDay
|
|
184
|
+
},
|
|
185
|
+
methods: {
|
|
186
|
+
// 取消穿透
|
|
187
|
+
clean() {},
|
|
188
|
+
bindDateChange(e) {
|
|
189
|
+
const value = e.detail.value + '-1';
|
|
190
|
+
console.log(this.cale.getDate(value));
|
|
191
|
+
this.init(value);
|
|
192
|
+
},
|
|
193
|
+
/**
|
|
194
|
+
* 初始化日期显示
|
|
195
|
+
* @param {Object} date
|
|
196
|
+
*/
|
|
197
|
+
init(date) {
|
|
198
|
+
this.cale.setDate(date);
|
|
199
|
+
this.weeks = this.cale.weeks;
|
|
200
|
+
this.nowDate = this.calendar = this.cale.getInfo(date);
|
|
201
|
+
},
|
|
202
|
+
/**
|
|
203
|
+
* 打开日历弹窗
|
|
204
|
+
*/
|
|
205
|
+
open() {
|
|
206
|
+
// 弹窗模式并且清理数据
|
|
207
|
+
if (this.clearDate && !this.insert) {
|
|
208
|
+
this.cale.cleanMultipleStatus();
|
|
209
|
+
// this.cale.setDate(this.date)
|
|
210
|
+
this.init(this.date);
|
|
211
|
+
}
|
|
212
|
+
this.show = true;
|
|
213
|
+
this.$nextTick(() => {
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
this.aniMaskShow = true;
|
|
216
|
+
}, 50);
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
/**
|
|
220
|
+
* 关闭日历弹窗
|
|
221
|
+
*/
|
|
222
|
+
close() {
|
|
223
|
+
this.aniMaskShow = false;
|
|
224
|
+
this.$nextTick(() => {
|
|
225
|
+
setTimeout(() => {
|
|
226
|
+
this.show = false;
|
|
227
|
+
this.$emit('close');
|
|
228
|
+
}, 300);
|
|
229
|
+
});
|
|
230
|
+
},
|
|
231
|
+
/**
|
|
232
|
+
* 确认按钮
|
|
233
|
+
*/
|
|
234
|
+
confirm() {
|
|
235
|
+
this.setEmit('confirm');
|
|
236
|
+
this.close();
|
|
237
|
+
},
|
|
238
|
+
/**
|
|
239
|
+
* 变化触发
|
|
240
|
+
*/
|
|
241
|
+
change() {
|
|
242
|
+
if (!this.insert) return;
|
|
243
|
+
this.setEmit('change');
|
|
244
|
+
},
|
|
245
|
+
/**
|
|
246
|
+
* 选择月份触发
|
|
247
|
+
*/
|
|
248
|
+
monthSwitch() {
|
|
249
|
+
let { year, month } = this.nowDate;
|
|
250
|
+
this.$emit('monthSwitch', {
|
|
251
|
+
year,
|
|
252
|
+
month: Number(month)
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
/**
|
|
256
|
+
* 派发事件
|
|
257
|
+
* @param {Object} name
|
|
258
|
+
*/
|
|
259
|
+
setEmit(name) {
|
|
260
|
+
let { year, month, date, fullDate, lunar, extraInfo } = this.calendar;
|
|
261
|
+
this.$emit(name, {
|
|
262
|
+
range: this.cale.multipleStatus,
|
|
263
|
+
year,
|
|
264
|
+
month,
|
|
265
|
+
date,
|
|
266
|
+
fulldate: fullDate,
|
|
267
|
+
lunar,
|
|
268
|
+
extraInfo: extraInfo || {}
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
/**
|
|
272
|
+
* 选择天触发
|
|
273
|
+
* @param {Object} weeks
|
|
274
|
+
*/
|
|
275
|
+
choiceDate(weeks) {
|
|
276
|
+
if (weeks.disable) return;
|
|
277
|
+
this.calendar = weeks;
|
|
278
|
+
// 设置多选
|
|
279
|
+
this.cale.setMultiple(this.calendar.fullDate);
|
|
280
|
+
this.weeks = this.cale.weeks;
|
|
281
|
+
this.change();
|
|
282
|
+
},
|
|
283
|
+
/**
|
|
284
|
+
* 回到今天
|
|
285
|
+
*/
|
|
286
|
+
backtoday() {
|
|
287
|
+
console.log(this.cale.getDate(new Date()).fullDate);
|
|
288
|
+
let date = this.cale.getDate(new Date()).fullDate;
|
|
289
|
+
// this.cale.setDate(date)
|
|
290
|
+
this.init(date);
|
|
291
|
+
this.change();
|
|
292
|
+
},
|
|
293
|
+
/**
|
|
294
|
+
* 上个月
|
|
295
|
+
*/
|
|
296
|
+
pre() {
|
|
297
|
+
const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate;
|
|
298
|
+
this.setDate(preDate);
|
|
299
|
+
this.monthSwitch();
|
|
300
|
+
},
|
|
301
|
+
/**
|
|
302
|
+
* 下个月
|
|
303
|
+
*/
|
|
304
|
+
next() {
|
|
305
|
+
const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate;
|
|
306
|
+
this.setDate(nextDate);
|
|
307
|
+
this.monthSwitch();
|
|
308
|
+
},
|
|
309
|
+
/**
|
|
310
|
+
* 设置日期
|
|
311
|
+
* @param {Object} date
|
|
312
|
+
*/
|
|
313
|
+
setDate(date) {
|
|
314
|
+
this.cale.setDate(date);
|
|
315
|
+
this.weeks = this.cale.weeks;
|
|
316
|
+
this.nowDate = this.cale.getInfo(date);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
</script>
|
|
321
|
+
|
|
322
|
+
<style scoped>
|
|
323
|
+
.uni-calendar {
|
|
324
|
+
/* #ifndef APP-NVUE */
|
|
325
|
+
display: flex;
|
|
326
|
+
/* #endif */
|
|
327
|
+
flex-direction: column;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.uni-calendar__mask {
|
|
331
|
+
position: fixed;
|
|
332
|
+
bottom: 0;
|
|
333
|
+
top: 0;
|
|
334
|
+
left: 0;
|
|
335
|
+
right: 0;
|
|
336
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
337
|
+
transition-property: opacity;
|
|
338
|
+
transition-duration: 0.3s;
|
|
339
|
+
opacity: 0;
|
|
340
|
+
/* #ifndef APP-NVUE */
|
|
341
|
+
z-index: 99;
|
|
342
|
+
/* #endif */
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.uni-calendar--mask-show {
|
|
346
|
+
opacity: 1;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.uni-calendar--fixed {
|
|
350
|
+
position: fixed;
|
|
351
|
+
bottom: calc(var(--window-bottom));
|
|
352
|
+
left: 0;
|
|
353
|
+
right: 0;
|
|
354
|
+
transition-property: transform;
|
|
355
|
+
transition-duration: 0.3s;
|
|
356
|
+
transform: translateY(460px);
|
|
357
|
+
/* #ifndef APP-NVUE */
|
|
358
|
+
z-index: 99;
|
|
359
|
+
/* #endif */
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.uni-calendar--ani-show {
|
|
363
|
+
transform: translateY(0);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.uni-calendar__content {
|
|
367
|
+
background-color: #fff;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.uni-calendar__header {
|
|
371
|
+
position: relative;
|
|
372
|
+
/* #ifndef APP-NVUE */
|
|
373
|
+
display: flex;
|
|
374
|
+
/* #endif */
|
|
375
|
+
flex-direction: row;
|
|
376
|
+
justify-content: center;
|
|
377
|
+
align-items: center;
|
|
378
|
+
height: 50px;
|
|
379
|
+
border-bottom-color: #e5e5e5;
|
|
380
|
+
border-bottom-style: solid;
|
|
381
|
+
border-bottom-width: 1px;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.uni-calendar--fixed-top {
|
|
385
|
+
/* #ifndef APP-NVUE */
|
|
386
|
+
display: flex;
|
|
387
|
+
/* #endif */
|
|
388
|
+
flex-direction: row;
|
|
389
|
+
justify-content: space-between;
|
|
390
|
+
border-top-color: #e5e5e5;
|
|
391
|
+
border-top-style: solid;
|
|
392
|
+
border-top-width: 1px;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.uni-calendar--fixed-width {
|
|
396
|
+
width: 50px;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
.uni-calendar__backtoday {
|
|
400
|
+
position: absolute;
|
|
401
|
+
right: 0;
|
|
402
|
+
top: 25rpx;
|
|
403
|
+
padding: 0 5px;
|
|
404
|
+
padding-left: 10px;
|
|
405
|
+
height: 25px;
|
|
406
|
+
line-height: 25px;
|
|
407
|
+
font-size: 12px;
|
|
408
|
+
border-top-left-radius: 25px;
|
|
409
|
+
border-bottom-left-radius: 25px;
|
|
410
|
+
color: #333;
|
|
411
|
+
background-color: #f1f1f1;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.uni-calendar__header-text {
|
|
415
|
+
text-align: center;
|
|
416
|
+
width: 100px;
|
|
417
|
+
font-size: 14px;
|
|
418
|
+
color: #333;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.uni-calendar__header-btn-box {
|
|
422
|
+
/* #ifndef APP-NVUE */
|
|
423
|
+
display: flex;
|
|
424
|
+
/* #endif */
|
|
425
|
+
flex-direction: row;
|
|
426
|
+
align-items: center;
|
|
427
|
+
justify-content: center;
|
|
428
|
+
width: 50px;
|
|
429
|
+
height: 50px;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.uni-calendar__header-btn {
|
|
433
|
+
width: 10px;
|
|
434
|
+
height: 10px;
|
|
435
|
+
border-left-color: #808080;
|
|
436
|
+
border-left-style: solid;
|
|
437
|
+
border-left-width: 2px;
|
|
438
|
+
border-top-color: #555555;
|
|
439
|
+
border-top-style: solid;
|
|
440
|
+
border-top-width: 2px;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.uni-calendar--left {
|
|
444
|
+
transform: rotate(-45deg);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
.uni-calendar--right {
|
|
448
|
+
transform: rotate(135deg);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.uni-calendar__weeks {
|
|
452
|
+
position: relative;
|
|
453
|
+
/* #ifndef APP-NVUE */
|
|
454
|
+
display: flex;
|
|
455
|
+
/* #endif */
|
|
456
|
+
flex-direction: row;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
.uni-calendar__weeks-item {
|
|
460
|
+
flex: 1;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.uni-calendar__weeks-day {
|
|
464
|
+
flex: 1;
|
|
465
|
+
/* #ifndef APP-NVUE */
|
|
466
|
+
display: flex;
|
|
467
|
+
/* #endif */
|
|
468
|
+
flex-direction: column;
|
|
469
|
+
justify-content: center;
|
|
470
|
+
align-items: center;
|
|
471
|
+
height: 45px;
|
|
472
|
+
border-bottom-color: #f5f5f5;
|
|
473
|
+
border-bottom-style: solid;
|
|
474
|
+
border-bottom-width: 1px;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.uni-calendar__weeks-day-text {
|
|
478
|
+
font-size: 14px;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.uni-calendar__box {
|
|
482
|
+
position: relative;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.uni-calendar__box-bg {
|
|
486
|
+
/* #ifndef APP-NVUE */
|
|
487
|
+
display: flex;
|
|
488
|
+
/* #endif */
|
|
489
|
+
justify-content: center;
|
|
490
|
+
align-items: center;
|
|
491
|
+
position: absolute;
|
|
492
|
+
top: 0;
|
|
493
|
+
left: 0;
|
|
494
|
+
right: 0;
|
|
495
|
+
bottom: 0;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.uni-calendar__box-bg-text {
|
|
499
|
+
font-size: 200px;
|
|
500
|
+
font-weight: bold;
|
|
501
|
+
color: #999;
|
|
502
|
+
opacity: 0.1;
|
|
503
|
+
text-align: center;
|
|
504
|
+
/* #ifndef APP-NVUE */
|
|
505
|
+
line-height: 1;
|
|
506
|
+
/* #endif */
|
|
507
|
+
}
|
|
508
|
+
</style>
|