chore(master): 重构师傅端 tabbar 为独立页面路由模式

- 新增 tabbar 配置,改为独立页面路由
- 替换所有 reLaunch 为 switchTab 跳转 tab 页面
- 新增未读消息角标同步逻辑
- 移除旧的多 tab 组件化实现
- 新增 tabbar 图标资源文件
这个提交包含在:
2026-11-28 09:24:48 +08:00
父节点 4e69f326e5
当前提交 cb32db0984
共有 28 个文件被更改,包括 125 次插入 和 117 次删除

查看文件

@@ -1,7 +1,30 @@
<script>
import api from '@/utils/api.js';
import { isLogin } from '@/utils/request.js';
let lastNavUrl = '';
let lastNavAt = 0;
async function syncMasterTabBadge() {
if (!isLogin()) {
uni.removeTabBarBadge({ index: 2, fail: () => {} });
return;
}
try {
const res = await api.messageUnread({ type: 'master' });
const count = Number(res?.unread || 0);
if (count > 0) {
uni.setTabBarBadge({
index: 2,
text: count > 99 ? '99+' : String(count),
fail: () => {}
});
} else {
uni.removeTabBarBadge({ index: 2, fail: () => {} });
}
} catch (e) {}
}
export default {
onLaunch: function() {
// #ifdef MP-WEIXIN
@@ -11,6 +34,7 @@
});
}
// #endif
uni.$on('yjyf:refreshUnread', syncMasterTabBadge);
if (typeof uni !== 'undefined' && typeof uni.addInterceptor === 'function') {
uni.addInterceptor('navigateTo', {
invoke(args) {
@@ -27,7 +51,7 @@
}
},
onShow: function() {
console.log('App Show')
syncMasterTabBadge();
},
onHide: function() {
console.log('App Hide')

查看文件

@@ -66,10 +66,10 @@
type: Number,
default: 0
},
// false:单母页组件切换模式,0ms 极速秒切不销毁组件
// true:独立页面路由切换模式
standalone: {
type: Boolean,
default: false
default: true
}
});
@@ -104,9 +104,9 @@
const TAB_ROUTES = [
'/pages/master/hall',
'/pages/master/hall?tab=1',
'/pages/master/hall?tab=2',
'/pages/master/hall?tab=3'
'/pages/master/orders',
'/pages/message/message',
'/pages/master/workbench'
];
function switchTab(index) {
@@ -123,7 +123,7 @@
const targetUrl = TAB_ROUTES[index];
if (targetUrl) {
uni.reLaunch({ url: targetUrl });
uni.switchTab({ url: targetUrl });
}
}
</script>

查看文件

@@ -195,18 +195,18 @@
if (pages.length > 1) {
uni.navigateBack({
fail: () => {
uni.reLaunch({ url: '/pages/master/hall' });
uni.switchTab({ url: '/pages/master/hall' });
}
});
} else {
// 单层页面栈(如分享页、直接跳转页),智能兜底返回接单大厅
uni.reLaunch({ url: '/pages/master/hall' });
uni.switchTab({ url: '/pages/master/hall' });
}
}
function handleHome() {
emit('home');
uni.reLaunch({ url: '/pages/master/hall' });
uni.switchTab({ url: '/pages/master/hall' });
}
</script>

查看文件

