@ -1,136 +1,164 @@
|
||||
<template>
|
||||
<view class="tab-bar">
|
||||
<!-- 添加移动的背景块 -->
|
||||
<view class="active-bg" :style="{ transform: `translateX(${100 * props.currentComponentIndex}%)` }"></view>
|
||||
|
||||
<view
|
||||
class="tab-item"
|
||||
:class="{
|
||||
'active': props.currentComponentIndex === index,
|
||||
'is-first-tab': index === 0
|
||||
}"
|
||||
v-for="(item, index) in tabList"
|
||||
v-for="(tab, index) in tabs"
|
||||
:key="index"
|
||||
@click="changeTab(index)">
|
||||
<text :class="{'active': props.currentComponentIndex === index}">{{ item.pageName }}</text>
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === index }"
|
||||
@click="switchTab(index)"
|
||||
>
|
||||
<view class="tab-icon-container" :class="{ active: activeTab === index }">
|
||||
<view class="tab-icon">
|
||||
<image :src="activeTab === index ? tab.activeIcon : tab.icon" mode="aspectFit"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tab-label" :class="{ active: activeTab === index }">{{ tab.label }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
// 定义emit事件
|
||||
const emit = defineEmits(['change-tab', 'change-index']);
|
||||
const props = defineProps(['currentComponentIndex']);
|
||||
|
||||
const tabList = [
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
activeTab: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tabs: [
|
||||
{
|
||||
pageName:'首页',
|
||||
component:'PageOfHome'
|
||||
label: '首页',
|
||||
icon: '/static/icons/home.png',
|
||||
activeIcon: '/static/icons/home-fill.png'
|
||||
},
|
||||
{
|
||||
pageName:'立论',
|
||||
component:'PageOfArgument'
|
||||
label: '辩论',
|
||||
icon: '/static/icons/chat-1-line.png',
|
||||
activeIcon: '/static/icons/chat-1-fill.png'
|
||||
},
|
||||
{
|
||||
pageName:'复盘',
|
||||
component:'PageOfReview'
|
||||
label: '立论',
|
||||
icon: '/static/icons/lightbulb-line.png',
|
||||
activeIcon: '/static/icons/lightbulb-fill.png'
|
||||
},
|
||||
{
|
||||
pageName:'辩论',
|
||||
component:'PageOfDebate'
|
||||
label: '复盘',
|
||||
icon: '/static/icons/file-chart-line.png',
|
||||
activeIcon: '/static/icons/file-chart-fill.png'
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
switchTab(index) {
|
||||
if (this.activeTab === index) return;
|
||||
this.$emit('tab-change', index);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const changeTab = (index) => {
|
||||
if(props.currentComponentIndex === index) return;
|
||||
// 触发事件并传递当前组件名称和索引
|
||||
emit('change-tab', tabList[index].component);
|
||||
emit('change-index', index);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.tab-bar {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 120rpx;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
display: flex;
|
||||
width: 70%;
|
||||
margin: 0 auto;
|
||||
height: 70%;
|
||||
background-color: #1A2C42;
|
||||
border: none;
|
||||
position: relative;
|
||||
border-radius: 25rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4rpx 15rpx rgba(0, 0, 0, 0.2);
|
||||
transform: translateZ(0);
|
||||
-webkit-transform: translateZ(0);
|
||||
backface-visibility: hidden;
|
||||
-webkit-backface-visibility: hidden;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
/* 移动的背景块 */
|
||||
.active-bg {
|
||||
position: absolute;
|
||||
width: 25%;
|
||||
.tab-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
background-color: #00D6B9;
|
||||
border-radius: 25rpx;
|
||||
transition: transform 0.3s ease;
|
||||
z-index: 1;
|
||||
box-shadow: 0 0 20rpx rgba(0, 214, 185, 0.5);
|
||||
/* 添加硬件加速 */
|
||||
will-change: transform;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
.tab-icon-container {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
transition: all 0.3s ease;
|
||||
z-index: 2;
|
||||
border-radius: 50%;
|
||||
min-width: 80rpx; /* 防止 flex 压缩 */
|
||||
min-height: 80rpx;
|
||||
flex-shrink: 0; /* 禁止压缩 */
|
||||
}
|
||||
|
||||
.tab-item::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 1px;
|
||||
height: 60%;
|
||||
z-index: 2;
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
transparent,
|
||||
rgba(0, 214, 185, 0.1) 15%,
|
||||
rgba(0, 214, 185, 0.5) 50%,
|
||||
rgba(0, 214, 185, 0.1) 85%,
|
||||
transparent
|
||||
);
|
||||
.tab-icon-container.active {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
background-color: #B59DF1;
|
||||
transform: translateY(-45rpx);
|
||||
border: 14rpx solid #6839E0;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 4rpx 20rpx rgba(104, 57, 224, 0.4);
|
||||
}
|
||||
|
||||
.tab-item.is-first-tab::before {
|
||||
display: none;
|
||||
.tab-icon {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.tab-item.active {
|
||||
background-color: transparent;
|
||||
.tab-icon image {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
filter: brightness(0) invert(0.8);
|
||||
opacity: 0.7;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.tab-item text {
|
||||
.tab-label {
|
||||
font-size: 24rpx;
|
||||
color: rgba(0, 214, 185, 0.7);
|
||||
transition: all 0.3s ease;
|
||||
text-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.2);
|
||||
font-weight: 400;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
transition: all 0.3s;
|
||||
margin-top: 6rpx;
|
||||
opacity: 0.7;
|
||||
font-family: 'Poppins' , 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
.tab-label.active {
|
||||
color: #FFFFFF;
|
||||
font-weight: 600;
|
||||
opacity: 1;
|
||||
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
|
||||
transform: translateY(-15rpx) scale(1.1);
|
||||
}
|
||||
|
||||
|
||||
.tab-icon-container.active .tab-icon image {
|
||||
opacity: 1;
|
||||
filter: brightness(0) invert(1);
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.tab-item text.active {
|
||||
color: #ffffff;
|
||||
font-weight: bold;
|
||||
text-shadow: 0 1rpx 8rpx rgba(255, 255, 255, 0.4);
|
||||
transform: scale(1.05);
|
||||
.tab-item:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 4.5 KiB |