123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <template>
- <view class="u-page__item" v-if="tabbar?.items?.length > 0">
- <su-tabbar :value="path" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true"
- :inactiveColor="tabbar.style.color" :activeColor="tabbar.style.activeColor" :midTabBar="tabbar.mode === 2"
- :customStyle="tabbarStyle">
- <su-tabbar-item v-for="(item, index) in tabbar.items" :key="item.text" :text="item.text" :name="item.url"
- :badge="item.badge" :dot="item.dot" :badgeStyle="{ ...tabbar.badgeStyle, paddingTop: '20px' }"
- :isCenter="getTabbarCenter(index)" :centerImage="sheep.$url.cdn(item.iconUrl)"
- @tap="sheep.$router.go(item.url)">
- <template v-slot:active-icon>
- <image class="u-page__item__slot-icon" :src="sheep.$url.cdn(item.activeIconUrl)"></image>
- </template>
- <template v-slot:inactive-icon>
- <image v-if="item.text" class="u-page__item__slot-icon" :src="sheep.$url.cdn(item.iconUrl)"></image>
- <image v-else class="imageClass" :src="sheep.$url.cdn(item.iconUrl)"></image>
- </template>
- </su-tabbar-item>
- </su-tabbar>
- </view>
- </template>
- <script setup>
- import { computed, unref } from 'vue';
- import sheep from '@/sheep';
- import SuTabbar from '@/sheep/ui/su-tabbar/su-tabbar.vue';
- import CouponApi from '@/sheep/api/promotion/coupon';
- const tabbar = computed(() => {
- return sheep.$store('app').template.basic?.tabbar;
- });
- const tabbarStyle = computed(() => {
- const backgroundStyle = tabbar.value.style;
- if (backgroundStyle.bgType === 'color') {
- return { background: backgroundStyle.bgColor };
- }
- if (backgroundStyle.bgType === 'img')
- return {
- background: `url(${sheep.$url.cdn(
- backgroundStyle.bgImg,
- )}) no-repeat top center / 100% auto`,
- };
- });
- const userInfo = computed(() => sheep.$store('user').userInfo);
- const routerGo = (item) => {
- if (item.url === '/pages/chat/index') {
- CouponApi.getKefuConversationByRelID({
- relID: 1
- }).then((res) => {
- sheep.$router.go('/pages/chat/index', { conversationId: res.data.id, relUserId: userInfo.value.id === res.data.relUserId ? res.data.userId : res.data.relUserId })
- })
- } else {
- sheep.$router.go(item.url)
- }
- }
- const getTabbarCenter = (index) => {
- if (unref(tabbar).mode !== 2) return false;
- return unref(tabbar).items % 2 > 0
- ? Math.ceil(unref(tabbar).items.length / 2) === index + 1
- : false;
- };
- const props = defineProps({
- path: String,
- default: '',
- });
- </script>
- <style lang="scss">
- .imageClass {
- width: 100px;
- height: 100px;
- margin-bottom: 60px;
- // background: red;
- }
- .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;
- }
- }
- }
- :deep(.u-tabbar__content) {
- padding-top: 10px !important;
- margin-top: 10px !important;
- }
- </style>
|