@kengic/uni 0.3.2-beta.11 → 0.3.2-beta.13

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.
@@ -1,566 +1,565 @@
1
1
  <template>
2
- <view class="uni-calendar">
3
- <view v-if="!insert&&show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}" @click="clean"></view>
4
- <view v-if="insert || show" class="uni-calendar__content" :class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow}">
5
- <view v-if="!insert" class="uni-calendar__header uni-calendar--fixed-top">
6
- <view class="uni-calendar__header-btn-box" @click="close">
7
- <text class="uni-calendar__header-text uni-calendar--fixed-width">{{cancelText}}</text>
8
- </view>
9
- <view class="uni-calendar__header-btn-box" @click="confirm">
10
- <text class="uni-calendar__header-text uni-calendar--fixed-width">{{okText}}</text>
11
- </view>
12
- </view>
13
- <view class="uni-calendar__header">
14
- <view class="uni-calendar__header-btn-box" @click.stop="pre">
15
- <view class="uni-calendar__header-btn uni-calendar--left"></view>
16
- </view>
17
- <picker mode="date" :value="date" fields="month" @change="bindDateChange">
18
- <text class="uni-calendar__header-text">{{ (nowDate.year||'') +' / '+( nowDate.month||'')}}</text>
19
- </picker>
20
- <view class="uni-calendar__header-btn-box" @click.stop="next">
21
- <view class="uni-calendar__header-btn uni-calendar--right"></view>
22
- </view>
23
- <text class="uni-calendar__backtoday" @click="backToday">{{todayText}}</text>
24
-
25
- </view>
26
- <view class="uni-calendar__box">
27
- <view v-if="showMonth" class="uni-calendar__box-bg">
28
- <text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
29
- </view>
30
- <view class="uni-calendar__weeks">
31
- <view class="uni-calendar__weeks-day">
32
- <text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
33
- </view>
34
- <view class="uni-calendar__weeks-day">
35
- <text class="uni-calendar__weeks-day-text">{{monText}}</text>
36
- </view>
37
- <view class="uni-calendar__weeks-day">
38
- <text class="uni-calendar__weeks-day-text">{{TUEText}}</text>
39
- </view>
40
- <view class="uni-calendar__weeks-day">
41
- <text class="uni-calendar__weeks-day-text">{{WEDText}}</text>
42
- </view>
43
- <view class="uni-calendar__weeks-day">
44
- <text class="uni-calendar__weeks-day-text">{{THUText}}</text>
45
- </view>
46
- <view class="uni-calendar__weeks-day">
47
- <text class="uni-calendar__weeks-day-text">{{FRIText}}</text>
48
- </view>
49
- <view class="uni-calendar__weeks-day">
50
- <text class="uni-calendar__weeks-day-text">{{SATText}}</text>
51
- </view>
52
- </view>
53
- <view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex">
54
- <view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex">
55
- <calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar" :selected="selected" :lunar="lunar" @change="choiceDate"></calendar-item>
56
- </view>
57
- </view>
58
- </view>
59
- </view>
60
- </view>
2
+ <view class="uni-calendar">
3
+ <view v-if="!insert && show" class="uni-calendar__mask" :class="{ 'uni-calendar--mask-show': aniMaskShow }" @click="clean"></view>
4
+ <view v-if="insert || show" class="uni-calendar__content" :class="{ 'uni-calendar--fixed': !insert, 'uni-calendar--ani-show': aniMaskShow }">
5
+ <view v-if="!insert" class="uni-calendar__header uni-calendar--fixed-top">
6
+ <view class="uni-calendar__header-btn-box" @click="close">
7
+ <text class="uni-calendar__header-text uni-calendar--fixed-width">{{ cancelText }}</text>
8
+ </view>
9
+ <view class="uni-calendar__header-btn-box" @click="confirm">
10
+ <text class="uni-calendar__header-text uni-calendar--fixed-width">{{ okText }}</text>
11
+ </view>
12
+ </view>
13
+ <view class="uni-calendar__header">
14
+ <view class="uni-calendar__header-btn-box" @click.stop="pre">
15
+ <view class="uni-calendar__header-btn uni-calendar--left"></view>
16
+ </view>
17
+ <picker mode="date" :value="date" fields="month" @change="bindDateChange">
18
+ <text class="uni-calendar__header-text">{{ (nowDate.year || '') + ' / ' + (nowDate.month || '') }} </text>
19
+ </picker>
20
+ <view class="uni-calendar__header-btn-box" @click.stop="next">
21
+ <view class="uni-calendar__header-btn uni-calendar--right"></view>
22
+ </view>
23
+ <text class="uni-calendar__backtoday" @click="backToday">{{ todayText }}</text>
24
+ </view>
25
+ <view class="uni-calendar__box">
26
+ <view v-if="showMonth" class="uni-calendar__box-bg">
27
+ <text class="uni-calendar__box-bg-text">{{ nowDate.month }}</text>
28
+ </view>
29
+ <view class="uni-calendar__weeks">
30
+ <view class="uni-calendar__weeks-day">
31
+ <text class="uni-calendar__weeks-day-text">{{ SUNText }}</text>
32
+ </view>
33
+ <view class="uni-calendar__weeks-day">
34
+ <text class="uni-calendar__weeks-day-text">{{ monText }}</text>
35
+ </view>
36
+ <view class="uni-calendar__weeks-day">
37
+ <text class="uni-calendar__weeks-day-text">{{ TUEText }}</text>
38
+ </view>
39
+ <view class="uni-calendar__weeks-day">
40
+ <text class="uni-calendar__weeks-day-text">{{ WEDText }}</text>
41
+ </view>
42
+ <view class="uni-calendar__weeks-day">
43
+ <text class="uni-calendar__weeks-day-text">{{ THUText }}</text>
44
+ </view>
45
+ <view class="uni-calendar__weeks-day">
46
+ <text class="uni-calendar__weeks-day-text">{{ FRIText }}</text>
47
+ </view>
48
+ <view class="uni-calendar__weeks-day">
49
+ <text class="uni-calendar__weeks-day-text">{{ SATText }}</text>
50
+ </view>
51
+ </view>
52
+ <view class="uni-calendar__weeks" v-for="(item, weekIndex) in weeks" :key="weekIndex">
53
+ <view class="uni-calendar__weeks-item" v-for="(weeks, weeksIndex) in item" :key="weeksIndex">
54
+ <calendar-item
55
+ class="uni-calendar-item--hook"
56
+ :weeks="weeks"
57
+ :calendar="calendar"
58
+ :selected="selected"
59
+ :lunar="lunar"
60
+ @change="choiceDate"
61
+ ></calendar-item>
62
+ </view>
63
+ </view>
64
+ </view>
65
+ </view>
66
+ </view>
61
67
  </template>
