完善页面

This commit is contained in:
wangxiaowei
2025-09-09 22:33:38 +08:00
parent ff964fbc87
commit 0064e83e20
23 changed files with 1344 additions and 162 deletions

View File

@ -0,0 +1,156 @@
<template>
<wd-popup v-model="showPopup" lock-scroll custom-style="border-radius: 32rpx 32rpx 0rpx 0rpx;" position="bottom">
<view class="relative pb-78rpx">
<view class="absolute top-18rpx right-30rpx" @click="showPopup = 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="">
<view class="booking-time ">
<wd-tabs v-model="selectedDay" color="#4C9F44">
<block v-for="item in days" :key="item">
<scroll-view scroll-y>
<wd-tab :title="`${item}`" :name="item">
<view class="">
<view class="!h-500rpx mt-30rpx">
<view class="grid grid-cols-4 gap-x-20rpx gap-y-20rpx mx-30rpx">
<view v-for="item in timeList" :key="item.time"
class="h-72rpx rounded-16rpx flex items-center justify-center text-28rpx leading-40rpx"
:class="[
item.disabled
? 'bg-[#F7F7F7] text-[#C9C9C9]' // 禁用高亮
: selectedTime.includes(item.time)
? 'bg-[#F1F8F0] text-[#4C9F44]' // 选中高亮
: 'bg-[#F7F7F7] text-[#303133]', // 可选高亮
]" @click="!item.disabled && bookingTime.handleSelectTime(item.time)">
{{ item.time }}
</view>
</view>
</view>
<view class="">
<view>
<wd-gap height="2rpx" bg-color="#E5E5E5"></wd-gap>
</view>
<view class="">
<view class="w-full fixed bottom-0 left-0 right-0 bg-white h-152rpx text-32rpx leading-44rpx flex items-center justify-center leading-90rpx text-center">
<view class="w-330rpx h-90rpx bg-[#F6F7F8] rounded-8rpx text-[#303133] mr-30rpx" @click="bookingTime.resetSelectedTime">重置</view>
<view class="w-330rpx h-90rpx bg-[#4C9F44] rounded-8rpx text-[#fff]" @click="bookingTime.handleConfirmSelectedTime">
<text>确定</text>
<text v-if="countSelectedTime">{{countSelectedTime}}小时</text>
</view>
</view>
</view>
</view>
</view>
</wd-tab>
</scroll-view>
</block>
</wd-tabs>
</view>
</view>
</view>
</wd-popup>
</template>
<script lang="ts" setup name="BookingTime">
const OSS = inject('OSS')
/**
* BookingTime 预约时间
* @description 茶室预约时间选择组件
*/
const props = defineProps({
modelValue: {
type: Boolean,
default: false
},
// ...其它props
})
// 初始化时间
onMounted(() => {
bookingTime.handleInitTime()
})
/** 日期相关 **/
const timeList = [
{ time: '09:00', disabled: true },
{ time: '09:30', disabled: false },
{ time: '10:00', disabled: false },
{ time: '10:30', disabled: false },
{ time: '11:00', disabled: false },
{ time: '11:30', disabled: false },
]
const weekMap = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
const days = ref<string[]>([])
const selectedDay = ref<number>(0)
const selectedTime = ref<string[]>([])
const countSelectedTime = ref<number>(0)
const bookingTime = {
// 初始化时间逻辑
handleInitTime: () => {
const today = new Date()
const result: string[] = []
for (let i = 0; i < 7; i++) {
const d = new Date(today)
d.setDate(today.getDate() + i)
const month = d.getMonth() + 1
const date = d.getDate()
const week = weekMap[d.getDay()]
result.push(`${month}/${date}${week}`)
}
days.value = result
},
// 选择的时间高亮显示
handleSelectTime: (time: string) => {
const idx = selectedTime.value.indexOf(time)
if (idx > -1) {
selectedTime.value.splice(idx, 1) // 取消选中
} else {
selectedTime.value.push(time) // 选中
}
// 计算时长
countSelectedTime.value = selectedTime.value.length * 0.5
},
// 确认选择的时间
handleConfirmSelectedTime: () => {
console.log('确认选择的时间:', selectedDay.value, selectedTime.value)
showPopup.value = false
},
// 重置选择的时间
resetSelectedTime: () => {
selectedTime.value = []
},
}
const showPopup = computed({
get: () => props.modelValue,
set: (val: boolean) => emit('update:modelValue', val)
})
const emit = defineEmits(['update:modelValue'])
</script>
<script lang="ts">
export default {}
</script>
<style lang="scss" scoped>
.booking-time {
:deep() {
.wd-tabs__line {
background-color: #4C9F44;
}
}
}
</style>