|
@@ -0,0 +1,181 @@
|
|
|
+<template>
|
|
|
+ <view class="shop-tabbar-container">
|
|
|
+ <view
|
|
|
+ class="tabbar-item"
|
|
|
+ @click="selectTabBar(category.path, 1)"
|
|
|
+ :class="{ 'tabbar-active': tabbarStore.curIdx === 1 }"
|
|
|
+ >
|
|
|
+ <view class="tabbar-item-wrapper">
|
|
|
+ <image :src="category.icon" class="tabbar-item-img" mode="widthFix"></image>
|
|
|
+ </view>
|
|
|
+ <view class="tabbar-item-text">{{ category.text }}</view>
|
|
|
+ </view>
|
|
|
+ <view
|
|
|
+ class="tabbar-item"
|
|
|
+ @click="selectTabBar(cate.path, 2)"
|
|
|
+ :class="{ 'tabbar-active': tabbarStore.curIdx === 2 }"
|
|
|
+ >
|
|
|
+ <view class="tabbar-item-wrapper">
|
|
|
+ <image :src="cate.icon" class="tabbar-item-img" mode="widthFix"></image>
|
|
|
+ </view>
|
|
|
+ <view class="tabbar-item-text">{{ cate.text }}</view>
|
|
|
+ </view>
|
|
|
+ <view
|
|
|
+ class="home-item"
|
|
|
+ @click="selectTabBar(home.path, 0)"
|
|
|
+ :class="{ 'home-active': tabbarStore.curIdx === 0 }"
|
|
|
+ >
|
|
|
+ <view class="home-item-wrapper">
|
|
|
+ <image :src="home.icon" class="home-item-img" mode="widthFix"></image>
|
|
|
+ </view>
|
|
|
+ <view class="home-item-text">{{ home.text }}</view>
|
|
|
+ </view>
|
|
|
+ <view
|
|
|
+ class="tabbar-item"
|
|
|
+ @click="selectTabBar(community.path, 3)"
|
|
|
+ :class="{ 'tabbar-active': tabbarStore.curIdx === 3 }"
|
|
|
+ >
|
|
|
+ <view class="tabbar-item-wrapper">
|
|
|
+ <image :src="community.icon" class="tabbar-item-img" mode="widthFix"></image>
|
|
|
+ </view>
|
|
|
+ <view class="tabbar-item-text">{{ community.text }}</view>
|
|
|
+ </view>
|
|
|
+ <view
|
|
|
+ class="tabbar-item"
|
|
|
+ @click="selectTabBar(person.path, 4)"
|
|
|
+ :class="{ 'tabbar-active': tabbarStore.curIdx === 4 }"
|
|
|
+ >
|
|
|
+ <view class="tabbar-item-wrapper">
|
|
|
+ <image :src="person.icon" class="tabbar-item-img" mode="widthFix"></image>
|
|
|
+ </view>
|
|
|
+ <view class="tabbar-item-text">{{ person.text }}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+ import { tabBar } from '@/pages.json'
|
|
|
+ import { t } from '@/locale'
|
|
|
+ import { useTabbarStore } from '@/store/tabbar'
|
|
|
+
|
|
|
+ const tabbarStore = useTabbarStore()
|
|
|
+
|
|
|
+ /** tabbarList 里面的 path 从 pages.config.ts 得到 */
|
|
|
+ const [home, category, cate, community, person] = tabBar.list.map((item) => ({
|
|
|
+ ...item,
|
|
|
+ path: `/${item.pagePath}`,
|
|
|
+ text: t(item.text),
|
|
|
+ }))
|
|
|
+
|
|
|
+ function selectTabBar(url: string, index: number) {
|
|
|
+ tabbarStore.setCurIdx(index)
|
|
|
+ uni.switchTab({ url })
|
|
|
+ }
|
|
|
+
|
|
|
+ onLoad(() => {
|
|
|
+ // #ifdef APP-PLUS | H5
|
|
|
+ uni.hideTabBar({
|
|
|
+ fail(err) {
|
|
|
+ console.log('hideTabBar fail: ', err)
|
|
|
+ },
|
|
|
+ success(res) {
|
|
|
+ console.log('hideTabBar success: ', res)
|
|
|
+ },
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
+ })
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .shop-tabbar-container {
|
|
|
+ position: fixed;
|
|
|
+ bottom: 0;
|
|
|
+ left: 0;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ width: 100vw;
|
|
|
+ height: 144rpx;
|
|
|
+ overflow: hidden;
|
|
|
+ background-color: transparent;
|
|
|
+ background-image: url(@/static/images/tabbar-bg.svg);
|
|
|
+ background-size: cover;
|
|
|
+
|
|
|
+ .tabbar-item {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ justify-content: flex-end;
|
|
|
+ width: 110rpx;
|
|
|
+ text-align: center;
|
|
|
+
|
|
|
+ .tabbar-item-text {
|
|
|
+ font-family: 'PingFang SC';
|
|
|
+ font-size: 20rpx;
|
|
|
+ font-style: normal;
|
|
|
+ font-weight: 600;
|
|
|
+ line-height: 30rpx; /* 180% */
|
|
|
+ color: var(--333, #333);
|
|
|
+ }
|
|
|
+
|
|
|
+ .tabbar-item-wrapper {
|
|
|
+ width: 66rpx;
|
|
|
+ height: 66rpx;
|
|
|
+ margin: 0 auto;
|
|
|
+ border-radius: 50%;
|
|
|
+
|
|
|
+ .tabbar-item-img {
|
|
|
+ width: 56rpx;
|
|
|
+ margin: 5rpx auto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &.tabbar-active {
|
|
|
+ .tabbar-item-text {
|
|
|
+ color: #ff4c1b;
|
|
|
+ }
|
|
|
+ .tabbar-item-wrapper {
|
|
|
+ background: radial-gradient(#ff4c1b, transparent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .home-item {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ justify-content: flex-end;
|
|
|
+ width: 96rpx;
|
|
|
+ text-align: center;
|
|
|
+
|
|
|
+ .home-item-text {
|
|
|
+ font-family: 'PingFang SC';
|
|
|
+ font-size: 20rpx;
|
|
|
+ font-style: normal;
|
|
|
+ font-weight: 600;
|
|
|
+ line-height: 36rpx; /* 180% */
|
|
|
+ color: var(--333, #333);
|
|
|
+ }
|
|
|
+
|
|
|
+ .home-item-wrapper {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ width: 96rpx;
|
|
|
+ height: 96rpx;
|
|
|
+ background-color: #f2f2f2;
|
|
|
+ border-radius: 24rpx;
|
|
|
+
|
|
|
+ .home-item-img {
|
|
|
+ width: 80rpx;
|
|
|
+ margin-top: 10rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &.home-active {
|
|
|
+ .home-item-wrapper {
|
|
|
+ background-color: #ff4c1b;
|
|
|
+ }
|
|
|
+
|
|
|
+ .home-item-text {
|
|
|
+ color: #ff4c1b;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|