diff --git a/docs/bug/1.0.0bug.md b/docs/bug/1.0.0bug.md index 7d0f7bb..b1e72ca 100644 --- a/docs/bug/1.0.0bug.md +++ b/docs/bug/1.0.0bug.md @@ -2,8 +2,8 @@ ## Bug统计 - **总数量**: 9个 -- **已修复**: 1个 ✅ -- **未修改**: 8个 +- **已修复**: 2个 ✅ +- **未修改**: 7个 - **分类**: 后端问题 6个,前端问题 2个,前后端问题 3个 --- @@ -40,7 +40,7 @@ --- ### cs110_24 - 已评价组局消息未消失 -**状态**: 未修改 +**状态**: ✅ 已修复 **类型**: 后端 **优先级**: 中 @@ -48,11 +48,32 @@ 我的页面中,已结束的牌局在给牌友评价后,该组局消息没有消失。 **解决方案**: -需要明确消失逻辑: -- 所有参与者都完成评价后消息消失 -- 或者预约结束后7天自动消失 -- 需要产品确认具体的消失逻辑 -- uniapp\mahjong_group\pages\me\me-page.vue 我的页面 +用户只要评价过一次(不管评价了谁),这个预约就应该从"我的页面"中消失。如果用户还想继续评价其他人,可以去"预约记录"页面找到这个预约继续评价。 + +**修复内容**: +1. **后端接口修改** (`server/CoreCms.Net.Web.WebApi/Controllers/SQController.cs`) + - 修改`GetMyUseReservation`接口的SQL查询条件 + - 添加`NOT EXISTS`子查询,排除当前用户已经评价过的预约 + - 查询逻辑:如果用户对某个预约有评价记录,该预约就不会显示在"我的页面"中 + +2. **前端评价组件** (`uniapp/mahjong_group/components/com/page/reservation-evaluate.vue`) + - 修改`submitEvaluate`方法 + - 评价成功后触发全局事件`evaluateSuccess` + - 延迟1.5秒后关闭弹窗并通知刷新数据 + +3. **我的页面** (`uniapp/mahjong_group/pages/me/me-page.vue`) + - 添加`onLoad`、`onUnload`生命周期导入 + - 在`onLoad`中监听`evaluateSuccess`事件 + - 收到事件后重新调用`loadCurrentAppointment()`刷新数据 + - 在`onUnload`中移除事件监听,避免内存泄漏 + +**修复逻辑**: +- 用户评价任意一个人后,该预约立即从"我的页面"消失 +- 如需继续评价其他人,用户可前往"预约记录"页面查找 +- 保持页面简洁,避免已处理预约长期占用显示空间 + +**修复时间**: 2025-01-01 +**测试状态**: 待测试 --- ### cs120_1 - 时间段预约逻辑错误 @@ -238,7 +259,7 @@ - cs120_9 - 鸽子费审核功能缺失 ### 🟡 中优先级(影响用户体验) -- cs110_24 - 已评价组局消息未消失 +- ✅ cs110_24 - 已评价组局消息未消失(已修复) - cs120_3 - 首页高度显示异常 - cs120_4 - 房间卡片文字显示不全 - cs120_5 - 签到后页面状态未刷新 diff --git a/server/CoreCms.Net.Model/Entities/SQ/SQReservations.cs b/server/CoreCms.Net.Model/Entities/SQ/SQReservations.cs index 94c75c0..cfa9c3a 100644 --- a/server/CoreCms.Net.Model/Entities/SQ/SQReservations.cs +++ b/server/CoreCms.Net.Model/Entities/SQ/SQReservations.cs @@ -232,9 +232,6 @@ namespace CoreCms.Net.Model.Entities [Display(Name = "状态:0=待开始,1=锁定中,2=进行中,3=已结束,4=取消")] [Required(ErrorMessage = "请输入{0}")] - - - public System.Int32 status { get; set; } diff --git a/uniapp/mahjong_group/components/com/page/container-base.vue b/uniapp/mahjong_group/components/com/page/container-base.vue index 12a5752..5ab50e9 100644 --- a/uniapp/mahjong_group/components/com/page/container-base.vue +++ b/uniapp/mahjong_group/components/com/page/container-base.vue @@ -7,7 +7,7 @@ @@ -34,12 +34,14 @@ const openQianDaoPop = async (reservation) => { console.log("openQianDaoPop", reservation) _qianDaoPopup.value && _qianDaoPopup.value.show(reservation) } +let maxt=Date.now() + 6 * 24 * 60 * 60 * 1000; const _upDatesTimePicker = ref({ refId: null, show: false, value: Date.now(), title: '', minDate: Date.now(), + maxDate: maxt, // 当前日期+7天 filter: (mode, options) => { // console.log("filter", mode, options) if (mode == "minute") { diff --git a/uniapp/mahjong_group/components/index/MahjongCard.vue b/uniapp/mahjong_group/components/index/MahjongCard.vue index ff24a24..70793a5 100644 --- a/uniapp/mahjong_group/components/index/MahjongCard.vue +++ b/uniapp/mahjong_group/components/index/MahjongCard.vue @@ -248,7 +248,7 @@ const handleJoin = () => { .grid-item { width: 300rpx; - height: 405rpx; + height: 425rpx; background: #FFFFFF; box-shadow: -4rpx 12rpx 7rpx 0rpx rgba(0, 0, 0, 0.25); border-radius: 27rpx; diff --git a/uniapp/mahjong_group/pages/appointment/appointment-page-ls.vue b/uniapp/mahjong_group/pages/appointment/appointment-page-ls.vue new file mode 100644 index 0000000..2f73956 --- /dev/null +++ b/uniapp/mahjong_group/pages/appointment/appointment-page-ls.vue @@ -0,0 +1,899 @@ + + + + + \ No newline at end of file diff --git a/uniapp/mahjong_group/pages/appointment/appointment-page.vue b/uniapp/mahjong_group/pages/appointment/appointment-page.vue index 0172073..57bbef8 100644 --- a/uniapp/mahjong_group/pages/appointment/appointment-page.vue +++ b/uniapp/mahjong_group/pages/appointment/appointment-page.vue @@ -8,46 +8,33 @@ - - - {{ getDateDisplayText() }} - + + - - - {{ startTime || '请选择开始时间' }} - - + + {{ getDayDescription(reservationInfo.start_time * 1000) }} + - - - - {{ endTime || '请选择结束时间' }} - - - 当天 - / - 次日 - - - + + {{ getDayDescription(reservationInfo.end_time * 1000) }} + - + 预计时长: - {{ calculateDuration() }} + {{ calculateDurationFromTimestamp() }} 跨越时段: - {{ calculateCrossSlots() }} + {{ calculateCrossSlotsFromTimestamp() }} {{ timeError }} - + @@ -155,9 +142,6 @@ - @@ -218,10 +202,16 @@ import { getDetail } from '@/common/server/index' + import { + getDayDescription, + ceilMinuteToNext5 + } from '@/common/system/timeUtile'; import LabelField from '@/components/com/appointment/label-field.vue' import LabelSlectField from '@/components/com/appointment/label-slect-field.vue' import CardContainer from '@/components/com/appointment/card-container.vue' + import TimeSelectCell from '@/components/com/appointment/time-select-cell.vue' + import TagSelect from '@/components/com/appointment/tag-select.vue' import ComAppointmentRadioSelect from '@/components/com/appointment/radio-select.vue' import { addSQReservation, @@ -229,6 +219,7 @@ canCreateSQReservation, getRoomDetail } from '@/common/server/interface/sq' + const _containerBase = ref(null) const submitPopupRef = ref(null) // 年龄选择器状态 const agePickerVisible = ref(false) @@ -239,21 +230,14 @@ const agePickerDefaultIndex = ref([0, 0]) const reservationData = ref(null) const lineHeight = ref("15rpx") + // 预定时长选择 + const timeRange = ref(["2小时", "3小时", "4小时", "自定义"]) + const timeRangeValue = ref("") // 房间页跳转相关 - const selectedDate = ref(null) // 选中的日期时间戳(秒级) const roomDetail = ref(null) // 房间详情数据 const roomDetailLoading = ref(false) // 房间详情加载状态 - // 自由时间选择相关 - const startTime = ref('') // 开始时间 "HH:mm" - const endTime = ref('') // 结束时间 "HH:mm" + // 时间错误提示 const timeError = ref('') // 时间错误提示 - const isNextDay = ref(false) // 结束时间是否为次日(用于通宵预约) - // 日期选择器状态 - const datePickerVisible = ref(false) - const datePickerValue = ref(Date.now()) - const datePickerMinDate = ref(Date.now()) // 最小日期为今天 - // 最大日期为未来7天(今天+未来6天) - const datePickerMaxDate = ref(new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).getTime()) //提交表单数据 const reservationInfo = ref({ room_id: 0, //房间id 非空 @@ -275,224 +259,103 @@ const getRoomPickerName = () => { return reservationInfo.value.room_name; } - /** - * 获取日期显示文本 - */ - const getDateDisplayText = () => { - if (!selectedDate.value) { - return '请选择日期'; - } - const date = new Date(selectedDate.value * 1000); - const today = new Date(); - today.setHours(0, 0, 0, 0); - const targetDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()); - const tomorrow = new Date(today); - tomorrow.setDate(tomorrow.getDate() + 1); - const dayAfterTomorrow = new Date(today); - dayAfterTomorrow.setDate(dayAfterTomorrow.getDate() + 2); - - let dateText = ''; - if (targetDate.getTime() === today.getTime()) { - dateText = '今天'; - } else if (targetDate.getTime() === tomorrow.getTime()) { - dateText = '明天'; - } else if (targetDate.getTime() === dayAfterTomorrow.getTime()) { - dateText = '后天'; - } else { - const month = date.getMonth() + 1; - const day = date.getDate(); - dateText = `${month}月${day}日`; - } - - // 获取星期 - const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']; - const weekday = weekdays[date.getDay()]; - - return `${dateText} ${weekday}`; - } - /** - * 打开日期选择器 - */ - const openDatePicker = () => { - if (selectedDate.value) { - datePickerValue.value = selectedDate.value * 1000; // 转换为毫秒 - } else { - datePickerValue.value = Date.now(); - } - datePickerVisible.value = true; - } - /** - * 日期选择器确认 - */ - const onDatePickerConfirm = async (e) => { - console.log('日期选择器确认事件:', e); - console.log('datePickerValue.value:', datePickerValue.value); - - // up-datetime-picker 的 confirm 事件返回的是对象 { value: 毫秒级时间戳, mode: 'date' } - // 优先使用 v-model 绑定的 datePickerValue.value,因为它会在用户选择后自动更新 - let timestampMs = datePickerValue.value; - - // 如果 v-model 的值无效,尝试从事件参数获取 - if (!timestampMs || isNaN(timestampMs) || timestampMs <= 0) { - if (e && typeof e === 'object' && e.value !== undefined) { - timestampMs = e.value; - } else if (typeof e === 'number' && !isNaN(e) && e > 0) { - timestampMs = e; + + //自动计算结束时间 + const onTimeRangeChange = async (val) => { + timeRangeValue.value = val; + console.log('timeRange change:', val) + if (val != "") { + await openUpDatesTimePicker(false); + if (reservationInfo.value.start_time > 0) { + var str = val; + if (str == "2小时") { + reservationInfo.value.end_time = reservationInfo.value.start_time + 2 * 60 * 60; + } else if (str == "3小时") { + reservationInfo.value.end_time = reservationInfo.value.start_time + 3 * 60 * 60; + } else if (str == "4小时") { + reservationInfo.value.end_time = reservationInfo.value.start_time + 4 * 60 * 60; + } else { + await openUpDatesTimePickerEnd(false); + } } } - - console.log('提取的时间戳(毫秒):', timestampMs); - - // 确保是数字类型且有效 - if (typeof timestampMs !== 'number' || isNaN(timestampMs) || timestampMs <= 0) { - console.error('日期选择器返回的时间戳无效:', e, 'datePickerValue:', datePickerValue.value); + } + + const openUpDatesTimePicker = async (isManual = true) => { + var now = reservationInfo.value.start_time * 1000; + var min = Date.now(); + min += 1000 * 60 * 30; + min = ceilMinuteToNext5(min).valueOf(); + if (reservationInfo.value.start_time == 0) { + now = Date.now(); + now += 1000 * 60 * 30; + now = ceilMinuteToNext5(now).valueOf(); + } + const startTime = await _containerBase.value.openUpDatesTimePicker(now, min, "预约开始时间") + // 直接设置到表单对象,毫秒转秒 + reservationInfo.value.start_time = Math.floor(startTime / 1000) + // 手动选择时间则切换为"自定义" + if (isManual) { + timeRangeValue.value = "自定义" + } + // 清空时间错误 + timeError.value = '' + // 验证时间 + validateTimeFromTimestamp() + } + + const openUpDatesTimePickerEnd = async (isManual = true) => { + if (reservationInfo.value.start_time == 0) { uni.showToast({ - title: '日期选择失败,请重试', + title: '请先选择开始时间', icon: 'none' - }); - datePickerVisible.value = false; + }) return; } - - // 将日期转换为当天的 0 点(只取日期,不取时间) - const date = new Date(timestampMs); - if (isNaN(date.getTime())) { - console.error('日期转换失败:', timestampMs); - uni.showToast({ - title: '日期格式错误', - icon: 'none' - }); - datePickerVisible.value = false; - return; + var now = reservationInfo.value.end_time * 1000; + var min = (reservationInfo.value.start_time * 1000 + 1000 * 60 * 30); + if (now == 0) { + now = (reservationInfo.value.start_time * 1000 + 1000 * 60 * 30); } - - const year = date.getFullYear(); - const month = date.getMonth(); - const day = date.getDate(); - const dateAtMidnight = new Date(year, month, day, 0, 0, 0); - - // 转换为秒级时间戳 - const selectedTimestamp = Math.floor(dateAtMidnight.getTime() / 1000); - - console.log('转换后的秒级时间戳:', selectedTimestamp); - - // 验证转换后的时间戳是否有效 - if (isNaN(selectedTimestamp) || selectedTimestamp <= 0) { - console.error('时间戳转换失败:', dateAtMidnight, selectedTimestamp); - uni.showToast({ - title: '日期处理失败', - icon: 'none' - }); - datePickerVisible.value = false; - return; + //minDate+1000*60*30 最小间隔30分钟 + const endTime = await _containerBase.value.openUpDatesTimePicker(now, min, "预约结束时间") + // 直接设置到表单对象,毫秒转秒 + reservationInfo.value.end_time = Math.floor(endTime / 1000) + // 手动选择时间则切换为"自定义" + if (isManual) { + timeRangeValue.value = "自定义" } - - // 如果是同一天,不需要重新加载 - if (selectedDate.value && selectedDate.value === selectedTimestamp) { - datePickerVisible.value = false; - return; - } - - // 更新选中的日期 - selectedDate.value = selectedTimestamp; - - // 重置时间选择 - startTime.value = ''; - endTime.value = ''; - timeError.value = ''; - isNextDay.value = false; // 重置跨天标记 - reservationInfo.value.start_time = 0; - reservationInfo.value.end_time = 0; - - // 重新加载房间详情 - if (reservationInfo.value.room_id) { - console.log('重新加载房间详情, roomId:', reservationInfo.value.room_id, 'date:', selectedTimestamp); - await loadRoomDetailForReservation(reservationInfo.value.room_id, selectedTimestamp); - } - - datePickerVisible.value = false; + // 验证时间 + validateTimeFromTimestamp() } - + /** - * 开始时间变更处理 + * 验证时间范围(基于时间戳) */ - const onStartTimeChange = (e) => { - startTime.value = e.detail.value; - validateTimeRange(); - buildTimeFromPicker(); - } - - /** - * 结束时间变更处理 - */ - const onEndTimeChange = (e) => { - endTime.value = e.detail.value; - // 自动判断是否需要切换到次日 - autoDetectNextDay(); - validateTimeRange(); - buildTimeFromPicker(); - } - - /** - * 自动检测是否需要切换到次日(当结束时间小于开始时间时) - */ - const autoDetectNextDay = () => { - if (!startTime.value || !endTime.value) return; - - const [startH, startM] = startTime.value.split(':').map(Number); - const [endH, endM] = endTime.value.split(':').map(Number); - const startMinutes = startH * 60 + startM; - const endMinutes = endH * 60 + endM; - - // 如果结束时间小于开始时间,自动切换到次日 - if (endMinutes <= startMinutes) { - isNextDay.value = true; - } - } - - /** - * 设置结束时间是否为次日 - */ - const setNextDay = (value) => { - isNextDay.value = value; - validateTimeRange(); - buildTimeFromPicker(); - } - - /** - * 验证时间范围(支持跨天预约) - */ - const validateTimeRange = () => { + const validateTimeFromTimestamp = () => { timeError.value = ''; - if (!startTime.value || !endTime.value) { + if (!reservationInfo.value.start_time || !reservationInfo.value.end_time) { return true; } - const [startH, startM] = startTime.value.split(':').map(Number); - const [endH, endM] = endTime.value.split(':').map(Number); - const startMinutes = startH * 60 + startM; - let endMinutes = endH * 60 + endM; + const startTime = reservationInfo.value.start_time; + const endTime = reservationInfo.value.end_time; - // 如果是次日,结束时间加24小时 - if (isNextDay.value) { - endMinutes += 24 * 60; - } + // 计算时长(秒) + const durationSeconds = endTime - startTime; - // 计算时长(分钟) - const durationMinutes = endMinutes - startMinutes; - - if (durationMinutes <= 0) { + if (durationSeconds <= 0) { timeError.value = '结束时间必须晚于开始时间'; return false; } - if (durationMinutes < 60) { + if (durationSeconds < 3600) { timeError.value = '预约时长不能少于1小时'; return false; } - if (durationMinutes > 720) { + if (durationSeconds > 43200) { timeError.value = '预约时长不能超过12小时'; return false; } @@ -501,60 +364,17 @@ } /** - * 构建时间戳(从时间选择器值,支持跨天预约) + * 计算时长显示(基于时间戳) */ - const buildTimeFromPicker = () => { - if (!selectedDate.value || !startTime.value || !endTime.value) { - return; - } + const calculateDurationFromTimestamp = () => { + if (!reservationInfo.value.start_time || !reservationInfo.value.end_time) return '-'; - if (!validateTimeRange()) { - // 清空时间戳 - reservationInfo.value.start_time = 0; - reservationInfo.value.end_time = 0; - return; - } + const diffSeconds = reservationInfo.value.end_time - reservationInfo.value.start_time; - const date = new Date(selectedDate.value * 1000); - const [startH, startM] = startTime.value.split(':').map(Number); - const [endH, endM] = endTime.value.split(':').map(Number); + if (diffSeconds <= 0) return '-'; - const startDateTime = new Date(date.getFullYear(), date.getMonth(), date.getDate(), startH, startM, 0); - - // 如果是次日,结束时间加1天 - let endDateTime; - if (isNextDay.value) { - const nextDay = new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1, endH, endM, 0); - endDateTime = nextDay; - } else { - endDateTime = new Date(date.getFullYear(), date.getMonth(), date.getDate(), endH, endM, 0); - } - - reservationInfo.value.start_time = Math.floor(startDateTime.getTime() / 1000); - reservationInfo.value.end_time = Math.floor(endDateTime.getTime() / 1000); - } - - /** - * 计算时长显示(支持跨天预约) - */ - const calculateDuration = () => { - if (!startTime.value || !endTime.value) return '-'; - - const [startH, startM] = startTime.value.split(':').map(Number); - const [endH, endM] = endTime.value.split(':').map(Number); - let endMinutes = endH * 60 + endM; - - // 如果是次日,结束时间加24小时 - if (isNextDay.value) { - endMinutes += 24 * 60; - } - - const diffMinutes = endMinutes - (startH * 60 + startM); - - if (diffMinutes <= 0) return '-'; - - const hours = Math.floor(diffMinutes / 60); - const mins = diffMinutes % 60; + const hours = Math.floor(diffSeconds / 3600); + const mins = Math.floor((diffSeconds % 3600) / 60); if (mins === 0) { return `${hours}小时`; @@ -563,14 +383,17 @@ } /** - * 计算跨越时段(支持跨天预约) + * 计算跨越时段(基于时间戳) */ - const calculateCrossSlots = () => { - if (!startTime.value || !endTime.value) return '-'; - - const [startH] = startTime.value.split(':').map(Number); - const [endH] = endTime.value.split(':').map(Number); + const calculateCrossSlotsFromTimestamp = () => { + if (!reservationInfo.value.start_time || !reservationInfo.value.end_time) return '-'; + const startDate = new Date(reservationInfo.value.start_time * 1000); + const endDate = new Date(reservationInfo.value.end_time * 1000); + + const startH = startDate.getHours(); + const endH = endDate.getHours(); + const slots = []; const ranges = [ { name: '凌晨', start: 0, end: 6 }, @@ -579,7 +402,10 @@ { name: '晚上', start: 18, end: 24 } ]; - if (isNextDay.value) { + // 检查是否跨天 + const isNextDay = endDate.getDate() !== startDate.getDate(); + + if (isNextDay) { // 跨天预约:当天的时段 + 次日的时段 // 当天:从开始时间到24点 for (const r of ranges) { @@ -609,7 +435,58 @@ return slots.join('、') || '-'; } - + + /** + * 设置默认开始时间 + * @param {number} dateTimestamp 日期时间戳(秒级) + */ + const setDefaultStartTime = async (dateTimestamp) => { + try { + // 将日期时间戳转换为日期对象 + const selectedDate = new Date(dateTimestamp * 1000); + const today = new Date(); + + // 判断是否是今天 + const isToday = selectedDate.toDateString() === today.toDateString(); + + let defaultStartTime; + + if (isToday) { + // 如果是今天,设置为当前时间后30分钟,并向上取整到5分钟的倍数 + const now = new Date(); + now.setMinutes(now.getMinutes() + 30); // 加30分钟 + defaultStartTime = ceilMinuteToNext5(now.getTime()); + } else { + // 如果是其他日期,设置为当天的10:00 + const defaultTime = new Date(selectedDate); + defaultTime.setHours(10, 0, 0, 0); + defaultStartTime = defaultTime.getTime(); + } + + // 设置开始时间(毫秒转秒) + reservationInfo.value.start_time = Math.floor(defaultStartTime / 1000); + + // 默认选择2小时时长 + timeRangeValue.value = "2小时"; + + // 自动计算结束时间(2小时后) + reservationInfo.value.end_time = reservationInfo.value.start_time + 2 * 60 * 60; + + // 验证时间设置 + validateTimeFromTimestamp(); + + console.log('设置默认时间:', { + startTime: reservationInfo.value.start_time, + endTime: reservationInfo.value.end_time, + startTimeDisplay: getDayDescription(reservationInfo.value.start_time * 1000), + endTimeDisplay: getDayDescription(reservationInfo.value.end_time * 1000) + }); + + } catch (error) { + console.error('设置默认开始时间失败:', error); + } + } + const tipsShow = () => { submitPopupRef.value.open() } @@ -786,7 +663,7 @@ } // 检查是否选择了时间 - if (!startTime.value || !endTime.value) { + if (!reservationInfo.value.start_time || !reservationInfo.value.end_time) { uni.showToast({ title: '请选择开始和结束时间', icon: 'none' @@ -795,9 +672,9 @@ } // 检查时间是否有效 - if (timeError.value) { + if (!validateTimeFromTimestamp()) { uni.showToast({ - title: timeError.value, + title: timeError.value || '时间设置有误', icon: 'none' }) return false @@ -1050,10 +927,8 @@ peopleText.value = savedPeopleText; // 重置时间选择 - startTime.value = ''; - endTime.value = ''; - timeError.value = ''; - isNextDay.value = false; // 重置跨天标记 + timeRangeValue.value = "" + timeError.value = '' reservationInfo.value.start_time = 0; reservationInfo.value.end_time = 0; @@ -1063,7 +938,7 @@ /** * 加载房间详情,用于预约页面 */ - const loadRoomDetailForReservation = async (roomId, date) => { + const loadRoomDetailForReservation = async (roomId, date = null) => { console.log('loadRoomDetailForReservation 调用参数:', { roomId, date, @@ -1071,19 +946,39 @@ }); // 验证参数 - if (!roomId || !date) { + if (!roomId) { console.error('loadRoomDetailForReservation 参数无效:', { roomId, date }); uni.showToast({ - title: '参数错误', + title: '房间ID参数错误', icon: 'none' }); roomDetailLoading.value = false; return; } + // 如果没有日期,只设置房间基本信息 + if (!date) { + // 设置基本的人数范围(假设最大4人) + maxPlayerCount.value = 4; + const t = []; + peopleText.value = "请选择游玩人数"; + t.push({ + value: 1, + text: '无需组局' + }); + for (let i = 2; i <= 4; i++) { + t.push({ + value: i, + text: i + '人' + }); + } + peopleRange.value = t; + return; + } + // 确保 date 是数字类型 const dateTimestamp = Number(date); if (isNaN(dateTimestamp) || dateTimestamp <= 0) { @@ -1146,41 +1041,30 @@ gameTypeRange.value = [...config.config.playingMethodOptions]; } - // 必须从房间页跳转,需要传入房间信息 - if (!options || !options.roomId) { - uni.showToast({ - title: '参数错误,请从房间页进入', - icon: 'none' - }); - setTimeout(() => { - uni.navigateBack(); - }, 1500); - return; + // 可以从房间页跳转,也可以直接进入 + if (options && options.roomId) { + // 接收房间信息 + const roomId = Number(options.roomId); + const roomName = decodeURIComponent(options.roomName || '未知房间'); + + if (roomId) { + // 自动填充房间信息 + reservationInfo.value.room_id = roomId; + reservationInfo.value.room_name = roomName; + + // 如果有日期参数,设置默认开始时间 + if (options.date) { + const date = Number(options.date); + if (date) { + // 加载房间详情,获取可预约时段和容量信息 + await loadRoomDetailForReservation(roomId, date); + + // 设置默认开始时间为当天的合适时间 + await setDefaultStartTime(date); + } + } + } } - - // 接收房间信息 - const roomId = Number(options.roomId); - const roomName = decodeURIComponent(options.roomName || '未知房间'); - const date = Number(options.date); - - if (!roomId || !date) { - uni.showToast({ - title: '房间信息不完整', - icon: 'none' - }); - setTimeout(() => { - uni.navigateBack(); - }, 1500); - return; - } - - // 自动填充房间信息 - reservationInfo.value.room_id = roomId; - reservationInfo.value.room_name = roomName; - selectedDate.value = date; - - // 加载房间详情,获取可预约时段和容量信息 - await loadRoomDetailForReservation(roomId, date); }) onShow(async () => { // resetForm();