@@ -922,8 +922,7 @@
@import '@/uni.scss';
.hall-view {
height: calc(100vh - 112rpx - constant(safe-area-inset-bottom));
height: calc(100vh - 112rpx - env(safe-area-inset-bottom));
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;

查看文件

@@ -81,7 +81,7 @@
];
function goMasterLogin() {
toLogin('/pages/master/hall?tab=2');
toLogin('/pages/message/message');
}
async function load() {
@@ -158,8 +158,7 @@
<style lang="scss" scoped>
.message-view {
height: calc(100vh - 112rpx - constant(safe-area-inset-bottom));
height: calc(100vh - 112rpx - env(safe-area-inset-bottom));
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;

查看文件

@@ -216,7 +216,7 @@
}
function goMasterLogin() {
toLogin('/pages/master/hall?tab=1');
toLogin('/pages/master/orders');
}
async function load() {
@@ -333,7 +333,7 @@
emit('switch-tab', 0);
return;
}
uni.reLaunch({ url: '/pages/master/hall' });
uni.switchTab({ url: '/pages/master/hall' });
}
onMounted(() => {
@@ -444,7 +444,7 @@
/* 列表卡片 */
.list {
padding: 24rpx 24rpx calc(140rpx + env(safe-area-inset-bottom));
padding: 24rpx 24rpx 48rpx;
display: flex;
flex-direction: column;
gap: 20rpx;

查看文件

@@ -429,7 +429,7 @@
}
function goMasterLogin() {
toLogin('/pages/master/hall?tab=3');
toLogin('/pages/master/workbench');
}
function go(url) {
@@ -449,7 +449,7 @@
emit('switch-tab', 1);
return;
}
uni.reLaunch({ url: '/pages/master/hall?tab=1' });
uni.switchTab({ url: '/pages/master/orders' });
}
function goSkills() {
@@ -634,8 +634,7 @@
<style lang="scss" scoped>
.workbench-view {
height: calc(100vh - 112rpx - constant(safe-area-inset-bottom));
height: calc(100vh - 112rpx - env(safe-area-inset-bottom));
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;

查看文件

@@ -120,5 +120,37 @@
"navigationBarBackgroundColor": "#F0710D",
"backgroundColor": "#F5F6F8"
},
"tabBar": {
"color": "#9A9A9A",
"selectedColor": "#F0710D",
"backgroundColor": "#FFFFFF",
"borderStyle": "black",
"list": [
{
"pagePath": "pages/master/hall",
"text": "大厅",
"iconPath": "static/tabbar/master/hall-store.png",
"selectedIconPath": "static/tabbar/master/hall-store-active.png"
},
{
"pagePath": "pages/master/orders",
"text": "订单",
"iconPath": "static/tabbar/master/orders.png",
"selectedIconPath": "static/tabbar/master/orders-active.png"
},
{
"pagePath": "pages/message/message",
"text": "消息",
"iconPath": "static/tabbar/master/msg.png",
"selectedIconPath": "static/tabbar/master/msg-active.png"
},
{
"pagePath": "pages/master/workbench",
"text": "我的",
"iconPath": "static/tabbar/master/work.png",
"selectedIconPath": "static/tabbar/master/work-active.png"
}
]
},
"uniIdRouter": {}
}

查看文件

@@ -267,7 +267,7 @@
if (getCurrentPages().length > 1) {
uni.navigateBack();
} else {
uni.reLaunch({ url: '/pages/master/hall' });
uni.switchTab({ url: '/pages/master/hall' });
}
}

查看文件

