Files
lucky_shop/pages/empty/index.vue
ZF sun aa7d967422 fix: 修复鸿蒙元服务TabBar跳转失效问题
1.  修复多处页面onTabItemTap事件,使用uni.reLaunch兜底鸿蒙下switchTab静默失败的问题
2.  全局混入onTabItemTap兜底未手动处理的页面
3.  优化路由跳转逻辑,针对鸿蒙环境增加switchTab失败兜底和超时强制跳转
4.  优化可选链调用和空值判断,提升代码健壮性
2026-07-06 16:48:38 +08:00

34 lines
825 B
Vue

<template>
<view class="empty" :style="themeColor">
<splash-screen />
</view>
</template>
<script>
export default {
data() {
return {}
},
// 鸿蒙元服务环境: 系统 TabBar 点击 uni.switchTab 静默失败
// 手动接管 onTabItemTap, 用 uni.reLaunch 兜底, 确保 TabBar 跳转在鸿蒙下也能工作
// #ifdef MP-HARMONY
onTabItemTap(e) {
if (!e || !e.pagePath) return;
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
const currentPath = currentPage ? '/' + currentPage.route : '';
const targetPath = e.pagePath.startsWith('/') ? e.pagePath : '/' + e.pagePath;
// 已经在目标页则不重复跳转
if (currentPath === targetPath) return;
uni.reLaunch({ url: targetPath });
}
// #endif
}
</script>
<style scoped>
.empty {
display: flex;
}
</style>