|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
<template>
|
|
|
<wd-tabbar
|
|
<wd-tabbar
|
|
|
- v-if="CUSTOM_TABBAR_ENABLE"
|
|
|
|
|
|
|
+ v-if="customTabbarEnable"
|
|
|
fixed
|
|
fixed
|
|
|
v-model="tabbarStore.curIdx"
|
|
v-model="tabbarStore.curIdx"
|
|
|
bordered
|
|
bordered
|
|
@@ -33,34 +33,35 @@
|
|
|
</wd-tabbar-item>
|
|
</wd-tabbar-item>
|
|
|
</block>
|
|
</block>
|
|
|
</wd-tabbar>
|
|
</wd-tabbar>
|
|
|
- <view v-else></view>
|
|
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { tabbarList as _tabBarList, CUSTOM_TABBAR_ENABLE } from './tabbarList'
|
|
|
|
|
|
|
+import { tabbarList as _tabBarList, cacheTabbarEnable, selectedTabbarStrategy } from './tabbarList'
|
|
|
import { tabbarStore } from './tabbar'
|
|
import { tabbarStore } from './tabbar'
|
|
|
|
|
|
|
|
|
|
+const customTabbarEnable = selectedTabbarStrategy === 1 || selectedTabbarStrategy === 2
|
|
|
/** tabbarList 里面的 path 从 pages.config.ts 得到 */
|
|
/** tabbarList 里面的 path 从 pages.config.ts 得到 */
|
|
|
const tabbarList = _tabBarList.map((item) => ({ ...item, path: `/${item.pagePath}` }))
|
|
const tabbarList = _tabBarList.map((item) => ({ ...item, path: `/${item.pagePath}` }))
|
|
|
function selectTabBar({ value: index }: { value: number }) {
|
|
function selectTabBar({ value: index }: { value: number }) {
|
|
|
const url = tabbarList[index].path
|
|
const url = tabbarList[index].path
|
|
|
tabbarStore.setCurIdx(index)
|
|
tabbarStore.setCurIdx(index)
|
|
|
- if (CUSTOM_TABBAR_ENABLE) {
|
|
|
|
|
- uni.navigateTo({ url })
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ if (cacheTabbarEnable) {
|
|
|
uni.switchTab({ url })
|
|
uni.switchTab({ url })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.navigateTo({ url })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
onLoad(() => {
|
|
onLoad(() => {
|
|
|
// 解决原生 tabBar 未隐藏导致有2个 tabBar 的问题
|
|
// 解决原生 tabBar 未隐藏导致有2个 tabBar 的问题
|
|
|
- // !CUSTOM_TABBAR_ENABLE &&
|
|
|
|
|
- // uni.hideTabBar({
|
|
|
|
|
- // fail(err) {
|
|
|
|
|
- // console.log('hideTabBar fail: ', err)
|
|
|
|
|
- // },
|
|
|
|
|
- // success(res) {
|
|
|
|
|
- // console.log('hideTabBar success: ', res)
|
|
|
|
|
- // },
|
|
|
|
|
- // })
|
|
|
|
|
|
|
+ const hideRedundantTabbarEnable = selectedTabbarStrategy === 1
|
|
|
|
|
+ hideRedundantTabbarEnable &&
|
|
|
|
|
+ uni.hideTabBar({
|
|
|
|
|
+ fail(err) {
|
|
|
|
|
+ console.log('hideTabBar fail: ', err)
|
|
|
|
|
+ },
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ console.log('hideTabBar success: ', res)
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|