- 新增账号安全页面及支付密码验证组件 - 新增用户类型选择流程及商家资质管理 - 新增订单资质校验逻辑,师傅需满足订单证书要求 - 新增企业资质认证相关数据库表及接口 - 优化用户列表展示,区分个人与商家用户类型
748 行
30 KiB
Vue
748 行
30 KiB
Vue
<template>
|
||
<view class="page">
|
||
<YjyfNavBar theme="orange" title="确认订单" />
|
||
|
||
<view class="svc">
|
||
<view class="svc-thumb">
|
||
<image class="svc-img" :src="(svc && svc.image_url) ? svc.image_url : '/static/icons/service-default.svg'" :mode="(svc && svc.image_url && !svc.image_url.endsWith('.svg')) ? 'aspectFill' : 'aspectFit'" />
|
||
</view>
|
||
<view class="svc-info">
|
||
<text class="svc-name">{{ svc ? svc.name : '' }}</text>
|
||
<text class="svc-price">{{ svc ? svc.price_text : '' }}</text>
|
||
</view>
|
||
<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">
|
||
<image class="mode-check-img" src="/static/icons/check-orange.svg" mode="aspectFit" />
|
||
</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>
|
||
|
||
<!-- 多商品组合容器(对标奇兵到家 frame_010 / frame_025) -->
|
||
<view class="sec" v-for="(item, idx) in goodsGroups" :key="idx">
|
||
<view class="group-hd">
|
||
<view class="gh-left">
|
||
<text class="group-title">商品信息</text>
|
||
<text class="group-tag">第 {{ idx + 1 }} 组</text>
|
||
</view>
|
||
<view class="gh-del" v-if="goodsGroups.length > 1" @tap="delGroup(idx)">
|
||
<text class="del-txt">删除此组</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="fi">
|
||
<text class="fk">商品名称</text>
|
||
<input class="fv" v-model="item.goods_name" placeholder="如:洗衣柜 / 浴缸 / 马桶" />
|
||
</view>
|
||
<view class="fi">
|
||
<text class="fk">规格型号</text>
|
||
<input class="fv" v-model="item.goods_model" placeholder="如:0-60cm / 智能款" />
|
||
</view>
|
||
<view class="fi">
|
||
<text class="fk">商品数量</text>
|
||
<view class="stepper">
|
||
<view class="st-btn" @tap="stepGroupNum(idx, -1)">
|
||
<image class="st-ico" src="/static/icons/step-minus.svg" mode="aspectFit" />
|
||
</view>
|
||
<text class="st-val">{{ item.goods_num }}</text>
|
||
<view class="st-btn" @tap="stepGroupNum(idx, 1)">
|
||
<image class="st-ico" src="/static/icons/step-plus.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="fi">
|
||
<text class="fk">增值服务</text>
|
||
<view class="addons-row" v-if="availableAddons.length > 0">
|
||
<view
|
||
v-for="ad in availableAddons"
|
||
:key="ad.id || ad.name"
|
||
class="addon-pill"
|
||
:class="{ on: item.addons.includes(ad.name) }"
|
||
@tap="toggleAddon(idx, ad.name)"
|
||
>
|
||
<text class="ad-name">{{ ad.name }} (+¥{{ ad.price }})</text>
|
||
</view>
|
||
</view>
|
||
<text class="addon-empty-hint" v-else>该商品暂无额外增值服务</text>
|
||
</view>
|
||
<view class="group-ft">
|
||
<text class="g-price-tip">本组单项预估</text>
|
||
<text class="g-price-val">¥{{ calcGroupPrice(item) }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="add-group-btn clickable-hover" @tap="addGroup">
|
||
<image class="add-plus-ico" src="/static/icons/plus-orange.svg" mode="aspectFit" />
|
||
<text class="add-txt">继续添加商品组合 (如: 浴缸/马桶同时装)</text>
|
||
</view>
|
||
|
||
<view class="sec">
|
||
<view class="sec-title">服务地址</view>
|
||
<view class="addr" v-if="address">
|
||
<view class="addr-main">
|
||
<text class="addr-c">{{ address.contact }} {{ address.mobile }}</text>
|
||
<text class="addr-d">{{ address.province }}{{ address.city }}{{ address.district }}{{ address.address }}</text>
|
||
<text class="addr-x">楼层 {{ address.floor }} · {{ Number(address.has_elevator) ? '有电梯' : '无电梯' }}</text>
|
||
</view>
|
||
<text class="link" @tap="pickAddress">更换</text>
|
||
</view>
|
||
|
||
<view class="form" v-if="!address">
|
||
<view class="fi"><text class="fk">联系人</text><input class="fv" v-model="form.contact" placeholder="收货人姓名" /></view>
|
||
<view class="fi"><text class="fk">手机号</text><input class="fv" v-model="form.mobile" type="number" maxlength="11" placeholder="联系手机号" /></view>
|
||
<view class="fi">
|
||
<text class="fk">所在地区</text>
|
||
<!-- #ifdef MP-WEIXIN -->
|
||
<picker class="fv-picker" mode="region" :value="[form.province, form.city, form.district]" @change="onCreateRegionChange">
|
||
<view class="fv2-row"><text class="fv2" :class="{ 'ph-txt': !form.province }">{{ form.province ? (form.province + ' ' + form.city + ' ' + form.district) : '点击选择省 / 市 / 区' }}</text><image class="arrow-ico" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view>
|
||
</picker>
|
||
<!-- #endif -->
|
||
<!-- #ifndef MP-WEIXIN -->
|
||
<view class="fv2-row clickable-hover" @tap="showCreateRegion = true">
|
||
<text class="fv2" :class="{ 'ph-txt': !form.province }">{{ form.province ? (form.province + ' ' + form.city + ' ' + form.district) : '点击选择省 / 市 / 区' }}</text>
|
||
<image class="arrow-ico" src="/static/icons/arrow-right.svg" mode="aspectFit" />
|
||
</view>
|
||
<!-- #endif -->
|
||
</view>
|
||
<view class="fi"><text class="fk">详细地址</text><input class="fv" v-model="form.address" placeholder="小区/楼栋/门牌号" /></view>
|
||
<view class="fi">
|
||
<text class="fk">楼层</text>
|
||
<view class="stepper">
|
||
<view class="st-btn" @tap="stepFloor(-1)">
|
||
<image class="st-ico" src="/static/icons/step-minus.svg" mode="aspectFit" />
|
||
</view>
|
||
<text class="st-val">{{ form.floor }}</text>
|
||
<view class="st-btn" @tap="stepFloor(1)">
|
||
<image class="st-ico" src="/static/icons/step-plus.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="fi">
|
||
<text class="fk">有无电梯</text>
|
||
<view class="seg">
|
||
<view class="seg-i" :class="{ on: form.has_elevator === 1 }" @tap="form.has_elevator = 1">有</view>
|
||
<view class="seg-i" :class="{ on: form.has_elevator === 0 }" @tap="form.has_elevator = 0">无</view>
|
||
</view>
|
||
</view>
|
||
<view class="save-btn clickable-hover" @tap="saveAddress">保存地址</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="sec">
|
||
<view class="sec-title">预约与施工备注</view>
|
||
<picker mode="date" :value="date" :start="today" @change="onDate">
|
||
<view class="fi"><text class="fk">预约日期</text><text class="fv2">{{ date }}</text><image class="arrow-ico" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view>
|
||
</picker>
|
||
<picker mode="selector" :range="timeSlots" @change="onTimeSlot">
|
||
<view class="fi"><text class="fk">预约时段</text><text class="fv2">{{ time }}</text><image class="arrow-ico" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view>
|
||
</picker>
|
||
<view class="fi"><text class="fk">施工备注</text><input class="fv" v-model="form.remark" placeholder="门禁密码 / 施工特殊要求 / 宠物等" /></view>
|
||
</view>
|
||
|
||
<!-- 奇兵到家规则提示 (frame_028) -->
|
||
<view class="disclaimer-sec">
|
||
<view class="disclaimer-card">
|
||
<text class="disclaimer-txt">注:订单服务过程中,非师傅原因导致空跑,若师傅申请空跑费 30 元需由下单方承担(师傅不申请则无需支付)。</text>
|
||
</view>
|
||
|
||
<view class="auto-quote-card clickable-hover" v-if="priceType === 'fixed'" @tap="autoQuote = !autoQuote">
|
||
<view class="chk-box" :class="{ on: autoQuote }">
|
||
<image v-if="autoQuote" class="chk-ico" src="/static/icons/check-orange.svg" mode="aspectFit" />
|
||
</view>
|
||
<view class="aq-info">
|
||
<text class="aq-title">如超过 20 分钟无法匹配合适师傅,自动换成报价订单</text>
|
||
<text class="aq-sub">一口价转成报价订单后会生成新的竞标单,已支付的金额自动退回您的账户。</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="sec" v-if="amount">
|
||
<view class="sec-title">{{ priceType === 'quote' ? '费用预估' : '费用明细' }}</view>
|
||
<view class="li">
|
||
<text class="k">{{ priceType === 'custom' ? '您的出价' : `商品基础工费 (${goodsGroups.length}组)` }}</text>
|
||
<text class="v">¥{{ totalGroupBasePrice }}</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">¥{{ finalPayPrice }}</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">共 {{ goodsGroups.length }} 组合计</text>
|
||
<text class="bar-p">¥{{ finalPayPrice }}</text>
|
||
</view>
|
||
<view class="bar-btn clickable-hover" :class="{ disabled: submitting }" @tap="submit">
|
||
{{ submitting ? '提交中...' : (priceType === 'quote' ? '发布需求' : '发布订单') }}
|
||
</view>
|
||
</view>
|
||
|
||
<RegionPickerDrawer
|
||
:visible="showCreateRegion"
|
||
:province="form.province"
|
||
:city="form.city"
|
||
:district="form.district"
|
||
@update:visible="showCreateRegion = $event"
|
||
@confirm="onCreateRegionDrawerConfirm"
|
||
/>
|
||
<YjyfPaymentPassword ref="paymentPasswordDialog" />
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import YjyfPaymentPassword from '@/components/YjyfPaymentPassword.vue';
|
||
import { ref, reactive, watch, computed } from 'vue';
|
||
const paymentPasswordDialog = ref(null);
|
||
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
|
||
import api from '@/utils/api.js';
|
||
import { executeOrderWxPay, openOrderPaymentResult } from '@/utils/pay.js';
|
||
import { isLogin, toLogin } from '@/utils/request.js';
|
||
import RegionPickerDrawer from '@/components/RegionPickerDrawer.vue';
|
||
|
||
const svc = ref(null);
|
||
const address = ref(null);
|
||
const addresses = ref([]);
|
||
const amount = ref(null);
|
||
const urgent = ref(false);
|
||
const submitting = ref(false);
|
||
const autoQuote = ref(true);
|
||
const showCreateRegion = ref(false);
|
||
|
||
// 真实增值服务列表:从当前所选商品的真实 addons 动态派生(无 mock,按商品品类精准区分)
|
||
const availableAddons = computed(() => {
|
||
if (svc.value && svc.value.addons && Array.isArray(svc.value.addons) && svc.value.addons.length > 0) {
|
||
return svc.value.addons;
|
||
}
|
||
return [];
|
||
});
|
||
|
||
// 多商品组合容器 (对标奇兵到家 frame_010)
|
||
const goodsGroups = ref([
|
||
{ goods_name: '', goods_model: '', goods_num: 1, image: '', addons: [] }
|
||
]);
|
||
|
||
function addGroup() {
|
||
goodsGroups.value.push({
|
||
goods_name: svc.value ? svc.value.name : '',
|
||
goods_model: '',
|
||
goods_num: 1,
|
||
image: '',
|
||
addons: []
|
||
});
|
||
}
|
||
|
||
function delGroup(idx) {
|
||
goodsGroups.value.splice(idx, 1);
|
||
calc();
|
||
}
|
||
|
||
function stepGroupNum(idx, delta) {
|
||
const cur = goodsGroups.value[idx].goods_num + delta;
|
||
goodsGroups.value[idx].goods_num = Math.max(1, cur);
|
||
calc();
|
||
}
|
||
|
||
function toggleAddon(idx, addonName) {
|
||
const item = goodsGroups.value[idx];
|
||
const p = item.addons.indexOf(addonName);
|
||
if (p >= 0) {
|
||
item.addons.splice(p, 1);
|
||
} else {
|
||
item.addons.push(addonName);
|
||
}
|
||
calc();
|
||
}
|
||
|
||
function calcGroupPrice(item) {
|
||
const unitBase = svc.value && Number(svc.value.base_price) > 0 ? Number(svc.value.base_price) : 0;
|
||
let addonSum = 0;
|
||
for (const adName of item.addons) {
|
||
const hit = availableAddons.value.find(a => a.name === adName);
|
||
if (hit) addonSum += Number(hit.price) || 0;
|
||
}
|
||
return (unitBase * item.goods_num) + addonSum;
|
||
}
|
||
|
||
const totalGroupBasePrice = computed(() => {
|
||
let total = 0;
|
||
for (const g of goodsGroups.value) {
|
||
total += calcGroupPrice(g);
|
||
}
|
||
return total;
|
||
});
|
||
|
||
const finalPayPrice = computed(() => {
|
||
if (priceType.value === 'custom') {
|
||
return Number(userPrice.value) || 0;
|
||
}
|
||
const floor = amount.value ? Number(amount.value.floor_amount || 0) : 0;
|
||
const urg = urgent.value ? Math.round(totalGroupBasePrice.value * 0.2) : 0;
|
||
const disc = amount.value ? Number(amount.value.discount_amount || 0) : 0;
|
||
return Math.max(0.01, totalGroupBasePrice.value + floor + urg - disc).toFixed(2);
|
||
});
|
||
|
||
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 '按平台标准一口价结算,抢单后 2 小时内师傅主动联系确认';
|
||
});
|
||
|
||
const now = new Date();
|
||
const pad = (n) => (n < 10 ? '0' + n : '' + n);
|
||
const today = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
|
||
|
||
const timeSlots = [
|
||
'上午 07:00~10:59',
|
||
'中午 11:00~13:59',
|
||
'下午 14:00~17:59',
|
||
'晚上 18:00~20:59'
|
||
];
|
||
const date = ref(today);
|
||
const time = ref(timeSlots[2]);
|
||
|
||
function onDate(e) { date.value = e.detail.value; }
|
||
function onTimeSlot(e) { time.value = timeSlots[e.detail.value]; }
|
||
|
||
const form = reactive({
|
||
contact: '', mobile: '', province: '', city: '', district: '', address: '', floor: 1, has_elevator: 1,
|
||
goods_model: '', goods_num: 1, remark: ''
|
||
});
|
||
|
||
function stepFloor(delta) { form.floor = Math.max(1, form.floor + delta); }
|
||
|
||
function onCreateRegionChange(e) {
|
||
const val = e.detail.value || [];
|
||
if (val.length >= 3) {
|
||
form.province = val[0];
|
||
form.city = val[1];
|
||
form.district = val[2];
|
||
}
|
||
}
|
||
|
||
function onCreateRegionDrawerConfirm(reg) {
|
||
if (!reg) return;
|
||
form.province = reg.province;
|
||
form.city = reg.city;
|
||
form.district = reg.district;
|
||
}
|
||
|
||
async function loadAddress() {
|
||
try {
|
||
const res = await api.addressList();
|
||
addresses.value = res.list || [];
|
||
if (addresses.value.length) {
|
||
const def = addresses.value.find((a) => a.is_default === 1);
|
||
address.value = def || addresses.value[0];
|
||
}
|
||
} catch (e) {}
|
||
}
|
||
|
||
function onAddressSelectedEvent(addr) {
|
||
if (!addr) return;
|
||
address.value = addr;
|
||
calc();
|
||
}
|
||
|
||
function pickAddress() {
|
||
uni.navigateTo({
|
||
url: '/pages/address/list?select=1',
|
||
events: {
|
||
selectAddress: onAddressSelectedEvent
|
||
}
|
||
});
|
||
}
|
||
|
||
const savingAddr = ref(false);
|
||
|
||
async function saveAddress() {
|
||
if (savingAddr.value) return;
|
||
if (!form.contact || !form.mobile || !form.province || !form.address) {
|
||
uni.showToast({ title: '请完整填写联系人、电话、所在地区与详细地址', icon: 'none' });
|
||
return;
|
||
}
|
||
savingAddr.value = true;
|
||
try {
|
||
const res = await api.addressSave({
|
||
contact: form.contact,
|
||
mobile: form.mobile,
|
||
province: form.province,
|
||
city: form.city,
|
||
district: form.district,
|
||
address: form.address,
|
||
floor: form.floor,
|
||
has_elevator: form.has_elevator,
|
||
is_default: 1
|
||
});
|
||
address.value = res.address || {
|
||
id: res.id,
|
||
contact: form.contact,
|
||
mobile: form.mobile,
|
||
province: form.province, city: form.city, district: form.district,
|
||
address: form.address,
|
||
floor: form.floor,
|
||
has_elevator: form.has_elevator
|
||
};
|
||
calc();
|
||
} catch (e) {
|
||
} finally {
|
||
savingAddr.value = false;
|
||
}
|
||
}
|
||
|
||
async function calc() {
|
||
if (!serviceId) return;
|
||
try {
|
||
const res = await api.calc({
|
||
service_id: serviceId,
|
||
floor: address.value ? address.value.floor : form.floor,
|
||
has_elevator: address.value ? address.value.has_elevator : form.has_elevator,
|
||
urgent: urgent.value ? 1 : 0,
|
||
goods_num: 1,
|
||
price_type: priceType.value,
|
||
user_price: userPrice.value
|
||
});
|
||
amount.value = (res && res.amount) ? res.amount : res;
|
||
} catch (e) {
|
||
console.warn('[CreateOrder] calc failed:', e);
|
||
}
|
||
}
|
||
|
||
function selectMode(key) {
|
||
priceType.value = key;
|
||
calc();
|
||
}
|
||
|
||
watch(urgent, () => calc());
|
||
watch(userPrice, () => {
|
||
if (priceType.value === 'custom') calc();
|
||
});
|
||
|
||
let serviceId = 0;
|
||
|
||
async function submit() {
|
||
if (submitting.value) 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;
|
||
let createdOrderId = 0;
|
||
try {
|
||
// 封装多商品组合明细
|
||
const itemsPayload = goodsGroups.value.map(g => ({
|
||
service_id: serviceId,
|
||
goods_name: g.goods_name || (svc.value ? svc.value.name : '标准服务'),
|
||
goods_model: g.goods_model,
|
||
goods_num: g.goods_num,
|
||
goods_image: g.image,
|
||
addon_services: g.addons.join(','),
|
||
base_price: calcGroupPrice(g)
|
||
}));
|
||
|
||
let appointHourStr = '14:30:00';
|
||
if (time.value && time.value.indexOf('上午') > -1) appointHourStr = '10:00:00';
|
||
else if (time.value && time.value.indexOf('中午') > -1) appointHourStr = '12:00:00';
|
||
else if (time.value && time.value.indexOf('下午') > -1) appointHourStr = '14:30:00';
|
||
else if (time.value && time.value.indexOf('晚上') > -1) appointHourStr = '19:00:00';
|
||
const safeDateStr = String(date.value || today).replace(/-/g, '/');
|
||
let targetTime = Math.floor(new Date(`${safeDateStr} ${appointHourStr}`).getTime() / 1000);
|
||
const nowSec = Math.floor(Date.now() / 1000);
|
||
if (isNaN(targetTime) || targetTime <= nowSec) {
|
||
targetTime = nowSec + 3600;
|
||
}
|
||
|
||
const res = await api.orderCreate({
|
||
service_id: serviceId,
|
||
address_id: address.value.id,
|
||
appoint_time: targetTime,
|
||
urgent: urgent.value ? 1 : 0,
|
||
goods_model: goodsGroups.value[0].goods_model,
|
||
goods_num: goodsGroups.value[0].goods_num,
|
||
remark: form.remark,
|
||
price_type: priceType.value,
|
||
user_price: userPrice.value,
|
||
auto_quote_timeout: autoQuote.value ? 1200 : 0,
|
||
items: itemsPayload,
|
||
goods_list: JSON.stringify(itemsPayload)
|
||
});
|
||
|
||
createdOrderId = res.order_id;
|
||
if (priceType.value === 'quote') {
|
||
submitting.value = false;
|
||
uni.redirectTo({ url: `/pages/order/detail?id=${createdOrderId}` });
|
||
return;
|
||
}
|
||
|
||
// 检查用户可用余额,充足时可供选择,默认优先微信支付
|
||
let payType = 'wechat';
|
||
try {
|
||
const w = await api.userWallet();
|
||
const bal = w ? Number(w.balance || 0) : 0;
|
||
const needPay = Number(res.pay_amount || 0);
|
||
if (bal >= needPay && needPay > 0) {
|
||
const picked = await new Promise((resolve) => {
|
||
uni.showActionSheet({
|
||
itemList: [
|
||
'微信支付',
|
||
`余额支付(¥${bal.toFixed(2)})`
|
||
],
|
||
success: (r) => resolve(r.tapIndex === 1 ? 'balance' : 'wechat'),
|
||
fail: () => resolve('wechat')
|
||
});
|
||
});
|
||
if (picked) payType = picked;
|
||
}
|
||
} catch (pe) {}
|
||
|
||
// 一口价或自主定价调起支付
|
||
const payment = await executeOrderWxPay(api.orderPay, { order_id: createdOrderId, pay_type: payType }, () => paymentPasswordDialog.value.open({ createdOrderId }));
|
||
openOrderPaymentResult(createdOrderId, payment, true);
|
||
} catch (e) {
|
||
if (e && e.paymentSetupNavigation) { submitting.value = false; return; }
|
||
if (createdOrderId) {
|
||
if (!e || !e.unsupportedEnv) {
|
||
const reason = (e && e.message) ? `订单已创建(${e.message})` : '订单已创建,请在详情页完成支付';
|
||
uni.showToast({ title: reason, icon: 'none' });
|
||
}
|
||
setTimeout(() => {
|
||
submitting.value = false;
|
||
uni.redirectTo({ url: `/pages/order/detail?id=${createdOrderId}` });
|
||
}, 1200);
|
||
} else {
|
||
submitting.value = false;
|
||
uni.showToast({ title: (e && e.message) || '下单失败', icon: 'none' });
|
||
}
|
||
}
|
||
}
|
||
|
||
onLoad(async (options) => {
|
||
if (!isLogin()) { toLogin(); return; }
|
||
uni.$on('selectAddress', onAddressSelectedEvent);
|
||
serviceId = Number((options && (options.service_id || options.id)) || 0);
|
||
if (!serviceId) {
|
||
uni.redirectTo({ url: '/pages/order/quick' });
|
||
return;
|
||
}
|
||
try {
|
||
const res = await api.serviceDetail(serviceId);
|
||
svc.value = res && res.detail ? res.detail : null;
|
||
} catch (e) {
|
||
svc.value = null;
|
||
}
|
||
if (!svc.value) {
|
||
uni.redirectTo({ url: '/pages/order/quick' });
|
||
return;
|
||
}
|
||
if (svc.value.pricing_revision != null) {
|
||
uni.redirectTo({ url: `/pages/order/quick?service_id=${serviceId}&cat_id=${svc.value.cat_id}` });
|
||
return;
|
||
}
|
||
goodsGroups.value[0].goods_name = svc.value.name;
|
||
priceType.value = svc.value.price_type === 'quote' ? 'quote'
|
||
: (svc.value.price_type === 'range' ? 'custom' : 'fixed');
|
||
await loadAddress();
|
||
calc();
|
||
});
|
||
|
||
onUnload(() => {
|
||
uni.$off('selectAddress', onAddressSelectedEvent);
|
||
});
|
||
|
||
onShow(() => {
|
||
const picked = uni.getStorageSync('yjyf_selected_address');
|
||
if (picked) {
|
||
uni.removeStorageSync('yjyf_selected_address');
|
||
address.value = picked;
|
||
calc();
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<style scoped>
|
||
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 180rpx; }
|
||
.svc {
|
||
display: flex; align-items: center; margin: 24rpx 24rpx 0; padding: 24rpx;
|
||
background: #FFFFFF; border-radius: 20rpx; box-shadow: 0 6rpx 20rpx rgba(240, 113, 13, 0.06);
|
||
}
|
||
.svc-thumb {
|
||
width: 108rpx; height: 108rpx; border-radius: 16rpx; flex-shrink: 0; overflow: hidden;
|
||
background: #FFF7F0; display: flex; align-items: center; justify-content: center;
|
||
}
|
||
.svc-img { width: 100%; height: 100%; }
|
||
.svc-info { flex: 1; margin-left: 20rpx; display: flex; flex-direction: column; }
|
||
.svc-name { font-size: 32rpx; font-weight: 700; color: #1F1F1F; }
|
||
.svc-price { margin-top: 8rpx; font-size: 28rpx; font-weight: 700; color: #F0710D; }
|
||
.urgent {
|
||
flex-shrink: 0; height: 56rpx; padding: 0 24rpx; display: inline-flex; align-items: center; justify-content: center; line-height: 1; border-radius: 28rpx;
|
||
background: #F5F6F8; border: 2rpx solid #F0F0F2;
|
||
}
|
||
.urgent.on { background: #FFF7F0; border-color: #F0710D; }
|
||
.urgent-txt { font-size: 22rpx; color: #444444; line-height: 1; }
|
||
.urgent.on .urgent-txt { color: #F0710D; font-weight: 600; }
|
||
.sec { margin: 24rpx 24rpx 0; padding: 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: 12rpx; }
|
||
.modes { display: flex; margin-top: 8rpx; gap: 14rpx; }
|
||
.mode {
|
||
position: relative; flex: 1; min-width: 0; padding: 20rpx 16rpx;
|
||
border-radius: 16rpx; background: #F8F8F8; border: 2rpx solid transparent;
|
||
display: flex; flex-direction: column;
|
||
}
|
||
.mode.on { background: #FFF7F0; border-color: #F0710D; }
|
||
.mode-name { font-size: 28rpx; font-weight: 700; color: #444444; }
|
||
.mode.on .mode-name { color: #F0710D; }
|
||
.mode-desc { margin-top: 6rpx; font-size: 22rpx; color: #888888; line-height: 28rpx; }
|
||
.mode.on .mode-desc { color: #C07A3A; }
|
||
.mode-check {
|
||
position: absolute; right: 10rpx; top: 8rpx; width: 32rpx; height: 32rpx; display: flex; align-items: center; justify-content: center;
|
||
}
|
||
.mode-check-img { width: 28rpx; height: 28rpx; }
|
||
.mode-note {
|
||
margin-top: 14rpx; padding: 14rpx 16rpx; border-radius: 12rpx;
|
||
background: #FAFAFA; font-size: 22rpx; color: #888888; line-height: 32rpx;
|
||
}
|
||
.group-hd { display: flex; align-items: center; justify-content: space-between; padding-bottom: 12rpx; border-bottom: 1rpx solid #F0F0F2; }
|
||
.gh-left { display: flex; align-items: center; }
|
||
.group-title { font-size: 28rpx; font-weight: 700; color: #1F1F1F; }
|
||
.group-tag { margin-left: 12rpx; height: 36rpx; line-height: 36rpx; text-align: center; padding: 0 12rpx; display: inline-flex; align-items: center; justify-content: center; border-radius: 8rpx; font-size: 22rpx; background: #FFF7F0; color: #F0710D; font-weight: 600; }
|
||
.del-txt { font-size: 24rpx; color: #E8331B; }
|
||
.addons-row { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 12rpx; padding: 12rpx 0; }
|
||
.addon-empty-hint { font-size: 24rpx; color: #888888; padding: 12rpx 0; }
|
||
.addon-pill {
|
||
display: inline-flex; align-items: center; justify-content: center; height: 48rpx; line-height: 1;
|
||
padding: 0 20rpx; border-radius: 24rpx;
|
||
background: #F5F6F8; border: 1.5rpx solid transparent; font-size: 22rpx; color: #444444;
|
||
}
|
||
.addon-pill.on { background: #FFF7F0; border-color: #F0710D; color: #F0710D; font-weight: 600; }
|
||
.group-ft { display: flex; justify-content: flex-end; align-items: baseline; padding-top: 14rpx; }
|
||
.g-price-tip { font-size: 22rpx; color: #888888; margin-right: 8rpx; }
|
||
.g-price-val { font-size: 30rpx; font-weight: 700; color: #F0710D; }
|
||
.add-group-btn {
|
||
margin: 24rpx 24rpx 0; height: 84rpx; display: flex; align-items: center; justify-content: center;
|
||
background: #fff; border: 2rpx dashed #F0710D; border-radius: 20rpx;
|
||
}
|
||
.add-plus-ico { width: 28rpx; height: 28rpx; margin-right: 8rpx; }
|
||
.add-txt { font-size: 26rpx; color: #F0710D; font-weight: 600; line-height: 1; }
|
||
.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: #1F1F1F; }
|
||
.addr-d { margin-top: 6rpx; font-size: 24rpx; color: #444444; line-height: 34rpx; }
|
||
.addr-x { margin-top: 6rpx; font-size: 22rpx; color: #888888; }
|
||
.link { flex-shrink: 0; margin-left: 16rpx; font-size: 24rpx; color: #F0710D; }
|
||
.fi { display: flex; align-items: center; min-height: 88rpx; border-bottom: 1rpx solid #F0F0F2; }
|
||
.fk { width: 150rpx; flex-shrink: 0; font-size: 28rpx; color: #444444; }
|
||
.fv { flex: 1; min-width: 0; height: 88rpx; font-size: 28rpx; color: #1F1F1F; }
|
||
.fv-picker { flex: 1; }
|
||
.fv2-row { flex: 1; display: flex; align-items: center; justify-content: space-between; min-height: 88rpx; }
|
||
.fv2 { flex: 1; min-width: 0; font-size: 28rpx; color: #1F1F1F; }
|
||
.fv2.ph-txt { color: #C8C7CC; }
|
||
.arrow-ico { width: 26rpx; height: 26rpx; opacity: 0.5; flex-shrink: 0; }
|
||
.stepper { display: flex; align-items: center; }
|
||
.st-btn { width: 52rpx; height: 52rpx; display: inline-flex; align-items: center; justify-content: center; line-height: 1; border-radius: 26rpx; background: #F5F6F8; }
|
||
.st-ico { width: 24rpx; height: 24rpx; }
|
||
.st-val { min-width: 60rpx; text-align: center; font-size: 28rpx; color: #1F1F1F; }
|
||
.seg { display: flex; align-items: center; gap: 12rpx; }
|
||
.seg-i { height: 52rpx; padding: 0 26rpx; display: inline-flex; align-items: center; justify-content: center; line-height: 1; border-radius: 26rpx; background: #F5F6F8; font-size: 24rpx; color: #444444; }
|
||
.seg-i.on { background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%); color: #fff; font-weight: 600; }
|
||
.save-btn { margin-top: 20rpx; height: 76rpx; display: flex; align-items: center; justify-content: center; line-height: 1; border-radius: 38rpx; background: #FFF7F0; color: #F0710D; 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; }
|
||
.disclaimer-sec { margin: 24rpx 24rpx 0; }
|
||
.disclaimer-card {
|
||
padding: 16rpx 20rpx; border-radius: 14rpx;
|
||
background: #FFF7F0; border: 1rpx solid #FFE4CC;
|
||
}
|
||
.disclaimer-txt { font-size: 22rpx; color: #BA6424; line-height: 32rpx; }
|
||
.auto-quote-card {
|
||
display: flex; align-items: flex-start; margin-top: 16rpx; padding: 18rpx 20rpx;
|
||
background: #fff; border-radius: 14rpx; box-shadow: 0 4rpx 14rpx rgba(0,0,0,0.03);
|
||
}
|
||
.chk-box {
|
||
width: 34rpx; height: 34rpx; border-radius: 8rpx; border: 2rpx solid #CCC; flex-shrink: 0;
|
||
margin-right: 16rpx; margin-top: 4rpx; display: flex; align-items: center; justify-content: center;
|
||
}
|
||
.chk-box.on { background: #FFF7F0; border-color: #F0710D; }
|
||
.chk-ico { width: 24rpx; height: 24rpx; }
|
||
.aq-info { flex: 1; display: flex; flex-direction: column; }
|
||
.aq-title { font-size: 26rpx; font-weight: 600; color: #1F1F1F; }
|
||
.aq-sub { margin-top: 4rpx; font-size: 22rpx; color: #888888; line-height: 30rpx; }
|
||
.li { display: flex; justify-content: space-between; align-items: center; padding: 14rpx 0; border-bottom: 1rpx solid #F0F0F2; }
|
||
.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: 22rpx; color: #888888; line-height: 32rpx; }
|
||
.bar {
|
||
position: fixed; left: 0; right: 0; bottom: 0; height: 120rpx;
|
||
padding: 0 24rpx; padding-bottom: env(safe-area-inset-bottom);
|
||
box-sizing: content-box;
|
||
display: flex; align-items: center; justify-content: space-between;
|
||
background: #fff; box-shadow: 0 -6rpx 24rpx rgba(0,0,0,0.06);
|
||
z-index: 20;
|
||
}
|
||
.bar-l { display: flex; align-items: baseline; }
|
||
.bar-k { font-size: 24rpx; color: #666; }
|
||
.bar-p { margin-left: 8rpx; font-size: 38rpx; font-weight: 700; color: #F0710D; }
|
||
.bar-btn {
|
||
height: 84rpx; padding: 0 48rpx; display: inline-flex; align-items: center; justify-content: center; line-height: 1;
|
||
border-radius: 42rpx; color: #fff; font-size: 30rpx; font-weight: 600;
|
||
background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%);
|
||
box-shadow: 0 8rpx 20rpx rgba(240,113,13,0.3);
|
||
}
|
||
.bar-btn.disabled { opacity: 0.7; }
|
||
</style>
|