前端: - utils/request.js 统一请求层(token/错误码/401 引导登录) - utils/api.js 接口清单(与后端控制器一一对应) - pages/login 登录(手机号+验证码+角色选择) - pages/service/list|detail 服务列表/详情 - pages/order/create 下单(地址/预约/急单/费用试算/自动支付) - pages/order/list|detail|review 订单列表/详情轨迹/评价 - pages/master/apply|hall|orders 师傅入驻/订单大厅/接单履约 - YJYF/YJYF 首页接 home/index 真实类目 + 路由跳转 后端 Bug 修复(严重): - TP5 中 count() 会重置查询条件,导致 Order::index / Master::hall / Master::orders 在 select 时丢失 where 条件 → 泄漏全部用户订单/跨用户数据 - 改为闭包重建查询,已验证修复
100 行
3.3 KiB
Vue
100 行
3.3 KiB
Vue
<template>
|
|
<view class="page">
|
|
<view class="head">
|
|
<text class="cat">{{ catName || '全部服务' }}</text>
|
|
<text class="count">{{ list.length }} 项可预约</text>
|
|
</view>
|
|
|
|
<view class="list">
|
|
<view class="item" v-for="s in list" :key="s.id" @tap="goDetail(s)">
|
|
<view class="thumb"><text class="thumb-txt">{{ s.name.slice(0, 2) }}</text></view>
|
|
<view class="info">
|
|
<text class="name">{{ s.name }}</text>
|
|
<text class="desc">{{ s.description || '专业师傅上门服务,验收满意再付款' }}</text>
|
|
<view class="row">
|
|
<text class="price">{{ s.price_text }}</text>
|
|
<text class="sales">已售 {{ s.sales }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="btn">下单</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="empty" v-if="!loading && !list.length">
|
|
<text>该类目暂无服务</text>
|
|
</view>
|
|
<view class="loading" 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';
|
|
|
|
const list = ref([]);
|
|
const catName = ref('');
|
|
const loading = ref(false);
|
|
let catId = 0;
|
|
let keyword = '';
|
|
|
|
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 || [];
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
|
|
onLoad((options) => {
|
|
catId = Number(options.cat_id || 0);
|
|
keyword = options.keyword ? decodeURIComponent(options.keyword) : '';
|
|
catName.value = options.cat_name
|
|
? decodeURIComponent(options.cat_name)
|
|
: (keyword ? '搜索:' + keyword : '');
|
|
load();
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 40rpx; }
|
|
.head {
|
|
display: flex; align-items: baseline; justify-content: space-between;
|
|
padding: 26rpx 28rpx 18rpx;
|
|
}
|
|
.cat { font-size: 34rpx; font-weight: 700; color: #1F1F1F; }
|
|
.count { font-size: 22rpx; color: #9A9A9A; }
|
|
.list { padding: 0 28rpx; }
|
|
.item {
|
|
display: flex; align-items: center; padding: 24rpx;
|
|
background: #fff; border-radius: 20rpx; margin-bottom: 20rpx;
|
|
box-shadow: 0 6rpx 20rpx rgba(240,129,31,0.06);
|
|
}
|
|
.thumb {
|
|
width: 108rpx; height: 108rpx; border-radius: 16rpx; flex-shrink: 0;
|
|
background: linear-gradient(160deg, #FFF7F0 0%, #FCE9D6 100%);
|
|
display: flex; align-items: center; justify-content: center;
|
|
}
|
|
.thumb-txt { font-size: 30rpx; font-weight: 700; color: #B85E2A; }
|
|
.info { flex: 1; min-width: 0; margin-left: 20rpx; display: flex; flex-direction: column; }
|
|
.name { font-size: 30rpx; font-weight: 600; color: #1F1F1F; }
|
|
.desc { margin-top: 6rpx; font-size: 22rpx; color: #9A9A9A; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
.row { display: flex; align-items: baseline; margin-top: 10rpx; }
|
|
.price { font-size: 30rpx; font-weight: 700; color: #F0710D; }
|
|
.sales { margin-left: 14rpx; font-size: 20rpx; color: #B5B5B5; }
|
|
.btn {
|
|
flex-shrink: 0; margin-left: 12rpx; padding: 0 24rpx; line-height: 56rpx;
|
|
border-radius: 28rpx; color: #fff; font-size: 24rpx;
|
|
background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%);
|
|
}
|
|
.empty, .loading { padding: 80rpx 0; text-align: center; font-size: 24rpx; color: #9A9A9A; }
|
|
</style>
|