diff --git a/components/vant/calendar/calendar.wxml b/components/vant/calendar/calendar.wxml index 09a60b3..be285ea 100644 --- a/components/vant/calendar/calendar.wxml +++ b/components/vant/calendar/calendar.wxml @@ -31,6 +31,7 @@ allowSameDay="{{ allowSameDay }}" showMonthTitle="{{ index !== 0 || !showSubtitle }}" bind:click="onClickDay" + holiday="{{ holiday }}" /> diff --git a/components/vant/calendar/components/month/index.js b/components/vant/calendar/components/month/index.js index 0c88643..b86bc5c 100644 --- a/components/vant/calendar/components/month/index.js +++ b/components/vant/calendar/components/month/index.js @@ -19,6 +19,7 @@ VantComponent({ type: null, observer: 'setDays' }, + holiday:Array, showMark: Boolean, rowHeight: [Number, String], formatter: { @@ -53,7 +54,8 @@ VantComponent({ const totalDay = getMonthEndDay(startDate.getFullYear(), startDate.getMonth() + 1); for (let day = 1; day <= totalDay; day++) { const date = new Date(year, month, day); - const type = this.getDayType(date); + const dateFormat = year.toString() + '-' + (month + 1).toString() + '-' + day.toString() + const type = this.getDayType(date,dateFormat); let config = { date, type, @@ -65,6 +67,8 @@ VantComponent({ } days.push(config); } + + // console.log('days',days) this.setData({ days }); }, getMultipleDayType(day) { @@ -115,11 +119,15 @@ VantComponent({ return 'middle'; } }, - getDayType(day) { - const { type, minDate, maxDate, currentDate } = this.data; + getDayType(day,dateFormat) { + const { type, minDate, maxDate, currentDate, holiday} = this.data; if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) { return 'disabled'; } + if(holiday.includes(dateFormat)){ + return 'disabled'; + } + if (type === 'single') { return compareDay(day, currentDate) === 0 ? 'selected' : ''; } diff --git a/components/vant/calendar/index.js b/components/vant/calendar/index.js index e9a4614..f67166b 100644 --- a/components/vant/calendar/index.js +++ b/components/vant/calendar/index.js @@ -45,6 +45,10 @@ VantComponent({ type: null, value: new Date(new Date().getFullYear(), new Date().getMonth() + 6, new Date().getDate()).getTime() }, + holiday:{ + type: Array, + value:[] + }, position: { type: String, value: 'bottom' diff --git a/components/vant/calendar/index.wxml b/components/vant/calendar/index.wxml index 1a4f59c..9068aef 100644 --- a/components/vant/calendar/index.wxml +++ b/components/vant/calendar/index.wxml @@ -18,12 +18,12 @@ >