feat(ui): 登录起全链路页面接通 + 逐页面验证(47 项)+ 修复订单列表越权泄漏
前端: - 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 条件 → 泄漏全部用户订单/跨用户数据 - 改为闭包重建查询,已验证修复
这个提交包含在:
266
pages/order/create.vue
普通文件
266
pages/order/create.vue
普通文件
@@ -0,0 +1,266 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="svc">
|
||||
<view class="svc-thumb"><text class="svc-txt">{{ svc ? svc.name.slice(0, 2) : '' }}</text></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 }" @tap="urgent = !urgent">
|
||||
<text class="urgent-txt">{{ urgent ? '已加急 +20%' : '加急' }}</text>
|
||||
</view>
|
||||
</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><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)">-</view>
|
||||
<text class="st-val">{{ form.floor }}</text>
|
||||
<view class="st-btn" @tap="stepFloor(1)">+</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" @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><text class="arrow">›</text></view>
|
||||
</picker>
|
||||
<picker mode="time" :value="time" @change="onTime">
|
||||
<view class="fi"><text class="fk">预约时段</text><text class="fv2">{{ time }}</text><text class="arrow">›</text></view>
|
||||
</picker>
|
||||
<view class="fi" v-if="svc && svc.need_model === 1"><text class="fk">商品型号</text><input class="fv" v-model="form.goods_model" placeholder="如:三人位布艺沙发" /></view>
|
||||
<view class="fi"><text class="fk">数量</text><view class="stepper">
|
||||
<view class="st-btn" @tap="stepNum(-1)">-</view><text class="st-val">{{ form.goods_num }}</text><view class="st-btn" @tap="stepNum(1)">+</view>
|
||||
</view></view>
|
||||
<view class="fi"><text class="fk">备注</text><input class="fv" v-model="form.remark" placeholder="施工要求 / 门禁 / 宠物等" /></view>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import api from '@/utils/api.js';
|
||||
import { isLogin, toLogin } from '@/utils/request.js';
|
||||
|
||||
const svc = ref(null);
|
||||
const address = ref(null);
|
||||
const addresses = ref([]);
|
||||
const amount = ref(null);
|
||||
const urgent = ref(false);
|
||||
const submitting = ref(false);
|
||||
|
||||
const now = new Date();
|
||||
const pad = (n) => (n < 10 ? '0' + n : '' + n);
|
||||
const today = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
|
||||
const date = ref(today);
|
||||
const time = ref('14:00');
|
||||
|
||||
const form = reactive({
|
||||
contact: '', mobile: '', address: '', floor: 1, has_elevator: 1,
|
||||
goods_model: '', goods_num: 1, remark: ''
|
||||
});
|
||||
|
||||
let serviceId = 0;
|
||||
|
||||
async function calc() {
|
||||
if (!serviceId) 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
|
||||
});
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
watch([urgent, () => form.floor, () => form.has_elevator], () => calc());
|
||||
|
||||
function onDate(e) { date.value = e.detail.value; }
|
||||
function onTime(e) { time.value = e.detail.value; }
|
||||
function stepFloor(d) { form.floor = Math.max(1, form.floor + d); }
|
||||
function stepNum(d) { form.goods_num = Math.max(1, form.goods_num + d); }
|
||||
|
||||
async function loadAddress() {
|
||||
try {
|
||||
const res = await api.addressList();
|
||||
addresses.value = res.list || [];
|
||||
address.value = addresses.value.find(a => Number(a.is_default) === 1) || addresses.value[0] || null;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function pickAddress() {
|
||||
const names = addresses.value.map(a => (a.contact + ' ' + a.address).slice(0, 14));
|
||||
names.push('+ 新增地址');
|
||||
uni.showActionSheet({
|
||||
itemList: names,
|
||||
success: (r) => {
|
||||
if (r.tapIndex === addresses.value.length) {
|
||||
address.value = null;
|
||||
form.contact = '';
|
||||
form.address = '';
|
||||
} else {
|
||||
address.value = addresses.value[r.tapIndex];
|
||||
calc();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function saveAddress() {
|
||||
if (!form.contact || !form.mobile || !form.address) {
|
||||
uni.showToast({ title: '请填写联系人/手机号/地址', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await api.addressSave({
|
||||
contact: form.contact, mobile: form.mobile,
|
||||
province: '贵州省', city: '遵义市', district: '', address: form.address,
|
||||
floor: form.floor, has_elevator: form.has_elevator, is_default: 1
|
||||
});
|
||||
await loadAddress();
|
||||
const hit = addresses.value.find(a => Number(a.id) === Number(res.id));
|
||||
if (hit) address.value = hit;
|
||||
calc();
|
||||
uni.showToast({ title: '地址已保存' });
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (submitting.value) return;
|
||||
if (!isLogin()) { toLogin(); return; }
|
||||
if (!address.value) { 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);
|
||||
const res = await api.orderCreate({
|
||||
service_id: serviceId,
|
||||
address_id: address.value.id,
|
||||
appoint_time: appoint,
|
||||
urgent: urgent.value ? 1 : 0,
|
||||
goods_model: form.goods_model,
|
||||
goods_num: form.goods_num,
|
||||
remark: form.remark
|
||||
});
|
||||
await api.orderPay({ order_id: res.order_id, pay_type: 'mock' });
|
||||
uni.showToast({ title: '支付成功,等待师傅接单' });
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({ url: '/pages/order/detail?id=' + res.order_id });
|
||||
}, 600);
|
||||
} catch (e) {
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onLoad(async (options) => {
|
||||
if (!isLogin()) { toLogin(); return; }
|
||||
serviceId = Number(options.service_id || 0);
|
||||
const res = await api.serviceDetail(serviceId);
|
||||
svc.value = res.detail;
|
||||
await loadAddress();
|
||||
calc();
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 180rpx; }
|
||||
.svc {
|
||||
display: flex; align-items: center; padding: 26rpx 28rpx;
|
||||
background: linear-gradient(160deg, #FFB85C 0%, #F98D25 60%, #ED6F0E 100%);
|
||||
}
|
||||
.svc-thumb {
|
||||
width: 96rpx; height: 96rpx; border-radius: 18rpx; flex-shrink: 0;
|
||||
background: rgba(255,255,255,0.92); display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.svc-txt { font-size: 28rpx; font-weight: 700; color: #B85E2A; }
|
||||
.svc-info { flex: 1; margin-left: 18rpx; display: flex; flex-direction: column; }
|
||||
.svc-name { font-size: 32rpx; font-weight: 700; color: #fff; }
|
||||
.svc-price { margin-top: 6rpx; font-size: 24rpx; color: rgba(255,255,255,0.9); }
|
||||
.urgent {
|
||||
flex-shrink: 0; padding: 0 22rpx; line-height: 56rpx; border-radius: 28rpx;
|
||||
background: rgba(255,255,255,0.2); border: 2rpx solid rgba(255,255,255,0.5);
|
||||
}
|
||||
.urgent.on { background: #fff; border-color: #fff; }
|
||||
.urgent-txt { font-size: 22rpx; color: #fff; }
|
||||
.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; }
|
||||
.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; }
|
||||
.addr-d { margin-top: 6rpx; font-size: 24rpx; color: #666; line-height: 34rpx; }
|
||||
.addr-x { margin-top: 6rpx; font-size: 22rpx; color: #9A9A9A; }
|
||||
.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 #F4F4F4; }
|
||||
.fk { width: 150rpx; font-size: 26rpx; color: #666; }
|
||||
.fv { flex: 1; height: 88rpx; font-size: 28rpx; color: #222; }
|
||||
.fv2 { flex: 1; font-size: 28rpx; color: #222; }
|
||||
.arrow { font-size: 30rpx; color: #C4C4C4; }
|
||||
.stepper { display: flex; align-items: center; }
|
||||
.st-btn { width: 52rpx; height: 52rpx; line-height: 50rpx; text-align: center; border-radius: 26rpx; background: #F5F5F5; color: #666; font-size: 26rpx; }
|
||||
.st-val { min-width: 60rpx; text-align: center; font-size: 28rpx; color: #222; }
|
||||
.seg { display: flex; }
|
||||
.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; }
|
||||
.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; }
|
||||
.bar {
|
||||
position: fixed; left: 0; right: 0; bottom: 0; height: 120rpx;
|
||||
padding: 0 28rpx; padding-bottom: env(safe-area-inset-bottom);
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
background: #fff; box-shadow: 0 -6rpx 24rpx rgba(0,0,0,0.07);
|
||||
}
|
||||
.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: flex; align-items: center;
|
||||
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>
|
||||
|
||||
168
pages/order/detail.vue
普通文件
168
pages/order/detail.vue
普通文件
@@ -0,0 +1,168 @@
|
||||
<template>
|
||||
<view class="page" v-if="order">
|
||||
<view class="hero">
|
||||
<text class="hero-status">{{ order.status_text }}</text>
|
||||
<text class="hero-tip">{{ statusTip }}</text>
|
||||
</view>
|
||||
|
||||
<view class="card" v-if="master">
|
||||
<view class="card-title">服务师傅</view>
|
||||
<view class="master">
|
||||
<view class="avatar"><text class="avatar-txt">{{ (master.realname || '师').slice(0, 1) }}</text></view>
|
||||
<view class="m-info">
|
||||
<text class="m-name">{{ master.realname }}</text>
|
||||
<text class="m-sub">评分 {{ master.score }} · 完成 {{ master.order_count }} 单</text>
|
||||
</view>
|
||||
<text class="m-mobile">{{ master.mobile }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="card-title">服务信息</view>
|
||||
<view class="li"><text class="k">服务项目</text><text class="v">{{ order.service_name }}</text></view>
|
||||
<view class="li"><text class="k">订单号</text><text class="v">{{ order.order_no }}</text></view>
|
||||
<view class="li"><text class="k">联系人</text><text class="v">{{ order.contact }} {{ order.mobile }}</text></view>
|
||||
<view class="li"><text class="k">服务地址</text><text class="v">{{ order.province }}{{ order.city }}{{ order.district }}{{ order.address }}</text></view>
|
||||
<view class="li"><text class="k">楼层</text><text class="v">{{ order.floor }} 层 · {{ Number(order.has_elevator) ? '有电梯' : '无电梯' }}</text></view>
|
||||
<view class="li"><text class="k">预约时间</text><text class="v">{{ order.appoint_text }}</text></view>
|
||||
<view class="li" v-if="order.goods_model"><text class="k">商品型号</text><text class="v">{{ order.goods_model }}</text></view>
|
||||
<view class="li" v-if="order.remark"><text class="k">备注</text><text class="v">{{ order.remark }}</text></view>
|
||||
<view class="li" v-if="Number(order.urgent)"><text class="k">加急</text><text class="v">是(+20%)</text></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" v-if="Number(order.urgent_amount) > 0"><text class="k">加急费</text><text class="v">¥{{ order.urgent_amount }}</text></view>
|
||||
<view class="li"><text class="k">实付</text><text class="v big">¥{{ order.pay_amount }}</text></view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="card-title">订单轨迹</view>
|
||||
<view class="tl" v-for="(l, i) in logs" :key="i">
|
||||
<view class="dot" :class="{ on: i === logs.length - 1 }"></view>
|
||||
<view class="tl-body">
|
||||
<text class="tl-s">{{ l.status_text }}</text>
|
||||
<text class="tl-r">{{ l.remark }}</text>
|
||||
<text class="tl-t">{{ l.time_text }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card" v-if="media.length">
|
||||
<view class="card-title">现场取证</view>
|
||||
<view class="media">
|
||||
<view class="media-i" v-for="(m, i) in media" :key="i">
|
||||
<text class="media-txt">{{ m.stage === 'damage' ? '损坏申报' : '完工照片' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bar">
|
||||
<view class="op" v-if="order.can_cancel" @tap="cancel">取消订单</view>
|
||||
<view class="op primary" v-if="order.can_pay" @tap="pay">去支付</view>
|
||||
<view class="op primary" v-if="order.can_verify" @tap="verify">确认验收</view>
|
||||
<view class="op primary" v-if="order.can_review" @tap="review">去评价</view>
|
||||
<view class="op" @tap="backHome">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { onShow, onLoad } from '@dcloudio/uni-app';
|
||||
import api from '@/utils/api.js';
|
||||
|
||||
const order = ref(null);
|
||||
const master = ref(null);
|
||||
const logs = ref([]);
|
||||
const media = ref([]);
|
||||
let orderId = 0;
|
||||
|
||||
const statusTip = computed(() => {
|
||||
if (!order.value) return '';
|
||||
const tips = {
|
||||
0: '请尽快完成支付', 1: '已进入接单大厅,等待师傅接单', 2: '师傅报价中,请稍候',
|
||||
3: '师傅已接单,将尽快与您联系', 4: '已约定上门时间', 5: '师傅已到达现场',
|
||||
6: '服务进行中', 7: '师傅已完工,请确认验收', 8: '订单已完成,感谢您的信任',
|
||||
9: '订单已取消', 10: '售后处理中'
|
||||
};
|
||||
return tips[order.value.status] || '';
|
||||
});
|
||||
|
||||
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 || [];
|
||||
}
|
||||
|
||||
function toast(t) { uni.showToast({ title: t, icon: 'none' }); }
|
||||
function backHome() { uni.reLaunch({ url: '/YJYF/YJYF' }); }
|
||||
|
||||
function cancel() {
|
||||
uni.showModal({
|
||||
title: '取消订单', content: '确认取消该订单?',
|
||||
success: async (r) => {
|
||||
if (!r.confirm) return;
|
||||
try { await api.orderCancel({ order_id: orderId, reason: '用户取消' }); toast('已取消'); load(); } catch (e) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
async function pay() {
|
||||
try { await api.orderPay({ order_id: orderId, pay_type: 'mock' }); toast('支付成功'); load(); } catch (e) {}
|
||||
}
|
||||
function verify() {
|
||||
uni.showModal({
|
||||
title: '确认验收', content: '验收后平台将向师傅结算,确认服务已完成?',
|
||||
success: async (r) => {
|
||||
if (!r.confirm) return;
|
||||
try { await api.orderVerify({ order_id: orderId }); toast('验收成功'); load(); } catch (e) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
function review() { uni.navigateTo({ url: '/pages/order/review?id=' + orderId }); }
|
||||
|
||||
onLoad((o) => { orderId = Number(o.id || 0); });
|
||||
onShow(() => { if (orderId) load(); });
|
||||
</script>
|
||||
<style scoped>
|
||||
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 160rpx; }
|
||||
.hero { padding: 40rpx 36rpx; background: linear-gradient(160deg, #FFB85C 0%, #F98D25 60%, #ED6F0E 100%); }
|
||||
.hero-status { display: block; font-size: 40rpx; font-weight: 700; color: #fff; letter-spacing: 2rpx; }
|
||||
.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; }
|
||||
.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; }
|
||||
.v.big { font-size: 34rpx; font-weight: 700; color: #F0710D; }
|
||||
.master { display: flex; align-items: center; }
|
||||
.avatar { width: 76rpx; height: 76rpx; border-radius: 50%; background: #FFF1E3; display: flex; align-items: center; justify-content: center; }
|
||||
.avatar-txt { font-size: 30rpx; font-weight: 700; color: #E88A2C; }
|
||||
.m-info { flex: 1; margin-left: 16rpx; display: flex; flex-direction: column; }
|
||||
.m-name { font-size: 28rpx; font-weight: 600; color: #222; }
|
||||
.m-sub { margin-top: 4rpx; font-size: 22rpx; color: #9A9A9A; }
|
||||
.m-mobile { font-size: 24rpx; color: #666; }
|
||||
.tl { display: flex; padding: 10rpx 0; }
|
||||
.dot { width: 14rpx; height: 14rpx; margin: 8rpx 16rpx 0 0; border-radius: 50%; background: #E0E0E0; flex-shrink: 0; }
|
||||
.dot.on { background: #F0710D; box-shadow: 0 0 0 6rpx rgba(240,113,13,0.15); }
|
||||
.tl-body { flex: 1; display: flex; flex-direction: column; }
|
||||
.tl-s { font-size: 26rpx; font-weight: 600; color: #333; }
|
||||
.tl-r { margin-top: 2rpx; font-size: 22rpx; color: #9A9A9A; }
|
||||
.tl-t { margin-top: 2rpx; font-size: 20rpx; color: #C4C4C4; }
|
||||
.media { display: flex; flex-wrap: wrap; }
|
||||
.media-i { width: 150rpx; height: 110rpx; margin: 0 12rpx 12rpx 0; border-radius: 12rpx; background: linear-gradient(160deg,#FFF7F0,#FCE9D6); display: flex; align-items: center; justify-content: center; }
|
||||
.media-txt { font-size: 20rpx; color: #B85E2A; }
|
||||
.bar {
|
||||
position: fixed; left: 0; right: 0; bottom: 0; height: 118rpx;
|
||||
padding: 0 24rpx; padding-bottom: env(safe-area-inset-bottom);
|
||||
display: flex; align-items: center; justify-content: flex-end;
|
||||
background: #fff; box-shadow: 0 -6rpx 24rpx rgba(0,0,0,0.07);
|
||||
}
|
||||
.op { margin-left: 16rpx; padding: 0 28rpx; line-height: 68rpx; border-radius: 34rpx; border: 2rpx solid #DDD; font-size: 26rpx; color: #666; }
|
||||
.op.primary { border-color: #F0710D; color: #fff; background: linear-gradient(135deg,#FFA93F 0%,#F0710D 100%); }
|
||||
</style>
|
||||
|
||||
130
pages/order/list.vue
普通文件
130
pages/order/list.vue
普通文件
@@ -0,0 +1,130 @@
|
||||
<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" @tap="goDetail(o.id)">
|
||||
<view class="hd">
|
||||
<text class="no">{{ o.order_no }}</text>
|
||||
<text class="status" :class="'s' + o.status">{{ o.status_text }}</text>
|
||||
</view>
|
||||
<view class="bd">
|
||||
<view class="thumb"><text class="thumb-txt">{{ (o.service_name || '').slice(0, 2) }}</text></view>
|
||||
<view class="mi">
|
||||
<text class="sname">{{ o.service_name }}</text>
|
||||
<text class="saddr">{{ o.address }}</text>
|
||||
<text class="stime">预约 {{ o.appoint_text }}{{ Number(o.urgent) ? ' · 急单' : '' }}</text>
|
||||
</view>
|
||||
<text class="amt">¥{{ o.pay_amount }}</text>
|
||||
</view>
|
||||
<view class="ops" v-if="o.can_pay || o.can_cancel || o.can_verify || o.can_review">
|
||||
<view class="op" v-if="o.can_cancel" @tap.stop="cancel(o)">取消订单</view>
|
||||
<view class="op primary" v-if="o.can_pay" @tap.stop="pay(o)">去支付</view>
|
||||
<view class="op primary" v-if="o.can_verify" @tap.stop="verify(o)">确认验收</view>
|
||||
<view class="op primary" v-if="o.can_review" @tap.stop="review(o)">去评价</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="empty" v-if="!loading && !list.length"><text>暂无订单</text></view>
|
||||
<view class="tip" v-if="list.length"><text>仅展示前 {{ list.length }} 条</text></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import api from '@/utils/api.js';
|
||||
import { isLogin, toLogin } from '@/utils/request.js';
|
||||
|
||||
const tabs = [
|
||||
{ key: 'all', name: '全部' },
|
||||
{ key: 'active', name: '进行中' },
|
||||
{ key: 'completed', name: '已完成' },
|
||||
{ key: 'cancelled', name: '已取消' }
|
||||
];
|
||||
const cur = ref('all');
|
||||
const list = ref([]);
|
||||
const loading = ref(false);
|
||||
|
||||
async function load() {
|
||||
if (!isLogin()) { toLogin(); return; }
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await api.orderList({ status: cur.value, limit: 20 });
|
||||
list.value = res.list || [];
|
||||
} catch (e) {
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function switchTab(k) {
|
||||
cur.value = k;
|
||||
load();
|
||||
}
|
||||
function goDetail(id) {
|
||||
uni.navigateTo({ url: '/pages/order/detail?id=' + id });
|
||||
}
|
||||
function toast(t) { uni.showToast({ title: t, icon: 'none' }); }
|
||||
|
||||
function cancel(o) {
|
||||
uni.showModal({
|
||||
title: '取消订单', content: '确认取消该订单?',
|
||||
success: async (r) => {
|
||||
if (!r.confirm) return;
|
||||
try { await api.orderCancel({ order_id: o.id, reason: '用户取消' }); toast('已取消'); load(); } catch (e) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
async function pay(o) {
|
||||
try { await api.orderPay({ order_id: o.id, pay_type: 'mock' }); toast('支付成功'); load(); } catch (e) {}
|
||||
}
|
||||
function verify(o) {
|
||||
uni.showModal({
|
||||
title: '确认验收', content: '请确认服务已完成,验收后平台将向师傅结算',
|
||||
success: async (r) => {
|
||||
if (!r.confirm) return;
|
||||
try { await api.orderVerify({ order_id: o.id }); toast('验收成功'); load(); } catch (e) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
function review(o) {
|
||||
uni.navigateTo({ url: '/pages/order/review?id=' + o.id });
|
||||
}
|
||||
|
||||
onShow(() => load());
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page { min-height: 100vh; background: #F5F6F8; padding-bottom: 40rpx; }
|
||||
.tabs { display: flex; background: #fff; padding: 0 12rpx; 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: 20rpx 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; justify-content: space-between; align-items: center; padding-bottom: 16rpx; border-bottom: 1rpx solid #F4F4F4; }
|
||||
.no { font-size: 22rpx; color: #9A9A9A; }
|
||||
.status { font-size: 24rpx; font-weight: 600; color: #F0710D; }
|
||||
.status.s8 { color: #2FA84F; }
|
||||
.status.s9 { color: #9A9A9A; }
|
||||
.status.s7 { color: #E8331B; }
|
||||
.bd { display: flex; align-items: center; padding: 20rpx 0; }
|
||||
.thumb { width: 92rpx; height: 92rpx; border-radius: 16rpx; flex-shrink: 0; background: linear-gradient(160deg,#FFF7F0,#FCE9D6); display: flex; align-items: center; justify-content: center; }
|
||||
.thumb-txt { font-size: 26rpx; font-weight: 700; color: #B85E2A; }
|
||||
.mi { flex: 1; min-width: 0; margin-left: 18rpx; display: flex; flex-direction: column; }
|
||||
.sname { font-size: 28rpx; font-weight: 600; color: #1F1F1F; }
|
||||
.saddr { margin-top: 6rpx; font-size: 22rpx; color: #9A9A9A; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
||||
.stime { margin-top: 6rpx; font-size: 22rpx; color: #9A9A9A; }
|
||||
.amt { font-size: 32rpx; font-weight: 700; color: #F0710D; }
|
||||
.ops { display: flex; justify-content: flex-end; padding-top: 16rpx; border-top: 1rpx solid #F4F4F4; }
|
||||
.op { margin-left: 16rpx; padding: 0 26rpx; line-height: 60rpx; border-radius: 30rpx; border: 2rpx solid #DDD; font-size: 24rpx; color: #666; }
|
||||
.op.primary { border-color: #F0710D; color: #F0710D; background: #FFF7F0; }
|
||||
.empty { padding: 120rpx 0; text-align: center; font-size: 24rpx; color: #9A9A9A; }
|
||||
.tip { text-align: center; font-size: 20rpx; color: #C4C4C4; }
|
||||
</style>
|
||||
99
pages/order/review.vue
普通文件
99
pages/order/review.vue
普通文件
@@ -0,0 +1,99 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="card">
|
||||
<view class="title">给本次服务打分</view>
|
||||
<view class="stars">
|
||||
<text v-for="i in 5" :key="i" class="star" :class="{ on: i <= score }" @tap="score = i">★</text>
|
||||
</view>
|
||||
<text class="score-txt">{{ scoreText }}</text>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="title">服务标签</view>
|
||||
<view class="tags">
|
||||
<view v-for="t in tagList" :key="t" class="tag" :class="{ on: tags.indexOf(t) > -1 }" @tap="toggleTag(t)">
|
||||
<text class="tag-txt">{{ t }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card">
|
||||
<view class="title">评价内容</view>
|
||||
<textarea class="ta" v-model="content" maxlength="200" placeholder="说说师傅的服务、专业度和态度..." />
|
||||
<view class="anon">
|
||||
<text class="anon-txt">匿名评价</text>
|
||||
<switch :checked="anonymous" color="#F0710D" @change="e => (anonymous = e.detail.value)" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="submit" :class="{ disabled: submitting }" @tap="submit">{{ submitting ? '提交中...' : '提交评价' }}</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import api from '@/utils/api.js';
|
||||
|
||||
const score = ref(5);
|
||||
const tags = ref([]);
|
||||
const content = ref('');
|
||||
const anonymous = ref(false);
|
||||
const submitting = ref(false);
|
||||
const tagList = ['准时', '专业', '态度好', '收费透明', '干净利落', '值得推荐'];
|
||||
let orderId = 0;
|
||||
|
||||
const scoreText = computed(() => ['', '非常不满意', '不满意', '一般', '满意', '非常满意'][score.value]);
|
||||
|
||||
function toggleTag(t) {
|
||||
const i = tags.value.indexOf(t);
|
||||
if (i > -1) tags.value.splice(i, 1);
|
||||
else tags.value.push(t);
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (submitting.value) return;
|
||||
submitting.value = true;
|
||||
try {
|
||||
await api.reviewCreate({
|
||||
order_id: orderId,
|
||||
score: score.value,
|
||||
content: content.value,
|
||||
tags: tags.value.join(','),
|
||||
is_anonymous: anonymous.value ? 1 : 0
|
||||
});
|
||||
uni.showToast({ title: '评价成功' });
|
||||
setTimeout(() => uni.navigateBack(), 600);
|
||||
} catch (e) {
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onLoad((o) => { orderId = Number(o.id || 0); });
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page { min-height: 100vh; background: #F5F6F8; padding: 22rpx 28rpx 60rpx; }
|
||||
.card { padding: 26rpx 24rpx; background: #fff; border-radius: 20rpx; margin-bottom: 20rpx; box-shadow: 0 6rpx 20rpx rgba(240,129,31,0.06); }
|
||||
.title { font-size: 28rpx; font-weight: 700; color: #1F1F1F; }
|
||||
.stars { display: flex; justify-content: center; padding: 20rpx 0 8rpx; }
|
||||
.star { font-size: 60rpx; color: #E6E6E6; margin: 0 12rpx; }
|
||||
.star.on { color: #FFB120; }
|
||||
.score-txt { display: block; text-align: center; font-size: 24rpx; color: #F0710D; }
|
||||
.tags { display: flex; flex-wrap: wrap; padding-top: 14rpx; }
|
||||
.tag { padding: 0 22rpx; line-height: 56rpx; margin: 0 14rpx 14rpx 0; border-radius: 28rpx; background: #F5F5F5; }
|
||||
.tag.on { background: #FFF3E6; }
|
||||
.tag-txt { font-size: 24rpx; color: #666; }
|
||||
.tag.on .tag-txt { color: #E36B0C; font-weight: 600; }
|
||||
.ta { width: 100%; height: 180rpx; margin-top: 14rpx; font-size: 26rpx; color: #333; line-height: 38rpx; }
|
||||
.anon { display: flex; align-items: center; justify-content: space-between; margin-top: 10rpx; }
|
||||
.anon-txt { font-size: 26rpx; color: #666; }
|
||||
.submit {
|
||||
height: 96rpx; margin-top: 30rpx; display: flex; align-items: center; justify-content: center;
|
||||
border-radius: 48rpx; color: #fff; font-size: 32rpx; font-weight: 600;
|
||||
background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%);
|
||||
box-shadow: 0 10rpx 24rpx rgba(240,113,13,0.3);
|
||||
}
|
||||
.submit.disabled { opacity: 0.7; }
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户