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