更新代码

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() {
return {
dateList: [{
date: '06-05',
title: '周四',
disabled: true
}, {
date: '06-06',
title: '周四',
disabled: false
}, {
date: '06-07',
title: '周四',
disabled: false
}, {
date: '06-08',
title: '周四',
disabled: false
}, {
date: '06-09',
title: '周四',
disabled: false
}, ],
// dateList: [{
// date: '06-05',
// title: '',
// disabled: true
// }, {
// date: '06-06',
// title: '',
// disabled: false
// }, {
// date: '06-07',
// title: '',
// disabled: false
// }, {
// date: '06-08',
// title: '',
// disabled: false
// }, {
// date: '06-09',
// title: '',
// disabled: false
// }, ],
dateList:[],
chooseDate: '06-06',
chooseTime: '14:00',
chooseTime: '11:00',
timeList: [{
time: '09:00',
disabled: false
@ -186,8 +187,43 @@
},
onShow() {
this.initCarList()
this.initDateList()
},
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) {
if (time.disabled) {
return