文件
yjyf/yjyf-app/components/AddonServiceDrawer.vue
MiAn fafddceaf2 feat: 新增发票抬头、晒单、钱包日志等模型及后台管理功能
- 新增 invoice_title、showcase、wallet_log 模型及对应语言包
- 新增后台控制器、视图及搜索字段配置
- 修复服务类目删除保护逻辑
- 优化后台登录页面文案及样式
- 新增前端角色切换逻辑及页面拦截
- 新增 SVG 图标及样式变量
- 修复接口权限及下拉框默认值问题
2026-11-11 17:02:35 +08:00

337 行
6.8 KiB
Vue

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

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

<template>
<view class="drawer-mask" v-if="visible" @tap="close">
<view class="drawer-sheet" @tap.stop>
<!-- 标题栏(1:1 复刻视频 00:06 & 00:17:左标题 + 右侧叉 + 底部分割线) -->
<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>
<!-- 增项列表(1:1 复刻视频 00:06 报价模式无价格标签 / 00:17 一口价模式显示 50元/份) -->
<scroll-view class="drawer-body" scroll-y="true">
<view
class="addon-row"
:class="{ active: (item.num || 0) > 0 }"
v-for="(item, idx) in localList"
:key="item.key || idx"
>
<view class="ac-left clickable-hover" @tap="toggleQuickSelect(idx)">
<text class="ac-name">{{ item.name }}</text>
<view class="ac-price-tag" v-if="showPrice && Number(item.price) > 0">
<text class="apt-txt">{{ item.price }}元/{{ item.unit || '份' }}</text>
</view>
</view>
<view class="ac-stepper">
<view
class="step-btn step-btn-minus clickable-hover"
:class="{ disabled: (item.num || 0) <= 0 }"
@tap="stepNum(idx, -1)"
>
<image class="step-ico" src="/static/icons/step-minus.svg" mode="aspectFit" />
</view>
<view class="step-num">{{ item.num || 0 }}</view>
<view
class="step-btn step-btn-plus clickable-hover"
@tap="stepNum(idx, 1)"
>
<image class="step-ico" src="/static/icons/step-plus.svg" mode="aspectFit" />
</view>
</view>
</view>
<view class="empty-tip" v-if="!localList || localList.length === 0">
<text class="empty-txt">暂无可配置的增项服务</text>
</view>
</scroll-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, watch } from 'vue';
const props = defineProps({
visible: { type: Boolean, default: false },
list: { type: Array, default: () => [] },
showPrice: { type: Boolean, default: true }
});
const emit = defineEmits(['update:visible', 'confirm']);
const localList = ref([]);
watch(() => props.visible, (v) => {
if (v) {
localList.value = JSON.parse(JSON.stringify(props.list || []));
}
});
function stepNum(idx, d) {
const target = localList.value[idx];
if (!target) return;
const next = Math.max(0, (target.num || 0) + d);
target.num = next;
}
function toggleQuickSelect(idx) {
const target = localList.value[idx];
if (!target) return;
target.num = (target.num || 0) > 0 ? 0 : 1;
}
function showHelpTip() {
uni.showModal({
title: '增项服务说明',
content: '增项服务列表会根据您所选的具体商品自动匹配对应的拆旧、打孔、加固、配件等附加项目。点击项目名称可快速选中1份,也可通过右侧加减号调整数量。',
showCancel: false,
confirmText: '我知道了',
confirmColor: '#F0710D'
});
}
function close() {
emit('update:visible', false);
}
function handleConfirm() {
emit('confirm', localList.value);
close();
}
</script>
<style scoped>
.drawer-mask {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.55);
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-radius: 28rpx 28rpx 0 0;
padding: 0 0 calc(28rpx + env(safe-area-inset-bottom));
max-height: 75vh;
display: flex;
flex-direction: column;
box-sizing: border-box;
overflow: hidden;
animation: drawerSlideUp 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes drawerSlideUp {
from { transform: translateY(100%); }
to { transform: translateY(0); }
}
.drawer-head {
display: flex;
align-items: center;
justify-content: space-between;
height: 96rpx;
padding: 0 28rpx;
border-bottom: 1rpx solid #F0F0F2;
}
.dh-left {
display: flex;
align-items: center;
gap: 12rpx;
}
.dh-title {
font-size: 32rpx;
font-weight: 500;
color: #1F1F1F;
}
.dh-help {
width: 44rpx;
height: 44rpx;
display: flex;
align-items: center;
justify-content: center;
}
.dh-help-img {
width: 34rpx;
height: 34rpx;
}
.dh-close {
width: 56rpx;
height: 56rpx;
display: flex;
align-items: center;
justify-content: flex-end;
}
.dh-close-img {
width: 34rpx;
height: 34rpx;
opacity: 0.85;
}
.drawer-body {
max-height: 560rpx;
min-height: 360rpx;
padding: 16rpx 36rpx;
box-sizing: border-box;
}
.addon-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 22rpx 0;
border-bottom: 1rpx solid #F7F7F9;
}
.addon-row:last-child {
border-bottom: none;
}
.ac-left {
flex: 1;
padding-right: 20rpx;
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 8rpx;
}
.ac-name {
font-size: 30rpx;
font-weight: 500;
color: #1F1F1F;
transition: color 0.15s;
}
.addon-row.active .ac-name {
color: #F0710D;
}
.ac-price-tag {
background: #F5F5F5;
padding: 4rpx 12rpx;
border-radius: 4rpx;
display: inline-flex;
align-items: center;
justify-content: center;
transition: all 0.15s;
}
.addon-row.active .ac-price-tag {
background: #FFF7F0;
}
.apt-txt {
font-size: 24rpx;
color: #666666;
line-height: 1;
}
.addon-row.active .apt-txt {
color: #F0710D;
}
.ac-stepper {
display: flex;
align-items: center;
border: 1rpx solid #CCCCCC;
border-radius: 4rpx;
background: #FFFFFF;
overflow: hidden;
transition: border-color 0.15s;
}
.addon-row.active .ac-stepper {
border-color: #F0710D;
}
.step-btn {
width: 68rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 34rpx;
color: #333333;
background: #FFFFFF;
user-select: none;
}
.step-btn.disabled {
opacity: 0.38;
}
.step-ico {
width: 24rpx;
height: 24rpx;
}
.step-num {
width: 96rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
color: #1F1F1F;
border-left: 1rpx solid #CCCCCC;
border-right: 1rpx solid #CCCCCC;
background: #FFFFFF;
}
.empty-tip {
padding: 60rpx 0;
text-align: center;
}
.empty-txt {
font-size: 26rpx;
color: #999999;
}
.drawer-foot {
padding: 20rpx 24rpx 0;
}
.confirm-btn {
height: 88rpx;
background: #F0710D;
border-radius: 10rpx;
display: flex;
align-items: center;
justify-content: center;
}
.cb-txt {
font-size: 30rpx;
font-weight: 500;
color: #FFFFFF;
line-height: 1;
}
.clickable-hover:active {
opacity: 0.85;
}
</style>