|
@@ -14,7 +14,8 @@ Page({
|
|
|
afternoonDisabled: false,
|
|
|
morningDisabled: false,
|
|
|
showMorning: true,
|
|
|
- showAfternoon: true
|
|
|
+ showAfternoon: true,
|
|
|
+ isNextButtonDisabled: false
|
|
|
},
|
|
|
|
|
|
onLoad(options) {
|
|
@@ -149,6 +150,7 @@ Page({
|
|
|
morningText = `余票${morningData.pcs}张`;
|
|
|
} else {
|
|
|
morningText = '已约满';
|
|
|
+ morningDisabled = true;
|
|
|
}
|
|
|
morningTime = morningData.time;
|
|
|
morningId = morningData.id;
|
|
@@ -166,6 +168,7 @@ Page({
|
|
|
afternoonText = `余票${afternoonData.pcs}张`;
|
|
|
} else {
|
|
|
afternoonText = '已约满';
|
|
|
+ afternoonDisabled = true;
|
|
|
}
|
|
|
afternoonTime = afternoonData.time;
|
|
|
afternoonId = afternoonData.id;
|
|
@@ -176,16 +179,18 @@ Page({
|
|
|
|
|
|
// 检查时间段是否已过期(只有未被禁用且不是闭馆状态的时间段才检查过期)
|
|
|
if (morningData && !morningDisabled && morningText !== '闭馆') {
|
|
|
- morningDisabled = this.isTimeSlotExpired(morningTime, this.data.selectedDate);
|
|
|
- if (morningDisabled) {
|
|
|
+ const isExpired = this.isTimeSlotExpired(morningTime, this.data.selectedDate);
|
|
|
+ if (isExpired) {
|
|
|
morningText = '已过期';
|
|
|
+ morningDisabled = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (afternoonData && !afternoonDisabled && afternoonText !== '闭馆') {
|
|
|
- afternoonDisabled = this.isTimeSlotExpired(afternoonTime, this.data.selectedDate);
|
|
|
- if (afternoonDisabled) {
|
|
|
+ const isExpired = this.isTimeSlotExpired(afternoonTime, this.data.selectedDate);
|
|
|
+ if (isExpired) {
|
|
|
afternoonText = '已过期';
|
|
|
+ afternoonDisabled = true;
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -205,14 +210,16 @@ Page({
|
|
|
afternoonText = `余票${singleData.pcs}张`;
|
|
|
} else {
|
|
|
afternoonText = '已约满';
|
|
|
+ afternoonDisabled = true;
|
|
|
}
|
|
|
afternoonTime = singleData.time;
|
|
|
afternoonId = singleData.id;
|
|
|
|
|
|
if (!afternoonDisabled) {
|
|
|
- afternoonDisabled = this.isTimeSlotExpired(afternoonTime, this.data.selectedDate);
|
|
|
- if (afternoonDisabled) {
|
|
|
+ const isExpired = this.isTimeSlotExpired(afternoonTime, this.data.selectedDate);
|
|
|
+ if (isExpired) {
|
|
|
afternoonText = '已过期';
|
|
|
+ afternoonDisabled = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -227,14 +234,16 @@ Page({
|
|
|
morningText = `余票${singleData.pcs}张`;
|
|
|
} else {
|
|
|
morningText = '已约满';
|
|
|
+ morningDisabled = true;
|
|
|
}
|
|
|
morningTime = singleData.time;
|
|
|
morningId = singleData.id;
|
|
|
|
|
|
if (!morningDisabled) {
|
|
|
- morningDisabled = this.isTimeSlotExpired(morningTime, this.data.selectedDate);
|
|
|
- if (morningDisabled) {
|
|
|
+ const isExpired = this.isTimeSlotExpired(morningTime, this.data.selectedDate);
|
|
|
+ if (isExpired) {
|
|
|
morningText = '已过期';
|
|
|
+ morningDisabled = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -258,6 +267,22 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 计算下一步按钮是否应该禁用
|
|
|
+ let isNextButtonDisabled = false;
|
|
|
+
|
|
|
+ // 计算有几个时间段显示
|
|
|
+ const visibleSlots = [];
|
|
|
+ if (showMorning) visibleSlots.push({ disabled: morningDisabled, name: 'morning' });
|
|
|
+ if (showAfternoon) visibleSlots.push({ disabled: afternoonDisabled, name: 'afternoon' });
|
|
|
+
|
|
|
+ if (visibleSlots.length === 1) {
|
|
|
+ // 只有一个时间段,如果该时间段被禁用则置灰按钮
|
|
|
+ isNextButtonDisabled = visibleSlots[0].disabled;
|
|
|
+ } else if (visibleSlots.length === 2) {
|
|
|
+ // 有两个时间段,如果两个时间段都被禁用则置灰按钮
|
|
|
+ isNextButtonDisabled = visibleSlots.every(slot => slot.disabled);
|
|
|
+ }
|
|
|
|
|
|
this.setData({
|
|
|
morningAvailability: morningText,
|
|
@@ -269,7 +294,8 @@ Page({
|
|
|
afternoonDisabled: afternoonDisabled,
|
|
|
morningDisabled: morningDisabled,
|
|
|
showMorning: showMorning,
|
|
|
- showAfternoon: showAfternoon
|
|
|
+ showAfternoon: showAfternoon,
|
|
|
+ isNextButtonDisabled: isNextButtonDisabled
|
|
|
});
|
|
|
},
|
|
|
|
|
@@ -303,6 +329,15 @@ Page({
|
|
|
|
|
|
// 下一步
|
|
|
goNext() {
|
|
|
+ // 如果按钮被禁用,不允许进入下一步
|
|
|
+ if (this.data.isNextButtonDisabled) {
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '当前时间段不可预约',
|
|
|
+ // icon: 'none'
|
|
|
+ // });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (this.data.selectedTime && this.data.selectedDate) {
|
|
|
console.log('选择的时间段:', this.data.selectedTime);
|
|
|
console.log('选择的日期:', this.data.selectedDate);
|
|
@@ -323,10 +358,10 @@ Page({
|
|
|
url: `/pages/index/visit-people/visit-people?date=${this.data.selectedDate}&time=${actualTime}&appointmentSlotsId=${appointmentSlotsId}&type=1`
|
|
|
});
|
|
|
} else {
|
|
|
- wx.showToast({
|
|
|
- title: '请选择日期和时间段',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '请选择日期和时间段',
|
|
|
+ // icon: 'none'
|
|
|
+ // });
|
|
|
}
|
|
|
},
|
|
|
|