更新代码

This commit is contained in:
xiao-fajia 2024-09-25 10:22:50 +08:00
parent 90de7773a2
commit 47bda569f7

View File

@ -114,29 +114,30 @@
}, },
data() { data() {
return { return {
dateList: [{ // dateList: [{
date: '06-05', // date: '06-05',
title: '周四', // title: '',
disabled: true // disabled: true
}, { // }, {
date: '06-06', // date: '06-06',
title: '周四', // title: '',
disabled: false // disabled: false
}, { // }, {
date: '06-07', // date: '06-07',
title: '周四', // title: '',
disabled: false // disabled: false
}, { // }, {
date: '06-08', // date: '06-08',
title: '周四', // title: '',
disabled: false // disabled: false
}, { // }, {
date: '06-09', // date: '06-09',
title: '周四', // title: '',
disabled: false // disabled: false
}, ], // }, ],
dateList:[],
chooseDate: '06-06', chooseDate: '06-06',
chooseTime: '14:00', chooseTime: '11:00',
timeList: [{ timeList: [{
time: '09:00', time: '09:00',
disabled: false disabled: false
@ -186,8 +187,43 @@
}, },
onShow() { onShow() {
this.initCarList() this.initCarList()
this.initDateList()
}, },
methods: { methods: {
initDateList(){
const daysOfWeek = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
const currentDate = new Date();
const weekDates = [];
// 01
const todayDayOfWeek = currentDate.getDay();
//
currentDate.setDate(currentDate.getDate() - todayDayOfWeek);
for (let i = 0; i < 7; i++) {
// 'MM-DD'
let dateStr = `${currentDate.getMonth() + 1}-${currentDate.getDate()}`;
//
let title = daysOfWeek[currentDate.getDay()];
// disabledtruedisabledfalse
let disabled = currentDate < new Date(); //
//
weekDates.push({ date: dateStr, title, disabled });
//
currentDate.setDate(currentDate.getDate() + 1);
}
//
this.chooseDate = weekDates.find(day => day.disabled === false).date;
this.dateList = weekDates;
},
chooseTimeFun(time) { chooseTimeFun(time) {
if (time.disabled) { if (time.disabled) {
return return