fix:修复bug;新增订单列表页面订单监控
This commit is contained in:
@@ -15,6 +15,55 @@
|
||||
console.log('=== App onShow 被调用 ===')
|
||||
console.log('时间戳:', new Date().toLocaleTimeString())
|
||||
|
||||
// 检查启动路径,如果设置了启动路径则跳转
|
||||
try {
|
||||
const launchPath = uni.getStorageSync('launchPath')
|
||||
if (launchPath) {
|
||||
console.log('检测到启动路径:', launchPath)
|
||||
// 获取当前页面栈
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
const currentRoute = currentPage ? ('/' + currentPage.route) : ''
|
||||
|
||||
// 规范化路径格式进行比较
|
||||
const normalizedLaunchPath = launchPath.replace(/\.html$/, '')
|
||||
|
||||
// 只在「单页面栈」时生效,避免影响正常多页面跳转(如下单后跳详情)
|
||||
if (pages.length === 1 && currentRoute !== normalizedLaunchPath) {
|
||||
console.log('当前页面:', currentRoute, '目标页面:', normalizedLaunchPath)
|
||||
// 清除启动路径标记(在跳转前清除,避免重复触发)
|
||||
uni.removeStorageSync('launchPath')
|
||||
// 跳转到启动路径(首页)
|
||||
// 先尝试 switchTab(如果首页是 tabBar 页面)
|
||||
uni.reLaunch({
|
||||
url: normalizedLaunchPath,
|
||||
success: () => {
|
||||
console.log('成功跳转到启动路径(switchTab)')
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('switchTab 失败,使用 reLaunch:', err)
|
||||
// 如果 switchTab 失败,使用 reLaunch(适用于非 tabBar 页面)
|
||||
uni.reLaunch({
|
||||
url: normalizedLaunchPath,
|
||||
success: () => {
|
||||
console.log('成功跳转到启动路径(reLaunch)')
|
||||
},
|
||||
fail: (reLaunchErr) => {
|
||||
console.error('跳转到启动路径失败:', reLaunchErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
} else if (currentRoute === normalizedLaunchPath) {
|
||||
// 如果已经在目标页面,清除启动路径标记
|
||||
console.log('当前已在目标页面,清除启动路径标记')
|
||||
uni.removeStorageSync('launchPath')
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('App onShow - 启动路径检查失败:', e)
|
||||
}
|
||||
|
||||
// 检查并更新语言(uni.reLaunch 会触发 onShow)
|
||||
try {
|
||||
const savedLang = uni.getStorageSync('language')
|
||||
|
||||
Reference in New Issue
Block a user