feat(app): 重构底部导航为原生 tabbar 并优化页面跳转逻辑

- 新增底部导航栏配置,替换原有多页切换逻辑
- 统一页面跳转使用 switchTab 替代 reLaunch,优化性能
- 新增未读消息角标自动更新功能
- 修复登录后跳转逻辑,兼容旧版 tab 参数
- 调整页面高度为 100vh,修复安全区域适配问题
- 优化订单列表页加载逻辑,支持状态参数传递
这个提交包含在:
2026-11-28 11:29:43 +08:00
父节点 dcd39da1fa
当前提交 f71a12f5fa
共有 28 个文件被更改,包括 316 次插入 和 182 次删除

查看文件

@@ -83,7 +83,7 @@ assert.deepEqual(
}
);
// 5. 首页 / Tab 切页重定向保持 reLaunch 行为不变
// 5. 首页 / Tab 切页重定向走 switchTab,并兼容历史 ?tab=1 映射为 /pages/order/list
assert.deepEqual(
resolvePostLoginAction({
redirectUrl: '/pages/index/index?tab=1&status=wait_pay',
@@ -91,8 +91,20 @@ assert.deepEqual(
pages: [{ route: 'pages/index/index' }, { route: 'pages/login/login' }]
}),
{
type: 'reLaunch',
url: '/pages/index/index?tab=1&status=wait_pay'
type: 'switchTab',
url: '/pages/order/list'
}
);
assert.deepEqual(
resolvePostLoginAction({
redirectUrl: '/pages/mine/mine',
preferBack: false,
pages: [{ route: 'pages/mine/mine' }, { route: 'pages/login/login' }]
}),
{
type: 'switchTab',
url: '/pages/mine/mine'
}
);
@@ -120,7 +132,7 @@ assert.deepEqual(
}),
{
type: 'navigateBack',
fallbackType: 'reLaunch',
fallbackType: 'switchTab',
fallbackUrl: '/pages/index/index'
}
);
@@ -132,7 +144,7 @@ assert.deepEqual(
pages: [{ route: 'pages/login/login' }]
}),
{
type: 'reLaunch',
type: 'switchTab',
url: '/pages/index/index'
}
);

查看文件

