1027 行
24 KiB
Vue
1027 行
24 KiB
Vue
<template>
|
||
<view class="page">
|
||
<YjyfNavBar theme="orange" title="常用商品模板" />
|
||
|
||
<!-- 将当前编辑中的商品组保存为常用模板 -->
|
||
<view class="save-banner-wrap" v-if="canSaveCurrent">
|
||
<view class="save-current-card">
|
||
<view class="scc-top">
|
||
<image class="scc-ico" src="/static/icons/template-save.svg" mode="aspectFit" />
|
||
<text class="scc-label">将当前第 {{ groupIndex + 1 }} 组存为模板:{{ currentSummary }}</text>
|
||
</view>
|
||
<view class="scc-form-row">
|
||
<view class="scc-input-box">
|
||
<input
|
||
class="scc-input"
|
||
v-model="customTplName"
|
||
maxlength="40"
|
||
placeholder="模板名称(选填,默认使用商品规格名)"
|
||
confirm-type="done"
|
||
@confirm="handleSaveCurrent"
|
||
/>
|
||
<view class="scc-clear clickable-hover" v-if="customTplName" @tap="customTplName = ''">
|
||
<image class="scc-clear-ico" src="/static/icons/close.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
<view
|
||
class="scc-save-btn clickable-hover"
|
||
:class="{ disabled: saving }"
|
||
@tap="handleSaveCurrent"
|
||
>
|
||
<text class="scc-save-txt">{{ saving ? '保存中...' : '存为模板' }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 顶部搜索与多类目快捷筛选栏(存在已保存模板时展示) -->
|
||
<view class="filter-header" v-if="list.length > 0">
|
||
<view class="search-bar-row">
|
||
<view class="search-box">
|
||
<image class="search-ico" src="/static/icons/search-gray.svg" mode="aspectFit" />
|
||
<input
|
||
class="search-input"
|
||
v-model="keyword"
|
||
placeholder="搜索模板名称、商品或规格"
|
||
confirm-type="search"
|
||
/>
|
||
<view class="clear-btn clickable-hover" v-if="keyword" @tap="keyword = ''">
|
||
<image class="clear-ico" src="/static/icons/close.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
<text class="count-tag">共 {{ filteredList.length }} 个</text>
|
||
</view>
|
||
|
||
<!-- 类目胶囊筛选(当已保存模板跨多个类目时自动呈现) -->
|
||
<scroll-view
|
||
class="cat-scroll"
|
||
scroll-x="true"
|
||
:show-scrollbar="false"
|
||
v-if="availableCats.length > 1"
|
||
>
|
||
<view class="cat-track">
|
||
<view
|
||
class="cat-chip clickable-hover"
|
||
:class="{ active: activeFilterCatId === 0 }"
|
||
@tap="activeFilterCatId = 0"
|
||
>
|
||
<text class="cat-chip-txt">全部 ({{ list.length }})</text>
|
||
</view>
|
||
<view
|
||
class="cat-chip clickable-hover"
|
||
v-for="cat in availableCats"
|
||
:key="cat.id"
|
||
:class="{ active: Number(activeFilterCatId) === Number(cat.id) }"
|
||
@tap="activeFilterCatId = Number(cat.id)"
|
||
>
|
||
<text class="cat-chip-txt">{{ cat.name }} ({{ cat.count }})</text>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
|
||
<!-- 主体滚动区 -->
|
||
<scroll-view class="body-scroll" scroll-y="true">
|
||
<!-- 1. 1:1 等高骨架屏加载态 -->
|
||
<view class="tpl-list" v-if="loading && list.length === 0">
|
||
<view class="tpl-skeleton-card" v-for="n in 4" :key="'sk-tpl-' + n">
|
||
<view class="sk-thumb shimmer"></view>
|
||
<view class="sk-main">
|
||
<view class="sk-line sk-title shimmer"></view>
|
||
<view class="sk-line sk-spec shimmer"></view>
|
||
<view class="sk-line sk-srv shimmer"></view>
|
||
<view class="sk-foot">
|
||
<view class="sk-price shimmer"></view>
|
||
<view class="sk-btn shimmer"></view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 2. 网络或接口异常重试态 -->
|
||
<view class="state-box" v-else-if="loadError && list.length === 0">
|
||
<image class="empty-img" src="/static/icons/empty-template.svg" mode="aspectFit" />
|
||
<text class="empty-title">{{ loadError }}</text>
|
||
<view class="ghost-action-btn clickable-hover" @tap="fetchTemplates">
|
||
<text class="ghost-action-txt">重新加载</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 3. 尚未保存任何模板空状态 -->
|
||
<view class="state-box" v-else-if="list.length === 0">
|
||
<image class="empty-img" src="/static/icons/empty-template.svg" mode="aspectFit" />
|
||
<text class="empty-title">暂无已保存的商品模板</text>
|
||
<text class="empty-sub">选好商品规格与服务项目后可存为常用模板</text>
|
||
<view class="ghost-action-btn clickable-hover" @tap="handleBackToOrder">
|
||
<text class="ghost-action-txt">返回添加商品</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 4. 搜索或类目筛选无匹配结果 -->
|
||
<view class="state-box" v-else-if="filteredList.length === 0">
|
||
<image class="empty-img" src="/static/icons/empty-template.svg" mode="aspectFit" />
|
||
<text class="empty-title">未找到匹配的模板</text>
|
||
<view class="ghost-action-btn clickable-hover" @tap="resetFilter">
|
||
<text class="ghost-action-txt">清空筛选条件</text>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 5. 真实商品模板卡片列表 -->
|
||
<view class="tpl-list" v-else>
|
||
<view
|
||
class="tpl-card"
|
||
:class="{ 'is-just-saved': lastSavedId === tpl.id }"
|
||
v-for="(tpl, idx) in filteredList"
|
||
:key="tpl.id"
|
||
:style="{ animationDelay: Math.min(idx, 6) * 28 + 'ms' }"
|
||
>
|
||
<view class="tpl-thumb-wrap" @tap.stop="previewTplImages(tpl)">
|
||
<image
|
||
class="tpl-thumb"
|
||
:src="tpl.cover_image || tpl.cat_icon_url || '/static/icons/service-default.svg'"
|
||
mode="aspectFill"
|
||
lazy-load
|
||
/>
|
||
<view class="tpl-img-count" v-if="tpl.images && tpl.images.length > 1">
|
||
<text class="tpl-img-count-txt">{{ tpl.images.length }}张</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="tpl-main">
|
||
<view class="tpl-title-row">
|
||
<view class="tpl-title-left">
|
||
<text class="tpl-name">{{ tpl.tpl_name }}</text>
|
||
<text class="tpl-cur-badge" v-if="tpl.is_current_cat">当前类目</text>
|
||
</view>
|
||
<view
|
||
class="tpl-del-btn clickable-hover"
|
||
@tap.stop="handleDelete(tpl)"
|
||
>
|
||
<image class="tpl-del-ico" src="/static/icons/trash.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
|
||
<text class="tpl-spec">
|
||
{{ tpl.cat_name ? tpl.cat_name + ' · ' : '' }}{{ tpl.item_name }}{{ tpl.spec_name && tpl.spec_name !== tpl.item_name ? `(${tpl.spec_name})` : '' }} x{{ tpl.num }}{{ tpl.unit || '个' }}
|
||
</text>
|
||
|
||
<text class="tpl-service">{{ formatTplService(tpl) }}</text>
|
||
|
||
<view class="tpl-foot">
|
||
<view class="tpl-price-wrap">
|
||
<text class="tpl-price" v-if="tpl.price_type !== 'quote' && Number(tpl.base_price) > 0">¥{{ Number(tpl.base_price).toFixed(2) }}<text class="tpl-price-unit">/{{ tpl.unit || '个' }}</text></text>
|
||
<text class="tpl-quote-tag" v-else>师傅报价项目</text>
|
||
</view>
|
||
<view
|
||
class="tpl-apply-btn clickable-hover"
|
||
:class="{ disabled: applying }"
|
||
@tap="applyTemplate(tpl)"
|
||
>
|
||
<text class="tpl-apply-txt">一键套用</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="list-bottom-space"></view>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, computed } from 'vue';
|
||
import { onLoad } from '@dcloudio/uni-app';
|
||
import api from '@/utils/api.js';
|
||
import { isLogin, toLogin } from '@/utils/request.js';
|
||
|
||
// 来自下单页面的上下文状态
|
||
const preferCatId = ref(0);
|
||
const preferCatName = ref('');
|
||
const groupIndex = ref(0);
|
||
const currentGroup = ref(null);
|
||
|
||
// 列表与筛选状态
|
||
const list = ref([]);
|
||
const keyword = ref('');
|
||
const activeFilterCatId = ref(0);
|
||
const loading = ref(true);
|
||
const loadError = ref('');
|
||
|
||
// 操作锁定状态
|
||
const customTplName = ref('');
|
||
const saving = ref(false);
|
||
const lastSavedId = ref(0);
|
||
const deletingId = ref(0);
|
||
const applying = ref(false);
|
||
|
||
const canSaveCurrent = computed(() => {
|
||
const g = currentGroup.value;
|
||
if (!g) return false;
|
||
const name = (g.is_custom ? g.custom_name : g.item_name) || '';
|
||
return String(name).trim().length > 0;
|
||
});
|
||
|
||
const currentSummary = computed(() => {
|
||
const g = currentGroup.value;
|
||
if (!g) return '';
|
||
const baseName = (g.is_custom ? g.custom_name : g.item_name) || '';
|
||
const specPart = (g.spec_name && g.spec_name !== baseName) ? `(${g.spec_name})` : '';
|
||
return `${baseName}${specPart} x${g.num || 1}`;
|
||
});
|
||
|
||
// 从真实已保存模板中聚合类目筛选胶囊
|
||
const availableCats = computed(() => {
|
||
const map = new Map();
|
||
(list.value || []).forEach((tpl) => {
|
||
const cid = Number(tpl.cat_id) || 0;
|
||
const cname = String(tpl.cat_name || '').trim();
|
||
if (cid > 0 && cname) {
|
||
if (!map.has(cid)) {
|
||
map.set(cid, {
|
||
id: cid,
|
||
name: cname,
|
||
count: 0,
|
||
isCurrent: preferCatId.value > 0 && cid === Number(preferCatId.value)
|
||
});
|
||
}
|
||
map.get(cid).count += 1;
|
||
}
|
||
});
|
||
const arr = Array.from(map.values());
|
||
arr.sort((a, b) => {
|
||
if (a.isCurrent !== b.isCurrent) return a.isCurrent ? -1 : 1;
|
||
return b.count - a.count;
|
||
});
|
||
return arr;
|
||
});
|
||
|
||
const filteredList = computed(() => {
|
||
const cid = Number(activeFilterCatId.value) || 0;
|
||
const kw = keyword.value.trim().toLowerCase();
|
||
return (list.value || []).filter((tpl) => {
|
||
if (cid > 0 && Number(tpl.cat_id) !== cid) return false;
|
||
if (!kw) return true;
|
||
const hay = [
|
||
tpl.tpl_name,
|
||
tpl.cat_name,
|
||
tpl.item_name,
|
||
tpl.spec_name,
|
||
tpl.service_type_name,
|
||
tpl.remark
|
||
].filter(Boolean).join(' ').toLowerCase();
|
||
return hay.includes(kw);
|
||
});
|
||
});
|
||
|
||
function formatTplService(tpl) {
|
||
const parts = [tpl.service_type_name || '安装'];
|
||
if (Array.isArray(tpl.extras)) {
|
||
tpl.extras.filter(ex => Number(ex.num) > 0).forEach(ex => {
|
||
parts.push(`${ex.name}x${ex.num}`);
|
||
});
|
||
}
|
||
if (tpl.remark) {
|
||
parts.push(`备注:${tpl.remark}`);
|
||
}
|
||
return parts.join(' · ');
|
||
}
|
||
|
||
function resetFilter() {
|
||
keyword.value = '';
|
||
activeFilterCatId.value = 0;
|
||
}
|
||
|
||
async function fetchTemplates() {
|
||
if (!isLogin()) {
|
||
toLogin();
|
||
return;
|
||
}
|
||
loading.value = true;
|
||
loadError.value = '';
|
||
try {
|
||
const res = await api.goodsTemplates({ cat_id: preferCatId.value || 0 });
|
||
list.value = (res && Array.isArray(res.list)) ? res.list : [];
|
||
// 若当前选中的类目已无模板,自动退回“全部”
|
||
if (activeFilterCatId.value > 0 && !list.value.some(x => Number(x.cat_id) === Number(activeFilterCatId.value))) {
|
||
activeFilterCatId.value = 0;
|
||
}
|
||
} catch (e) {
|
||
loadError.value = (e && e.msg) ? e.msg : '获取商品模板失败';
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
}
|
||
|
||
async function handleSaveCurrent() {
|
||
if (!canSaveCurrent.value || saving.value) return;
|
||
const g = currentGroup.value;
|
||
const itemName = String((g.is_custom ? g.custom_name : g.item_name) || '').trim();
|
||
if (!itemName) {
|
||
uni.showToast({ title: '请先选择商品', icon: 'none' });
|
||
return;
|
||
}
|
||
saving.value = true;
|
||
try {
|
||
const saved = await api.saveGoodsTemplate({
|
||
tpl_name: customTplName.value.trim(),
|
||
cat_id: g.cat_id || preferCatId.value || 0,
|
||
cat_name: g.cat_name || preferCatName.value || '',
|
||
service_id: g.service_id || 0,
|
||
item_name: itemName,
|
||
spec_id: g.spec_id || 0,
|
||
spec_name: g.spec_name || '',
|
||
unit: g.unit || '个',
|
||
num: g.num || 1,
|
||
service_type: g.service_type || 'install',
|
||
service_type_name: g.service_type_name || '安装',
|
||
is_custom: g.is_custom ? 1 : 0,
|
||
custom_name: g.custom_name || '',
|
||
extras: JSON.stringify(g.extras || []),
|
||
images: JSON.stringify(g.images || []),
|
||
remark: g.remark || ''
|
||
});
|
||
customTplName.value = '';
|
||
if (saved && saved.id) {
|
||
lastSavedId.value = Number(saved.id);
|
||
}
|
||
uni.showToast({ title: '已保存为常用模板', icon: 'success' });
|
||
await fetchTemplates();
|
||
} catch (e) {
|
||
uni.showToast({ title: (e && e.msg) ? e.msg : '保存模板失败', icon: 'none' });
|
||
} finally {
|
||
saving.value = false;
|
||
}
|
||
}
|
||
|
||
function handleDelete(tpl) {
|
||
if (!tpl || deletingId.value) return;
|
||
uni.showModal({
|
||
title: '删除商品模板',
|
||
content: `确认删除模板“${tpl.tpl_name}”吗?`,
|
||
confirmColor: '#E8331B',
|
||
success: async (r) => {
|
||
if (!r.confirm || deletingId.value) return;
|
||
deletingId.value = tpl.id;
|
||
try {
|
||
await api.deleteGoodsTemplate({ id: tpl.id });
|
||
list.value = list.value.filter(x => x.id !== tpl.id);
|
||
if (activeFilterCatId.value > 0 && !list.value.some(x => Number(x.cat_id) === Number(activeFilterCatId.value))) {
|
||
activeFilterCatId.value = 0;
|
||
}
|
||
uni.showToast({ title: '已删除', icon: 'none' });
|
||
} catch (e) {
|
||
uni.showToast({ title: (e && e.msg) ? e.msg : '删除模板失败', icon: 'none' });
|
||
} finally {
|
||
deletingId.value = 0;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
function previewTplImages(tpl) {
|
||
if (!tpl) return;
|
||
const urls = (Array.isArray(tpl.images) && tpl.images.length > 0)
|
||
? tpl.images
|
||
: (tpl.cover_image ? [tpl.cover_image] : []);
|
||
if (!urls.length) return;
|
||
uni.previewImage({
|
||
current: urls[0],
|
||
urls
|
||
});
|
||
}
|
||
|
||
function applyTemplate(tpl) {
|
||
if (!tpl || applying.value) return;
|
||
applying.value = true;
|
||
const payload = {
|
||
groupIndex: groupIndex.value,
|
||
template: JSON.parse(JSON.stringify(tpl))
|
||
};
|
||
uni.setStorageSync('yjyf_picked_goods_template', payload);
|
||
uni.$emit('yjyf:applyGoodsTemplate', payload);
|
||
uni.navigateBack({
|
||
fail: () => {
|
||
applying.value = false;
|
||
uni.redirectTo({ url: '/pages/order/quick' });
|
||
}
|
||
});
|
||
}
|
||
|
||
function handleBackToOrder() {
|
||
let pages = [];
|
||
try {
|
||
pages = getCurrentPages() || [];
|
||
} catch (e) {}
|
||
if (pages.length > 1) {
|
||
uni.navigateBack();
|
||
} else {
|
||
uni.redirectTo({ url: '/pages/order/quick' });
|
||
}
|
||
}
|
||
|
||
onLoad((options) => {
|
||
const urlCatId = options && options.cat_id ? Number(options.cat_id) : 0;
|
||
const urlGroupIdx = options && options.group_index !== undefined ? Number(options.group_index) : 0;
|
||
preferCatId.value = urlCatId;
|
||
groupIndex.value = Math.max(0, urlGroupIdx || 0);
|
||
|
||
const ctx = uni.getStorageSync('yjyf_goods_template_ctx');
|
||
if (ctx && typeof ctx === 'object') {
|
||
uni.removeStorageSync('yjyf_goods_template_ctx');
|
||
if (typeof ctx.groupIndex === 'number') {
|
||
groupIndex.value = ctx.groupIndex;
|
||
}
|
||
if (ctx.catId && !preferCatId.value) {
|
||
preferCatId.value = Number(ctx.catId) || 0;
|
||
}
|
||
if (ctx.catName) {
|
||
preferCatName.value = String(ctx.catName);
|
||
}
|
||
if (ctx.currentGroup && typeof ctx.currentGroup === 'object') {
|
||
currentGroup.value = ctx.currentGroup;
|
||
}
|
||
}
|
||
|
||
fetchTemplates();
|
||
});
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.page {
|
||
height: 100vh;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow: hidden;
|
||
background-color: $yjyf-bg-page;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
/* ---------- 快捷保存当前商品组面板 ---------- */
|
||
.save-banner-wrap {
|
||
flex-shrink: 0;
|
||
padding: $yjyf-space-md $yjyf-space-md $yjyf-space-xs;
|
||
}
|
||
|
||
.save-current-card {
|
||
padding: $yjyf-space-md;
|
||
border-radius: $yjyf-radius-md;
|
||
background: linear-gradient(135deg, $yjyf-bg-card 0%, $yjyf-primary-bg 100%);
|
||
border: 1rpx solid $yjyf-primary-border;
|
||
box-shadow: $yjyf-shadow-card;
|
||
}
|
||
|
||
.scc-top {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12rpx;
|
||
margin-bottom: $yjyf-space-sm;
|
||
}
|
||
|
||
.scc-ico {
|
||
width: 34rpx;
|
||
height: 34rpx;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.scc-label {
|
||
flex: 1;
|
||
font-size: 26rpx;
|
||
font-weight: 700;
|
||
color: $yjyf-text-main;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
.scc-form-row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: $yjyf-space-sm;
|
||
}
|
||
|
||
.scc-input-box {
|
||
flex: 1;
|
||
height: 72rpx;
|
||
padding: 0 16rpx 0 20rpx;
|
||
border-radius: $yjyf-radius-sm;
|
||
background-color: $yjyf-bg-card;
|
||
border: 1rpx solid $yjyf-border-color;
|
||
display: flex;
|
||
align-items: center;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.scc-input {
|
||
flex: 1;
|
||
height: 100%;
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-main;
|
||
}
|
||
|
||
.scc-clear {
|
||
width: 40rpx;
|
||
height: 40rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.scc-clear-ico {
|
||
width: 22rpx;
|
||
height: 22rpx;
|
||
opacity: 0.55;
|
||
}
|
||
|
||
.scc-save-btn {
|
||
height: 72rpx;
|
||
padding: 0 28rpx;
|
||
border-radius: $yjyf-radius-sm;
|
||
background: $yjyf-gradient-primary;
|
||
box-shadow: 0 4rpx 12rpx rgba(240, 113, 13, 0.24);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.scc-save-btn.disabled {
|
||
opacity: 0.6;
|
||
pointer-events: none;
|
||
}
|
||
|
||
.scc-save-txt {
|
||
font-size: 26rpx;
|
||
font-weight: 700;
|
||
color: $yjyf-text-inverse;
|
||
}
|
||
|
||
/* ---------- 搜索与类目筛选头 ---------- */
|
||
.filter-header {
|
||
flex-shrink: 0;
|
||
padding: $yjyf-space-sm $yjyf-space-md 12rpx;
|
||
}
|
||
|
||
.search-bar-row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: $yjyf-space-sm;
|
||
}
|
||
|
||
.search-box {
|
||
flex: 1;
|
||
height: 68rpx;
|
||
border-radius: $yjyf-radius-pill;
|
||
background-color: $yjyf-bg-card;
|
||
border: 1rpx solid $yjyf-border-color;
|
||
padding: 0 $yjyf-space-md;
|
||
display: flex;
|
||
align-items: center;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.search-ico {
|
||
width: 30rpx;
|
||
height: 30rpx;
|
||
margin-right: 12rpx;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.search-input {
|
||
flex: 1;
|
||
font-size: 26rpx;
|
||
color: $yjyf-text-main;
|
||
}
|
||
|
||
.clear-btn {
|
||
width: 44rpx;
|
||
height: 44rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.clear-ico {
|
||
width: 22rpx;
|
||
height: 22rpx;
|
||
opacity: 0.6;
|
||
}
|
||
|
||
.count-tag {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-secondary;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.cat-scroll {
|
||
width: 100%;
|
||
white-space: nowrap;
|
||
margin-top: $yjyf-space-sm;
|
||
}
|
||
|
||
.cat-track {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: $yjyf-space-sm;
|
||
padding-right: $yjyf-space-sm;
|
||
}
|
||
|
||
.cat-chip {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
height: 54rpx;
|
||
padding: 0 24rpx;
|
||
border-radius: $yjyf-radius-pill;
|
||
background-color: $yjyf-bg-card;
|
||
border: 1rpx solid $yjyf-border-color;
|
||
transition: background-color 0.18s ease, border-color 0.18s ease;
|
||
}
|
||
|
||
.cat-chip.active {
|
||
background-color: $yjyf-primary-bg;
|
||
border-color: $yjyf-primary;
|
||
}
|
||
|
||
.cat-chip-txt {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-regular;
|
||
line-height: 1;
|
||
}
|
||
|
||
.cat-chip.active .cat-chip-txt {
|
||
color: $yjyf-primary;
|
||
font-weight: 600;
|
||
}
|
||
|
||
/* ---------- 主体滚动容器 ---------- */
|
||
.body-scroll {
|
||
flex: 1;
|
||
height: 0;
|
||
width: 100%;
|
||
}
|
||
|
||
/* ---------- 1:1 等高骨架屏与 GPU 流光动画 ---------- */
|
||
.tpl-skeleton-card {
|
||
display: flex;
|
||
gap: 20rpx;
|
||
padding: $yjyf-space-md;
|
||
border-radius: $yjyf-radius-md;
|
||
background-color: $yjyf-bg-card;
|
||
border: 1rpx solid $yjyf-border-color;
|
||
}
|
||
|
||
.sk-thumb {
|
||
width: 148rpx;
|
||
height: 148rpx;
|
||
border-radius: $yjyf-radius-sm;
|
||
background-color: $yjyf-border-color;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.sk-main {
|
||
flex: 1;
|
||
min-width: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.sk-line {
|
||
border-radius: 8rpx;
|
||
background-color: $yjyf-border-color;
|
||
}
|
||
|
||
.sk-title {
|
||
width: 68%;
|
||
height: 30rpx;
|
||
}
|
||
|
||
.sk-spec {
|
||
width: 84%;
|
||
height: 24rpx;
|
||
}
|
||
|
||
.sk-srv {
|
||
width: 56%;
|
||
height: 22rpx;
|
||
}
|
||
|
||
.sk-foot {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
margin-top: 8rpx;
|
||
}
|
||
|
||
.sk-price {
|
||
width: 112rpx;
|
||
height: 32rpx;
|
||
border-radius: 8rpx;
|
||
background-color: rgba(240, 113, 13, 0.12);
|
||
}
|
||
|
||
.sk-btn {
|
||
width: 136rpx;
|
||
height: 56rpx;
|
||
border-radius: $yjyf-radius-pill;
|
||
background-color: $yjyf-primary-bg;
|
||
}
|
||
|
||
.shimmer {
|
||
position: relative;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.shimmer::after {
|
||
content: '';
|
||
position: absolute;
|
||
top: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
left: 0;
|
||
transform: translate3d(-100%, 0, 0);
|
||
background: linear-gradient(
|
||
105deg,
|
||
rgba(255, 255, 255, 0) 20%,
|
||
rgba(255, 255, 255, 0.68) 50%,
|
||
rgba(255, 255, 255, 0) 80%
|
||
);
|
||
animation: tplShimmer 1.35s cubic-bezier(0.4, 0, 0.2, 1) infinite;
|
||
pointer-events: none;
|
||
}
|
||
|
||
@keyframes tplShimmer {
|
||
100% {
|
||
transform: translate3d(100%, 0, 0);
|
||
}
|
||
}
|
||
|
||
/* ---------- 空状态与错误重试状态 ---------- */
|
||
.state-box {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 112rpx $yjyf-space-xl;
|
||
text-align: center;
|
||
}
|
||
|
||
.empty-img {
|
||
width: 220rpx;
|
||
height: 176rpx;
|
||
margin-bottom: $yjyf-space-sm;
|
||
}
|
||
|
||
.empty-title {
|
||
font-size: 30rpx;
|
||
font-weight: 700;
|
||
color: $yjyf-text-main;
|
||
margin-bottom: $yjyf-space-xs;
|
||
}
|
||
|
||
.empty-sub {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-secondary;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
.ghost-action-btn {
|
||
margin-top: $yjyf-space-lg;
|
||
height: 68rpx;
|
||
padding: 0 40rpx;
|
||
border-radius: $yjyf-radius-pill;
|
||
background-color: $yjyf-primary-bg;
|
||
border: 1rpx solid $yjyf-primary;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.ghost-action-txt {
|
||
font-size: 26rpx;
|
||
font-weight: 600;
|
||
color: $yjyf-primary;
|
||
}
|
||
|
||
/* ---------- 商品模板卡片列表 ---------- */
|
||
.tpl-list {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 20rpx;
|
||
padding: $yjyf-space-sm $yjyf-space-md;
|
||
}
|
||
|
||
.tpl-card {
|
||
display: flex;
|
||
gap: 20rpx;
|
||
padding: $yjyf-space-md;
|
||
border-radius: $yjyf-radius-md;
|
||
background-color: $yjyf-bg-card;
|
||
border: 1rpx solid $yjyf-border-color;
|
||
box-shadow: 0 4rpx 16rpx rgba(31, 31, 31, 0.04);
|
||
animation: tplCardRise 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
||
}
|
||
|
||
.tpl-card.is-just-saved {
|
||
border-color: $yjyf-primary-border;
|
||
box-shadow: $yjyf-shadow-card;
|
||
}
|
||
|
||
@keyframes tplCardRise {
|
||
from {
|
||
opacity: 0;
|
||
transform: translate3d(0, 14rpx, 0);
|
||
}
|
||
to {
|
||
opacity: 1;
|
||
transform: translate3d(0, 0, 0);
|
||
}
|
||
}
|
||
|
||
.tpl-thumb-wrap {
|
||
position: relative;
|
||
width: 148rpx;
|
||
height: 148rpx;
|
||
border-radius: $yjyf-radius-sm;
|
||
background-color: $yjyf-bg-page;
|
||
overflow: hidden;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.tpl-thumb {
|
||
width: 100%;
|
||
height: 100%;
|
||
display: block;
|
||
}
|
||
|
||
.tpl-img-count {
|
||
position: absolute;
|
||
right: 8rpx;
|
||
bottom: 8rpx;
|
||
padding: 2rpx 10rpx;
|
||
border-radius: $yjyf-radius-pill;
|
||
background: rgba(0, 0, 0, 0.52);
|
||
display: inline-flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.tpl-img-count-txt {
|
||
font-size: $yjyf-font-micro;
|
||
color: $yjyf-text-inverse;
|
||
line-height: 1.2;
|
||
}
|
||
|
||
.tpl-main {
|
||
flex: 1;
|
||
min-width: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.tpl-title-row {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12rpx;
|
||
}
|
||
|
||
.tpl-title-left {
|
||
flex: 1;
|
||
min-width: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12rpx;
|
||
}
|
||
|
||
.tpl-name {
|
||
font-size: 30rpx;
|
||
font-weight: 700;
|
||
color: $yjyf-text-main;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
.tpl-cur-badge {
|
||
flex-shrink: 0;
|
||
padding: 2rpx 12rpx;
|
||
border-radius: 8rpx;
|
||
background-color: $yjyf-primary-bg;
|
||
color: $yjyf-primary;
|
||
font-size: $yjyf-font-micro;
|
||
font-weight: 600;
|
||
line-height: 1.35;
|
||
}
|
||
|
||
.tpl-del-btn {
|
||
width: 48rpx;
|
||
height: 48rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: flex-end;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.tpl-del-ico {
|
||
width: 30rpx;
|
||
height: 30rpx;
|
||
opacity: 0.68;
|
||
}
|
||
|
||
.tpl-spec {
|
||
margin-top: 8rpx;
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-regular;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
.tpl-service {
|
||
margin-top: 6rpx;
|
||
font-size: $yjyf-font-micro;
|
||
color: $yjyf-text-secondary;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
.tpl-foot {
|
||
margin-top: 16rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.tpl-price-wrap {
|
||
display: flex;
|
||
align-items: baseline;
|
||
}
|
||
|
||
.tpl-price {
|
||
font-size: $yjyf-font-title;
|
||
font-weight: 800;
|
||
color: $yjyf-primary;
|
||
}
|
||
|
||
.tpl-price-unit {
|
||
font-size: $yjyf-font-micro;
|
||
font-weight: 500;
|
||
color: $yjyf-text-secondary;
|
||
margin-left: 2rpx;
|
||
}
|
||
|
||
.tpl-quote-tag {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-warning;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.tpl-apply-btn {
|
||
height: 58rpx;
|
||
padding: 0 28rpx;
|
||
border-radius: $yjyf-radius-pill;
|
||
background: $yjyf-gradient-primary;
|
||
box-shadow: 0 4rpx 12rpx rgba(240, 113, 13, 0.22);
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.tpl-apply-btn.disabled {
|
||
opacity: 0.6;
|
||
pointer-events: none;
|
||
}
|
||
|
||
.tpl-apply-txt {
|
||
font-size: $yjyf-font-sub;
|
||
font-weight: 700;
|
||
color: $yjyf-text-inverse;
|
||
line-height: 1;
|
||
}
|
||
|
||
.list-bottom-space {
|
||
height: calc(32rpx + env(safe-area-inset-bottom));
|
||
}
|
||
|
||
.clickable-hover {
|
||
transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.16s ease;
|
||
}
|
||
|
||
.clickable-hover:active {
|
||
opacity: 0.85;
|
||
transform: scale(0.98);
|
||
}
|
||
|
||
@media (prefers-reduced-motion: reduce) {
|
||
.tpl-card,
|
||
.shimmer::after {
|
||
animation: none !important;
|
||
}
|
||
}
|
||
</style>
|