个人中心页跳转实现

This commit is contained in:
WindowBird 2025-08-15 15:26:13 +08:00
parent 26ecf5f4c8
commit 897fc160a0
2 changed files with 730 additions and 664 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,27 +6,29 @@
// 页面路由配置
export const PAGE_ROUTES = {
// 主要功能页面
MONK: '/pages/monk/monk',
MONK_DETAIL: '/pages/monk/monkDetail',
WALK_INTO: '/pages/walkInto/walkInto',
INSTITUTIONAL_STRUCTURE: '/pages/institutionalStructure/institutionalStructure',
ACTIVITY: '/pages/activity/activity',
PRAY: '/pages/pray/pray',
MONK: "/pages/monk/monk",
MONK_DETAIL: "/pages/monk/monkDetail",
WALK_INTO: "/pages/walkInto/walkInto",
INSTITUTIONAL_STRUCTURE:
"/pages/institutionalStructure/institutionalStructure",
ACTIVITY: "/pages/activity/activity",
PRAY: "/pages/pray/pray",
PC: "/pages/personalCenter/personalCenter",
// 待开发页面
NEWS: '/pages/news/news',
ABBOT: '/pages/abbot/abbot',
ANCIENT: '/pages/ancient/ancient',
FUTURE: '/pages/future/future',
NEWS: "/pages/news/news",
ABBOT: "/pages/abbot/abbot",
ANCIENT: "/pages/ancient/ancient",
FUTURE: "/pages/future/future",
// 其他页面
LOGIN: '/pages/login/login',
INDEX: '/pages/nearbystores/index',
MY: '/pages/my/my',
MY_ORDER: '/pages/myorder/index',
MY_ORDER_RETURNED: '/pages/myorder/returned/index',
}
LOGIN: "/pages/login/login",
INDEX: "/pages/nearbystores/index",
MY: "/pages/my/my",
MY_ORDER: "/pages/myorder/index",
MY_ORDER_RETURNED: "/pages/myorder/returned/index",
};
// 页面类型映射
export const PAGE_TYPE_MAP = {
@ -41,7 +43,8 @@ export const PAGE_TYPE_MAP = {
future: PAGE_ROUTES.FUTURE,
index: PAGE_ROUTES.INDEX,
pray: PAGE_ROUTES.PRAY,
}
pc: PAGE_ROUTES.PC,
};
/**
* 页面跳转方法
@ -51,37 +54,37 @@ export const PAGE_TYPE_MAP = {
export function navigateToPage(pageType, options = {}) {
// 清除loading状态
try {
uni.hideLoading()
uni.hideLoading();
} catch (error) {
console.warn('清除loading失败:', error)
console.warn("清除loading失败:", error);
}
const targetPage = PAGE_TYPE_MAP[pageType]
const targetPage = PAGE_TYPE_MAP[pageType];
if (!targetPage) {
// 使用uni.showToast替代console减少文件系统访问
uni.showToast({
title: '页面配置错误',
icon: 'none',
})
return
title: "页面配置错误",
icon: "none",
});
return;
}
const defaultOptions = {
url: targetPage,
fail: err => {
fail: (err) => {
// 避免在真机调试时输出过多日志
uni.showToast({
title: '页面开发中',
icon: 'none',
})
title: "页面开发中",
icon: "none",
});
},
}
};
uni.navigateTo({
...defaultOptions,
...options,
})
});
}
/**
@ -91,35 +94,35 @@ export function navigateToPage(pageType, options = {}) {
export function switchToTab(pageType) {
// 清除loading状态
try {
uni.hideLoading()
uni.hideLoading();
} catch (error) {
console.warn('清除loading失败:', error)
console.warn("清除loading失败:", error);
}
const tabRoutes = {
index: PAGE_ROUTES.INDEX,
my: PAGE_ROUTES.MY,
}
};
const targetPage = tabRoutes[pageType]
const targetPage = tabRoutes[pageType];
if (!targetPage) {
uni.showToast({
title: '页面配置错误',
icon: 'none',
})
return
title: "页面配置错误",
icon: "none",
});
return;
}
uni.switchTab({
url: targetPage,
fail: err => {
fail: (err) => {
uni.showToast({
title: '跳转失败',
icon: 'none',
})
title: "跳转失败",
icon: "none",
});
},
})
});
}
/**
@ -131,9 +134,9 @@ export function navigateBack(delta = 1) {
delta,
fail: () => {
// 如果没有上一页,跳转到首页
switchToTab('index')
switchToTab("index");
},
})
});
}
/**
@ -143,24 +146,24 @@ export function navigateBack(delta = 1) {
export function redirectToPage(pageType) {
// 清除loading状态
try {
uni.hideLoading()
uni.hideLoading();
} catch (error) {
console.warn('清除loading失败:', error)
console.warn("清除loading失败:", error);
}
const targetPage = PAGE_TYPE_MAP[pageType]
const targetPage = PAGE_TYPE_MAP[pageType];
if (!targetPage) {
console.error('未知的页面类型:', pageType)
return
console.error("未知的页面类型:", pageType);
return;
}
uni.redirectTo({
url: targetPage,
fail: err => {
console.error('页面重定向失败:', err)
fail: (err) => {
console.error("页面重定向失败:", err);
},
})
});
}
/**
@ -170,22 +173,22 @@ export function redirectToPage(pageType) {
export function reLaunchToPage(pageType) {
// 清除loading状态
try {
uni.hideLoading()
uni.hideLoading();
} catch (error) {
console.warn('清除loading失败:', error)
console.warn("清除loading失败:", error);
}
const targetPage = PAGE_TYPE_MAP[pageType]
const targetPage = PAGE_TYPE_MAP[pageType];
if (!targetPage) {
console.error('未知的页面类型:', pageType)
return
console.error("未知的页面类型:", pageType);
return;
}
uni.reLaunch({
url: targetPage,
fail: err => {
console.error('页面重启失败:', err)
fail: (err) => {
console.error("页面重启失败:", err);
},
})
});
}