62
68
 
63
69
  <script>
64
- import Calendar from './util.js';
65
- import CalendarItem from './uni-calendar-item.vue'
66
-
67
- import { initVueI18n } from '@dcloudio/uni-i18n'
68
- import i18nMessages from './i18n'
69
- const { t } = initVueI18n(i18nMessages)
70
-
71
- /**
72
- * Calendar 日历
73
- * @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
74
- * @tutorial https://ext.dcloud.net.cn/plugin?id=56
75
- * @property {String} date 自定义当前时间,默认为今天
76
- * @property {Boolean} lunar 显示农历
77
- * @property {String} startDate 日期选择范围-开始日期
78
- * @property {String} endDate 日期选择范围-结束日期
79
- * @property {Boolean} range 范围选择
80
- * @property {Boolean} insert = [true|false] 插入模式,默认为false
81
- * @value true 弹窗模式
82
- * @value false 插入模式
83
- * @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
84
- * @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
85
- * @property {Boolean} showMonth 是否选择月份为背景
86
- * @event {Function} change 日期改变,`insert :ture` 时生效
87
- * @event {Function} confirm 确认选择`insert :false` 时生效
88
- * @event {Function} monthSwitch 切换月份时触发
89
- * @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
90
- */
91
- export default {
92
- components: {
93
- CalendarItem
94
- },
95
- emits:['close','confirm','change','monthSwitch'],
96
- props: {
97
- date: {
98
- type: String,
99
- default: ''
100
- },
101
- selected: {
102
- type: Array,
103
- default () {
104
- return []
105
- }
106
- },
107
- lunar: {
108
- type: Boolean,
109
- default: false
110
- },
111
- startDate: {
112
- type: String,
113
- default: ''
114
- },
115
- endDate: {
116
- type: String,
117
- default: ''
118
- },
119
- range: {
120
- type: Boolean,
121
- default: false
122
- },
123
- insert: {
124
- type: Boolean,
125
- default: true
126
- },
127
- showMonth: {
128
- type: Boolean,
129
- default: true
130
- },
131
- clearDate: {
132
- type: Boolean,
133
- default: true
134
- }
135
- },
136
- data() {
137
- return {
138
- show: false,
139
- weeks: [],
140
- calendar: {},
141
- nowDate: '',
142
- aniMaskShow: false
143
- }
144
- },
145
- computed:{
146
- /**
147
- * for i18n
148
- */
149
-
150
- okText() {
151
- return t("uni-calender.ok")
152
- },
153
- cancelText() {
154
- return t("uni-calender.cancel")
155
- },
156
- todayText() {
157
- return t("uni-calender.today")
158
- },
159
- monText() {
160
- return t("uni-calender.MON")
161
- },
162
- TUEText() {
163
- return t("uni-calender.TUE")
164
- },
165
- WEDText() {
166
- return t("uni-calender.WED")
167
- },
168
- THUText() {
169
- return t("uni-calender.THU")
170
- },
171
- FRIText() {
172
- return t("uni-calender.FRI")
173
- },
174
- SATText() {
175
- return t("uni-calender.SAT")
176
- },
177
- SUNText() {
178
- return t("uni-calender.SUN")
179
- },
180
- },
181
- watch: {
182
- date(newVal) {
183
- // this.cale.setDate(newVal)
184
- this.init(newVal)
185
- },
186
- startDate(val){
187
- this.cale.resetSatrtDate(val)
188
- this.cale.setDate(this.nowDate.fullDate)
189
- this.weeks = this.cale.weeks
190
- },
191
- endDate(val){
192
- this.cale.resetEndDate(val)
193
- this.cale.setDate(this.nowDate.fullDate)
194
- this.weeks = this.cale.weeks
195
- },
196
- selected(newVal) {
197
- this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
198
- this.weeks = this.cale.weeks
199
- }
200
- },
201
- created() {
202
- this.cale = new Calendar({
203
- selected: this.selected,
204
- startDate: this.startDate,
205
- endDate: this.endDate,
206
- range: this.range,
207
- })
208
- this.init(this.date)
209
- },
210
- methods: {
211
- // 取消穿透
212
- clean() {},
213
- bindDateChange(e) {
214
- const value = e.detail.value + '-1'
215
- this.setDate(value)
216
-
217
- const { year,month } = this.cale.getDate(value)
218
- this.$emit('monthSwitch', {
219
- year,
220
- month
221
- })
222
- },
223
- /**
224
- * 初始化日期显示
225
- * @param {Object} date
226
- */
227
- init(date) {
228
- this.cale.setDate(date)
229
- this.weeks = this.cale.weeks
230
- this.nowDate = this.calendar = this.cale.getInfo(date)
231
- },
232
- /**
233
- * 打开日历弹窗
234
- */
235
- open() {
236
- // 弹窗模式并且清理数据
237
- if (this.clearDate && !this.insert) {
238
- this.cale.cleanMultipleStatus()
239
- // this.cale.setDate(this.date)
240
- this.init(this.date)
241
- }
242
- this.show = true
243
- this.$nextTick(() => {
244
- setTimeout(() => {
245
- this.aniMaskShow = true
246
- }, 50)
247
- })
248
- },
249
- /**
250
- * 关闭日历弹窗
251
- */
252
- close() {
253
- this.aniMaskShow = false
254
- this.$nextTick(() => {
255
- setTimeout(() => {
256
- this.show = false
257
- this.$emit('close')
258
- }, 300)
259
- })
260
- },
261
- /**
262
- * 确认按钮
263
- */
264
- confirm() {
265
- this.setEmit('confirm')
266
- this.close()
267
- },
268
- /**
269
- * 变化触发
270
- */
271
- change() {
272
- if (!this.insert) return
273
- this.setEmit('change')
274
- },
275
- /**
276
- * 选择月份触发
277
- */
278
- monthSwitch() {
279
- let {
280
- year,
281
- month
282
- } = this.nowDate
283
- this.$emit('monthSwitch', {
284
- year,
285
- month: Number(month)
286
- })
287
- },
288
- /**
289
- * 派发事件
290
- * @param {Object} name
291
- */
292
- setEmit(name) {
293
- let {
294
- year,
295
- month,
296
- date,
297
- fullDate,
298
- lunar,
299
- extraInfo
300
- } = this.calendar
301
- this.$emit(name, {
302
- range: this.cale.multipleStatus,
303
- year,
304
- month,
305
- date,
306
- fulldate: fullDate,
307
- lunar,
308
- extraInfo: extraInfo || {}
309
- })
310
- },
311
- /**
312
- * 选择天触发
313
- * @param {Object} weeks
314
- */
315
- choiceDate(weeks) {
316
- if (weeks.disable) return
317
- this.calendar = weeks
318
- // 设置多选
319
- this.cale.setMultiple(this.calendar.fullDate)
320
- this.weeks = this.cale.weeks
321
- this.change()
322
- },
323
- /**
324
- * 回到今天
325
- */
326
- backToday() {
327
- const nowYearMonth = `${this.nowDate.year}-${this.nowDate.month}`
328
- const date = this.cale.getDate(new Date())
329
- const todayYearMonth = `${date.year}-${date.month}`
330
-
331
- if(nowYearMonth !== todayYearMonth) {
332
- this.monthSwitch()
333
- }
334
-
335
- this.init(date.fullDate)
336
- this.change()
337
- },
338
- /**
339
- * 上个月
340
- */
341
- pre() {
342
- const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate
343
- this.setDate(preDate)
344
- this.monthSwitch()
345
-
346
- },
347
- /**
348
- * 下个月
349
- */
350
- next() {
351
- const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate
352
- this.setDate(nextDate)
353
- this.monthSwitch()
354
- },
355
- /**
356
- * 设置日期
357
- * @param {Object} date
358
- */
359
- setDate(date) {
360
- this.cale.setDate(date)
361
- this.weeks = this.cale.weeks
362
- this.nowDate = this.cale.getInfo(date)
363
- }
364
- }
365
- }
70
+ import Calendar from './util.js';
71
+ import CalendarItem from './uni-calendar-item.vue';
72
+
73
+ import { initVueI18n } from '@dcloudio/uni-i18n';
74
+ import i18nMessages from './i18n';
75
+
76
+ const { t } = initVueI18n(i18nMessages);
77
+
78
+ /**
79
+ * Calendar 日历
80
+ * @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
81
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=56
82
+ * @property {String} date 自定义当前时间,默认为今天
83
+ * @property {Boolean} lunar 显示农历
84
+ * @property {String} startDate 日期选择范围-开始日期
85
+ * @property {String} endDate 日期选择范围-结束日期
86
+ * @property {Boolean} range 范围选择
87
+ * @property {Boolean} insert = [true|false] 插入模式,默认为false
88
+ * @value true 弹窗模式
89
+ * @value false 插入模式
90
+ * @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
91
+ * @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
92
+ * @property {Boolean} showMonth 是否选择月份为背景
93
+ * @event {Function} change 日期改变,`insert :ture` 时生效
94
+ * @event {Function} confirm 确认选择`insert :false` 时生效
95
+ * @event {Function} monthSwitch 切换月份时触发
96
+ * @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
97
+ */
98
+ export default {
99
+ name: 'UniCalendar',
100
+ components: {
101
+ CalendarItem,
102
+ },
103
+ emits: ['close', 'confirm', 'change', 'monthSwitch'],
104
+ props: {
105
+ date: {
106
+ type: String,
107
+ default: '',
108
+ },
109
+ selected: {
110
+ type: Array,
111
+ default() {
112
+ return [];
113
+ },
114
+ },
115
+ lunar: {
116
+ type: Boolean,
117
+ default: false,
118
+ },
119
+ startDate: {
120
+ type: String,
121
+ default: '',
122
+ },
123
+ endDate: {
124
+ type: String,
125
+ default: '',
126
+ },
127
+ range: {
128
+ type: Boolean,
129
+ default: false,
130
+ },
131
+ insert: {
132
+ type: Boolean,
133
+ default: true,
134
+ },
135
+ showMonth: {
136
+ type: Boolean,
137
+ default: true,
138
+ },
139
+ clearDate: {
140
+ type: Boolean,
141
+ default: true,
142
+ },
143
+ },
144
+ data() {
145
+ return {
146
+ show: false,
147
+ weeks: [],
148
+ calendar: {},
149
+ nowDate: '',
150
+ aniMaskShow: false,
151
+ };
152
+ },
153
+ computed: {
154
+ /**
155
+ * for i18n
156
+ */
157
+
158
+ okText() {
159
+ return t('uni-calender.ok');
160
+ },
161
+ cancelText() {
162
+ return t('uni-calender.cancel');
163
+ },
164
+ todayText() {
165
+ return t('uni-calender.today');
166
+ },
167
+ monText() {
168
+ return t('uni-calender.MON');
169
+ },
170
+ TUEText() {
171
+ return t('uni-calender.TUE');
172
+ },
173
+ WEDText() {
174
+ return t('uni-calender.WED');
175
+ },
176
+ THUText() {
177
+ return t('uni-calender.THU');
178
+ },
179
+ FRIText() {
180
+ return t('uni-calender.FRI');
181
+ },
182
+ SATText() {
183
+ return t('uni-calender.SAT');
184
+ },
185
+ SUNText() {
186
+ return t('uni-calender.SUN');
187
+ },
188
+ },
189
+ watch: {
190
+ date(newVal) {
191
+ // this.cale.setDate(newVal)
192
+ this.init(newVal);
193
+ },
194
+ startDate(val) {
195
+ this.cale.resetSatrtDate(val);
196
+ this.cale.setDate(this.nowDate.fullDate);
197
+ this.weeks = this.cale.weeks;
198
+ },
199
+ endDate(val) {
200
+ this.cale.resetEndDate(val);
201
+ this.cale.setDate(this.nowDate.fullDate);
202
+ this.weeks = this.cale.weeks;
203
+ },
204
+ selected(newVal) {
205
+ this.cale.setSelectInfo(this.nowDate.fullDate, newVal);
206
+ this.weeks = this.cale.weeks;
207
+ },
208
+ },
209
+ created() {
210
+ this.cale = new Calendar({
211
+ selected: this.selected,
212
+ startDate: this.startDate,
213
+ endDate: this.endDate,
214
+ range: this.range,
215
+ });
216
+ this.init(this.date);
217
+ },
218
+ methods: {
219
+ // 取消穿透
220
+ clean() {},
221
+ bindDateChange(e) {
222
+ const value = e.detail.value + '-1';
223
+ this.setDate(value);
224
+
225
+ const { year, month } = this.cale.getDate(value);
226
+ this.$emit('monthSwitch', {
227
+ year,
228
+ month,
229
+ });
230
+ },
231
+ /**
232
+ * 初始化日期显示
233
+ * @param {Object} date
234
+ */
235
+ init(date) {
236
+ this.cale.setDate(date);
237
+ this.weeks = this.cale.weeks;
238
+ this.nowDate = this.calendar = this.cale.getInfo(date);
239
+ },
240
+ /**
241
+ * 打开日历弹窗
242
+ */
243
+ open() {
244
+ // 弹窗模式并且清理数据
245
+ if (this.clearDate && !this.insert) {
246
+ this.cale.cleanMultipleStatus();
247
+ // this.cale.setDate(this.date)
248
+ this.init(this.date);
249
+ }
250
+ this.show = true;
251
+ this.$nextTick(() => {
252
+ setTimeout(() => {
253
+ this.aniMaskShow = true;
254
+ }, 50);
255
+ });
256
+ },
257
+ /**
258
+ * 关闭日历弹窗
259
+ */
260
+ close() {
261
+ this.aniMaskShow = false;
262
+ this.$nextTick(() => {
263
+ setTimeout(() => {
264
+ this.show = false;
265
+ this.$emit('close');
266
+ }, 300);
267
+ });
268
+ },
269
+ /**
270
+ * 确认按钮
271
+ */
272
+ confirm() {
273
+ this.setEmit('confirm');
274
+ this.close();
275
+ },
276
+ /**
277
+ * 变化触发
278
+ */
279
+ change() {
280
+ if (!this.insert) return;
281
+ this.setEmit('change');
282
+ },
283
+ /**
284
+ * 选择月份触发
285
+ */
286
+ monthSwitch() {
287
+ let { year, month } = this.nowDate;
288
+ this.$emit('monthSwitch', {
289
+ year,
290
+ month: Number(month),
291
+ });
292
+ },
293
+ /**
294
+ * 派发事件
295
+ * @param {Object} name
296
+ */
297
+ setEmit(name) {
298
+ let { year, month, date, fullDate, lunar, extraInfo } = this.calendar;
299
+ this.$emit(name, {
300
+ range: this.cale.multipleStatus,
301
+ year,
302
+ month,
303
+ date,
304
+ fulldate: fullDate,
305
+ lunar,
306
+ extraInfo: extraInfo || {},
307
+ });
308
+ },
309
+ /**
310
+ * 选择天触发
311
+ * @param {Object} weeks
312
+ */
313
+ choiceDate(weeks) {
314
+ if (weeks.disable) return;
315
+ this.calendar = weeks;
316
+ // 设置多选
317
+ this.cale.setMultiple(this.calendar.fullDate);
318
+ this.weeks = this.cale.weeks;
319
+ this.change();
320
+ },
321
+ /**
322
+ * 回到今天
323
+ */
324
+ backToday() {
325
+ const nowYearMonth = `${this.nowDate.year}-${this.nowDate.month}`;
326
+ const date = this.cale.getDate(new Date());
327
+ const todayYearMonth = `${date.year}-${date.month}`;
328
+
329
+ if (nowYearMonth !== todayYearMonth) {
330
+ this.monthSwitch();
331
+ }
332
+
333
+ this.init(date.fullDate);
334
+ this.change();
335
+ },
336
+ /**
337
+ * 上个月
338
+ */
339
+ pre() {
340
+ const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate;
341
+ this.setDate(preDate);
342
+ this.monthSwitch();
343
+ },
344
+ /**
345
+ * 下个月
346
+ */
347
+ next() {
348
+ const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate;
349
+ this.setDate(nextDate);
350
+ this.monthSwitch();
351
+ },
352
+ /**
353
+ * 设置日期
354
+ * @param {Object} date
355
+ */
356
+ setDate(date) {
357
+ this.cale.setDate(date);
358
+ this.weeks = this.cale.weeks;
359
+ this.nowDate = this.cale.getInfo(date);
360
+ },
361
+ },
362
+ };
366
363
  </script>