@@ -1,9 +1,30 @@
<script>
import api from '@/utils/api.js';
import { isLogin } from '@/utils/request.js';
let lastNavUrl = '';
let lastNavAt = 0;
async function syncUserTabBadge() {
if (!isLogin()) {
uni.removeTabBarBadge({ index: 2, fail: () => {} });
return;
}
try {
const res = await api.messageUnread({ type: 'user' });
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() {
api.getServiceConfig(true).catch(() => {});
@@ -14,6 +35,7 @@
});
}
// #endif
uni.$on('yjyf:refreshUnread', syncUserTabBadge);
if (typeof uni !== 'undefined' && typeof uni.addInterceptor === 'function') {
uni.addInterceptor('navigateTo', {
invoke(args) {
@@ -30,7 +52,7 @@
}
},
onShow: function() {
console.log('App Show')
syncUserTabBadge();
},
onHide: function() {
console.log('App Hide')

查看文件

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

查看文件

@@ -104,9 +104,9 @@
const TAB_ROUTES = [
'/pages/index/index',
'/pages/index/index?tab=1',
'/pages/index/index?tab=2',
'/pages/index/index?tab=3'
'/pages/order/list',
'/pages/message/message',
'/pages/mine/mine'
];
function needLogin(targetUrl) {
@@ -128,7 +128,7 @@
emit('change', index);
if (props.standalone) {
uni.reLaunch({
uni.switchTab({
url: targetUrl
});
}

查看文件

@@ -1234,7 +1234,7 @@
}
const targetUrl = link.replace(/^\/YJYF\/YJYF/, '/pages/index/index');
if (targetUrl === '/pages/index/index') {
uni.reLaunch({ url: targetUrl });
uni.switchTab({ url: targetUrl });
return;
}
uni.navigateTo({ url: targetUrl });
@@ -1264,8 +1264,7 @@
<style lang="scss" scoped>
.home-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;

查看文件

@@ -138,7 +138,7 @@
}
function goLogin() {
toLogin('/pages/index/index?tab=2');
toLogin('/pages/message/message');
}
async function load() {

查看文件

@@ -234,7 +234,7 @@
function go(url) {
if (!isLogin()) {
toLogin('/pages/index/index?tab=3');
toLogin('/pages/mine/mine');
return;
}
uni.navigateTo({ url });
@@ -242,10 +242,13 @@
function goOrders(statusKey = 'all') {
if (!isLogin()) {
toLogin('/pages/index/index?tab=3');
toLogin('/pages/mine/mine');
return;
}
emit('go-orders', statusKey);
try {
uni.setStorageSync('yjyf_pending_order_status', statusKey || 'all');
} catch (e) {}
uni.switchTab({ url: '/pages/order/list' });
}
function showBalanceTip() {
@@ -352,8 +355,7 @@
<style scoped>
.user-mine-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;

查看文件

@@ -328,7 +328,7 @@
const savingTag = ref(false);
function goLogin() {
toLogin('/pages/index/index?tab=1');
toLogin('/pages/order/list');
}
// 加载订单列表
@@ -629,8 +629,7 @@
<style lang="scss" scoped>
.user-orders-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;
@@ -830,7 +829,7 @@
/* 3. 订单列表主体 */
.list-container {
padding: 20rpx 24rpx 120rpx;
padding: 20rpx 24rpx 48rpx;
}
.sk-card {

查看文件

@@ -68,7 +68,12 @@
},
{
"path": "pages/order/list",
"style": { "navigationStyle": "custom", "backgroundColor": "#F5F6F8" }
"style": {
"navigationStyle": "custom",
"backgroundColor": "#F5F6F8",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "pages/order/detail",
@@ -109,7 +114,12 @@
},
{
"path": "pages/mine/mine",
"style": { "navigationStyle": "custom", "backgroundColor": "#F5F6F8" }
"style": {
"navigationStyle": "custom",
"backgroundColor": "#F5F6F8",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "pages/mine/aftersale",
@@ -186,5 +196,37 @@
"navigationBarBackgroundColor": "#F0710D",
"backgroundColor": "#F5F6F8"
},
"tabBar": {
"color": "#9A9A9A",
"selectedColor": "#F0710D",
"backgroundColor": "#FFFFFF",
"borderStyle": "black",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "static/tabbar/home.png",
"selectedIconPath": "static/tabbar/home-active.png"
},
{
"pagePath": "pages/order/list",
"text": "订单",
"iconPath": "static/tabbar/order.png",
"selectedIconPath": "static/tabbar/order-active.png"
},
{
"pagePath": "pages/message/message",
"text": "消息",
"iconPath": "static/tabbar/message.png",
"selectedIconPath": "static/tabbar/message-active.png"
},
{
"pagePath": "pages/mine/mine",
"text": "我的",
"iconPath": "static/tabbar/mine.png",
"selectedIconPath": "static/tabbar/mine-active.png"
}
]
},
"uniIdRouter": {}
}

查看文件

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

查看文件

@@ -92,8 +92,6 @@
@select="onSpecSelected"
@custom="goCustomOrder"
/>
<YjyfTabBar :current="'order'" :standalone="true" />
</view>
</template>
@@ -101,7 +99,6 @@
import { ref, computed, watch } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import YjyfNavBar from '@/components/YjyfNavBar.vue';
import YjyfTabBar from '@/components/YjyfTabBar.vue';
import GoodsPickerDrawer from '@/components/GoodsPickerDrawer.vue';
import api from '@/utils/api.js';
import { useShare } from '@/utils/share.js';
@@ -551,6 +548,6 @@
}
.body-bottom-space {
height: 200rpx;
height: 48rpx;
}
</style>

查看文件

@@ -1,51 +1,30 @@
<template>
<view class="user-container-page">
<!-- 1. 首页 (Tab 0) -->
<view class="tab-pane" v-show="activeTab === 0">
<UserHomeView ref="homeRef" :active="activeTab === 0" @switch-tab="onTabChange" />
</view>
<!-- 2. 订单 (Tab 1) -->
<view class="tab-pane" v-if="visitedTabs[1]" v-show="activeTab === 1">
<UserOrdersView ref="ordersRef" :initial-status="initialOrderStatus" />
</view>
<!-- 3. 消息 (Tab 2) -->
<view class="tab-pane" v-if="visitedTabs[2]" v-show="activeTab === 2">
<UserMessageView ref="messageRef" role-type="user" />
</view>
<!-- 4. 我的 (Tab 3) -->
<view class="tab-pane" v-if="visitedTabs[3]" v-show="activeTab === 3">
<UserMineView ref="mineRef" @go-orders="goOrdersWithStatus" />
</view>
<!-- 全局统一底部导航 (方案 A:单母页组件化调度,0ms 极速秒切) -->
<YjyfTabBar :current="activeTab" @change="onTabChange" />
<view class="user-home-page">
<UserHomeView ref="homeRef" :active="isPageActive" />
<YjyfPrivacyPopup />
<YjyfIdentityPicker v-model:visible="showIdentityPicker" />
</view>
</template>
<script setup>
import { ref, reactive } from 'vue';
import { onLoad, onShow, onBackPress } from '@dcloudio/uni-app';
import { ref } from 'vue';
import { onLoad, onShow, onHide, onBackPress } from '@dcloudio/uni-app';
import UserHomeView from '@/components/user/UserHomeView.vue';
import UserOrdersView from '@/components/user/UserOrdersView.vue';
import UserMessageView from '@/components/user/UserMessageView.vue';
import UserMineView from '@/components/user/UserMineView.vue';
import YjyfTabBar from '@/components/YjyfTabBar.vue';
import YjyfPrivacyPopup from '@/components/YjyfPrivacyPopup.vue';
import YjyfIdentityPicker from '@/components/YjyfIdentityPicker.vue';
import { isLogin, toLogin, getUser } from '@/utils/request.js';
import { isLogin, getUser } from '@/utils/request.js';
import { useShare } from '@/utils/share.js';
const showIdentityPicker = ref(false);
const activeTab = ref(0);
const initialOrderStatus = ref('all');
const visitedTabs = reactive({ 0: true, 1: false, 2: false, 3: false });
const isPageActive = ref(true);
let initialLoaded = false;
const LEGACY_TAB_ROUTES = {
1: '/pages/order/list',
2: '/pages/message/message',
3: '/pages/mine/mine'
};
useShare(() => ({
title: '优匠优服 · 专业家居安装维修平台,实名师傅极速上门',
path: '/pages/index/index',
@@ -53,70 +32,22 @@
}));
const homeRef = ref(null);
const ordersRef = ref(null);
const messageRef = ref(null);
const mineRef = ref(null);
function refreshCurrentTab() {
if (activeTab.value === 0 && homeRef.value?.load) {
homeRef.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 && mineRef.value?.load) {
mineRef.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);
}
}
function goOrdersWithStatus(statusKey = 'all') {
const targetStatus = statusKey || 'all';
if (!isLogin()) {
toLogin(`/pages/index/index?tab=1&status=${targetStatus}`);
return;
}
initialOrderStatus.value = targetStatus;
const firstVisit = !visitedTabs[1];
visitedTabs[1] = true;
activeTab.value = 1;
if (!firstVisit) {
setTimeout(() => {
if (ordersRef.value?.switchTab) {
ordersRef.value.switchTab(targetStatus);
} else if (ordersRef.value?.load) {
ordersRef.value.load();
}
}, 0);
}
}
onLoad((query) => {
const currentUser = getUser();
if (isLogin() && currentUser && currentUser.identity_selected === false) {
return;
}
if (query && query.status) {
initialOrderStatus.value = String(query.status);
}
if (query && query.tab !== undefined) {
const t = parseInt(query.tab);
if (!isNaN(t) && t >= 0 && t <= 3) {
activeTab.value = t;
visitedTabs[t] = true;
const targetUrl = LEGACY_TAB_ROUTES[t];
if (targetUrl) {
if (t === 1 && query.status) {
try {
uni.setStorageSync('yjyf_pending_order_status', String(query.status));
} catch (e) {}
}
uni.switchTab({ url: targetUrl });
}
}
});
@@ -124,32 +55,33 @@
onBackPress(() => showIdentityPicker.value);
onShow(() => {
isPageActive.value = true;
const currentUser = getUser();
if (isLogin() && currentUser && currentUser.identity_selected === false) {
activeTab.value = 0;
showIdentityPicker.value = true;
return;
}
uni.$emit('yjyf:refreshUnread');
if (!initialLoaded) {
initialLoaded = true;
return;
}
refreshCurrentTab();
if (homeRef.value?.load) {
homeRef.value.load();
}
});
onHide(() => {
isPageActive.value = false;
});
</script>
<style lang="scss" scoped>
@import '@/uni.scss';
.user-container-page {
.user-home-page {
height: 100vh;
overflow: hidden;
background: #F5F6F8;
}
.tab-pane {
width: 100%;
height: calc(100vh - 112rpx - constant(safe-area-inset-bottom));
height: calc(100vh - 112rpx - env(safe-area-inset-bottom));
overflow: hidden;
}
</style>

查看文件

@@ -435,15 +435,15 @@
function handleBackOrHome() {
if (getCurrentPages().length > 1) {
uni.navigateBack({
fail: () => uni.reLaunch({ url: '/pages/index/index' })
fail: () => uni.switchTab({ url: '/pages/index/index' })
});
} else {
uni.reLaunch({ url: '/pages/index/index' });
uni.switchTab({ url: '/pages/index/index' });
}
}
function handleSkip() {
uni.reLaunch({ url: '/pages/index/index' });
uni.switchTab({ url: '/pages/index/index' });
}
function safeVibrate() {
@@ -527,7 +527,7 @@
if (preferBack && (getCurrentPages() || []).length > 1) {
showIdentityPicker.value = true;
} else {
uni.reLaunch({ url: '/pages/index/index' });
uni.switchTab({ url: '/pages/index/index' });
}
return;
}
@@ -581,7 +581,7 @@
if (preferBack && (getCurrentPages() || []).length > 1) {
showIdentityPicker.value = true;
} else {
uni.reLaunch({ url: '/pages/index/index' });
uni.switchTab({ url: '/pages/index/index' });
}
return;
}
@@ -603,6 +603,16 @@
}, 400);
}
function applyPendingOrderStatusFromRedirect(url) {
if (!url) return;
const match = String(url).match(/(?:^|[?&])status=([^&#]+)/);
if (match && match[1]) {
try {
uni.setStorageSync('yjyf_pending_order_status', decodeURIComponent(match[1]));
} catch (e) {}
}
}
/** 登录完成后流转回原目标页或用户首页 */
function finishLogin() {
const action = resolvePostLoginAction({
@@ -613,11 +623,22 @@
if (action.type === 'navigateBack') {
uni.navigateBack({
fail: () => {
uni.reLaunch({ url: action.fallbackUrl || '/pages/index/index' });
if (action.fallbackType === 'switchTab') {
uni.switchTab({ url: action.fallbackUrl || '/pages/index/index' });
} else {
uni.reLaunch({ url: action.fallbackUrl || '/pages/index/index' });
}
}
});
return;
}
if (action.type === 'switchTab') {
if (action.url === '/pages/order/list') {
applyPendingOrderStatusFromRedirect(redirectUrl);
}
uni.switchTab({ url: action.url || '/pages/index/index' });
return;
}
if (action.type === 'redirectTo') {
uni.redirectTo({
url: action.url,

查看文件

@@ -1,18 +1,37 @@
<template>
<view class="page"></view>
<view class="page">
<UserMessageView ref="msgRef" role-type="user" />
<YjyfPrivacyPopup />
</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import UserMessageView from '@/components/user/UserMessageView.vue';
import YjyfPrivacyPopup from '@/components/YjyfPrivacyPopup.vue';
onLoad(() => {
uni.reLaunch({ url: '/pages/index/index?tab=2' });
const msgRef = ref(null);
let initialShown = false;
onShow(() => {
uni.$emit('yjyf:refreshUnread');
if (!initialShown) {
initialShown = true;
return;
}
if (msgRef.value?.load) {
msgRef.value.load();
}
});
</script>
<style lang="scss" scoped>
.page {
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
background: $yjyf-bg-page;
}
</style>

查看文件

@@ -46,7 +46,10 @@ export default {
} catch (e) { this.error = true; } finally { this.loading = false; }
},
goDetail(item) { uni.navigateTo({ url: `/pages/mine/aftersale-detail?id=${item.id}` }); },
goOrderList() { uni.reLaunch({ url: '/pages/index/index?tab=1&status=completed' }); }
goOrderList() {
try { uni.setStorageSync('yjyf_pending_order_status', 'completed'); } catch (e) {}
uni.switchTab({ url: '/pages/order/list' });
}
}
};
</script>

查看文件

@@ -1,24 +1,35 @@
<template>
<view>
<UserMineView />
<YjyfTabBar :current="3" @change="onSwitchTab" />
<view class="user-mine-page">
<UserMineView ref="mineRef" />
<YjyfPrivacyPopup />
</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import UserMineView from '@/components/user/UserMineView.vue';
import YjyfTabBar from '@/components/YjyfTabBar.vue';
import YjyfPrivacyPopup from '@/components/YjyfPrivacyPopup.vue';
onLoad(() => {
uni.reLaunch({
url: '/pages/index/index?tab=3'
});
const mineRef = ref(null);
let initialShown = false;
onShow(() => {
uni.$emit('yjyf:refreshUnread');
if (!initialShown) {
initialShown = true;
return;
}
if (mineRef.value?.load) {
mineRef.value.load();
}
});
function onSwitchTab(index) {
uni.reLaunch({
url: `/pages/index/index?tab=${index}`
});
}
</script>
<style scoped>
.user-mine-page {
height: 100vh;
overflow: hidden;
background: #F5F6F8;
}
</style>

查看文件

@@ -1,27 +1,75 @@
<template>
<view>
<UserOrdersView />
<YjyfTabBar :current="1" @change="onSwitchTab" />
<view class="user-orders-page">
<UserOrdersView ref="ordersRef" :initial-status="initialStatus" />
<YjyfPrivacyPopup />
</view>
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import UserOrdersView from '@/components/user/UserOrdersView.vue';
import YjyfTabBar from '@/components/YjyfTabBar.vue';
import YjyfPrivacyPopup from '@/components/YjyfPrivacyPopup.vue';
const ordersRef = ref(null);
const initialStatus = ref('all');
let initialShown = false;
const STATUS_MAP = {
0: 'pending_pay',
1: 'pending_accept',
2: 'quoting',
3: 'select_master',
4: 'scheduled',
6: 'serving',
7: 'pending_verify',
8: 'completed',
9: 'cancelled'
};
function consumePendingStatus() {
try {
const val = uni.getStorageSync('yjyf_pending_order_status');
if (val) {
uni.removeStorageSync('yjyf_pending_order_status');
return String(val);
}
} catch (e) {}
return '';
}
onLoad((query) => {
// 收敛到单母页订单 Tab,透传状态参数(与 UserOrdersView 的 tab key 对齐)
const statusMap = { 0: 'pending_pay', 1: 'pending_accept', 2: 'quoting', 3: 'select_master', 4: 'scheduled', 6: 'serving', 7: 'pending_verify', 8: 'completed', 9: 'cancelled' };
const target = query && query.tab !== undefined && statusMap[query.tab] ? statusMap[query.tab] : (query && query.status) || 'all';
uni.reLaunch({
url: `/pages/index/index?tab=1&status=${target}`
});
const pending = consumePendingStatus();
const fromQuery = query && query.tab !== undefined && STATUS_MAP[query.tab]
? STATUS_MAP[query.tab]
: ((query && query.status) ? String(query.status) : '');
initialStatus.value = fromQuery || pending || 'all';
});
function onSwitchTab(index) {
uni.reLaunch({
url: `/pages/index/index?tab=${index}`
});
}
onShow(() => {
const pending = consumePendingStatus();
uni.$emit('yjyf:refreshUnread');
if (!initialShown) {
initialShown = true;
if (pending) {
initialStatus.value = pending;
}
return;
}
if (pending && ordersRef.value?.switchTab) {
ordersRef.value.switchTab(pending);
return;
}
if (ordersRef.value?.load) {
ordersRef.value.load();
}
});
</script>
<style scoped>
.user-orders-page {
height: 100vh;
overflow: hidden;
background: #F5F6F8;
}
</style>

查看文件

@@ -77,7 +77,7 @@
else goOrders();
}
function goOrders() {
uni.reLaunch({ url: '/pages/index/index?tab=1' });
uni.switchTab({ url: '/pages/order/list' });
}
</script>

查看文件

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

二进制文件未显示。

之后

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

二进制
yjyf-app/static/tabbar/home.png 普通文件

二进制文件未显示。

之后

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

二进制文件未显示。

之后

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

二进制
yjyf-app/static/tabbar/message.png 普通文件

二进制文件未显示。

之后

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

二进制文件未显示。

之后

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

二进制
yjyf-app/static/tabbar/mine.png 普通文件

二进制文件未显示。

之后

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

二进制文件未显示。

之后

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

二进制
yjyf-app/static/tabbar/order.png 普通文件

二进制文件未显示。

之后

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

查看文件

@@ -7,6 +7,31 @@ const PRESERVE_STATE_ROUTES = new Set([
'pages/order/quick'
]);
const TAB_BAR_ROUTES = new Set([
'pages/index/index',
'pages/order/list',
'pages/message/message',
'pages/mine/mine'
]);
const LEGACY_TAB_MAP = {
'1': 'pages/order/list',
'2': 'pages/message/message',
'3': 'pages/mine/mine'
};
function resolveTabRoute(urlOrRoute) {
const route = normalizeRoutePath(urlOrRoute);
if (route === 'pages/index/index') {
const raw = String(urlOrRoute || '');
const match = raw.match(/(?:^|[?&])tab=([123])(?:&|$|#)/);
if (match && LEGACY_TAB_MAP[match[1]]) {
return LEGACY_TAB_MAP[match[1]];
}
}
return TAB_BAR_ROUTES.has(route) ? route : '';
}
/**
* 规范化页面路由(去除前导斜杠与查询参数)
* @param {string} routeOrUrl
@@ -71,7 +96,7 @@ export function parseLoginParams(options = {}) {
/**
* 决策登录完成后的页面流转动作
* @param {{ redirectUrl?: string, preferBack?: boolean, pages?: Array<{ route?: string }> }} ctx
* @returns {{ type: 'navigateBack' | 'redirectTo' | 'reLaunch', url?: string, fallbackType?: 'reLaunch', fallbackUrl?: string }}
* @returns {{ type: 'navigateBack' | 'redirectTo' | 'reLaunch' | 'switchTab', url?: string, fallbackType?: 'reLaunch' | 'switchTab', fallbackUrl?: string }}
*/
export function resolvePostLoginAction(ctx = {}) {
const redirectUrl = String(ctx.redirectUrl || '').trim();
@@ -83,17 +108,19 @@ export function resolvePostLoginAction(ctx = {}) {
const prevRoute = normalizeRoutePath(prevPage && prevPage.route);
const targetRoute = normalizeRoutePath(redirectUrl);
if (!targetRoute || !prevRoute || prevRoute === targetRoute) {
const tabTarget = resolveTabRoute(redirectUrl);
return {
type: 'navigateBack',
fallbackType: 'reLaunch',
fallbackUrl: redirectUrl || '/pages/index/index'
fallbackType: (!redirectUrl || tabTarget) ? 'switchTab' : 'reLaunch',
fallbackUrl: tabTarget ? `/${tabTarget}` : (redirectUrl || '/pages/index/index')
};
}
}
if (redirectUrl) {
if (redirectUrl.startsWith('/pages/index/') || redirectUrl.startsWith('/pages/mine/')) {
return { type: 'reLaunch', url: redirectUrl };
const tabTarget = resolveTabRoute(redirectUrl);
if (tabTarget) {
return { type: 'switchTab', url: `/${tabTarget}` };
}
return {
type: 'redirectTo',
@@ -106,10 +133,10 @@ export function resolvePostLoginAction(ctx = {}) {
if (pages.length > 1) {
return {
type: 'navigateBack',
fallbackType: 'reLaunch',
fallbackType: 'switchTab',
fallbackUrl: '/pages/index/index'
};
}
return { type: 'reLaunch', url: '/pages/index/index' };
return { type: 'switchTab', url: '/pages/index/index' };
}