添加预约时间和已被预约数量限制

This commit is contained in:
Leo_Ding 2025-09-16 11:01:43 +08:00
parent e0579b82ab
commit b0b79b2ce0

View File

@ -198,11 +198,7 @@
<!-- 日历组件 -->
<u-calendar
:key="calendarKey"
:show="showCalendar"
mode="single" :min-date="minDate"
:max-date="maxDate"
<u-calendar :key="calendarKey" :show="showCalendar" mode="single" :min-date="minDate" :max-date="maxDate"
@confirm="handleDateConfirm" @close="showCalendar = false" :mask-close-able="true"></u-calendar>
<!-- 时间选择器 -->
@ -279,7 +275,7 @@
if (endHours >= 24) endHours = 0;
return {
noIsSelfStudy:false,
noIsSelfStudy: false,
pickerType: 1,
borrowTimeData: '',
borrowTimeShow: false,
@ -399,18 +395,11 @@
endTimePickerValue: ``,
applyInfo: {},
//
// selectedDate: `${year}-${month}-${day}`,
// minDate: `${year}-${month}-${day}`,
// maxDate: `${year + 1}-12-31`,
selectedDate: `2025-08-11`, // 81
minDate: `2025-08-01`, // 81
maxDate: `2025-08-31`, // 831
selectedDate: `${year}-${month}-${day}`,
minDate: `${year}-${month}-${day}`,
maxDate: `${year + 1}-12-31`,
//
// startTime: `2025-08`,
// endTime: `2025-08`,
// startTimeValue: `${startHours.toString().padStart(2, '0')}:${startMinutes.toString().padStart(2, '0')}`,
// endTimeValue: `${endHours.toString().padStart(2, '0')}:${endMinutes.toString().padStart(2, '0')}`,
startTimeValue: `09:00`,
endTimeValue: `10:00`,
@ -614,7 +603,7 @@
} else {
this.endTime = `${e.value[0]}:${e.value[1]}`
}
this.noIsSelfStudy=false
this.noIsSelfStudy = false
},
handleEndTimeConfirm(e) {
if (this.isSelfStudy) {
@ -726,9 +715,39 @@
resolve('所有属性验证通过');
});
},
validateBorrowTime(applyInfo = {}) {
return new Promise(async (resolve, reject) => {
const response = await post('/api/v1/app_auth/metting-room/order/check_time', applyInfo)
if (!response || !response.success) {
reject(
uni.showToast({
title: response.msg,
icon: 'none'
})
)
}
if (response.success == true) {
resolve()
}
})
},
async handleBook() {
try {
this.readShow = false
if (!this.isSelfStudy) {
if (!this.startTime || !this.endTime) {
return uni.showToast({
title: '开始和结束时间不能为空',
icon: 'none'
})
}
if(this.startTime>this.endTime){
return uni.showToast({
title: '开始时间不能晚于结束时间',
icon: 'none'
})
}
}
// console.log(this.applyType);
let bookingInfo = {
roomId: this.Id,
@ -743,14 +762,17 @@
userPhone: this.userPhone,
userAddress: this.userAddress,
userCardId: this.userCardId,
startTime: this.isSelfStudy?this.startTime:`${this.borrowTimeData} ${this.startTime}`,
endTime: this.isSelfStudy?this.endTime:`${this.borrowTimeData} ${this.endTime}`,
startTime: this.isSelfStudy ? this.startTime :
`${this.borrowTimeData}${this.startTime}`,
endTime: this.isSelfStudy ? this.endTime : `${this.borrowTimeData}${this.endTime}`,
counter: this.counter,
num: this.num,
// applyType:this.applyType
}
await this.validateObject(userApplyInfo, this.applyRules)
const applyInfo = Object.assign(bookingInfo, userApplyInfo)
await this.validateBorrowTime(applyInfo)
// A
const app = getApp()
app.globalData.applyInfo = applyInfo
@ -767,16 +789,19 @@
concatName: this.concatName,
concatPhone: this.concatPhone,
companyName: this.companyName,
startTime: this.isSelfStudy?this.startTime:`${this.borrowTimeData} ${this.startTime}`,
endTime: this.isSelfStudy?this.endTime:`${this.borrowTimeData} ${this.endTime}`,
startTime: this.isSelfStudy ? this.startTime :
`${this.borrowTimeData}${this.startTime}`,
endTime: this.isSelfStudy ? this.endTime : `${this.borrowTimeData}${this.endTime}`,
counter: this.counter,
num: this.num,
stampUrl: this.stampUrl,
// applyType:this.applyType
}
await this.validateObject(userApplyInfo, this.applyRules)
const applyInfo = Object.assign(bookingInfo, userApplyInfo)
await this.validateBorrowTime(applyInfo)
const app = getApp()
app.globalData.applyInfo = Object.assign(bookingInfo, userApplyInfo)
app.globalData.applyInfo = applyInfo
this.readShow = true
}
} catch (error) {