| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <template>
- <view class="u-page__item">
- <su-tabbar
- :value="path"
- :fixed="true"
- :placeholder="true"
- :safeAreaInsetBottom="true"
- :inactiveColor="state.tabbar.style.color"
- :activeColor="state.tabbar.style.activeColor"
- :midTabBar="state.tabbar.mode === 2"
- :customStyle="tabbarStyle"
- >
- <su-tabbar-item
- v-for="(item, index) in state.tabbar.items"
- :key="item.text"
- :text="item.text"
- :name="item.url"
- :badge="item.badge"
- :dot="item.dot"
- :badgeStyle="state.tabbar.badgeStyle"
- :isCenter="getTabbarCenter(index)"
- :centerImage="item.iconUrl"
- @tap="sheep.$router.go(item.url)"
- >
- <template v-slot:active-icon>
- <image class="u-page__item__slot-icon" :src="item.activeIconUrl"></image>
- </template>
- <template v-slot:inactive-icon>
- <image class="u-page__item__slot-icon" :src="item.iconUrl"></image>
- </template>
- </su-tabbar-item>
- </su-tabbar>
- </view>
- </template>
- <script setup>
- import { computed, reactive } from 'vue';
- import sheep from '@/common';
- import SuTabbar from '@/common/ui/su-tabbar/su-tabbar.vue';
- const state = reactive({
- tabbar: {
- mode: 2,
- style:{
- bgType: 'color',
- bgColor: '#ffffff',
- bgImg: '',
- activeColor:'#35E89A',
- color:'#222222'
- },
- badgeStyle: {},
- items:[
- {
- text:'首页',
- url:'/pages/index/index',
- badge:0,
- dot: false,
- iconUrl:'/static/homeIconUrl.png',
- activeIconUrl:'/static/homeActiveIconUrl.png'
- },
- {
- text:'任务创建',
- url:'/pages/task/create',
- badge:0,
- dot: false,
- iconUrl:'/static/createIconUrl.png',
- },
- {
- text:'我的',
- url:'/pages/index/user',
- badge:10,
- dot: false,
- iconUrl:'/static/userIconUrl.png',
- activeIconUrl:'/static/userActiveIconUrl.png'
- }
- ]
- },
- })
- const tabbarStyle = computed(() => {
- const backgroundStyle = state.tabbar.style;
- if (backgroundStyle.bgType === 'color') {
- return { background: backgroundStyle.bgColor };
- }
- if (backgroundStyle.bgType === 'img')
- return {
- background: `url(${backgroundStyle.bgImg}) no-repeat top center / 100% auto`,
- };
- });
-
- const getTabbarCenter = (index) => {
- if (state.tabbar.mode !== 2) return false;
- return state.tabbar.items.length % 2 > 0
- ? Math.ceil(state.tabbar.items.length / 2) === index + 1
- : false;
- };
-
- const props = defineProps({
- path: String,
- default: '',
- });
- </script>
- <style lang="scss">
- .u-page {
- padding: 0;
- &__item {
- &__title {
- color: var(--textSize);
- background-color: #fff;
- padding: 15px;
- font-size: 15px;
- &__slot-title {
- color: var(--textSize);
- font-size: 14px;
- }
- }
- &__slot-icon {
- width: 25px;
- height: 25px;
- }
- }
- }
- </style>
|