feat(order): 下单支持一口价/师傅报价竞价/用户自主定价三种方式

- 下单页新增计价方式选择;自主定价填写总价,师傅报价单进入报价大厅
- 用户订单详情展示师傅报价列表并可选定师傅;选定后同步师傅、金额与订单状态
- 师傅大厅新增用户定价筛选与按价接单;报价单禁止直接抢单
- 后端订单新增 custom 价态、金额口径统一由 calcAmount 输出
- 报价中状态纳入用户可取消范围;超时回流重新开放报价
- 新增 fa_order.price_type custom 枚举迁移脚本(schema_phase6)
这个提交包含在:
linda
2026-10-28 17:48:23 +08:00
父节点 3bba2d6e94
当前提交 e1bf139c5a
共有 11 个文件被更改,包括 500 次插入 和 50 次删除

查看文件

@@ -23,6 +23,8 @@
<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>
@@ -36,7 +38,7 @@
<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)">立即抢单</view>
<view class="grab" v-else @tap="grab(o)">{{ o.price_type === 'custom' ? '按此价接单' : '立即抢单' }}</view>
</view>
</view>
</view>
@@ -64,7 +66,8 @@
const typeTabs = [
{ key: 'all', name: '全部订单' },
{ key: 'fixed', name: '一口价' },
{ key: 'quote', name: '报价订单' }
{ key: 'quote', name: '报价订单' },
{ key: 'custom', name: '用户定价' }
];
const sortTabs = [
{ key: 'new', name: '最新' },
@@ -147,6 +150,9 @@
.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; }

查看文件

