- 新增用户消息中心组件 UserMessageView - 新增师傅消息中心组件 MasterMessageView - 新增用户订单列表组件 UserOrdersView - 重构订单列表页,复用独立组件 - 新增系统工具 getWindowInfoSafe 兼容多端系统信息获取 - 重构 TabBar 组件,支持单母页模式和事件回调 - 优化消息跳转逻辑,支持角色自适应 Tab 切换
161 行
7.1 KiB
Vue
161 行
7.1 KiB
Vue
<template>
|
|
<view class="user-orders-view">
|
|
<!-- 统一规范顶部橙色导航栏 -->
|
|
<YjyfNavBar theme="orange" title="我的订单" />
|
|
|
|
<view class="tabs">
|
|
<view v-for="t in tabs" :key="t.key" class="tab clickable-hover" :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">
|
|
<image v-if="o.service_image" class="thumb-img" :src="o.service_image" mode="aspectFill" />
|
|
<text v-else 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 clickable-hover" v-if="o.can_cancel" @tap.stop="cancel(o)">取消订单</view>
|
|
<view class="op primary clickable-hover" v-if="o.can_pay" @tap.stop="pay(o)">去支付</view>
|
|
<view class="op primary clickable-hover" v-if="o.can_verify" @tap.stop="verify(o)">确认验收</view>
|
|
<view class="op primary clickable-hover" v-if="o.can_review" @tap.stop="review(o)">去评价</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="empty-state" v-if="!loading && !list.length">
|
|
<view class="empty-badge">
|
|
<image class="empty-badge-img" src="/static/icons/scan-paste.svg" mode="aspectFit" />
|
|
</view>
|
|
<text class="empty-title">暂无相关订单</text>
|
|
<text class="empty-desc">优匠师傅随时待命,准时上门,售后有保障</text>
|
|
<view class="empty-btn clickable-hover" @tap="goOrder">立即找师傅</view>
|
|
</view>
|
|
<view class="tip" v-if="list.length"><text>仅展示前 {{ list.length }} 条</text></view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, onMounted } from 'vue';
|
|
import YjyfNavBar from '@/components/YjyfNavBar.vue';
|
|
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 goOrder() { uni.navigateTo({ url: "/pages/order/quick" }); }
|
|
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 });
|
|
}
|
|
|
|
onMounted(() => {
|
|
load();
|
|
});
|
|
|
|
defineExpose({
|
|
load
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.user-orders-view { 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; overflow: hidden; }
|
|
.thumb-img { width: 100%; height: 100%; }
|
|
.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; }
|
|
|
|
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 120rpx 40rpx 80rpx; }
|
|
.empty-badge-img { width: 56rpx; height: 56rpx; opacity: 0.6; }
|
|
.empty-badge { width: 120rpx; height: 120rpx; line-height: 120rpx; text-align: center; border-radius: 50%; background: #FFF3E6; font-size: 54rpx; margin-bottom: 24rpx; }
|
|
.empty-title { font-size: 30rpx; font-weight: 700; color: #1F1F1F; margin-bottom: 10rpx; }
|
|
.empty-desc { font-size: 24rpx; color: #888888; margin-bottom: 36rpx; text-align: center; line-height: 36rpx; }
|
|
.empty-btn { height: 80rpx; padding: 0 48rpx; display: flex; align-items: center; justify-content: center; border-radius: 40rpx; background: linear-gradient(135deg,#FFA93F 0%,#F0710D 100%); color: #fff; font-size: 28rpx; font-weight: 600; box-shadow: 0 8rpx 20rpx rgba(240,113,13,0.28); }
|
|
|
|
.clickable-hover:active { opacity: 0.85; transform: scale(0.98); }
|
|
</style>
|