diff --git a/pages/meetingDetail/index.vue b/pages/meetingDetail/index.vue
index d6a1820..915f42a 100644
--- a/pages/meetingDetail/index.vue
+++ b/pages/meetingDetail/index.vue
@@ -180,12 +180,23 @@
@confirm="handleDateConfirm" @close="showCalendar = false" :mask-close-able="true">
-
+
-
+
+
@@ -342,20 +353,51 @@
this.Id = options.Id;
this.isSelfStudy = JSON.parse(options.isSelfStudy)
this.mode = options.isSelfStudy === 'true' ? 'year-month' : 'datetime'
+
+ // 设置默认时间值
+ if (this.isSelfStudy) {
+ // 自习室模式,只显示年月
+ const now = new Date();
+ const year = now.getFullYear();
+ const month = (now.getMonth() + 1).toString().padStart(2, '0');
+
+ this.startTime = `${year}-${month}`;
+ this.endTime = `${year}-${month}`;
+ this.startTimePickerValue = this.startTime;
+ this.endTimePickerValue = this.endTime;
+ } else {
+ // 普通会议室模式,显示完整日期时间
+ const now = new Date();
+ const year = now.getFullYear();
+ const month = (now.getMonth() + 1).toString().padStart(2, '0');
+ const day = now.getDate().toString().padStart(2, '0');
+
+ this.startTime = `${year}-${month}-${day} 09:00`;
+ this.endTime = `${year}-${month}-${day} 10:00`;
+ this.startTimePickerValue = this.startTime;
+ this.endTimePickerValue = this.endTime;
+ }
+
}
},
computed: {
formattedSelectedDate() {
- if (!this.selectedDate) return '请选择日期';
- console.log(this.selectedDate)
- // const date = new Date(this.selectedDate);
- // const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
- // const month = date.getMonth() + 1;
- // const day = date.getDate();
- // const weekday = weekdays[date.getDay()];
-
- // return `${month}月${day}日 ${weekday}`;
- return this.selectedDate
+ if (!this.selectedDate) return '请选择日期';
+
+ if (this.isSelfStudy) {
+ // 自习室模式,显示年月格式
+ const [year, month] = this.selectedDate.split('-');
+ return `${year}年${month}月`;
+ } else {
+ // 普通会议室模式,显示完整日期
+ const date = new Date(this.selectedDate);
+ const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
+ const month = date.getMonth() + 1;
+ const day = date.getDate();
+ const weekday = weekdays[date.getDay()];
+
+ return `${month}月${day}日 ${weekday}`;
+ }
}
},
mounted() {
@@ -441,42 +483,53 @@
},
handleStartTimeConfirm(e) {
- // 对于uView的datetime-picker,e.value是时间戳
- const date = new Date(e.value);
-
- const year = date.getFullYear();
- const month = String(date.getMonth() + 1).padStart(2, '0');
- const day = String(date.getDate()).padStart(2, '0');
- const hours = String(date.getHours()).padStart(2, '0');
- const minutes = String(date.getMinutes()).padStart(2, '0');
-
- this.startTime = `${year}-${month}-${day} ${hours}:${minutes}`;
- this.startTimePickerValue = this.startTime;
- this.showStartTimePicker = false;
-
- // 如果结束时间早于开始时间,自动调整结束时间
- if (new Date(this.endTime) < new Date(this.startTime)) {
- const endDate = new Date(date.getTime() + 60 * 60 * 1000); // 加1小时
- this.endTime = `${endDate.getFullYear()}-${String(endDate.getMonth() + 1).padStart(2, '0')}-${String(endDate.getDate()).padStart(2, '0')} ${String(endDate.getHours()).padStart(2, '0')}:${String(endDate.getMinutes()).padStart(2, '0')}`;
- this.endTimePickerValue = this.endTime;
- }
+ if (this.isSelfStudy) {
+ // 自习室模式处理年月
+ const date = new Date(e.value);
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+
+ this.startTime = `${year}-${month}`;
+ this.startTimePickerValue = this.startTime;
+ } else {
+ // 普通会议室模式处理完整日期时间
+ const date = new Date(e.value);
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+ const day = String(date.getDate()).padStart(2, '0');
+ const hours = String(date.getHours()).padStart(2, '0');
+ const minutes = String(date.getMinutes()).padStart(2, '0');
+
+ this.startTime = `${year}-${month}-${day} ${hours}:${minutes}`;
+ this.startTimePickerValue = this.startTime;
+ }
+
+ this.showStartTimePicker = false;
},
handleEndTimeConfirm(e) {
- const date = new Date(e.value);
-
- const year = date.getFullYear();
- const month = String(date.getMonth() + 1).padStart(2, '0');
- const day = String(date.getDate()).padStart(2, '0');
- const hours = String(date.getHours()).padStart(2, '0');
- const minutes = String(date.getMinutes()).padStart(2, '0');
-
- this.endTime = `${year}-${month}-${day} ${hours}:${minutes}`;
- this.endTimePickerValue = this.endTime;
- this.showEndTimePicker = false;
-
- // 验证时间是否合理
- this.validateTime();
+ if (this.isSelfStudy) {
+ // 自习室模式处理年月
+ const date = new Date(e.value);
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+
+ this.endTime = `${year}-${month}`;
+ this.endTimePickerValue = this.endTime;
+ } else {
+ // 普通会议室模式处理完整日期时间
+ const date = new Date(e.value);
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+ const day = String(date.getDate()).padStart(2, '0');
+ const hours = String(date.getHours()).padStart(2, '0');
+ const minutes = String(date.getMinutes()).padStart(2, '0');
+
+ this.endTime = `${year}-${month}-${day} ${hours}:${minutes}`;
+ this.endTimePickerValue = this.endTime;
+ }
+
+ this.showEndTimePicker = false;
},
adjustEndTime() {
diff --git a/pages/meetingList/index.vue b/pages/meetingList/index.vue
index 1776828..69b2f47 100644
--- a/pages/meetingList/index.vue
+++ b/pages/meetingList/index.vue
@@ -284,32 +284,67 @@
}
},
- goDetail(item) {
-
- // 安全获取ID(兼容各种可能的字段名)
- const id = item.id;
- const isSelfStudy = item.title === '自习室' ? true : false
- if (!id) {
- uni.showToast({
- title: '会议室信息异常',
- icon: 'none'
- });
- return;
- }
-
- uni.navigateTo({
- url: `/pages/meetingDetail/index?Id=${encodeURIComponent(id)}&isSelfStudy=${isSelfStudy}`, // 使用encodeURIComponent防止特殊字符问题
- success: () => {
- console.log('导航成功,ID:', id);
- },
- fail: (err) => {
- console.error('导航失败:', err);
- uni.showToast({
- title: '打开详情页失败',
- icon: 'none'
- });
- }
- });
+ goDetail(item) {
+ console.log("====item",item)
+ // 安全获取ID(兼容各种可能的字段名)
+ const id = item.id;
+ const isSelfStudy = item.title === '自习室';
+
+ if (!id) {
+ uni.showToast({
+ title: '会议室信息异常',
+ icon: 'none'
+ });
+ return;
+ }
+
+ // 如果是自习室,先弹出提示确认框
+ if (item.roomType == 2 ) {
+ uni.showModal({
+ title: '温馨提示',
+ content: '自习室预约时间按月为单位,单次预约最长两个月,请确认是否继续?',
+ confirmColor: '#007AFF', // 可根据uView主题色调整
+ success: (res) => {
+ if (res.confirm) {
+ // 用户点击确定,执行跳转
+ this.navigateToDetail(id, true);
+ } else if (res.cancel) {
+ // 用户点击取消,可选操作(如提示取消)
+ uni.showToast({
+ title: '已取消',
+ icon: 'none'
+ });
+ }
+ },
+ fail: (err) => {
+ console.error('弹窗失败:', err);
+ uni.showToast({
+ title: '操作失败',
+ icon: 'none'
+ });
+ }
+ });
+ } else {
+ // 非自习室,直接跳转
+ this.navigateToDetail(id, false);
+ }
+ },
+
+ // 封装跳转逻辑,避免重复代码
+ navigateToDetail(id, isSelfStudy) {
+ uni.navigateTo({
+ url: `/pages/meetingDetail/index?Id=${encodeURIComponent(id)}&isSelfStudy=${isSelfStudy}`,
+ success: () => {
+ console.log('导航成功,ID:', id);
+ },
+ fail: (err) => {
+ console.error('导航失败:', err);
+ uni.showToast({
+ title: '打开详情页失败',
+ icon: 'none'
+ });
+ }
+ });
},
// 获取会议室列表
async getList() {