- 新增 invoice_title、showcase、wallet_log 模型及对应语言包 - 新增后台控制器、视图及搜索字段配置 - 修复服务类目删除保护逻辑 - 优化后台登录页面文案及样式 - 新增前端角色切换逻辑及页面拦截 - 新增 SVG 图标及样式变量 - 修复接口权限及下拉框默认值问题
216 行
5.1 KiB
Vue
216 行
5.1 KiB
Vue
<template>
|
|
<view class="page">
|
|
<YjyfNavBar theme="orange" :title="catName || '服务列表'" />
|
|
|
|
<view class="head" v-if="!loading && list.length">
|
|
<text class="cat">{{ catName || '全部服务' }}</text>
|
|
<text class="count">{{ list.length }} 项服务</text>
|
|
</view>
|
|
|
|
<view class="list" v-if="list.length">
|
|
<view class="item clickable-hover" v-for="s in list" :key="s.id" @tap="goDetail(s)">
|
|
<view class="thumb">
|
|
<image class="thumb-img" :src="s.image_url || '/static/icons/service-default.svg'" mode="aspectFill" />
|
|
</view>
|
|
<view class="info">
|
|
<text class="name">{{ s.name }}</text>
|
|
<text class="desc" v-if="s.description || s.price_type_text">{{ s.description || s.price_type_text }}</text>
|
|
<view class="row">
|
|
<text class="price">{{ s.price_text }}</text>
|
|
<text class="sales">已售 {{ s.sales || 0 }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="btn">预约</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="empty-box" v-else-if="!loading">
|
|
<image class="empty-ico" src="/static/icons/empty-service.svg" mode="aspectFit" />
|
|
<text class="empty-title">暂无相关服务项目</text>
|
|
</view>
|
|
|
|
<view class="loading-box" v-if="loading">
|
|
<text>加载中...</text>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref } from 'vue';
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
import api from '@/utils/api.js';
|
|
import { useShare } from '@/utils/share.js';
|
|
|
|
const list = ref([]);
|
|
const catName = ref('');
|
|
const loading = ref(false);
|
|
let catId = 0;
|
|
let keyword = '';
|
|
|
|
useShare(() => {
|
|
const firstImg = list.value && list.value.length && list.value[0].image_url && !list.value[0].image_url.endsWith('.svg')
|
|
? list.value[0].image_url
|
|
: '';
|
|
const queryObj = {};
|
|
if (catId) queryObj.cat_id = catId;
|
|
if (catName.value) queryObj.cat_name = catName.value;
|
|
if (keyword) queryObj.keyword = keyword;
|
|
const queryStr = Object.keys(queryObj).map(k => `${k}=${encodeURIComponent(queryObj[k])}`).join('&');
|
|
return {
|
|
title: catName.value ? `优匠优服 · ${catName.value}` : '优匠优服 · 服务列表',
|
|
path: queryStr ? `/pages/service/list?${queryStr}` : '/pages/service/list',
|
|
query: queryObj,
|
|
imageUrl: firstImg
|
|
};
|
|
});
|
|
|
|
function goDetail(s) {
|
|
uni.navigateTo({ url: '/pages/service/detail?id=' + s.id });
|
|
}
|
|
|
|
async function load() {
|
|
loading.value = true;
|
|
try {
|
|
const params = { cat_id: catId };
|
|
if (keyword) params.keyword = keyword;
|
|
const res = await api.services(params);
|
|
list.value = res.list || [];
|
|
} catch (e) {
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
|
|
onLoad((options) => {
|
|
catId = Number((options && options.cat_id) || 0);
|
|
keyword = options && options.keyword ? decodeURIComponent(options.keyword) : '';
|
|
catName.value = options && options.cat_name
|
|
? decodeURIComponent(options.cat_name)
|
|
: (keyword ? '搜索:' + keyword : '');
|
|
load();
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import '@/uni.scss';
|
|
.page {
|
|
min-height: 100vh;
|
|
background: $yjyf-bg-page;
|
|
padding-bottom: 48rpx;
|
|
}
|
|
.head {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: $yjyf-space-md $yjyf-space-md $yjyf-space-sm;
|
|
}
|
|
.cat {
|
|
font-size: $yjyf-font-title;
|
|
font-weight: 700;
|
|
color: $yjyf-text-main;
|
|
}
|
|
.count {
|
|
font-size: $yjyf-font-sub;
|
|
color: $yjyf-text-secondary;
|
|
}
|
|
.list {
|
|
padding: 0 $yjyf-space-md;
|
|
}
|
|
.item {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: $yjyf-space-md;
|
|
background: $yjyf-bg-card;
|
|
border-radius: $yjyf-radius-md;
|
|
margin-bottom: $yjyf-space-sm;
|
|
box-shadow: $yjyf-shadow-card;
|
|
}
|
|
.thumb {
|
|
width: 112rpx;
|
|
height: 112rpx;
|
|
border-radius: $yjyf-radius-sm;
|
|
flex-shrink: 0;
|
|
background: $yjyf-primary-bg;
|
|
overflow: hidden;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.thumb-img {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
.info {
|
|
flex: 1;
|
|
min-width: 0;
|
|
margin-left: 20rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.name {
|
|
font-size: 30rpx;
|
|
font-weight: 700;
|
|
color: $yjyf-text-main;
|
|
}
|
|
.desc {
|
|
margin-top: 8rpx;
|
|
font-size: $yjyf-font-sub;
|
|
color: $yjyf-text-secondary;
|
|
overflow: hidden;
|
|
white-space: nowrap;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.row {
|
|
display: flex;
|
|
align-items: baseline;
|
|
margin-top: 12rpx;
|
|
}
|
|
.price {
|
|
font-size: 30rpx;
|
|
font-weight: 700;
|
|
color: $yjyf-primary;
|
|
}
|
|
.sales {
|
|
margin-left: $yjyf-space-sm;
|
|
font-size: $yjyf-font-micro;
|
|
color: $yjyf-text-secondary;
|
|
}
|
|
.btn {
|
|
flex-shrink: 0;
|
|
margin-left: 12rpx;
|
|
padding: 0 28rpx;
|
|
height: 60rpx;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
line-height: 1;
|
|
border-radius: $yjyf-radius-pill;
|
|
color: $yjyf-text-inverse;
|
|
font-size: $yjyf-font-sub;
|
|
font-weight: 600;
|
|
background: $yjyf-gradient-primary;
|
|
}
|
|
|
|
.empty-box {
|
|
padding: 160rpx 40rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
}
|
|
.empty-ico {
|
|
width: 160rpx;
|
|
height: 160rpx;
|
|
margin-bottom: $yjyf-space-md;
|
|
}
|
|
.empty-title {
|
|
font-size: $yjyf-font-body;
|
|
color: $yjyf-text-secondary;
|
|
}
|
|
.loading-box {
|
|
padding: 100rpx 0;
|
|
text-align: center;
|
|
font-size: $yjyf-font-sub;
|
|
color: $yjyf-text-secondary;
|
|
}
|
|
</style>
|