@@ -421,15 +421,15 @@
function handleBackOrHome() {
if (getCurrentPages().length > 1) {
uni.navigateBack({
fail: () => uni.reLaunch({ url: '/pages/master/hall' })
fail: () => uni.switchTab({ url: '/pages/master/hall' })
});
} else {
uni.reLaunch({ url: '/pages/master/hall' });
uni.switchTab({ url: '/pages/master/hall' });
}
}
function handleSkip() {
uni.reLaunch({ url: '/pages/master/hall' });
uni.switchTab({ url: '/pages/master/hall' });
}
function safeVibrate() {
@@ -558,17 +558,17 @@
redirectUrl.startsWith('/pages/master/workbench') ||
redirectUrl.startsWith('/pages/message/message')
) {
uni.reLaunch({ url: redirectUrl });
uni.switchTab({ url: redirectUrl.split('?')[0] });
} else {
uni.redirectTo({
url: redirectUrl,
fail: () => uni.reLaunch({ url: '/pages/master/hall' })
fail: () => uni.switchTab({ url: '/pages/master/hall' })
});
}
return;
}
uni.reLaunch({ url: '/pages/master/hall' });
uni.switchTab({ url: '/pages/master/hall' });
}
function openAgreement(type) {

查看文件

@@ -426,7 +426,7 @@
}
function goWorkbench() {
uni.reLaunch({ url: '/pages/master/hall?tab=3' });
uni.switchTab({ url: '/pages/master/workbench' });
}
function openAgreement() {
@@ -655,7 +655,7 @@
setUser(u);
uni.showToast({ title: '提交成功,等待审核', icon: 'success' });
setTimeout(() => {
uni.reLaunch({ url: '/pages/master/hall?tab=3' });
uni.switchTab({ url: '/pages/master/workbench' });
}, 1200);
} catch (e) {
// request.js 已统一弹出具体失败原因 Toast,此处保留 submits 防重恢复即可

查看文件

@@ -415,7 +415,7 @@
uni.showToast({ title: '提交成功,等待审核', icon: 'success' });
setTimeout(() => {
uni.navigateBack({
fail: () => uni.reLaunch({ url: '/pages/master/hall?tab=3' })
fail: () => uni.switchTab({ url: '/pages/master/workbench' })
});
}, 1200);
} catch (e) {

查看文件

@@ -1309,7 +1309,7 @@
}
function goOrdersList() {
uni.reLaunch({ url: '/pages/master/hall?tab=1' });
uni.switchTab({ url: '/pages/master/orders' });
}
onLoad((opts) => {

查看文件

@@ -1,50 +1,25 @@
<template>
<view class="master-container-page">
<!-- 1. 抢单大厅 (Tab 0) -->
<view class="tab-pane" v-if="visitedTabs[0]" v-show="activeTab === 0">
<MasterHallView ref="hallRef" @switch-tab="onTabChange" />
</view>
<!-- 2. 我的工单 (Tab 1) -->
<view class="tab-pane" v-if="visitedTabs[1]" v-show="activeTab === 1">
<MasterOrdersView ref="ordersRef" :in-container="true" @switch-tab="onTabChange" />
</view>
<!-- 3. 消息 (Tab 2) -->
<view class="tab-pane" v-if="visitedTabs[2]" v-show="activeTab === 2">
<MasterMessageView ref="messageRef" @switch-tab="onTabChange" />
</view>
<!-- 4. 工作台 (Tab 3) -->
<view class="tab-pane" v-if="visitedTabs[3]" v-show="activeTab === 3">
<MasterWorkbenchView ref="workbenchRef" :in-container="true" @switch-tab="onTabChange" />
</view>
<!-- 全局统一师傅端底部导航(单母页组件化调度,0ms 极速秒切不闪烁) -->
<YjyfMasterTabBar :current="activeTab" :standalone="false" @change="onTabChange" />
<view class="master-hall-page">
<MasterHallView ref="hallRef" />
<YjyfPrivacyPopup />
</view>
</template>
<script setup>
import { ref, reactive } from 'vue';
import { ref } from 'vue';
import { onLoad, onShow } 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';
import YjyfPrivacyPopup from '@/components/YjyfPrivacyPopup.vue';
import { useShare } from '@/utils/share.js';
const activeTab = ref(0);
const visitedTabs = reactive({ 0: true, 1: false, 2: false, 3: false });
const hallRef = ref(null);
let initialShown = false;
const hallRef = ref(null);
const ordersRef = ref(null);
const messageRef = ref(null);
const workbenchRef = ref(null);
const LEGACY_TAB_ROUTES = {
1: '/pages/master/orders',
2: '/pages/message/message',
3: '/pages/master/workbench'
};
useShare(() => ({
title: '优匠优服 · 师傅接单大厅,海量同城好单实时派发',
@@ -52,41 +27,11 @@
query: ''
}));
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 (isNaN(targetIndex) || targetIndex < 0 || targetIndex > 3) return;
if (activeTab.value === targetIndex) return;
const firstVisit = !visitedTabs[targetIndex];
visitedTabs[targetIndex] = true;
activeTab.value = targetIndex;
if (!firstVisit) {
setTimeout(() => {
refreshCurrentTab();
}, 0);
}
}
onLoad((query) => {
if (query && query.tab !== undefined) {
const t = parseInt(query.tab);
if (!isNaN(t) && t >= 0 && t <= 3) {
if (t !== 0) {
visitedTabs[0] = false;
}
visitedTabs[t] = true;
activeTab.value = t;
const targetUrl = LEGACY_TAB_ROUTES[parseInt(query.tab)];
if (targetUrl) {
uni.switchTab({ url: targetUrl });
}
}
});
@@ -96,20 +41,17 @@
initialShown = true;
return;
}
refreshCurrentTab();
if (hallRef.value?.load) {
hallRef.value.load();
}
uni.$emit('yjyf:refreshUnread');
});
</script>
<style scoped>
.master-container-page {
.master-hall-page {
height: 100vh;
overflow: hidden;
background: #F5F6F8;
}
.tab-pane {
width: 100%;
height: 100%;
}
</style>

查看文件

@@ -1135,7 +1135,7 @@
if (pages.length > 1) {
uni.navigateBack();
} else {
uni.reLaunch({ url: '/pages/master/hall' });
uni.switchTab({ url: '/pages/master/hall' });
}
}, 360);
} catch (e) {

查看文件

@@ -1,7 +1,7 @@
<template>
<view class="master-orders-page">
<MasterOrdersView ref="ordersRef" />
<YjyfMasterTabBar :current="1" :standalone="true" />
<YjyfPrivacyPopup />
</view>
</template>
@@ -9,14 +9,20 @@
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import MasterOrdersView from '@/components/master/MasterOrdersView.vue';
import YjyfMasterTabBar from '@/components/YjyfMasterTabBar.vue';
import YjyfPrivacyPopup from '@/components/YjyfPrivacyPopup.vue';
const ordersRef = ref(null);
let initialShown = false;
onShow(() => {
if (!initialShown) {
initialShown = true;
return;
}
if (ordersRef.value?.load) {
ordersRef.value.load();
}
uni.$emit('yjyf:refreshUnread');
});
</script>

查看文件

@@ -136,7 +136,7 @@
}
function goHall() {
uni.reLaunch({ url: '/pages/master/hall' });
uni.switchTab({ url: '/pages/master/hall' });
}
async function submitQuote() {

查看文件

@@ -179,12 +179,12 @@
if (orderId.value > 0) {
uni.redirectTo({ url: `/pages/master/detail?id=${orderId.value}` });
} else {
uni.reLaunch({ url: '/pages/master/hall?tab=1' });
uni.switchTab({ url: '/pages/master/orders' });
}
}
function goHall() {
uni.reLaunch({ url: '/pages/master/hall' });
uni.switchTab({ url: '/pages/master/hall' });
}
</script>

