廢話不多說,從晚上摘了一個月曆,修改為可預訂系統 ,現在記錄一下備忘,我已經把這個月曆系統定制為元件,以便以後友善調用.
calendar檔案夾下 的三個檔案為
calendar.js
// components/calendar/calendar.js
Component({
/**
* 元件的屬性清單
*/
properties: {
workDayNum: { // 激活幾個工作日
type: Number,
value: 7
},
offset: { // 向後順延幾天後預定
type: Number,
value: 1
},
// holidays: { // 添加幾個休息日
// type: Object,
// value: {}
// },
},
/**
* 元件的初始資料
*/
data: {
year: 0,
month: 0,
date: ['日', '一', '二', '三', '四', '五', '六'],
dateArr: [],
isToday: 0,
isTodayWeek: false,
todayIndex: 0,
},
/**
* 元件的方法清單
*/
methods: {
bookatThisDay(e){
let info=e.currentTarget.dataset;
let value=`${info.year}-${info.month}-${info.datenum}`;
let canBook=info.canbook
this.triggerEvent('bookatThisDay',{value:value,canBook:canBook});
},
calculateActiveDays(w