@@ -6,11 +6,38 @@
<text class="svc-name">{{ svc ? svc.name : '' }}</text>
<text class="svc-price">{{ svc ? svc.price_text : '' }}</text>
</view>
<view class="urgent" :class="{ on: urgent }" @tap="urgent = !urgent">
<view class="urgent" :class="{ on: urgent }" v-if="priceType !== 'custom'" @tap="urgent = !urgent">
<text class="urgent-txt">{{ urgent ? '已加急 +20%' : '加急' }}</text>
</view>
</view>
<!-- 计价方式:一口价 / 师傅报价竞价 / 用户自主定价 -->
<view class="sec">
<view class="sec-title">选择下单方式</view>
<view class="modes">
<view
v-for="m in modes"
:key="m.key"
class="mode"
:class="{ on: priceType === m.key }"
@tap="selectMode(m.key)"
>
<text class="mode-name">{{ m.name }}</text>
<text class="mode-desc">{{ m.desc }}</text>
<view class="mode-check" v-if="priceType === m.key">✓</view>
</view>
</view>
<view class="mode-note">{{ modeNote }}</view>
<view class="fi" v-if="priceType === 'custom'">
<text class="fk">我的出价</text>
<view class="price-input-wrap">
<text class="price-unit">¥</text>
<input class="fv price-input" v-model="userPrice" type="digit" placeholder="请输入您愿意支付的总价" />
</view>
</view>
</view>
<view class="sec">
<view class="sec-title">服务地址</view>
<view class="addr" v-if="address">
@@ -61,22 +88,42 @@
</view>
<view class="sec" v-if="amount">
<view class="sec-title">费用明细</view>
<view class="li"><text class="k">基础价</text><text class="v">¥{{ amount.base_amount }}</text></view>
<view class="li"><text class="k">楼层费</text><text class="v">¥{{ amount.floor_amount }}</text></view>
<view class="li" v-if="amount.urgent_amount > 0"><text class="k">加急费</text><text class="v">¥{{ amount.urgent_amount }}</text></view>
<view class="li total"><text class="k">应付合计</text><text class="v big">¥{{ amount.pay_amount }}</text></view>
<view class="sec-title">{{ priceType === 'quote' ? '费用预估' : '费用明细' }}</view>
<view class="li">
<text class="k">{{ priceType === 'custom' ? '您的出价' : '基础价' }}</text>
<text class="v">¥{{ amount.base_amount }}</text>
</view>
<view class="li" v-if="priceType !== 'custom'">
<text class="k">楼层费</text>
<text class="v">¥{{ amount.floor_amount }}</text>
</view>
<view class="li" v-if="priceType !== 'custom' && amount.urgent_amount > 0">
<text class="k">加急费</text>
<text class="v">¥{{ amount.urgent_amount }}</text>
</view>
<view class="li" v-if="amount.discount_amount > 0">
<text class="k">优惠券抵扣</text>
<text class="v">-¥{{ amount.discount_amount }}</text>
</view>
<view class="li total">
<text class="k">{{ priceType === 'quote' ? '参考合计' : '应付合计' }}</text>
<text class="v big">¥{{ amount.pay_amount }}</text>
</view>
<text class="fee-note" v-if="priceType === 'quote'">先支付参考价,选定师傅报价后按最终报价结算</text>
<text class="fee-note" v-if="priceType === 'custom'">自主定价为含楼层/加急的总价,师傅接单即按此价服务</text>
</view>
<view class="bar">
<view class="bar-l"><text class="bar-k">合计</text><text class="bar-p">¥{{ amount ? amount.pay_amount : 0 }}</text></view>
<view class="bar-btn" :class="{ disabled: submitting }" @tap="submit">{{ submitting ? '提交中...' : '提交并支付' }}</view>
<view class="bar-l"><text class="bar-k">{{ priceType === 'quote' ? '参考价' : '合计' }}</text><text class="bar-p">¥{{ amount ? amount.pay_amount : 0 }}</text></view>
<view class="bar-btn" :class="{ disabled: submitting }" @tap="submit">
{{ submitting ? '提交中...' : (priceType === 'quote' ? '发布需求' : '提交并支付') }}
</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive, watch } from 'vue';
import { ref, reactive, watch, computed } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import api from '@/utils/api.js';
import { isLogin, toLogin } from '@/utils/request.js';
@@ -88,6 +135,21 @@
const urgent = ref(false);
const submitting = ref(false);
/** 三种下单方式:一口价 / 师傅报价竞价 / 用户自主定价 */
const modes = [
{ key: 'fixed', name: '一口价', desc: '平台明码标价' },
{ key: 'quote', name: '师傅报价', desc: '师傅竞价,您来选' },
{ key: 'custom', name: '自主定价', desc: '您出价,师傅接单' }
];
const priceType = ref('fixed');
const userPrice = ref('');
const modeNote = computed(() => {
if (priceType.value === 'quote') return '发布后进入报价大厅,师傅提交报价,您对比价格与评分后选择';
if (priceType.value === 'custom') return '填写您愿意支付的总价(含楼层等),师傅认可即可接单';
return '按平台标准价结算,支付后师傅先到先得';
});
const now = new Date();
const pad = (n) => (n < 10 ? '0' + n : '' + n);
const today = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
@@ -100,19 +162,43 @@
});
let serviceId = 0;
let calcTimer = null;
async function calc() {
if (!serviceId) return;
const custom = priceType.value === 'custom';
if (custom && (!userPrice.value || Number(userPrice.value) <= 0)) {
amount.value = null;
return;
}
const floor = address.value ? address.value.floor : form.floor;
const elev = address.value ? address.value.has_elevator : form.has_elevator;
try {
amount.value = await api.calc({
service_id: serviceId, floor: floor, has_elevator: elev, urgent: urgent.value ? 1 : 0
service_id: serviceId,
floor: floor,
has_elevator: elev,
urgent: urgent.value ? 1 : 0,
price_type: priceType.value,
user_price: custom ? Number(userPrice.value) : 0
});
} catch (e) {}
}
watch([urgent, () => form.floor, () => form.has_elevator], () => calc());
function scheduleCalc() {
clearTimeout(calcTimer);
calcTimer = setTimeout(calc, 300);
}
function selectMode(key) {
if (priceType.value === key) return;
priceType.value = key;
amount.value = null;
calc();
}
watch([urgent, () => form.floor, () => form.has_elevator, priceType], scheduleCalc);
watch(userPrice, scheduleCalc);
function onDate(e) { date.value = e.detail.value; }
function onTime(e) { time.value = e.detail.value; }
@@ -168,6 +254,10 @@
if (submitting.value) return;
if (!isLogin()) { toLogin(); return; }
if (!address.value) { uni.showToast({ title: '请先保存服务地址', icon: 'none' }); return; }
if (priceType.value === 'custom' && (!userPrice.value || Number(userPrice.value) <= 0)) {
uni.showToast({ title: '请填写您的出价', icon: 'none' });
return;
}
submitting.value = true;
try {
const appoint = Math.floor(new Date(date.value.replace(/-/g, '/') + ' ' + time.value + ':00').getTime() / 1000);
@@ -175,13 +265,16 @@
service_id: serviceId,
address_id: address.value.id,
appoint_time: appoint,
urgent: urgent.value ? 1 : 0,
urgent: priceType.value === 'custom' ? 0 : (urgent.value ? 1 : 0),
goods_model: form.goods_model,
goods_num: form.goods_num,
remark: form.remark
remark: form.remark,
price_type: priceType.value,
user_price: priceType.value === 'custom' ? Number(userPrice.value) : 0
});
await api.orderPay({ order_id: res.order_id, pay_type: 'mock' });
uni.showToast({ title: '支付成功,等待师傅接单' });
const tip = priceType.value === 'quote' ? '支付成功,等待师傅报价' : '支付成功,等待师傅接单';
uni.showToast({ title: tip });
setTimeout(() => {
uni.redirectTo({ url: '/pages/order/detail?id=' + res.order_id });
}, 600);
@@ -196,6 +289,9 @@
serviceId = Number(options.service_id || 0);
const res = await api.serviceDetail(serviceId);
svc.value = res.detail;
// 默认沿用服务价态:报价服务 → 师傅报价;区间服务 → 自主定价;其余 → 一口价
priceType.value = svc.value.price_type === 'quote' ? 'quote'
: (svc.value.price_type === 'range' ? 'custom' : 'fixed');
await loadAddress();
calc();
});
@@ -223,6 +319,26 @@
.urgent.on .urgent-txt { color: #E36B0C; font-weight: 600; }
.sec { margin: 22rpx 28rpx 0; padding: 22rpx 24rpx; background: #fff; border-radius: 20rpx; box-shadow: 0 6rpx 20rpx rgba(240,129,31,0.06); }
.sec-title { font-size: 28rpx; font-weight: 700; color: #1F1F1F; margin-bottom: 10rpx; }
.modes { display: flex; margin-top: 8rpx; }
.mode {
position: relative; flex: 1; min-width: 0; margin-right: 14rpx; padding: 20rpx 16rpx;
border-radius: 16rpx; background: #F8F8F8; border: 2rpx solid transparent;
display: flex; flex-direction: column;
}
.mode:last-child { margin-right: 0; }
.mode.on { background: #FFF3E6; border-color: #F0710D; }
.mode-name { font-size: 27rpx; font-weight: 700; color: #444; }
.mode.on .mode-name { color: #E36B0C; }
.mode-desc { margin-top: 6rpx; font-size: 20rpx; color: #9A9A9A; line-height: 28rpx; }
.mode.on .mode-desc { color: #C07A3A; }
.mode-check {
position: absolute; right: 10rpx; top: 8rpx; width: 30rpx; height: 30rpx; line-height: 30rpx;
text-align: center; border-radius: 50%; background: #F0710D; color: #fff; font-size: 20rpx;
}
.mode-note {
margin-top: 14rpx; padding: 14rpx 16rpx; border-radius: 12rpx;
background: #FAFAFA; font-size: 22rpx; color: #8A8A8A; line-height: 32rpx;
}
.addr { display: flex; align-items: center; }
.addr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.addr-c { font-size: 28rpx; font-weight: 600; color: #222; }
@@ -241,11 +357,15 @@
.seg-i { padding: 0 26rpx; line-height: 52rpx; margin-right: 12rpx; border-radius: 26rpx; background: #F5F5F5; font-size: 24rpx; color: #666; }
.seg-i.on { background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%); color: #fff; }
.save-btn { margin-top: 20rpx; height: 76rpx; display: flex; align-items: center; justify-content: center; border-radius: 38rpx; background: #FFF3E6; color: #E36B0C; font-size: 26rpx; font-weight: 600; }
.price-input-wrap { flex: 1; display: flex; align-items: center; }
.price-unit { font-size: 32rpx; font-weight: 700; color: #F0710D; margin-right: 8rpx; }
.price-input { flex: 1; }
.li { display: flex; justify-content: space-between; padding: 14rpx 0; border-bottom: 1rpx solid #F4F4F4; }
.li.total { border-bottom: none; }
.k { font-size: 26rpx; color: #666; }
.v { font-size: 26rpx; color: #333; }
.v.big { font-size: 34rpx; font-weight: 700; color: #F0710D; }
.fee-note { display: block; margin-top: 10rpx; font-size: 21rpx; color: #9A9A9A; line-height: 30rpx; }
.bar {
position: fixed; left: 0; right: 0; bottom: 0; height: 120rpx;
padding: 0 28rpx; padding-bottom: env(safe-area-inset-bottom);
@@ -263,4 +383,3 @@
}
.bar-btn.disabled { opacity: 0.7; }
</style>

查看文件

@@ -30,11 +30,37 @@
<view class="li" v-if="Number(order.urgent)"><text class="k">加急</text><text class="v">是(+20%)</text></view>
</view>
<view class="card" v-if="order.price_type === 'quote'">
<view class="card-head">
<text class="card-title">师傅报价</text>
<text class="card-refresh" @tap="load">刷新</text>
</view>
<view class="quote-tip" v-if="order.status === 2 && quotes.length">已有 {{ quotes.length }} 位师傅报价,选择后师傅将上门服务</view>
<view class="quote-empty" v-if="!quotes.length">暂无师傅报价,请稍候…</view>
<view class="quote-item" v-for="q in quotes" :key="q.id" :class="{ chosen: q.status === 'accept' }">
<view class="q-top">
<view class="q-master">
<text class="q-name">{{ q.realname }}</text>
<text class="q-meta">评分 {{ q.score }} · 完成 {{ q.order_count }} 单</text>
</view>
<text class="q-amt">¥{{ q.amount }}</text>
</view>
<text class="q-desc" v-if="q.description">{{ q.description }}</text>
<view class="q-foot">
<text class="q-expire">有效期至 {{ q.expire_text }}</text>
<text class="q-status" :class="'qs-' + q.status">{{ q.status_text }}</text>
<view class="q-choose" v-if="canChoose && q.status === 'wait'" @tap="chooseQuote(q)">选择该师傅</view>
</view>
</view>
</view>
<view class="card">
<view class="card-title">费用明细</view>
<view class="li"><text class="k">基础价</text><text class="v">¥{{ order.base_amount }}</text></view>
<view class="li"><text class="k">楼层费</text><text class="v">¥{{ order.floor_amount }}</text></view>
<view class="li"><text class="k">计价方式</text><text class="v">{{ order.price_type_text }}</text></view>
<view class="li"><text class="k">{{ order.price_type === 'custom' ? '您的出价' : (order.price_type === 'quote' && Number(order.master_id) > 0 ? '师傅报价' : '基础价') }}</text><text class="v">¥{{ order.base_amount }}</text></view>
<view class="li" v-if="Number(order.floor_amount) > 0"><text class="k">楼层费</text><text class="v">¥{{ order.floor_amount }}</text></view>
<view class="li" v-if="Number(order.urgent_amount) > 0"><text class="k">加急费</text><text class="v">¥{{ order.urgent_amount }}</text></view>
<view class="li" v-if="Number(order.discount_amount) > 0"><text class="k">优惠券抵扣</text><text class="v">-¥{{ order.discount_amount }}</text></view>
<view class="li"><text class="k">实付</text><text class="v big">¥{{ order.pay_amount }}</text></view>
</view>
@@ -78,6 +104,7 @@
const master = ref(null);
const logs = ref([]);
const media = ref([]);
const quotes = ref([]);
let orderId = 0;
const statusTip = computed(() => {
@@ -85,12 +112,34 @@
return order.value.status_tip || '';
});
const canChoose = computed(() => {
return !!(order.value && order.value.price_type === 'quote'
&& Number(order.value.status) === 2 && Number(order.value.master_id) === 0
&& quotes.value.some(q => q.status === 'wait'));
});
async function load() {
const res = await api.orderDetail(orderId);
order.value = res.order;
master.value = res.master;
logs.value = res.logs || [];
media.value = res.media || [];
quotes.value = res.quotes || [];
}
function chooseQuote(q) {
uni.showModal({
title: '选择服务师傅',
content: `确认选择 ${q.realname} 的报价 ¥${q.amount}?选定后师傅将与您联系`,
success: async (r) => {
if (!r.confirm) return;
try {
await api.orderChooseQuote({ order_id: orderId, quote_id: q.id });
toast('已选定师傅');
load();
} catch (e) {}
}
});
}
function toast(t) { uni.showToast({ title: t, icon: 'none' }); }
@@ -129,6 +178,26 @@
.hero-tip { display: block; margin-top: 10rpx; font-size: 24rpx; color: rgba(255,255,255,0.9); }
.card { margin: 22rpx 28rpx 0; padding: 24rpx; background: #fff; border-radius: 20rpx; box-shadow: 0 6rpx 20rpx rgba(240,129,31,0.06); }
.card-title { font-size: 28rpx; font-weight: 700; color: #1F1F1F; margin-bottom: 12rpx; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card-refresh { font-size: 22rpx; color: #F0710D; }
.quote-tip { margin-bottom: 10rpx; padding: 12rpx 16rpx; border-radius: 12rpx; background: #FFF3E6; font-size: 22rpx; color: #C07A3A; line-height: 30rpx; }
.quote-empty { padding: 30rpx 0; text-align: center; font-size: 24rpx; color: #9A9A9A; }
.quote-item { padding: 18rpx 0; border-bottom: 1rpx solid #F4F4F4; }
.quote-item:last-child { border-bottom: none; }
.quote-item.chosen { background: #FFFBF6; border-radius: 12rpx; padding: 18rpx 14rpx; }
.q-top { display: flex; align-items: flex-start; justify-content: space-between; }
.q-master { display: flex; flex-direction: column; }
.q-name { font-size: 28rpx; font-weight: 700; color: #222; }
.q-meta { margin-top: 4rpx; font-size: 21rpx; color: #9A9A9A; }
.q-amt { font-size: 34rpx; font-weight: 700; color: #F0710D; }
.q-desc { display: block; margin-top: 10rpx; font-size: 23rpx; color: #666; line-height: 32rpx; }
.q-foot { display: flex; align-items: center; margin-top: 10rpx; }
.q-expire { flex: 1; font-size: 20rpx; color: #B5B5B5; }
.q-status { font-size: 21rpx; color: #9A9A9A; margin-right: 14rpx; }
.q-status.qs-wait { color: #4A7CFF; }
.q-status.qs-accept { color: #2FA84F; }
.q-status.qs-reject, .q-status.qs-expired { color: #B5B5B5; }
.q-choose { padding: 0 24rpx; line-height: 56rpx; border-radius: 28rpx; color: #fff; font-size: 23rpx; font-weight: 600; background: linear-gradient(135deg,#FFA93F 0%,#F0710D 100%); }
.li { display: flex; justify-content: space-between; padding: 12rpx 0; border-bottom: 1rpx solid #F4F4F4; }
.k { flex-shrink: 0; width: 150rpx; font-size: 26rpx; color: #666; }
.v { flex: 1; text-align: right; font-size: 26rpx; color: #333; line-height: 36rpx; }