|
@ -130,18 +130,18 @@ |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
<view class="picker-section"> |
|
|
<view class="picker-section"> |
|
|
<view class="section-title">选择时间</view> |
|
|
|
|
|
<view class="time-btns"> |
|
|
|
|
|
<view |
|
|
|
|
|
v-for="(slot, idx) in timeSlots" |
|
|
|
|
|
:key="idx" |
|
|
|
|
|
:class="['time-btn', {active: selectedTimeSlot === idx}]" |
|
|
|
|
|
@tap="selectTimeSlot(idx)" |
|
|
|
|
|
> |
|
|
|
|
|
{{ slot }} |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
<view class="section-title">选择时间</view> |
|
|
|
|
|
<view class="time-btns"> |
|
|
|
|
|
<view |
|
|
|
|
|
v-for="(slot, idx) in timeSlots" |
|
|
|
|
|
:key="idx" |
|
|
|
|
|
:class="['time-btn', {active: selectedTimeSlot === idx, disabled: !availableTimeSlots[idx]}]" |
|
|
|
|
|
@tap="availableTimeSlots[idx] ? selectTimeSlot(idx) : null" |
|
|
|
|
|
> |
|
|
|
|
|
{{ slot }} |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
<view class="confirm-btn" @tap="confirmTime">确认</view> |
|
|
<view class="confirm-btn" @tap="confirmTime">确认</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
@ -167,8 +167,8 @@ export default { |
|
|
showTimePicker: false, |
|
|
showTimePicker: false, |
|
|
currentDateTab: 0, |
|
|
currentDateTab: 0, |
|
|
dateTabs: [], // 动态生成 |
|
|
dateTabs: [], // 动态生成 |
|
|
timeSlots: ['11:00~13:00', '13:00~15:00', '15:00~17:00'], |
|
|
|
|
|
selectedTimeSlot: 0, |
|
|
|
|
|
|
|
|
timeSlots: ['09:00~11:00', '11:00~13:00', '13:00~15:00', '15:00~17:00', '17:00~19:00'], |
|
|
|
|
|
selectedTimeSlot: -1, |
|
|
steps: [], // 改为空数组,由接口获取 |
|
|
steps: [], // 改为空数组,由接口获取 |
|
|
showAllItems: false, |
|
|
showAllItems: false, |
|
|
addressId: '' |
|
|
addressId: '' |
|
@ -237,6 +237,18 @@ export default { |
|
|
uni.$off('clearRecycleData') |
|
|
uni.$off('clearRecycleData') |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
|
|
|
|
availableTimeSlots() { |
|
|
|
|
|
const tab = this.dateTabs[this.currentDateTab]; |
|
|
|
|
|
if (!tab) return this.timeSlots.map(() => true); |
|
|
|
|
|
const dateObj = tab.date; |
|
|
|
|
|
const now = new Date(); |
|
|
|
|
|
return this.timeSlots.map(slot => { |
|
|
|
|
|
const startTime = slot.split('~')[0]; |
|
|
|
|
|
const [h, m] = startTime.split(':'); |
|
|
|
|
|
const slotDate = new Date(dateObj.getFullYear(), dateObj.getMonth(), dateObj.getDate(), h, m); |
|
|
|
|
|
return slotDate > now; |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
totalCount() { |
|
|
totalCount() { |
|
|
return this.selectedItems.reduce((sum, item) => sum + item.quantity, 0) |
|
|
return this.selectedItems.reduce((sum, item) => sum + item.quantity, 0) |
|
|
}, |
|
|
}, |
|
@ -299,23 +311,29 @@ export default { |
|
|
this.currentDateTab = index |
|
|
this.currentDateTab = index |
|
|
}, |
|
|
}, |
|
|
selectTimeSlot(index) { |
|
|
selectTimeSlot(index) { |
|
|
this.selectedTimeSlot = index |
|
|
|
|
|
}, |
|
|
|
|
|
confirmTime() { |
|
|
|
|
|
const tab = this.dateTabs[this.currentDateTab] |
|
|
|
|
|
const dateObj = tab.date |
|
|
|
|
|
const timeStr = this.timeSlots[this.selectedTimeSlot] // 例如 '11:00~13:00' |
|
|
|
|
|
const startTime = timeStr.split('~')[0] // '11:00' |
|
|
|
|
|
const yyyy = dateObj.getFullYear() |
|
|
|
|
|
const mm = (dateObj.getMonth() + 1).toString().padStart(2, '0') |
|
|
|
|
|
const dd = dateObj.getDate().toString().padStart(2, '0') |
|
|
|
|
|
this.selectedTime = `${yyyy}-${mm}-${dd} ${startTime}:00` |
|
|
|
|
|
this.closeTimePicker() |
|
|
|
|
|
}, |
|
|
|
|
|
resetPicker() { |
|
|
|
|
|
this.currentDateTab = 0 |
|
|
|
|
|
this.selectedTimeSlot = 0 |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
if (this.availableTimeSlots[index]) { |
|
|
|
|
|
this.selectedTimeSlot = index; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
confirmTime() { |
|
|
|
|
|
if (this.selectedTimeSlot === -1) { |
|
|
|
|
|
uni.showToast({ title: '请选择可用时间段', icon: 'none' }); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
const tab = this.dateTabs[this.currentDateTab]; |
|
|
|
|
|
const dateObj = tab.date; |
|
|
|
|
|
const timeStr = this.timeSlots[this.selectedTimeSlot]; |
|
|
|
|
|
const startTime = timeStr.split('~')[0]; |
|
|
|
|
|
const yyyy = dateObj.getFullYear(); |
|
|
|
|
|
const mm = (dateObj.getMonth() + 1).toString().padStart(2, '0'); |
|
|
|
|
|
const dd = dateObj.getDate().toString().padStart(2, '0'); |
|
|
|
|
|
this.selectedTime = `${yyyy}-${mm}-${dd} ${startTime}:00`; |
|
|
|
|
|
this.closeTimePicker(); |
|
|
|
|
|
}, |
|
|
|
|
|
resetPicker() { |
|
|
|
|
|
this.currentDateTab = 0; |
|
|
|
|
|
this.selectedTimeSlot = -1; |
|
|
|
|
|
}, |
|
|
toggleAgreement() { |
|
|
toggleAgreement() { |
|
|
this.agreed = !this.agreed |
|
|
this.agreed = !this.agreed |
|
|
}, |
|
|
}, |
|
@ -832,4 +850,12 @@ export default { |
|
|
padding: 36rpx 0 24rpx 30rpx; |
|
|
padding: 36rpx 0 24rpx 30rpx; |
|
|
letter-spacing: 1rpx; |
|
|
letter-spacing: 1rpx; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.time-btn.disabled { |
|
|
|
|
|
color: #ccc; |
|
|
|
|
|
background: #f0f0f0; |
|
|
|
|
|
border-color: #eee; |
|
|
|
|
|
pointer-events: none; |
|
|
|
|
|
} |
|
|
</style> |
|
|
</style> |