|
@@ -1,41 +1,33 @@
|
|
-<template>
|
|
|
|
- <view class="shop-tabbar-container">
|
|
|
|
- <view class="home-item" @click="selectTabBar(Parenting.path, 0)">
|
|
|
|
- <view class="home-item-wrapper">
|
|
|
|
- <image :src="Parenting.icon" class="home-item-img" mode="widthFix"></image>
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
|
|
+<!-- 代码已包含 CSS:使用 TailwindCSS , 安装 TailwindCSS 后方可看到布局样式效果 -->
|
|
|
|
|
|
- <view class="home-item" @click="selectTabBar(music.path, 0)">
|
|
|
|
- <view class="home-item-wrapper">
|
|
|
|
- <image :src="music.icon" class="home-item-img" mode="widthFix"></image>
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
- <view class="home-item" @click="selectTabBar(user.path, 0)">
|
|
|
|
- <view class="home-item-wrapper">
|
|
|
|
- <image :src="user.icon" class="home-item-img" mode="widthFix"></image>
|
|
|
|
|
|
+<template>
|
|
|
|
+ <view class="tab-bar">
|
|
|
|
+ <view
|
|
|
|
+ v-for="(item, index) in tabBar.list"
|
|
|
|
+ :key="index"
|
|
|
|
+ :class="['tab-item', { active: currentTab === index }]"
|
|
|
|
+ @click="selectTabBar(index, item.pagePath)"
|
|
|
|
+ >
|
|
|
|
+ <view class="icon-wrapper">
|
|
|
|
+ <image v-if="currentTab === index" :src="item.iconShow" class="home-item-isShow"></image>
|
|
|
|
+ <image v-else :src="item.icon" class="home-item-img"></image>
|
|
</view>
|
|
</view>
|
|
|
|
+ <span class="label">{{ item.text }}</span>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
-<script setup lang="ts">
|
|
|
|
|
|
+<script lang="ts" setup>
|
|
import { tabBar } from '@/pages.json'
|
|
import { tabBar } from '@/pages.json'
|
|
import { t } from '@/locale'
|
|
import { t } from '@/locale'
|
|
import { useTabbarStore } from '@/store/tabbar'
|
|
import { useTabbarStore } from '@/store/tabbar'
|
|
|
|
+ import { ref } from 'vue'
|
|
|
|
|
|
const tabbarStore = useTabbarStore()
|
|
const tabbarStore = useTabbarStore()
|
|
|
|
+ const currentTab = ref(0)
|
|
|
|
|
|
- const [Parenting, music, user] = tabBar.list.map((item) => ({
|
|
|
|
- ...item,
|
|
|
|
- path: `/${item.pagePath}`,
|
|
|
|
- text: t(item.text),
|
|
|
|
- }))
|
|
|
|
-
|
|
|
|
- function selectTabBar(url: string, index: number) {
|
|
|
|
- console.log(url, '11111111')
|
|
|
|
- console.log(index, '222222')
|
|
|
|
-
|
|
|
|
|
|
+ function selectTabBar(index: number, url: string) {
|
|
|
|
+ currentTab.value = index
|
|
tabbarStore.setCurIdx(index)
|
|
tabbarStore.setCurIdx(index)
|
|
uni.switchTab({ url })
|
|
uni.switchTab({ url })
|
|
}
|
|
}
|
|
@@ -63,35 +55,66 @@
|
|
// #endif
|
|
// #endif
|
|
})
|
|
})
|
|
</script>
|
|
</script>
|
|
-<style lang="scss" scoped>
|
|
|
|
- .shop-tabbar-container {
|
|
|
|
|
|
+
|
|
|
|
+<style scoped>
|
|
|
|
+ .tab-bar {
|
|
position: fixed;
|
|
position: fixed;
|
|
|
|
+ right: 0;
|
|
bottom: 0;
|
|
bottom: 0;
|
|
left: 0;
|
|
left: 0;
|
|
display: flex;
|
|
display: flex;
|
|
- justify-content: space-between;
|
|
|
|
- width: 100vw;
|
|
|
|
- height: 3.5rem;
|
|
|
|
- background-color: #fff;
|
|
|
|
|
|
+ align-items: center;
|
|
|
|
+ justify-content: space-around;
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 80px;
|
|
|
|
+ background: #ffffff;
|
|
|
|
+ box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
|
|
}
|
|
}
|
|
- .home-item {
|
|
|
|
|
|
+
|
|
|
|
+ .tab-item {
|
|
display: flex;
|
|
display: flex;
|
|
- flex: 1;
|
|
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
align-items: center;
|
|
- justify-content: center;
|
|
|
|
|
|
+ width: 80px;
|
|
|
|
+ padding: 6px 0;
|
|
|
|
+ color: #999999;
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
|
|
+ transition: color 0.3s ease;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .icon-wrapper {
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ justify-content: center;
|
|
|
|
+ width: 45px;
|
|
|
|
+ height: 45px;
|
|
|
|
+ border-radius: 50%;
|
|
transition: all 0.3s ease;
|
|
transition: all 0.3s ease;
|
|
}
|
|
}
|
|
- .home-item-wrapper {
|
|
|
|
- margin-bottom: 5rpx;
|
|
|
|
|
|
+
|
|
|
|
+ .tab-item.active {
|
|
|
|
+ color: #60a5fa;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ .tab-item.active .icon-wrapper {
|
|
|
|
+ /* background: #60a5fa; */
|
|
|
|
+ color: #ffffff;
|
|
|
|
+ transform: translateY(-18px);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .label {
|
|
|
|
+ margin-top: 3px;
|
|
|
|
+ font-size: 12px;
|
|
|
|
+ transition: all 0.3s ease;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .tab-item.active .label {
|
|
|
|
+ transform: translateY(-8px);
|
|
|
|
+ }
|
|
|
|
+
|
|
.home-item-img {
|
|
.home-item-img {
|
|
- width: 7.125rem;
|
|
|
|
- height: 2.5rem;
|
|
|
|
|
|
+ width: 1.25rem;
|
|
|
|
+ height: 1.25rem;
|
|
object-fit: contain;
|
|
object-fit: contain;
|
|
}
|
|
}
|
|
- .home-item-img:hover {
|
|
|
|
- color: #007aff;
|
|
|
|
- }
|
|
|
|
</style>
|
|
</style>
|