前端: - 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 条件 → 泄漏全部用户订单/跨用户数据 - 改为闭包重建查询,已验证修复
131 行
5.5 KiB
Vue
131 行
5.5 KiB
Vue
<template>
|
|
<view class="page">
|
|
<view class="tabs">
|
|
<view v-for="t in tabs" :key="t.key" class="tab" :class="{ on: cur === t.key }" @tap="switchTab(t.key)">
|
|
<text class="tab-txt">{{ t.name }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="list">
|
|
<view class="item" v-for="o in list" :key="o.id">
|
|
<view class="hd">
|
|
<text class="svc">{{ o.service_name }}</text>
|
|
<text class="status" :class="'s' + o.status">{{ o.status_text }}</text>
|
|
</view>
|
|
<view class="bd">
|
|
<text class="addr">{{ o.address }}</text>
|
|
<text class="meta">预约 {{ o.appoint_text }} · 楼层 {{ o.floor }} 层 · {{ Number(o.has_elevator) ? '有电梯' : '无电梯' }}</text>
|
|
<view class="row">
|
|
<text class="phone">客户 {{ o.mobile }}</text>
|
|
<text class="amt">¥{{ o.pay_amount }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="ops">
|
|
<view class="op" v-if="Number(o.status) === 3 && !o.contact_time" @tap="act('contact', o)">标记已联系</view>
|
|
<view class="op" v-if="Number(o.status) === 3" @tap="act('schedule', o)">约定上门</view>
|
|
<view class="op" v-if="Number(o.status) === 4" @tap="act('arrive', o)">到达打卡</view>
|
|
<view class="op" v-if="Number(o.status) === 5" @tap="act('start', o)">开始服务</view>
|
|
<view class="op primary" v-if="Number(o.status) === 6" @tap="act('finish', o)">完工提交</view>
|
|
<view class="op" v-if="Number(o.status) === 3 || Number(o.status) === 4" @tap="call(o)">打电话</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="empty" v-if="!loading && !list.length"><text>暂无订单</text></view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref } from 'vue';
|
|
import { onShow, onPullDownRefresh } from '@dcloudio/uni-app';
|
|
import api from '@/utils/api.js';
|
|
import { isLogin, toLogin } from '@/utils/request.js';
|
|
|
|
const tabs = [
|
|
{ key: 'active', name: '待处理' },
|
|
{ key: 'verify', name: '待验收' },
|
|
{ key: 'completed', name: '已完成' }
|
|
];
|
|
const cur = ref('active');
|
|
const list = ref([]);
|
|
const loading = ref(false);
|
|
|
|
async function load() {
|
|
if (!isLogin()) { toLogin(); return; }
|
|
loading.value = true;
|
|
try {
|
|
const res = await api.masterOrders({ status: cur.value, limit: 20 });
|
|
list.value = res.list || [];
|
|
} catch (e) {
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
|
|
function switchTab(k) { cur.value = k; load(); }
|
|
function call(o) { uni.makePhoneCall({ phoneNumber: o.mobile }); }
|
|
|
|
function act(type, o) {
|
|
const id = o.id;
|
|
if (type === 'contact') {
|
|
api.masterContact({ order_id: id }).then(() => { uni.showToast({ title: '已记录联系' }); load(); }).catch(() => {});
|
|
return;
|
|
}
|
|
if (type === 'arrive') {
|
|
api.masterArrive({ order_id: id }).then(() => { uni.showToast({ title: '已到达' }); load(); }).catch(() => {});
|
|
return;
|
|
}
|
|
if (type === 'start') {
|
|
api.masterStart({ order_id: id }).then(() => { uni.showToast({ title: '已开工' }); load(); }).catch(() => {});
|
|
return;
|
|
}
|
|
if (type === 'finish') {
|
|
uni.showModal({
|
|
title: '确认完工',
|
|
content: '提交后进入待验收,需上传现场照片(联调使用示例图)',
|
|
success: (r) => {
|
|
if (!r.confirm) return;
|
|
api.masterFinish({ order_id: id, 'images[0]': 'https://yjyf.gzyakj.com.cn/uploads/sample-finish.jpg' })
|
|
.then((res) => {
|
|
uni.showModal({ title: '已提交完工', content: '验收码:' + res.verify_code + '(告知客户)', showCancel: false });
|
|
load();
|
|
}).catch(() => {});
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
if (type === 'schedule') {
|
|
const ts = Math.floor(Date.now() / 1000) + 7200;
|
|
api.masterSchedule({ order_id: id, appoint_time: ts }).then(() => { uni.showToast({ title: '已约定 2 小时后上门' }); load(); }).catch(() => {});
|
|
}
|
|
}
|
|
|
|
onShow(() => load());
|
|
onPullDownRefresh(() => { load().then(() => uni.stopPullDownRefresh()); });
|
|
</script>
|
|
|
|
<style scoped>
|
|
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 60rpx; }
|
|
.tabs { display: flex; background: #fff; box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.03); }
|
|
.tab { flex: 1; text-align: center; padding: 26rpx 0; }
|
|
.tab-txt { font-size: 28rpx; color: #666; }
|
|
.tab.on .tab-txt { color: #F0710D; font-weight: 700; }
|
|
.list { padding: 22rpx 28rpx; }
|
|
.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; justify-content: space-between; padding-bottom: 14rpx; border-bottom: 1rpx solid #F4F4F4; }
|
|
.svc { font-size: 30rpx; font-weight: 700; color: #1F1F1F; }
|
|
.status { font-size: 24rpx; font-weight: 600; color: #F0710D; }
|
|
.status.s7 { color: #E8331B; }
|
|
.status.s8 { color: #2FA84F; }
|
|
.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; }
|
|
.row { display: flex; align-items: center; justify-content: space-between; margin-top: 10rpx; }
|
|
.phone { font-size: 24rpx; color: #666; }
|
|
.amt { font-size: 32rpx; font-weight: 700; color: #F0710D; }
|
|
.ops { display: flex; flex-wrap: wrap; justify-content: flex-end; padding-top: 14rpx; border-top: 1rpx solid #F4F4F4; }
|
|
.op { margin: 8rpx 0 0 14rpx; padding: 0 24rpx; line-height: 62rpx; border-radius: 31rpx; border: 2rpx solid #DDD; font-size: 24rpx; color: #666; }
|
|
.op.primary { border-color: #F0710D; color: #fff; background: linear-gradient(135deg,#FFA93F 0%,#F0710D 100%); }
|
|
.empty { padding: 120rpx 0; text-align: center; font-size: 24rpx; color: #9A9A9A; }
|
|
</style>
|