Merge branch 'main' of https://gitlab.guxuan.icu/Leo_Ding/JinShan_uniapp
This commit is contained in:
commit
f48f805d61
@ -180,12 +180,23 @@
|
|||||||
@confirm="handleDateConfirm" @close="showCalendar = false" :mask-close-able="true"></u-calendar>
|
@confirm="handleDateConfirm" @close="showCalendar = false" :mask-close-able="true"></u-calendar>
|
||||||
|
|
||||||
<!-- 时间选择器 -->
|
<!-- 时间选择器 -->
|
||||||
<u-datetime-picker :show="showStartTimePicker" v-model="startTimePickerValue" :min-date="Date.now()"
|
<u-datetime-picker :show="showStartTimePicker"
|
||||||
:mode="mode" @confirm="handleStartTimeConfirm" @cancel="showStartTimePicker = false"
|
v-model="startTimePickerValue"
|
||||||
ref="startTimePicker"></u-datetime-picker>
|
:min-date="Date.now()"
|
||||||
|
:mode="mode"
|
||||||
|
@confirm="handleStartTimeConfirm"
|
||||||
|
@cancel="showStartTimePicker = false"
|
||||||
|
ref="startTimePicker"></u-datetime-picker>
|
||||||
|
|
||||||
<u-datetime-picker :show="showEndTimePicker" v-model="endTimePickerValue" :min-date="Date.now()" :mode="mode"
|
<u-datetime-picker
|
||||||
@confirm="handleEndTimeConfirm" @cancel="showEndTimePicker = false" ref="endTimePicker"></u-datetime-picker>
|
:show="showEndTimePicker"
|
||||||
|
v-model="endTimePickerValue"
|
||||||
|
:min-date="Date.now()"
|
||||||
|
:mode="mode"
|
||||||
|
@confirm="handleEndTimeConfirm"
|
||||||
|
@cancel="showEndTimePicker = false"
|
||||||
|
ref="endTimePicker">
|
||||||
|
</u-datetime-picker>
|
||||||
<u-picker :show="showApplyType" :columns="applyTypeColumns" @confirm="applyConfirm"
|
<u-picker :show="showApplyType" :columns="applyTypeColumns" @confirm="applyConfirm"
|
||||||
@cancel="showApplyType=false"></u-picker>
|
@cancel="showApplyType=false"></u-picker>
|
||||||
<u-popup :show="readShow" mode="center" :round="10">
|
<u-popup :show="readShow" mode="center" :round="10">
|
||||||
@ -342,20 +353,51 @@
|
|||||||
this.Id = options.Id;
|
this.Id = options.Id;
|
||||||
this.isSelfStudy = JSON.parse(options.isSelfStudy)
|
this.isSelfStudy = JSON.parse(options.isSelfStudy)
|
||||||
this.mode = options.isSelfStudy === 'true' ? 'year-month' : 'datetime'
|
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: {
|
computed: {
|
||||||
formattedSelectedDate() {
|
formattedSelectedDate() {
|
||||||
if (!this.selectedDate) return '请选择日期';
|
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}`;
|
if (this.isSelfStudy) {
|
||||||
return this.selectedDate
|
// 自习室模式,显示年月格式
|
||||||
|
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() {
|
mounted() {
|
||||||
@ -441,42 +483,53 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleStartTimeConfirm(e) {
|
handleStartTimeConfirm(e) {
|
||||||
// 对于uView的datetime-picker,e.value是时间戳
|
if (this.isSelfStudy) {
|
||||||
const date = new Date(e.value);
|
// 自习室模式处理年月
|
||||||
|
const date = new Date(e.value);
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
|
||||||
const year = date.getFullYear();
|
this.startTime = `${year}-${month}`;
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
this.startTimePickerValue = this.startTime;
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
} else {
|
||||||
const hours = String(date.getHours()).padStart(2, '0');
|
// 普通会议室模式处理完整日期时间
|
||||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
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.startTime = `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||||
this.startTimePickerValue = this.startTime;
|
this.startTimePickerValue = this.startTime;
|
||||||
this.showStartTimePicker = false;
|
}
|
||||||
|
|
||||||
// 如果结束时间早于开始时间,自动调整结束时间
|
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;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleEndTimeConfirm(e) {
|
handleEndTimeConfirm(e) {
|
||||||
const date = new Date(e.value);
|
if (this.isSelfStudy) {
|
||||||
|
// 自习室模式处理年月
|
||||||
|
const date = new Date(e.value);
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
|
||||||
const year = date.getFullYear();
|
this.endTime = `${year}-${month}`;
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
this.endTimePickerValue = this.endTime;
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
} else {
|
||||||
const hours = String(date.getHours()).padStart(2, '0');
|
// 普通会议室模式处理完整日期时间
|
||||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
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.endTime = `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||||
this.endTimePickerValue = this.endTime;
|
this.endTimePickerValue = this.endTime;
|
||||||
this.showEndTimePicker = false;
|
}
|
||||||
|
|
||||||
// 验证时间是否合理
|
this.showEndTimePicker = false;
|
||||||
this.validateTime();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
adjustEndTime() {
|
adjustEndTime() {
|
||||||
|
|||||||
@ -285,10 +285,11 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
goDetail(item) {
|
goDetail(item) {
|
||||||
|
console.log("====item",item)
|
||||||
// 安全获取ID(兼容各种可能的字段名)
|
// 安全获取ID(兼容各种可能的字段名)
|
||||||
const id = item.id;
|
const id = item.id;
|
||||||
const isSelfStudy = item.title === '自习室' ? true : false
|
const isSelfStudy = item.title === '自习室';
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '会议室信息异常',
|
title: '会议室信息异常',
|
||||||
@ -297,8 +298,42 @@
|
|||||||
return;
|
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({
|
uni.navigateTo({
|
||||||
url: `/pages/meetingDetail/index?Id=${encodeURIComponent(id)}&isSelfStudy=${isSelfStudy}`, // 使用encodeURIComponent防止特殊字符问题
|
url: `/pages/meetingDetail/index?Id=${encodeURIComponent(id)}&isSelfStudy=${isSelfStudy}`,
|
||||||
success: () => {
|
success: () => {
|
||||||
console.log('导航成功,ID:', id);
|
console.log('导航成功,ID:', id);
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user