367
364
 
368
365
  <style lang="scss" scoped>
369
- $uni-bg-color-mask: rgba($color: #000000, $alpha: 0.4);
370
- $uni-border-color: #EDEDED;
371
- $uni-text-color: #333;
372
- $uni-bg-color-hover:#f1f1f1;
373
- $uni-font-size-base:14px;
374
- $uni-text-color-placeholder: #808080;
375
- $uni-color-subtitle: #555555;
376
- $uni-text-color-grey:#999;
377
- .uni-calendar {
378
- /* #ifndef APP-NVUE */
379
- display: flex;
380
- /* #endif */
381
- flex-direction: column;
382
- }
383
-
384
- .uni-calendar__mask {
385
- position: fixed;
386
- bottom: 0;
387
- top: 0;
388
- left: 0;
389
- right: 0;
390
- background-color: $uni-bg-color-mask;
391
- transition-property: opacity;
392
- transition-duration: 0.3s;
393
- opacity: 0;
394
- /* #ifndef APP-NVUE */
395
- z-index: 99;
396
- /* #endif */
397
- }
398
-
399
- .uni-calendar--mask-show {
400
- opacity: 1
401
- }
402
-
403
- .uni-calendar--fixed {
404
- position: fixed;
405
- /* #ifdef APP-NVUE */
406
- bottom: 0;
407
- /* #endif */
408
- left: 0;
409
- right: 0;
410
- transition-property: transform;
411
- transition-duration: 0.3s;
412
- transform: translateY(460px);
413
- /* #ifndef APP-NVUE */
414
- bottom: calc(var(--window-bottom));
415
- z-index: 99;
416
- /* #endif */
417
- }
418
-
419
- .uni-calendar--ani-show {
420
- transform: translateY(0);
421
- }
422
-
423
- .uni-calendar__content {
424
- background-color: #fff;
425
- }
426
-
427
- .uni-calendar__header {
428
- position: relative;
429
- /* #ifndef APP-NVUE */
430
- display: flex;
431
- /* #endif */
432
- flex-direction: row;
433
- justify-content: center;
434
- align-items: center;
435
- height: 50px;
436
- border-bottom-color: $uni-border-color;
437
- border-bottom-style: solid;
438
- border-bottom-width: 1px;
439
- }
440
-
441
- .uni-calendar--fixed-top {
442
- /* #ifndef APP-NVUE */
443
- display: flex;
444
- /* #endif */
445
- flex-direction: row;
446
- justify-content: space-between;
447
- border-top-color: $uni-border-color;
448
- border-top-style: solid;
449
- border-top-width: 1px;
450
- }
451
-
452
- .uni-calendar--fixed-width {
453
- width: 50px;
454
- }
455
-
456
- .uni-calendar__backtoday {
457
- position: absolute;
458
- right: 0;
459
- top: 25rpx;
460
- padding: 0 5px;
461
- padding-left: 10px;
462
- height: 25px;
463
- line-height: 25px;
464
- font-size: 12px;
465
- border-top-left-radius: 25px;
466
- border-bottom-left-radius: 25px;
467
- color: $uni-text-color;
468
- background-color: $uni-bg-color-hover;
469
- }
470
-
471
- .uni-calendar__header-text {
472
- text-align: center;
473
- width: 100px;
474
- font-size: $uni-font-size-base;
475
- color: $uni-text-color;
476
- }
477
-
478
- .uni-calendar__header-btn-box {
479
- /* #ifndef APP-NVUE */
480
- display: flex;
481
- /* #endif */
482
- flex-direction: row;
483
- align-items: center;
484
- justify-content: center;
485
- width: 50px;
486
- height: 50px;
487
- }
488
-
489
- .uni-calendar__header-btn {
490
- width: 10px;
491
- height: 10px;
492
- border-left-color: $uni-text-color-placeholder;
493
- border-left-style: solid;
494
- border-left-width: 2px;
495
- border-top-color: $uni-color-subtitle;
496
- border-top-style: solid;
497
- border-top-width: 2px;
498
- }
499
-
500
- .uni-calendar--left {
501
- transform: rotate(-45deg);
502
- }
503
-
504
- .uni-calendar--right {
505
- transform: rotate(135deg);
506
- }
507
-
508
-
509
- .uni-calendar__weeks {
510
- position: relative;
511
- /* #ifndef APP-NVUE */
512
- display: flex;
513
- /* #endif */
514
- flex-direction: row;
515
- }
516
-
517
- .uni-calendar__weeks-item {
518
- flex: 1;
519
- }
520
-
521
- .uni-calendar__weeks-day {
522
- flex: 1;
523
- /* #ifndef APP-NVUE */
524
- display: flex;
525
- /* #endif */
526
- flex-direction: column;
527
- justify-content: center;
528
- align-items: center;
529
- height: 45px;
530
- border-bottom-color: #F5F5F5;
531
- border-bottom-style: solid;
532
- border-bottom-width: 1px;
533
- }
534
-
535
- .uni-calendar__weeks-day-text {
536
- font-size: 14px;
537
- }
538
-
539
- .uni-calendar__box {
540
- position: relative;
541
- }
542
-
543
- .uni-calendar__box-bg {
544
- /* #ifndef APP-NVUE */
545
- display: flex;
546
- /* #endif */
547
- justify-content: center;
548
- align-items: center;
549
- position: absolute;
550
- top: 0;
551
- left: 0;
552
- right: 0;
553
- bottom: 0;
554
- }
555
-
556
- .uni-calendar__box-bg-text {
557
- font-size: 200px;
558
- font-weight: bold;
559
- color: $uni-text-color-grey;
560
- opacity: 0.1;
561
- text-align: center;
562
- /* #ifndef APP-NVUE */
563
- line-height: 1;
564
- /* #endif */
565
- }
366
+ $uni-bg-color-mask: rgba(
367
+ $color: #000000,
368
+ $alpha: 0.4,
369
+ );
370
+ $uni-border-color: #ededed;
371
+ $uni-text-color: #333;
372
+ $uni-bg-color-hover: #f1f1f1;
373
+ $uni-font-size-base: 14px;
374
+ $uni-text-color-placeholder: #808080;
375
+ $uni-color-subtitle: #555555;
376
+ $uni-text-color-grey: #999;
377
+ .uni-calendar {
378
+ /* #ifndef APP-NVUE */
379
+ display: flex;
380
+ /* #endif */
381
+ flex-direction: column;
382
+ }
383
+
384
+ .uni-calendar__mask {
385
+ position: fixed;
386
+ bottom: 0;
387
+ top: 0;
388
+ left: 0;
389
+ right: 0;
390
+ background-color: $uni-bg-color-mask;
391
+ transition-property: opacity;
392
+ transition-duration: 0.3s;
393
+ opacity: 0;
394
+ /* #ifndef APP-NVUE */
395
+ z-index: 99;
396
+ /* #endif */
397
+ }
398
+
399
+ .uni-calendar--mask-show {
400
+ opacity: 1;
401
+ }
402
+
403
+ .uni-calendar--fixed {
404
+ position: fixed;
405
+ /* #ifdef APP-NVUE */
406
+ bottom: 0;
407
+ /* #endif */
408
+ left: 0;
409
+ right: 0;
410
+ transition-property: transform;
411
+ transition-duration: 0.3s;
412
+ transform: translateY(460px);
413
+ /* #ifndef APP-NVUE */
414
+ bottom: calc(var(--window-bottom));
415
+ z-index: 99;
416
+ /* #endif */
417
+ }
418
+
419
+ .uni-calendar--ani-show {
420
+ transform: translateY(0);
421
+ }
422
+
423
+ .uni-calendar__content {
424
+ background-color: #fff;
425
+ }
426
+
427
+ .uni-calendar__header {
428
+ position: relative;
429
+ /* #ifndef APP-NVUE */
430
+ display: flex;
431
+ /* #endif */
432
+ flex-direction: row;
433
+ justify-content: center;
434
+ align-items: center;
435
+ height: 50px;
436
+ border-bottom-color: $uni-border-color;
437
+ border-bottom-style: solid;
438
+ border-bottom-width: 1px;
439
+ }
440
+
441
+ .uni-calendar--fixed-top {
442
+ /* #ifndef APP-NVUE */
443
+ display: flex;
444
+ /* #endif */
445
+ flex-direction: row;
446
+ justify-content: space-between;
447
+ border-top-color: $uni-border-color;
448
+ border-top-style: solid;
449
+ border-top-width: 1px;
450
+ }
451
+
452
+ .uni-calendar--fixed-width {
453
+ width: 50px;
454
+ }
455
+
456
+ .uni-calendar__backtoday {
457
+ position: absolute;
458
+ right: 0;
459
+ top: 25 rpx;
460
+ padding: 0 5px;
461
+ padding-left: 10px;
462
+ height: 25px;
463
+ line-height: 25px;
464
+ font-size: 12px;
465
+ border-top-left-radius: 25px;
466
+ border-bottom-left-radius: 25px;
467
+ color: $uni-text-color;
468
+ background-color: $uni-bg-color-hover;
469
+ }
470
+
471
+ .uni-calendar__header-text {
472
+ text-align: center;
473
+ width: 100px;
474
+ font-size: $uni-font-size-base;
475
+ color: $uni-text-color;
476
+ }
477
+
478
+ .uni-calendar__header-btn-box {
479
+ /* #ifndef APP-NVUE */
480
+ display: flex;
481
+ /* #endif */
482
+ flex-direction: row;
483
+ align-items: center;
484
+ justify-content: center;
485
+ width: 50px;
486
+ height: 50px;
487
+ }
488
+
489
+ .uni-calendar__header-btn {
490
+ width: 10px;
491
+ height: 10px;
492
+ border-left-color: $uni-text-color-placeholder;
493
+ border-left-style: solid;
494
+ border-left-width: 2px;
495
+ border-top-color: $uni-color-subtitle;
496
+ border-top-style: solid;
497
+ border-top-width: 2px;
498
+ }
499
+
500
+ .uni-calendar--left {
501
+ transform: rotate(-45deg);
502
+ }
503
+
504
+ .uni-calendar--right {
505
+ transform: rotate(135deg);
506
+ }
507
+
508
+ .uni-calendar__weeks {
509
+ position: relative;
510
+ /* #ifndef APP-NVUE */
511
+ display: flex;
512
+ /* #endif */
513
+ flex-direction: row;
514
+ }
515
+
516
+ .uni-calendar__weeks-item {
517
+ flex: 1;
518
+ }
519
+
520
+ .uni-calendar__weeks-day {
521
+ flex: 1;
522
+ /* #ifndef APP-NVUE */
523
+ display: flex;
524
+ /* #endif */
525
+ flex-direction: column;
526
+ justify-content: center;
527
+ align-items: center;
528
+ height: 45px;
529
+ border-bottom-color: #f5f5f5;
530
+ border-bottom-style: solid;
531
+ border-bottom-width: 1px;
532
+ }
533
+
534
+ .uni-calendar__weeks-day-text {
535
+ font-size: 14px;
536
+ }
537
+
538
+ .uni-calendar__box {
539
+ position: relative;
540
+ }
541
+
542
+ .uni-calendar__box-bg {
543
+ /* #ifndef APP-NVUE */
544
+ display: flex;
545
+ /* #endif */
546
+ justify-content: center;
547
+ align-items: center;
548
+ position: absolute;
549
+ top: 0;
550
+ left: 0;
551
+ right: 0;
552
+ bottom: 0;
553
+ }
554
+
555
+ .uni-calendar__box-bg-text {
556
+ font-size: 200px;
557
+ font-weight: bold;
558
+ color: $uni-text-color-grey;
559
+ opacity: 0.1;
560
+ text-align: center;
561
+ /* #ifndef APP-NVUE */
562
+ line-height: 1;
563
+ /* #endif */
564
+ }
566
565
  </style>