diff --git a/tests/login_navigation.test.mjs b/tests/login_navigation.test.mjs
index 2afc403..2c74171 100644
--- a/tests/login_navigation.test.mjs
+++ b/tests/login_navigation.test.mjs
@@ -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'
}
);
diff --git a/yjyf-app/App.vue b/yjyf-app/App.vue
index e1ceb16..84deb8c 100644
--- a/yjyf-app/App.vue
+++ b/yjyf-app/App.vue
@@ -1,9 +1,30 @@
diff --git a/yjyf-app/components/YjyfTabBar.vue b/yjyf-app/components/YjyfTabBar.vue
index bf48394..8d62ed1 100644
--- a/yjyf-app/components/YjyfTabBar.vue
+++ b/yjyf-app/components/YjyfTabBar.vue
@@ -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
});
}
diff --git a/yjyf-app/components/user/UserHomeView.vue b/yjyf-app/components/user/UserHomeView.vue
index 5a2225c..3d2161f 100644
--- a/yjyf-app/components/user/UserHomeView.vue
+++ b/yjyf-app/components/user/UserHomeView.vue
@@ -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 @@
diff --git a/yjyf-app/pages/index/index.vue b/yjyf-app/pages/index/index.vue
index 0f6ac00..572e723 100644
--- a/yjyf-app/pages/index/index.vue
+++ b/yjyf-app/pages/index/index.vue
@@ -1,51 +1,30 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/yjyf-app/pages/login/login.vue b/yjyf-app/pages/login/login.vue
index 48d1a2c..15c69e8 100644
--- a/yjyf-app/pages/login/login.vue
+++ b/yjyf-app/pages/login/login.vue
@@ -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,
diff --git a/yjyf-app/pages/message/message.vue b/yjyf-app/pages/message/message.vue
index 6240ed0..c9c3a8c 100644
--- a/yjyf-app/pages/message/message.vue
+++ b/yjyf-app/pages/message/message.vue
@@ -1,18 +1,37 @@
-
+
+
+
+
diff --git a/yjyf-app/pages/mine/aftersale.vue b/yjyf-app/pages/mine/aftersale.vue
index de3ed74..d9159dd 100644
--- a/yjyf-app/pages/mine/aftersale.vue
+++ b/yjyf-app/pages/mine/aftersale.vue
@@ -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' });
+ }
}
};
diff --git a/yjyf-app/pages/mine/mine.vue b/yjyf-app/pages/mine/mine.vue
index 7d07c08..1982067 100644
--- a/yjyf-app/pages/mine/mine.vue
+++ b/yjyf-app/pages/mine/mine.vue
@@ -1,24 +1,35 @@
-
-
-
+
+
+
+
+
diff --git a/yjyf-app/pages/order/list.vue b/yjyf-app/pages/order/list.vue
index d60776d..e4125b5 100644
--- a/yjyf-app/pages/order/list.vue
+++ b/yjyf-app/pages/order/list.vue
@@ -1,27 +1,75 @@
-
-
-
+
+
+
+
+
diff --git a/yjyf-app/pages/order/payment-success.vue b/yjyf-app/pages/order/payment-success.vue
index e7ee9a2..364f505 100644
--- a/yjyf-app/pages/order/payment-success.vue
+++ b/yjyf-app/pages/order/payment-success.vue
@@ -77,7 +77,7 @@
else goOrders();
}
function goOrders() {
- uni.reLaunch({ url: '/pages/index/index?tab=1' });
+ uni.switchTab({ url: '/pages/order/list' });
}
diff --git a/yjyf-app/pages/order/quick.vue b/yjyf-app/pages/order/quick.vue
index 4f45331..0f01421 100644
--- a/yjyf-app/pages/order/quick.vue
+++ b/yjyf-app/pages/order/quick.vue
@@ -1191,7 +1191,7 @@
if (pages.length > 1) {
uni.navigateBack();
} else {
- uni.reLaunch({ url: '/pages/index/index' });
+ uni.switchTab({ url: '/pages/index/index' });
}
}
}
diff --git a/yjyf-app/static/tabbar/home-active.png b/yjyf-app/static/tabbar/home-active.png
new file mode 100644
index 0000000..a20230d
Binary files /dev/null and b/yjyf-app/static/tabbar/home-active.png differ
diff --git a/yjyf-app/static/tabbar/home.png b/yjyf-app/static/tabbar/home.png
new file mode 100644
index 0000000..e89fe0f
Binary files /dev/null and b/yjyf-app/static/tabbar/home.png differ
diff --git a/yjyf-app/static/tabbar/message-active.png b/yjyf-app/static/tabbar/message-active.png
new file mode 100644
index 0000000..82a4781
Binary files /dev/null and b/yjyf-app/static/tabbar/message-active.png differ
diff --git a/yjyf-app/static/tabbar/message.png b/yjyf-app/static/tabbar/message.png
new file mode 100644
index 0000000..f303f06
Binary files /dev/null and b/yjyf-app/static/tabbar/message.png differ
diff --git a/yjyf-app/static/tabbar/mine-active.png b/yjyf-app/static/tabbar/mine-active.png
new file mode 100644
index 0000000..5cebf0a
Binary files /dev/null and b/yjyf-app/static/tabbar/mine-active.png differ
diff --git a/yjyf-app/static/tabbar/mine.png b/yjyf-app/static/tabbar/mine.png
new file mode 100644
index 0000000..ca676a2
Binary files /dev/null and b/yjyf-app/static/tabbar/mine.png differ
diff --git a/yjyf-app/static/tabbar/order-active.png b/yjyf-app/static/tabbar/order-active.png
new file mode 100644
index 0000000..b4d6c53
Binary files /dev/null and b/yjyf-app/static/tabbar/order-active.png differ
diff --git a/yjyf-app/static/tabbar/order.png b/yjyf-app/static/tabbar/order.png
new file mode 100644
index 0000000..2254bf5
Binary files /dev/null and b/yjyf-app/static/tabbar/order.png differ
diff --git a/yjyf-app/utils/login-navigation.mjs b/yjyf-app/utils/login-navigation.mjs
index 555ae3d..7ce9ae9 100644
--- a/yjyf-app/utils/login-navigation.mjs
+++ b/yjyf-app/utils/login-navigation.mjs
@@ -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' };
}