文件
yjyf/pages/master/hall.vue
linda e1bf139c5a feat(order): 下单支持一口价/师傅报价竞价/用户自主定价三种方式
- 下单页新增计价方式选择;自主定价填写总价,师傅报价单进入报价大厅
- 用户订单详情展示师傅报价列表并可选定师傅;选定后同步师傅、金额与订单状态
- 师傅大厅新增用户定价筛选与按价接单;报价单禁止直接抢单
- 后端订单新增 custom 价态、金额口径统一由 calcAmount 输出
- 报价中状态纳入用户可取消范围;超时回流重新开放报价
- 新增 fa_order.price_type custom 枚举迁移脚本(schema_phase6)
2026-10-28 17:48:23 +08:00

176 行
7.6 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<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="filters">
<view class="ftabs">
<view v-for="t in typeTabs" :key="t.key" class="ftab" :class="{ on: type === t.key }" @tap="type = t.key">{{ t.name }}</view>
</view>
<view class="sorts">
<view v-for="s in sortTabs" :key="s.key" class="sort" :class="{ on: sort === s.key }" @tap="sort = s.key">{{ s.name }}</view>
</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="tag-mode quote" v-if="o.price_type === 'quote'">师傅报价</text>
<text class="tag-mode custom" v-if="o.price_type === 'custom'">用户定价</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.left_seconds > 0 ? ('剩余 ' + countdown(o.left_seconds)) : '即将关闭' }}</text>
<view class="ft-btns">
<view class="quote-btn" v-if="o.price_type === 'quote'" @tap="goQuote(o)">我要报价({{ o.quote_count }})</view>
<view class="grab" v-else @tap="grab(o)">{{ o.price_type === 'custom' ? '按此价接单' : '立即抢单' }}</view>
</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, watch } 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);
const type = ref('all');
const sort = ref('new');
const typeTabs = [
{ key: 'all', name: '全部订单' },
{ key: 'fixed', name: '一口价' },
{ key: 'quote', name: '报价订单' },
{ key: 'custom', name: '用户定价' }
];
const sortTabs = [
{ key: 'new', name: '最新' },
{ key: 'amount', name: '报酬高' },
{ key: 'urgent', name: '急单优先' },
{ key: 'time', name: '时效近' }
];
watch([type, sort], () => load());
function countdown(sec) {
const s = Number(sec) || 0;
if (s <= 0) return '已结束';
const m = Math.floor(s / 60);
return m >= 60 ? (Math.floor(m / 60) + '小时' + (m % 60) + '分') : (m + '分');
}
function goQuote(o) {
uni.navigateTo({ url: '/pages/master/quote?order_id=' + o.id });
}
async function load() {
if (!isLogin()) { toLogin(); return; }
loading.value = true;
try {
const res = await api.masterHall({ limit: 20, type: type.value, sort: sort.value });
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; }
.tag-mode { padding: 0 12rpx; line-height: 34rpx; border-radius: 8rpx; font-size: 20rpx; margin-right: 10rpx; }
.tag-mode.quote { background: #F0EDFF; color: #5B3FD8; }
.tag-mode.custom { background: #E9F7EE; color: #2FA84F; }
.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; }
.filters { padding: 20rpx 28rpx 0; }
.ftabs { display: flex; }
.ftab { padding: 0 26rpx; line-height: 64rpx; margin-right: 14rpx; border-radius: 32rpx; background: #fff; font-size: 24rpx; color: #666; }
.ftab.on { background: linear-gradient(135deg,#FFA93F 0%,#F0710D 100%); color: #fff; font-weight: 600; }
.sorts { display: flex; padding: 16rpx 0 4rpx; }
.sort { padding: 0 20rpx; line-height: 52rpx; margin-right: 12rpx; border-radius: 26rpx; background: #fff; font-size: 22rpx; color: #9A9A9A; }
.sort.on { background: #FFF3E6; color: #E36B0C; font-weight: 600; }
.ft-btns { display: flex; align-items: center; }
.quote-btn { padding: 0 30rpx; line-height: 68rpx; border-radius: 34rpx; color: #fff; font-size: 26rpx; font-weight: 600; background: linear-gradient(135deg,#7A5AF8 0%,#5B3FD8 100%); box-shadow: 0 6rpx 16rpx rgba(122,90,248,.28); }
.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>