- 新增用户消息中心组件 UserMessageView - 新增师傅消息中心组件 MasterMessageView - 新增用户订单列表组件 UserOrdersView - 重构订单列表页,复用独立组件 - 新增系统工具 getWindowInfoSafe 兼容多端系统信息获取 - 重构 TabBar 组件,支持单母页模式和事件回调 - 优化消息跳转逻辑,支持角色自适应 Tab 切换
103 行
2.9 KiB
Vue
103 行
2.9 KiB
Vue
<template>
|
||
<view class="master-container-page">
|
||
<!-- 1. 抢单大厅 (Tab 0) -->
|
||
<view v-show="activeTab === 0">
|
||
<MasterHallView ref="hallRef" />
|
||
</view>
|
||
|
||
<!-- 2. 接单管理 (Tab 1) -->
|
||
<view v-show="activeTab === 1">
|
||
<MasterOrdersView ref="ordersRef" @switch-tab="onTabChange" />
|
||
</view>
|
||
|
||
<!-- 3. 消息中心 (Tab 2) -->
|
||
<view v-show="activeTab === 2">
|
||
<MasterMessageView ref="messageRef" @switch-tab="onTabChange" />
|
||
</view>
|
||
|
||
<!-- 4. 师傅工作台 (Tab 3) -->
|
||
<view v-show="activeTab === 3">
|
||
<MasterWorkbenchView ref="workbenchRef" @switch-tab="onTabChange" />
|
||
</view>
|
||
|
||
<!-- 师傅端专属底部导航 (方案 A:单母页组件化调度,0ms 极速秒切) -->
|
||
<YjyfMasterTabBar :current="activeTab" @change="onTabChange" />
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref } from 'vue';
|
||
import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app';
|
||
import MasterHallView from '@/components/master/MasterHallView.vue';
|
||
import MasterOrdersView from '@/components/master/MasterOrdersView.vue';
|
||
import MasterMessageView from '@/components/master/MasterMessageView.vue';
|
||
import MasterWorkbenchView from '@/components/master/MasterWorkbenchView.vue';
|
||
import YjyfMasterTabBar from '@/components/YjyfMasterTabBar.vue';
|
||
|
||
const activeTab = ref(0);
|
||
|
||
const hallRef = ref(null);
|
||
const ordersRef = ref(null);
|
||
const messageRef = ref(null);
|
||
const workbenchRef = ref(null);
|
||
|
||
function refreshCurrentTab() {
|
||
if (activeTab.value === 0 && hallRef.value?.load) {
|
||
hallRef.value.load();
|
||
} else if (activeTab.value === 1 && ordersRef.value?.load) {
|
||
ordersRef.value.load();
|
||
} else if (activeTab.value === 2 && messageRef.value?.load) {
|
||
messageRef.value.load();
|
||
} else if (activeTab.value === 3 && workbenchRef.value?.load) {
|
||
workbenchRef.value.load();
|
||
}
|
||
}
|
||
|
||
function onTabChange(index) {
|
||
const targetIndex = Number(index);
|
||
if (activeTab.value === targetIndex) return;
|
||
activeTab.value = targetIndex;
|
||
// 切换时静默刷新对应 Tab 数据,保证最新状态
|
||
setTimeout(() => {
|
||
refreshCurrentTab();
|
||
}, 0);
|
||
}
|
||
|
||
onLoad((query) => {
|
||
if (query && query.tab !== undefined) {
|
||
const t = parseInt(query.tab);
|
||
if (!isNaN(t) && t >= 0 && t <= 3) {
|
||
activeTab.value = t;
|
||
}
|
||
}
|
||
});
|
||
|
||
onShow(() => {
|
||
refreshCurrentTab();
|
||
});
|
||
|
||
onPullDownRefresh(async () => {
|
||
try {
|
||
if (activeTab.value === 0 && hallRef.value?.load) {
|
||
await hallRef.value.load();
|
||
} else if (activeTab.value === 1 && ordersRef.value?.load) {
|
||
await ordersRef.value.load();
|
||
} else if (activeTab.value === 2 && messageRef.value?.load) {
|
||
await messageRef.value.load();
|
||
} else if (activeTab.value === 3 && workbenchRef.value?.load) {
|
||
await workbenchRef.value.load();
|
||
}
|
||
} catch (e) {
|
||
} finally {
|
||
uni.stopPullDownRefresh();
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<style scoped>
|
||
.master-container-page {
|
||
min-height: 100vh;
|
||
background: #F5F6F8;
|
||
}
|
||
</style>
|