去除旧版本的预定时间选择
This commit is contained in:
@ -7,60 +7,6 @@
|
||||
}</route>
|
||||
<template>
|
||||
<view class="pb-180rpx">
|
||||
<!-- 预定时间 -->
|
||||
<!-- <wd-popup v-model="showReservePopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" position="bottom">
|
||||
<view class="relative">
|
||||
<view class="absolute top-18rpx right-30rpx" @click="showReservePopup = false">
|
||||
<wd-img width="60rpx" height='60rpx' :src="`${OSS}icon/icon_close.png`"></wd-img>
|
||||
</view>
|
||||
<view class="text-36rpx text-[#121212] leading-50rpx text-center pt-50rpx pb-40rpx">选择时间</view>
|
||||
<view class="w-[100%] h-100rpx flex justify-between items-center">
|
||||
<view
|
||||
class="w-[50%] h-[100%] flex flex-col items-center justify-center rounded-l-[8rpx]"
|
||||
:class="`${currentTimePicker == 'start' ? 'bg-[#4C9F44] text-[#fff]' : 'bg-[#F6F7F8] text-[#303133]'}`"
|
||||
@click="currentTimePicker = 'start'">
|
||||
<view class="text-28rpx leading-40rpx">开始时间</view>
|
||||
<view class="text-26rpx leading-36rpx mt-2rpx">{{ startTimeLayout }}</view>
|
||||
</view>
|
||||
<view
|
||||
class="w-[50%] h-[100%] flex flex-col items-center justify-center rounded-r-[8rpx]"
|
||||
:class="`${currentTimePicker == 'end' ? 'bg-[#4C9F44] text-[#fff]' : 'bg-[#F6F7F8] text-[#303133]'}`"
|
||||
@click="currentTimePicker = 'end'">
|
||||
<view class="text-28rpx leading-40rpx">结束时间</view>
|
||||
<view class="text-26rpx leading-36rpx mt-2rpx">{{ endTimeLayout }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="date-picker">
|
||||
<view class="" v-if="currentTimePicker == 'start'">
|
||||
<wd-datetime-picker-view
|
||||
:minDate='minTimestamp'
|
||||
:maxDate='maxTimestamp'
|
||||
type="datetime"
|
||||
v-model="startTimeValue"
|
||||
:formatter="TeaRoom.handleFormatTime"
|
||||
@change="TeaRoom.handleStartTimePicker"
|
||||
/>
|
||||
</view>
|
||||
<view class="" v-if="currentTimePicker == 'end'">
|
||||
<wd-datetime-picker-view
|
||||
:minDate='minTimestamp'
|
||||
:maxDate='maxTimestamp'
|
||||
type="datetime"
|
||||
v-model="endTimeValue"
|
||||
:formatter="TeaRoom.handleFormatTime"
|
||||
@change="TeaRoom.handleEndTimePicker"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="pb-22rpx mt-40rpx mx-30rpx flex justify-between items-center text-[32rpx] text-center">
|
||||
<view class='bg-[#F6F7F8] text-[#303133] rounded-8rpx h-90rpx leading-90rpx w-[50%] mr-28rpx' @click="TeaRoom.handleResetTime">重置</view>
|
||||
<view class='bg-[#4C9F44] text-[#fff] rounded-8rpx h-90rpx leading-90rpx w-[50%]' @click="TeaRoom.handleConfirmHour">确定({{ totalHour }}小时)</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup> -->
|
||||
|
||||
<!-- 费用明细 -->
|
||||
<wd-popup v-model="showCostPopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" @close="showCostPopup = false" position="bottom">
|
||||
<view class='bg-[#FBFBFB] py-40rpx realtive'>
|
||||
@ -496,21 +442,6 @@
|
||||
const html: string = '<p>这里是富文本内容,需要后台传递</p>'
|
||||
const isGroupBuying: boolean = false // 是否是团购套餐
|
||||
|
||||
|
||||
// 预定时间相关
|
||||
const showReservePopup = ref<boolean>(false) // 预定时间popup
|
||||
const currentTimePicker = ref<string>('start') // 当前选择的时间类型
|
||||
const startTimeValue = ref<string>('') // 开始时间
|
||||
const endTimeValue = ref<string>('') // 结束时间
|
||||
const now = new Date()
|
||||
const minTimestamp = Date.now()
|
||||
|
||||
// 允许选择未来两个月的日期
|
||||
const maxTimestamp = new Date(now.getFullYear(), now.getMonth() + 1, now.getDate()).getTime()
|
||||
const startTimeLayout = ref<string>('')
|
||||
const endTimeLayout = ref<string>('')
|
||||
const totalHour = ref<number>(0)
|
||||
|
||||
// 费用明细相关
|
||||
const showCostPopup = ref<boolean>(false) // 费用明细popup
|
||||
const showPayPopup = ref<boolean>(false) // 支付popup
|
||||
@ -568,66 +499,12 @@
|
||||
})
|
||||
|
||||
const TeaRoom = {
|
||||
startTimeTimestamp: 0, // 记录开始时间戳
|
||||
endTimeTimestamp: 0, // 记录结束时间戳
|
||||
|
||||
handleStartTimePicker: (e: {value: number}) => {
|
||||
TeaRoom.startTimeTimestamp = e.value
|
||||
startTimeLayout.value = TeaRoom.formatDate(e.value)
|
||||
TeaRoom.totalTimestamp()
|
||||
},
|
||||
|
||||
handleEndTimePicker: (e: {value: number}) => {
|
||||
TeaRoom.endTimeTimestamp = e.value
|
||||
endTimeLayout.value = TeaRoom.formatDate(e.value)
|
||||
TeaRoom.totalTimestamp()
|
||||
},
|
||||
|
||||
handleFormatTime: (type: string, values: string) => {
|
||||
if (type === 'year') {
|
||||
return `${values}年`
|
||||
}
|
||||
if (type === 'month') {
|
||||
return `${values}月`
|
||||
}
|
||||
if (type === 'date') {
|
||||
return `${values}日`
|
||||
}
|
||||
if (type === 'hour') {
|
||||
return `${values}时`
|
||||
}
|
||||
if (type === 'minute') {
|
||||
return `${values}分`
|
||||
}
|
||||
return values
|
||||
},
|
||||
|
||||
handleClick: (item: any) => {
|
||||
// 处理点击事件
|
||||
console.log('Clicked item:', item)
|
||||
},
|
||||
|
||||
// 重置预定时间
|
||||
handleResetTime: () => {
|
||||
startTimeValue.value = ''
|
||||
endTimeValue.value = ''
|
||||
startTimeLayout.value = ''
|
||||
endTimeLayout.value = ''
|
||||
TeaRoom.startTimeTimestamp = 0
|
||||
TeaRoom.endTimeTimestamp = 0
|
||||
totalHour.value = 0
|
||||
currentTimePicker.value = 'start'
|
||||
},
|
||||
|
||||
// 确定时间
|
||||
handleConfirmHour: () => {
|
||||
if (totalHour.value <= 0) {
|
||||
toast.info('至少起订N小时')
|
||||
return
|
||||
}
|
||||
showReservePopup.value = false
|
||||
},
|
||||
|
||||
// 跳转优惠券页面
|
||||
handleToCoupon(type) {
|
||||
// 1:优惠券 2:团购券
|
||||
@ -678,35 +555,7 @@
|
||||
handleSubmitOrder: () => {
|
||||
showPayPopup.value = true
|
||||
uni.navigateTo({ url: '/pages/notice/reserve?type=teaSpecialist' })
|
||||
},
|
||||
|
||||
// 格式化时间
|
||||
formatDate: (timestamp: number) => {
|
||||
const date = new Date(timestamp)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const hour = String(date.getHours()).padStart(2, '0')
|
||||
const minute = String(date.getMinutes()).padStart(2, '0')
|
||||
|
||||
return `${year}-${month}-${day} ${hour}:${minute}`
|
||||
},
|
||||
|
||||
// 计算起订时间时长
|
||||
totalTimestamp: () => {
|
||||
if (TeaRoom.startTimeTimestamp && TeaRoom.endTimeTimestamp) {
|
||||
const diffMs = TeaRoom.endTimeTimestamp - TeaRoom.startTimeTimestamp
|
||||
// 计算小时,保留一位小数
|
||||
const hours = (diffMs / 1000 / 60 / 60)
|
||||
const result = Math.round(hours * 10) / 10 // 保留一位小数
|
||||
if (result >= 0) {
|
||||
totalHour.value = result
|
||||
}
|
||||
return result
|
||||
}
|
||||
totalHour.value = 0
|
||||
return 0
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user