查看文件

@@ -1,7 +1,7 @@
<template>
<view class="master-workbench-page">
<MasterWorkbenchView ref="workbenchRef" />
<YjyfMasterTabBar :current="3" :standalone="true" />
<YjyfPrivacyPopup />
</view>
</template>
@@ -9,14 +9,20 @@
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import MasterWorkbenchView from '@/components/master/MasterWorkbenchView.vue';
import YjyfMasterTabBar from '@/components/YjyfMasterTabBar.vue';
import YjyfPrivacyPopup from '@/components/YjyfPrivacyPopup.vue';
const workbenchRef = ref(null);
let initialShown = false;
onShow(() => {
if (!initialShown) {
initialShown = true;
return;
}
if (workbenchRef.value?.load) {
workbenchRef.value.load();
}
uni.$emit('yjyf:refreshUnread');
});
</script>

查看文件

@@ -1,7 +1,7 @@
<template>
<view class="page">
<MasterMessageView ref="msgRef" />
<YjyfMasterTabBar :current="2" :standalone="true" />
<YjyfPrivacyPopup />
</view>
</template>
@@ -9,7 +9,7 @@
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import MasterMessageView from '@/components/master/MasterMessageView.vue';
import YjyfMasterTabBar from '@/components/YjyfMasterTabBar.vue';
import YjyfPrivacyPopup from '@/components/YjyfPrivacyPopup.vue';
const msgRef = ref(null);
let initialShown = false;
@@ -22,6 +22,7 @@
if (msgRef.value?.load) {
msgRef.value.load();
}
uni.$emit('yjyf:refreshUnread');
});
</script>

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 964 B

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 914 B

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 1.4 KiB

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 1.4 KiB

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 1.2 KiB

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 1.1 KiB

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 1.0 KiB

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 991 B