- 新增师傅端路由和页面配置,切换登录后默认跳转到师傅大厅 - 新增服务分类图标上传功能和增项服务管理模块 - 新增订单、申诉、结算等模型关联关系及后台控制器 - 新增师傅端TabBar组件和消息页面跳转逻辑 - 新增文件上传接口和服务计算逻辑 - 新增各类SVG图标和空状态提示
320 行
12 KiB
Vue
320 行
12 KiB
Vue
<template>
|
||
<view class="page">
|
||
<!-- 顶部状态漏斗看板(对标工奇兵 4 态流转漏斗) -->
|
||
<view class="funnel-card">
|
||
<view class="funnel-row">
|
||
<view class="f-item clickable-hover" :class="{ on: cur === 'active' }" @tap="switchTab('active')">
|
||
<text class="f-num">{{ activeCount }}</text>
|
||
<text class="f-lab">待处理</text>
|
||
<view class="f-line" v-if="cur === 'active'"></view>
|
||
</view>
|
||
<view class="f-divider"></view>
|
||
<view class="f-item clickable-hover" :class="{ on: cur === 'verify' }" @tap="switchTab('verify')">
|
||
<text class="f-num">{{ verifyCount }}</text>
|
||
<text class="f-lab">待验收</text>
|
||
<view class="f-line" v-if="cur === 'verify'"></view>
|
||
</view>
|
||
<view class="f-divider"></view>
|
||
<view class="f-item clickable-hover" :class="{ on: cur === 'completed' }" @tap="switchTab('completed')">
|
||
<text class="f-num">{{ completedCount }}</text>
|
||
<text class="f-lab">已完成</text>
|
||
<view class="f-line" v-if="cur === 'completed'"></view>
|
||
</view>
|
||
<view class="f-divider"></view>
|
||
<view class="f-item clickable-hover" @tap="goQuotes">
|
||
<text class="f-num f-quote">{{ quoteCount }}</text>
|
||
<text class="f-lab">我的报价</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 订单列表 -->
|
||
<view class="list" v-if="list.length">
|
||
<view class="item" v-for="o in list" :key="o.id">
|
||
<view class="hd">
|
||
<text class="svc">{{ o.service_name }}</text>
|
||
<view class="status-badge" :class="'st-' + o.status">
|
||
<text class="status-txt">{{ o.status_text }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="bd">
|
||
<view class="info-line">
|
||
<image class="info-ico" src="/static/icons/master/order-loc.svg" mode="aspectFit" />
|
||
<text class="addr-txt">{{ o.address }}</text>
|
||
</view>
|
||
<view class="info-line">
|
||
<image class="info-ico" src="/static/icons/master/order-time.svg" mode="aspectFit" />
|
||
<text class="meta-txt">预约时间:{{ o.appoint_text }}</text>
|
||
</view>
|
||
<view class="meta-tags">
|
||
<text class="tag">楼层 {{ o.floor }} 层</text>
|
||
<text class="tag">{{ Number(o.has_elevator) ? '有电梯' : '步梯无电梯' }}</text>
|
||
<text class="tag" v-if="o.goods_model">型号:{{ o.goods_model }}</text>
|
||
</view>
|
||
<view class="customer-row">
|
||
<view class="cust-mobile" @tap="call(o)">
|
||
<image class="phone-ico" src="/static/icons/phone.svg" mode="aspectFit" />
|
||
<text class="phone-num">客户:{{ o.mobile }}</text>
|
||
</view>
|
||
<view class="amt-box">
|
||
<text class="amt-symbol">¥</text>
|
||
<text class="amt-val">{{ o.pay_amount }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 操作动作条 -->
|
||
<view class="ops">
|
||
<view class="op clickable-hover" v-if="Number(o.status) === 3 && !o.contact_time" @tap="act('contact', o)">标记已联系</view>
|
||
<view class="op clickable-hover" v-if="Number(o.status) === 3" @tap="act('schedule', o)">约定上门</view>
|
||
<view class="op clickable-hover" v-if="Number(o.status) === 4" @tap="act('arrive', o)">到达打卡</view>
|
||
<view class="op clickable-hover" v-if="Number(o.status) === 5" @tap="act('start', o)">开始服务</view>
|
||
<view class="op primary clickable-hover" v-if="Number(o.status) === 6" @tap="act('finish', o)">完工拍照提交</view>
|
||
<view class="op clickable-hover" v-if="Number(o.status) === 3 || Number(o.status) === 4" @tap="call(o)">联系客户</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 空状态引导 -->
|
||
<view class="empty-state" v-if="!loading && !list.length">
|
||
<image class="empty-img" src="/static/icons/master/empty-orders.svg" mode="aspectFit" />
|
||
<text class="empty-title">当前无{{ curTabText }}工单</text>
|
||
<text class="empty-sub">前往订单大厅,海量订单实时抢</text>
|
||
<view class="empty-cta clickable-hover" @tap="goHall">前往大厅抢单</view>
|
||
</view>
|
||
|
||
<!-- 师傅端专属底部导航 (当前 Tab 1: 订单) -->
|
||
<YjyfMasterTabBar :current="1" />
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, computed } from 'vue';
|
||
import { onShow, onPullDownRefresh } from '@dcloudio/uni-app';
|
||
import api from '@/utils/api.js';
|
||
import { isLogin, toLogin } from '@/utils/request.js';
|
||
import YjyfMasterTabBar from '@/components/YjyfMasterTabBar.vue';
|
||
|
||
const cur = ref('active');
|
||
const list = ref([]);
|
||
const loading = ref(false);
|
||
const activeCount = ref(0);
|
||
const verifyCount = ref(0);
|
||
const completedCount = ref(0);
|
||
const quoteCount = ref(0);
|
||
|
||
const curTabText = computed(() => {
|
||
const m = { active: '待处理', verify: '待验收', completed: '已完成' };
|
||
return m[cur.value] || '';
|
||
});
|
||
|
||
async function loadCounts() {
|
||
try {
|
||
const infoRes = await api.masterInfo();
|
||
if (infoRes && infoRes.master) {
|
||
activeCount.value = infoRes.master.todo_count || 0;
|
||
verifyCount.value = infoRes.master.verify_count || 0;
|
||
}
|
||
const qRes = await api.masterQuotes();
|
||
quoteCount.value = (qRes.list || []).length;
|
||
} catch (e) {}
|
||
}
|
||
|
||
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 || [];
|
||
if (cur.value === 'completed') {
|
||
completedCount.value = (res.list || []).length;
|
||
}
|
||
} catch (e) {
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
}
|
||
|
||
function switchTab(k) {
|
||
cur.value = k;
|
||
load();
|
||
}
|
||
|
||
function goQuotes() {
|
||
uni.navigateTo({ url: '/pages/master/quote' });
|
||
}
|
||
|
||
function call(o) {
|
||
if (!o.mobile) return;
|
||
uni.makePhoneCall({ phoneNumber: String(o.mobile) });
|
||
}
|
||
|
||
function goHall() {
|
||
uni.redirectTo({ url: '/pages/master/hall' });
|
||
}
|
||
|
||
function act(type, o) {
|
||
const id = o.id;
|
||
if (type === 'contact') {
|
||
api.masterContact({ order_id: id }).then(() => {
|
||
uni.showToast({ title: '已记录已联系' });
|
||
load();
|
||
loadCounts();
|
||
}).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.showActionSheet({
|
||
itemList: ['现场拍照', '从手机相册选择'],
|
||
success: (tapRes) => {
|
||
const sourceType = tapRes.tapIndex === 0 ? ['camera'] : ['album'];
|
||
uni.chooseImage({
|
||
count: 1,
|
||
sourceType: sourceType,
|
||
success: async (chooseRes) => {
|
||
const tempFile = chooseRes.tempFilePaths[0];
|
||
uni.showLoading({ title: '上传施工凭证中...' });
|
||
try {
|
||
const uploadData = await api.upload(tempFile);
|
||
const remoteImg = uploadData.fullurl || uploadData.url;
|
||
const res = await api.masterFinish({
|
||
order_id: id,
|
||
'images[0]': remoteImg
|
||
});
|
||
uni.hideLoading();
|
||
uni.showModal({
|
||
title: '已提交完工',
|
||
content: '请将核销验收码【' + res.verify_code + '】告知客户核销确认',
|
||
showCancel: false
|
||
});
|
||
load();
|
||
loadCounts();
|
||
} catch (err) {
|
||
uni.hideLoading();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
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();
|
||
loadCounts();
|
||
});
|
||
|
||
onPullDownRefresh(async () => {
|
||
await Promise.all([load(), loadCounts()]);
|
||
uni.stopPullDownRefresh();
|
||
});
|
||
</script>
|
||
|
||
<style scoped>
|
||
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 30rpx; }
|
||
|
||
/* 顶部工奇兵风格数据漏斗看板 */
|
||
.funnel-card {
|
||
background: #ffffff;
|
||
padding: 24rpx 20rpx 16rpx;
|
||
box-shadow: 0 4rpx 14rpx rgba(0,0,0,0.03);
|
||
position: sticky; top: 0; z-index: 10;
|
||
}
|
||
.funnel-row { display: flex; align-items: center; justify-content: space-around; }
|
||
.f-item {
|
||
flex: 1; display: flex; flex-direction: column; align-items: center;
|
||
position: relative; padding-bottom: 12rpx;
|
||
}
|
||
.f-num { font-size: 38rpx; font-weight: 700; color: #666; line-height: 1.1; }
|
||
.f-quote { color: #7A5AF8; }
|
||
.f-item.on .f-num { color: #F0710D; }
|
||
.f-lab { margin-top: 8rpx; font-size: 22rpx; color: #8E8E93; }
|
||
.f-item.on .f-lab { color: #F0710D; font-weight: 600; }
|
||
.f-line {
|
||
position: absolute; bottom: 0; width: 44rpx; height: 6rpx;
|
||
border-radius: 3rpx; background: #F0710D;
|
||
}
|
||
.f-divider { width: 1rpx; height: 38rpx; background: #EEEEEE; }
|
||
|
||
/* 列表卡片 */
|
||
.list { padding: 20rpx 24rpx; }
|
||
.item {
|
||
background: #fff; border-radius: 20rpx; margin-bottom: 20rpx; padding: 24rpx;
|
||
box-shadow: 0 6rpx 20rpx rgba(240,129,31,0.06);
|
||
}
|
||
.hd { display: flex; align-items: center; justify-content: space-between; padding-bottom: 16rpx; border-bottom: 1rpx solid #F4F4F4; }
|
||
.svc { font-size: 30rpx; font-weight: 700; color: #1F1F1F; }
|
||
.status-badge { padding: 4rpx 16rpx; border-radius: 20rpx; background: #FFF3E6; }
|
||
.status-txt { font-size: 22rpx; font-weight: 600; color: #E36B0C; }
|
||
.status-badge.st-7 { background: #FDEEEB; }
|
||
.status-badge.st-7 .status-txt { color: #E8331B; }
|
||
.status-badge.st-8 { background: #E9F7EE; }
|
||
.status-badge.st-8 .status-txt { color: #2FA84F; }
|
||
|
||
.bd { padding: 18rpx 0; display: flex; flex-direction: column; }
|
||
.info-line { display: flex; align-items: flex-start; margin-bottom: 10rpx; }
|
||
.info-ico { width: 28rpx; height: 28rpx; margin-right: 10rpx; margin-top: 4rpx; flex-shrink: 0; }
|
||
.addr-txt { font-size: 26rpx; color: #222; font-weight: 500; line-height: 36rpx; }
|
||
.meta-txt { font-size: 24rpx; color: #666; line-height: 36rpx; }
|
||
.meta-tags { display: flex; flex-wrap: wrap; margin-top: 6rpx; }
|
||
.tag { padding: 4rpx 14rpx; background: #F5F6F8; color: #777; font-size: 20rpx; border-radius: 8rpx; margin-right: 10rpx; margin-bottom: 6rpx; }
|
||
|
||
.customer-row {
|
||
display: flex; align-items: center; justify-content: space-between;
|
||
margin-top: 14rpx; padding-top: 14rpx; border-top: 1rpx dashed #EEEEEE;
|
||
}
|
||
.cust-mobile { display: flex; align-items: center; }
|
||
.phone-ico { width: 28rpx; height: 28rpx; margin-right: 8rpx; }
|
||
.phone-num { font-size: 24rpx; color: #4A7CFF; font-weight: 500; }
|
||
.amt-box { display: flex; align-items: baseline; }
|
||
.amt-symbol { font-size: 24rpx; font-weight: 700; color: #F0710D; }
|
||
.amt-val { font-size: 34rpx; font-weight: 700; color: #F0710D; line-height: 1; }
|
||
|
||
.ops { display: flex; flex-wrap: wrap; justify-content: flex-end; padding-top: 16rpx; border-top: 1rpx solid #F4F4F4; }
|
||
.op {
|
||
margin: 8rpx 0 0 14rpx; padding: 0 26rpx; height: 60rpx; line-height: 58rpx;
|
||
border-radius: 30rpx; border: 1.5rpx solid #DDD; font-size: 24rpx; color: #555;
|
||
}
|
||
.op.primary {
|
||
border-color: #F0710D; color: #fff;
|
||
background: linear-gradient(135deg,#FFA93F 0%,#F0710D 100%);
|
||
box-shadow: 0 4rpx 14rpx rgba(240,113,13,0.25);
|
||
}
|
||
|
||
/* 空状态 */
|
||
.empty-state { display: flex; flex-direction: column; align-items: center; padding: 120rpx 40rpx 40rpx; }
|
||
.empty-img { width: 180rpx; height: 180rpx; margin-bottom: 24rpx; }
|
||
.empty-title { font-size: 28rpx; font-weight: 600; color: #333; margin-bottom: 8rpx; }
|
||
.empty-sub { font-size: 22rpx; color: #9A9A9A; text-align: center; margin-bottom: 32rpx; }
|
||
.empty-cta {
|
||
padding: 0 48rpx; height: 74rpx; line-height: 74rpx; border-radius: 37rpx;
|
||
background: linear-gradient(135deg,#FFA93F 0%,#F0710D 100%);
|
||
color: #fff; font-size: 26rpx; font-weight: 600;
|
||
box-shadow: 0 6rpx 16rpx rgba(240,113,13,0.25);
|
||
}
|
||
</style>
|