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