2024-05-22 15:42:13 +08:00
|
|
|
<template>
|
2024-05-31 01:06:20 +08:00
|
|
|
<view class="u-page__item" v-if="tabbar?.items?.length > 0">
|
|
|
|
<pb-s-tabbar :value="path" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true"
|
|
|
|
:inactiveColor="tabbar.style.color" :activeColor="tabbar.style.activeColor" :midTabBar="tabbar.mode === 2"
|
|
|
|
:customStyle="tabbarStyle">
|
|
|
|
<pb-tabbar-item v-for="(item, index) in tabbar.items" :key="item.text" :text="item.text" :name="item.url"
|
|
|
|
:isCenter="getTabbarCenter(index)" :centerImage="peach.$url.cdn(item.iconUrl)"
|
|
|
|
@tap="peach.$router.go(item.url)">
|
|
|
|
<template v-slot:active-icon>
|
|
|
|
<image class="u-page__item__slot-icon" :src="peach.$url.static(item.activeIconUrl, 'local')"></image>
|
|
|
|
</template>
|
|
|
|
<template v-slot:inactive-icon>
|
|
|
|
<image class="u-page__item__slot-icon" :src="peach.$url.static(item.iconUrl, 'local')"></image>
|
|
|
|
</template>
|
|
|
|
</pb-tabbar-item>
|
|
|
|
</pb-s-tabbar>
|
|
|
|
</view>
|
2024-05-22 15:42:13 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
2024-05-29 17:07:37 +08:00
|
|
|
import { onLoad } from '@dcloudio/uni-app'
|
2024-05-22 15:42:13 +08:00
|
|
|
import { computed, unref } from 'vue'
|
|
|
|
import PbSTabbar from './pb-s-tabbar.vue'
|
|
|
|
import peach from '@/peach'
|
|
|
|
|
|
|
|
const tabbar = computed(() => {
|
2024-05-31 01:06:20 +08:00
|
|
|
return peach.$store('app').template.basic?.tabbar
|
2024-05-22 15:42:13 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
const tabbarStyle = computed(() => {
|
2024-05-31 01:06:20 +08:00
|
|
|
const backgroundStyle = tabbar.value.style
|
|
|
|
if (backgroundStyle.bgType === 'color') {
|
|
|
|
return { background: backgroundStyle.bgColor }
|
|
|
|
}
|
|
|
|
if (backgroundStyle.bgType === 'img')
|
|
|
|
return {
|
|
|
|
background: `url(${peach.$url.cdn(backgroundStyle.bgImg)}) no-repeat top center / 100% auto`,
|
2024-05-22 15:42:13 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const getTabbarCenter = (index) => {
|
2024-05-31 01:06:20 +08:00
|
|
|
if (unref(tabbar).mode !== 2) return false
|
|
|
|
return unref(tabbar).items % 2 > 0 ? Math.ceil(unref(tabbar).items.length / 2) === index + 1 : false
|
2024-05-22 15:42:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const props = defineProps({
|
2024-05-31 01:06:20 +08:00
|
|
|
path: String,
|
|
|
|
default: '',
|
2024-05-22 15:42:13 +08:00
|
|
|
})
|
2024-05-29 17:07:37 +08:00
|
|
|
|
|
|
|
onLoad(() => {
|
2024-05-31 01:06:20 +08:00
|
|
|
// 隐藏原生导航栏 使用自定义底部导航
|
|
|
|
// app.vue 内直接调用,在首页是非 tabbar 页面时,会报错
|
|
|
|
uni.hideTabBar()
|
2024-05-29 17:07:37 +08:00
|
|
|
})
|
2024-05-22 15:42:13 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.u-page {
|
2024-05-31 01:06:20 +08:00
|
|
|
padding: 0;
|
2024-05-22 15:42:13 +08:00
|
|
|
|
2024-05-31 01:06:20 +08:00
|
|
|
&__item {
|
|
|
|
&__title {
|
|
|
|
color: var(--textSize);
|
|
|
|
background-color: #fff;
|
|
|
|
padding: 15px;
|
|
|
|
font-size: 15px;
|
2024-05-22 15:42:13 +08:00
|
|
|
|
2024-05-31 01:06:20 +08:00
|
|
|
&__slot-title {
|
|
|
|
color: var(--textSize);
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
}
|
2024-05-22 15:42:13 +08:00
|
|
|
|
2024-05-31 01:06:20 +08:00
|
|
|
&__slot-icon {
|
|
|
|
width: 25px;
|
|
|
|
height: 25px;
|
2024-05-22 15:42:13 +08:00
|
|
|
}
|
2024-05-31 01:06:20 +08:00
|
|
|
}
|
2024-05-22 15:42:13 +08:00
|
|
|
}
|
|
|
|
</style>
|