前端: - 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 条件 → 泄漏全部用户订单/跨用户数据 - 改为闭包重建查询,已验证修复
120 行
4.9 KiB
Vue
120 行
4.9 KiB
Vue
<template>
|
||
<view class="page">
|
||
<view class="top">
|
||
<view class="top-l">
|
||
<text class="top-t">订单大厅</text>
|
||
<text class="top-s">{{ info ? '评分 ' + info.score + ' · 完成 ' + info.order_count + ' 单' : '加载中' }}</text>
|
||
</view>
|
||
<view class="switch" :class="{ off: info && info.work_status === 'off' }" @tap="toggleWork">
|
||
<text class="switch-t">{{ info && info.work_status === 'off' ? '已暂停接单' : '接单中' }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="list">
|
||
<view class="item" v-for="o in list" :key="o.id">
|
||
<view class="hd">
|
||
<text class="tag-urgent" v-if="Number(o.urgent)">急单</text>
|
||
<text class="svc">{{ o.service_name }}</text>
|
||
<text class="amt">¥{{ o.pay_amount }}</text>
|
||
</view>
|
||
<view class="bd">
|
||
<text class="addr">{{ o.address }}</text>
|
||
<text class="meta">楼层 {{ o.floor }} 层 · {{ Number(o.has_elevator) ? '有电梯' : '无电梯' }} · 预约 {{ o.appoint_text }}</text>
|
||
<text class="meta" v-if="o.goods_model">型号:{{ o.goods_model }}</text>
|
||
<text class="meta" v-if="o.remark">备注:{{ o.remark }}</text>
|
||
</view>
|
||
<view class="ft">
|
||
<text class="phone">{{ o.mobile }}</text>
|
||
<view class="grab" @tap="grab(o)">立即抢单</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="empty" v-if="!loading && !list.length"><text>暂无待接订单,稍后刷新试试</text></view>
|
||
<view class="refresh" @tap="load">刷新大厅</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref } from 'vue';
|
||
import { onShow } from '@dcloudio/uni-app';
|
||
import api from '@/utils/api.js';
|
||
import { isLogin, toLogin } from '@/utils/request.js';
|
||
|
||
const list = ref([]);
|
||
const info = ref(null);
|
||
const loading = ref(false);
|
||
|
||
async function load() {
|
||
if (!isLogin()) { toLogin(); return; }
|
||
loading.value = true;
|
||
try {
|
||
const res = await api.masterHall({ limit: 20 });
|
||
list.value = res.list || [];
|
||
} catch (e) {
|
||
}
|
||
try {
|
||
const me = await api.masterInfo();
|
||
info.value = me.applied ? me.master : null;
|
||
} catch (e) {}
|
||
loading.value = false;
|
||
}
|
||
|
||
async function toggleWork() {
|
||
if (!info.value) return;
|
||
const next = info.value.work_status === 'off' ? 'on' : 'off';
|
||
try {
|
||
await api.masterToggle({ work_status: next });
|
||
info.value.work_status = next;
|
||
uni.showToast({ title: next === 'on' ? '已开启接单' : '已暂停接单', icon: 'none' });
|
||
} catch (e) {}
|
||
}
|
||
|
||
function grab(o) {
|
||
uni.showModal({
|
||
title: '确认抢单',
|
||
content: '抢单后需在 2 小时内联系客户,否则订单将自动回流大厅',
|
||
success: async (r) => {
|
||
if (!r.confirm) return;
|
||
try {
|
||
await api.masterGrab({ order_id: o.id });
|
||
uni.showToast({ title: '抢单成功' });
|
||
setTimeout(() => uni.navigateTo({ url: '/pages/master/orders' }), 600);
|
||
} catch (e) {}
|
||
}
|
||
});
|
||
}
|
||
|
||
onShow(() => load());
|
||
</script>
|
||
|
||
<style scoped>
|
||
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 60rpx; }
|
||
.top {
|
||
display: flex; align-items: center; justify-content: space-between;
|
||
padding: 34rpx 30rpx;
|
||
background: linear-gradient(160deg, #FFB85C 0%, #F98D25 60%, #ED6F0E 100%);
|
||
}
|
||
.top-l { display: flex; flex-direction: column; }
|
||
.top-t { font-size: 38rpx; font-weight: 700; color: #fff; }
|
||
.top-s { margin-top: 8rpx; font-size: 22rpx; color: rgba(255,255,255,0.9); }
|
||
.switch { padding: 0 26rpx; line-height: 60rpx; border-radius: 30rpx; background: #fff; }
|
||
.switch.off { background: rgba(255,255,255,0.35); }
|
||
.switch-t { font-size: 24rpx; font-weight: 600; color: #E36B0C; }
|
||
.switch.off .switch-t { color: #fff; }
|
||
.list { padding: 22rpx 28rpx 0; }
|
||
.item { background: #fff; border-radius: 20rpx; margin-bottom: 20rpx; padding: 22rpx 24rpx; box-shadow: 0 6rpx 20rpx rgba(240,129,31,0.06); }
|
||
.hd { display: flex; align-items: center; padding-bottom: 14rpx; border-bottom: 1rpx solid #F4F4F4; }
|
||
.tag-urgent { padding: 0 12rpx; line-height: 34rpx; border-radius: 8rpx; background: #FDEEEB; color: #E8331B; font-size: 20rpx; margin-right: 10rpx; }
|
||
.svc { flex: 1; font-size: 30rpx; font-weight: 700; color: #1F1F1F; }
|
||
.amt { font-size: 32rpx; font-weight: 700; color: #F0710D; }
|
||
.bd { display: flex; flex-direction: column; padding: 16rpx 0; }
|
||
.addr { font-size: 26rpx; color: #333; line-height: 36rpx; }
|
||
.meta { margin-top: 6rpx; font-size: 22rpx; color: #9A9A9A; }
|
||
.ft { display: flex; align-items: center; justify-content: space-between; padding-top: 14rpx; border-top: 1rpx solid #F4F4F4; }
|
||
.phone { font-size: 24rpx; color: #666; }
|
||
.grab { padding: 0 34rpx; line-height: 68rpx; border-radius: 34rpx; color: #fff; font-size: 26rpx; font-weight: 600; background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%); box-shadow: 0 6rpx 16rpx rgba(240,113,13,0.28); }
|
||
.empty { padding: 90rpx 0 30rpx; text-align: center; font-size: 24rpx; color: #9A9A9A; }
|
||
.refresh { margin: 10rpx 28rpx; height: 84rpx; display: flex; align-items: center; justify-content: center; border-radius: 42rpx; background: #fff; color: #F0710D; font-size: 26rpx; font-weight: 600; }
|
||
</style>
|