文件
yjyf/yjyf-app/components/AppointTimeDrawer.vue
YuanWen 78d45eea74 chore: 新增epay和cos插件相关类库及配置文件
- 新增epay v2、v3、v3new版本的支付类库及证书文件
- 新增cos云存储类库文件
- 调整文件上传保存格式为按分类存储
- 修复会员、规则、类目等语言翻译键名
- 新增小程序图标等静态资源文件
2026-11-04 09:33:57 +08:00

299 行
6.1 KiB
Vue

<template>
<view class="drawer-mask" v-if="visible" @tap="close">
<view class="drawer-sheet" @tap.stop>
<!-- 标题栏 -->
<view class="drawer-head">
<text class="dh-title">选择期望上门时间</text>
<view class="dh-close clickable-hover" @tap="close">
<image class="dh-close-img" src="/static/icons/close.svg" mode="aspectFit" />
</view>
</view>
<!-- 上门日期滚动条 -->
<view class="section-box">
<text class="section-title">上门日期</text>
<scroll-view class="date-scroll" scroll-x="true" show-scrollbar="false">
<view class="date-list">
<view
class="date-card clickable-hover"
v-for="d in dateList"
:key="d.fullDate"
:class="{ active: selectedDate === d.fullDate }"
@tap="selectedDate = d.fullDate"
>
<text class="dc-tag">{{ d.tag }}</text>
<text class="dc-date">{{ d.dateStr }}</text>
</view>
</view>
</scroll-view>
</view>
<!-- 上门时段纯净卡片 -->
<view class="section-box">
<text class="section-title">上门时段</text>
<view class="slot-grid">
<view
class="slot-card clickable-hover"
v-for="name in slotList"
:key="name"
:class="{ active: selectedSlot === name }"
@tap="selectedSlot = name"
>
<text class="slot-txt">{{ name }}</text>
</view>
</view>
</view>
<!-- 底部确定按钮 -->
<view class="drawer-foot">
<view class="confirm-btn clickable-hover" @tap="handleConfirm">
<text class="cb-txt">确定</text>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed, watch } from 'vue';
const props = defineProps({
visible: { type: Boolean, default: false },
date: { type: String, default: '' },
slot: { type: String, default: '' }
});
const emit = defineEmits(['update:visible', 'confirm']);
const slotList = ['上午', '下午', '晚上', '全天'];
// 生成未来 7 天日期
const dateList = computed(() => {
const list = [];
const weekNames = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
const now = new Date();
for (let i = 0; i < 7; i++) {
const target = new Date(now.getTime() + i * 24 * 3600 * 1000);
const year = target.getFullYear();
const month = String(target.getMonth() + 1).padStart(2, '0');
const day = String(target.getDate()).padStart(2, '0');
const fullDate = `${year}-${month}-${day}`;
const dateStr = `${month}-${day}`;
let tag = weekNames[target.getDay()];
if (i === 0) tag = '今天';
else if (i === 1) tag = '明天';
else if (i === 2) tag = '后天';
list.push({ fullDate, dateStr, tag });
}
return list;
});
const selectedDate = ref('');
const selectedSlot = ref('晚上');
watch(() => props.visible, (v) => {
if (v) {
selectedDate.value = props.date || (dateList.value[0] ? dateList.value[0].fullDate : '');
selectedSlot.value = props.slot || '晚上';
}
}, { immediate: true });
function close() {
emit('update:visible', false);
}
function handleConfirm() {
emit('confirm', {
date: selectedDate.value,
slot: selectedSlot.value,
display: `${selectedDate.value} ${selectedSlot.value}`
});
close();
}
</script>
<style scoped>
.drawer-mask {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(2px);
z-index: 999;
display: flex;
flex-direction: column;
justify-content: flex-end;
animation: drawerFadeIn 0.2s ease-out;
}
@keyframes drawerFadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.drawer-sheet {
background: #FFFFFF;
border-top-left-radius: 28rpx;
border-top-right-radius: 28rpx;
padding: 36rpx 36rpx calc(30rpx + env(safe-area-inset-bottom));
box-sizing: border-box;
animation: drawerSlideUp 0.24s cubic-bezier(0.16, 1, 0.3, 1);
box-shadow: 0 -8rpx 32rpx rgba(0, 0, 0, 0.08);
}
@keyframes drawerSlideUp {
from { transform: translateY(100%); }
to { transform: translateY(0); }
}
.drawer-head {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 24rpx;
}
.dh-title {
font-size: 34rpx;
font-weight: 700;
color: #1A1A1A;
}
.dh-close {
width: 56rpx;
height: 56rpx;
display: flex;
align-items: center;
justify-content: flex-end;
}
.dh-close-img {
width: 32rpx;
height: 32rpx;
opacity: 0.75;
}
.section-box {
margin-top: 20rpx;
}
.section-title {
display: block;
font-size: 28rpx;
font-weight: 600;
color: #333333;
margin-bottom: 16rpx;
}
.date-scroll {
width: 100%;
white-space: nowrap;
}
.date-list {
display: inline-flex;
gap: 16rpx;
padding: 4rpx 0;
}
.date-card {
display: inline-flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 136rpx;
height: 124rpx;
border-radius: 12rpx;
background: #F8F9FA;
border: 2rpx solid transparent;
box-sizing: border-box;
transition: all 0.18s ease;
}
.date-card.active {
background: #FFF9F5;
border-color: #F0710D;
}
.dc-tag {
font-size: 26rpx;
font-weight: 600;
color: #333333;
margin-bottom: 4rpx;
}
.date-card.active .dc-tag {
color: #F0710D;
}
.dc-date {
font-size: 24rpx;
color: #888888;
}
.date-card.active .dc-date {
color: #F0710D;
}
.slot-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 16rpx;
}
.slot-card {
height: 84rpx;
border-radius: 12rpx;
background: #F8F9FA;
border: 2rpx solid transparent;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.18s ease;
}
.slot-card.active {
background: #FFF9F5;
border-color: #F0710D;
}
.slot-txt {
font-size: 28rpx;
font-weight: 600;
color: #333333;
}
.slot-card.active .slot-txt {
color: #F0710D;
}
.drawer-foot {
padding-top: 36rpx;
}
.confirm-btn {
height: 88rpx;
background: #F0710D;
border-radius: 12rpx;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.15s ease, transform 0.1s ease;
}
.confirm-btn:active {
background: #E06305;
transform: scale(0.99);
}
.cb-txt {
font-size: 32rpx;
font-weight: 600;
color: #FFFFFF;
letter-spacing: 2rpx;
}
.clickable-hover:active {
opacity: 0.85;
}
</style>