文件
yjyf/yjyf-app/components/LogisticsDrawer.vue

254 行
5.3 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">
<view class="dh-back clickable-hover" @tap="close">
<image class="dh-back-img" src="/static/icons/back-white.svg" mode="aspectFit" />
</view>
<text class="dh-title">选择物流公司</text>
<view class="dh-right-placeholder"></view>
</view>
<!-- 搜索栏 -->
<view class="search-wrap">
<view class="search-box">
<image class="search-ico" src="/static/icons/search-gray.svg" mode="aspectFit" />
<input
class="search-input"
v-model="keyword"
placeholder="搜索"
placeholder-style="color: #999999;"
/>
<view class="clear-btn" v-if="keyword" @tap="keyword = ''">
<image class="clear-ico" src="/static/icons/close.svg" mode="aspectFit" />
</view>
</view>
</view>
<!-- 按首字母分组列表(1:1 复刻图五) -->
<scroll-view class="drawer-body" scroll-y="true">
<template v-if="filteredGroups.length">
<view class="letter-group" v-for="grp in filteredGroups" :key="grp.letter">
<view class="letter-bar">
<text class="letter-txt">{{ grp.letter }}</text>
</view>
<view
class="company-row clickable-hover"
v-for="name in grp.items"
:key="name"
:class="{ active: currentName === name }"
@tap="selectCompany(name)"
>
<text class="cr-name">{{ name }}</text>
<image v-if="currentName === name" class="cr-check" src="/static/icons/check-orange.svg" mode="aspectFit" />
</view>
</view>
</template>
<view class="empty-box" v-else>
<text class="empty-txt">未找到匹配的物流公司</text>
</view>
</scroll-view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
defineProps({
visible: { type: Boolean, default: false },
currentName: { type: String, default: '' }
});
const emit = defineEmits(['update:visible', 'select']);
const keyword = ref('');
// 1:1 对标奇兵到家图五按字母分组列表
const rawGroups = [
{ letter: 'A', items: ['安能物流'] },
{ letter: 'B', items: ['百世快递'] },
{ letter: 'D', items: ['德邦快递'] },
{ letter: 'J', items: ['京东快递', '极兔速递'] },
{ letter: 'K', items: ['跨越速运'] },
{ letter: 'S', items: ['顺丰速运', '申通快递'] },
{ letter: 'T', items: ['天天快递'] },
{ letter: 'Y', items: ['韵达', '圆通速递', '邮政特快专递', '壹米滴答'] },
{ letter: 'Z', items: ['中国邮政', '宅急送', '中通快递'] },
{ letter: 'Q', items: ['其它'] }
];
const filteredGroups = computed(() => {
const kw = keyword.value.trim().toLowerCase();
if (!kw) return rawGroups;
const res = [];
for (const g of rawGroups) {
const hits = g.items.filter(name => name.toLowerCase().includes(kw) || g.letter.toLowerCase() === kw);
if (hits.length) {
res.push({ letter: g.letter, items: hits });
}
}
return res;
});
function selectCompany(name) {
emit('select', name);
close();
}
function close() {
emit('update:visible', false);
}
</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;
}
.drawer-sheet {
background: #F5F6F8;
height: 92vh;
border-top-left-radius: 24rpx;
border-top-right-radius: 24rpx;
overflow: hidden;
display: flex;
flex-direction: column;
}
.drawer-head {
height: 96rpx;
background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24rpx;
flex-shrink: 0;
}
.dh-back {
width: 64rpx;
height: 64rpx;
display: flex;
align-items: center;
}
.dh-back-img {
width: 36rpx;
height: 36rpx;
}
.dh-title {
font-size: 32rpx;
font-weight: 600;
color: #FFFFFF;
}
.dh-right-placeholder {
width: 64rpx;
}
.search-wrap {
padding: 18rpx 24rpx;
background: #F5F6F8;
flex-shrink: 0;
}
.search-box {
height: 72rpx;
background: #FFFFFF;
border-radius: 12rpx;
padding: 0 24rpx;
display: flex;
align-items: center;
}
.search-ico {
width: 30rpx;
height: 30rpx;
margin-right: 14rpx;
opacity: 0.6;
}
.search-input {
flex: 1;
height: 72rpx;
font-size: 28rpx;
color: #1F1F1F;
}
.clear-btn {
padding: 10rpx;
display: flex;
align-items: center;
justify-content: center;
}
.clear-ico {
width: 26rpx;
height: 26rpx;
opacity: 0.5;
}
.drawer-body {
flex: 1;
min-height: 0;
background: #FFFFFF;
}
.letter-bar {
height: 56rpx;
padding: 0 28rpx;
background: #D9D9D9;
display: flex;
align-items: center;
}
.letter-txt {
font-size: 28rpx;
font-weight: 700;
color: #333333;
}
.company-row {
min-height: 96rpx;
padding: 0 28rpx;
background: #FFFFFF;
border-bottom: 1rpx solid #F0F0F2;
display: flex;
align-items: center;
justify-content: space-between;
}
.cr-name {
font-size: 28rpx;
color: #333333;
}
.company-row.active .cr-name {
color: #F0710D;
font-weight: 600;
}
.cr-check {
width: 32rpx;
height: 32rpx;
}
.empty-box {
padding: 80rpx 0;
text-align: center;
}
.empty-txt {
font-size: 26rpx;
color: #888888;
}
</style>