87 lines
2.1 KiB
Vue
87 lines
2.1 KiB
Vue
<template>
|
|
<view class="bottom-nav">
|
|
<view class="nav-item" @click="navigateTo('index')">
|
|
<image :src="activeTab === 'index' ? '/static/imgs/footer/home-active.png' : '/static/imgs/footer/home.png'"
|
|
mode="aspectFit"></image>
|
|
<text :class="{active: activeTab === 'index'}">首页</text>
|
|
</view>
|
|
<view class="nav-item" @click="navigateTo('chat')">
|
|
<image :src="activeTab === 'chat' ? '/static/imgs/footer/ai-active.png' : '/static/imgs/footer/ai.png'"
|
|
mode="aspectFit"></image>
|
|
<text :class="{active: activeTab === 'chat'}">AI助手</text>
|
|
</view>
|
|
<view class="nav-item" @click="navigateTo('mine')">
|
|
<image :src="activeTab === 'mine' ? '/static/imgs/footer/mine-active.png' : '/static/imgs/footer/mine.png'"
|
|
mode="aspectFit"></image>
|
|
<text :class="{active: activeTab === 'mine'}">我的</text>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
activeTab: 'index' // 默认激活首页
|
|
}
|
|
},
|
|
created() {
|
|
// 获取当前页面路径设置激活状态
|
|
const pages = getCurrentPages();
|
|
if (pages.length) {
|
|
const currentPage = pages[pages.length - 1].route;
|
|
this.activeTab = currentPage.split('/')[1] || 'index';
|
|
}
|
|
},
|
|
methods: {
|
|
navigateTo(page) {
|
|
this.activeTab = page;
|
|
uni.redirectTo({
|
|
url: `/pages/${page}/index`,
|
|
success: () => {},
|
|
fail: () => {},
|
|
complete: () => {}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.bottom-nav {
|
|
display: flex;
|
|
justify-content: space-around;
|
|
align-items: center;
|
|
background-color: #f8f8f8;
|
|
position: fixed;
|
|
bottom: 0;
|
|
padding-bottom: 40rpx;
|
|
left: 0;
|
|
right: 0;
|
|
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.1);
|
|
z-index: 999;
|
|
height: 100rpx;
|
|
padding-top: 10rpx;
|
|
|
|
.nav-item {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex: 1;
|
|
text-align: center;
|
|
color: #4F4F4F;
|
|
font-size: 24rpx;
|
|
|
|
image {
|
|
width: 46rpx;
|
|
height: 46rpx;
|
|
margin: 12rpx 0 6rpx 0;
|
|
}
|
|
|
|
.active {
|
|
color: #5b9cf8; // 激活状态文字颜色
|
|
}
|
|
}
|
|
}
|
|
</style> |