diff --git a/pending_bookings.php b/pending_bookings.php index 87e2a00..fbd0ed5 100644 --- a/pending_bookings.php +++ b/pending_bookings.php @@ -655,14 +655,24 @@ try { slotDuration: 30 // 30分钟一个时段 }; - // 预约数据 - const bookingsByDate_ = ; + // 预约数据 - 为每个提交创建独立的预约数据对象 + const allBookingsByDate = ; - // 页面加载时初始化第一个预约的日期和时间 + // 页面加载时初始化所有预约的日期、时间和套餐信息 document.addEventListener('DOMContentLoaded', function() { // 初始化日期 selectDate(, ''); + + // 初始化默认套餐信息(如果有默认选择的话) + const packageSelect = document.getElementById('selected_package_'); + if (packageSelect.value) { + updatePackageInfo(); + } else if (packageSelect.options.length > 1) { + // 默认选择第一个套餐 + packageSelect.selectedIndex = 1; + updatePackageInfo(); + } }); @@ -693,7 +703,7 @@ try { timeGrid.innerHTML = ''; // 获取当天已有预约 - const dayBookings = bookingsByDate_[date] || []; + const dayBookings = allBookingsByDate[date] || []; // 生成时间段 for (let hour = workingHours.start; hour < workingHours.end; hour++) { @@ -702,7 +712,7 @@ try { const slotTime = new Date(`${date} ${timeString}:00`); const now = new Date(); const isPast = slotTime <= now; - const isBooked = checkTimeSlotBooked(date, timeString, submissionId); + const isBooked = checkTimeSlotBooked(date, timeString); const slotDiv = document.createElement('div'); slotDiv.className = `time-slot ${isPast ? 'past' : ''} ${isBooked ? 'booked' : 'available'}`; @@ -717,8 +727,8 @@ try { } // 检查时间段是否已被预约 - function checkTimeSlotBooked(date, time, submissionId) { - const bookings = bookingsByDate_[date] || []; + function checkTimeSlotBooked(date, time) { + const bookings = allBookingsByDate[date] || []; for (let booking of bookings) { const bookingStart = booking.start_time;