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

263 行
5.4 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<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="drawer-body">
<view
class="type-card clickable-hover"
v-for="item in displayList"
:key="item.code"
:class="{ active: selectedCode === item.code }"
@tap="selectItem(item)"
>
<view class="tc-left">
<view class="tc-icon-wrap">
<image class="tc-icon" :src="getServiceIcon(item.code)" mode="aspectFit" />
</view>
<text class="tc-name">{{ item.name }}</text>
</view>
<view class="tc-radio" :class="{ on: selectedCode === item.code }">
<image class="check-icon" v-if="selectedCode === item.code" src="/static/icons/check-white.svg" mode="aspectFit" />
</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 },
list: { type: Array, default: () => [] },
currentCode: { type: String, default: 'install' }
});
const emit = defineEmits(['update:visible', 'confirm']);
const defaultTypes = [
{ code: 'install', name: '安装', price: 60, unit: '件' },
{ code: 'repair', name: '维修', price: 40, unit: '次' },
{ code: 'remove', name: '拆旧', price: 30, unit: '件' }
];
const displayList = computed(() => {
return props.list && props.list.length ? props.list : defaultTypes;
});
const selectedCode = ref(props.currentCode);
watch(() => props.currentCode, (v) => {
selectedCode.value = v;
});
watch(() => props.visible, (v) => {
if (v) selectedCode.value = props.currentCode;
});
function getServiceIcon(code) {
if (code === 'repair') return '/static/icons/scene-repair.svg';
if (code === 'remove' || code === 'tear') return '/static/icons/scene-tear.svg';
return '/static/icons/scene-install.svg';
}
function selectItem(item) {
selectedCode.value = item.code;
}
function close() {
emit('update:visible', false);
}
function handleConfirm() {
const hit = displayList.value.find(item => item.code === selectedCode.value) || displayList.value[0];
emit('confirm', hit);
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;
}
.drawer-body {
padding: 10rpx 0;
display: flex;
flex-direction: column;
gap: 16rpx;
}
.type-card {
display: flex;
align-items: center;
justify-content: space-between;
height: 110rpx;
padding: 0 28rpx;
border-radius: 16rpx;
background: #F8F9FA;
border: 2rpx solid transparent;
transition: all 0.18s ease;
}
.type-card.active {
background: #FFF9F5;
border-color: #F0710D;
}
.tc-left {
display: flex;
align-items: center;
gap: 20rpx;
}
.tc-icon-wrap {
width: 56rpx;
height: 56rpx;
border-radius: 12rpx;
background: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
}
.tc-icon {
width: 36rpx;
height: 36rpx;
}
.tc-name {
font-size: 30rpx;
font-weight: 600;
color: #222222;
}
.type-card.active .tc-name {
color: #F0710D;
}
.tc-radio {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
border: 2rpx solid #D1D5DB;
display: flex;
align-items: center;
justify-content: center;
background: #FFFFFF;
transition: all 0.18s ease;
}
.tc-radio.on {
background: #F0710D;
border-color: #F0710D;
}
.check-icon {
width: 24rpx;
height: 24rpx;
}
.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>