171 lines
4.8 KiB
Vue
Executable File
171 lines
4.8 KiB
Vue
Executable File
<template>
|
|
<!-- #ifndef MP-TOUTIAO -->
|
|
<view class="clay-tab-bar">
|
|
<view class="tab-bar-item" @tap="switchTab('pages/index/index')" :class="{ active: selected === 0 }">
|
|
<view class="tab-icon-wrapper" :class="{ 'icon-active': selected === 0 }">
|
|
<image class="tab-icon" :src="selected === 0 ? '/static/tab/home_active.png' : '/static/tab/home.png'" mode="aspectFit"></image>
|
|
</view>
|
|
<text class="tab-text" :class="{ active: selected === 0 }">首页</text>
|
|
</view>
|
|
|
|
<view class="tab-bar-item" @tap="switchTab('pages/shop/index')" :class="{ active: selected === 1 }">
|
|
<view class="tab-icon-wrapper" :class="{ 'icon-active': selected === 1 }">
|
|
<image class="tab-icon" :src="selected === 1 ? '/static/tab/shop_active.png' : '/static/tab/shop.png'" mode="aspectFit"></image>
|
|
</view>
|
|
<text class="tab-text" :class="{ active: selected === 1 }">商城</text>
|
|
</view>
|
|
|
|
<view class="tab-bar-item" @tap="switchTab('pages/cabinet/index')" :class="{ active: selected === 2 }">
|
|
<view class="tab-icon-wrapper" :class="{ 'icon-active': selected === 2 }">
|
|
<image class="tab-icon" :src="selected === 2 ? '/static/tab/box_active.png' : '/static/tab/box.png'" mode="aspectFit"></image>
|
|
</view>
|
|
<text class="tab-text" :class="{ active: selected === 2 }">盒柜</text>
|
|
</view>
|
|
|
|
<view class="tab-bar-item" @tap="switchTab('pages/mine/index')" :class="{ active: selected === 3 }">
|
|
<view class="tab-icon-wrapper" :class="{ 'icon-active': selected === 3 }">
|
|
<image class="tab-icon" :src="selected === 3 ? '/static/tab/profile_active.png' : '/static/tab/profile.png'" mode="aspectFit"></image>
|
|
</view>
|
|
<text class="tab-text" :class="{ active: selected === 3 }">我的</text>
|
|
</view>
|
|
</view>
|
|
<!-- #endif -->
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
// #ifndef MP-TOUTIAO
|
|
data() {
|
|
return {
|
|
selected: 0 // 默认选中"首页"
|
|
}
|
|
},
|
|
mounted() {
|
|
this.updateSelected()
|
|
},
|
|
onShow() {
|
|
this.updateSelected()
|
|
},
|
|
methods: {
|
|
updateSelected() {
|
|
const pages = getCurrentPages()
|
|
if (pages.length > 0) {
|
|
const currentPage = pages[pages.length - 1]
|
|
const route = currentPage.route
|
|
|
|
if (route === 'pages/index/index') this.selected = 0
|
|
else if (route === 'pages/shop/index') this.selected = 1
|
|
else if (route === 'pages/cabinet/index') this.selected = 2
|
|
else if (route === 'pages/mine/index') this.selected = 3
|
|
}
|
|
},
|
|
switchTab(url) {
|
|
uni.switchTab({
|
|
url: '/' + url
|
|
})
|
|
}
|
|
}
|
|
// #endif
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
/* #ifndef MP-TOUTIAO */
|
|
/* ============================================
|
|
Claymorphism 底部导航栏
|
|
粘土风格 - 柔和浮感 & 双阴影效果
|
|
============================================ */
|
|
|
|
.clay-tab-bar {
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
background: linear-gradient(145deg, #ffffff, #f5f5f5);
|
|
border-top: 1px solid rgba(255, 255, 255, 0.6);
|
|
display: flex;
|
|
justify-content: space-around;
|
|
align-items: center;
|
|
padding: 12rpx 0 calc(12rpx + env(safe-area-inset-bottom));
|
|
z-index: 999;
|
|
|
|
/* Claymorphism 双阴影 - 创造浮起效果 */
|
|
box-shadow:
|
|
0 -8rpx 16rpx rgba(0, 0, 0, 0.04),
|
|
0 8rpx 16rpx rgba(255, 255, 255, 0.8),
|
|
inset 0 2rpx 4rpx rgba(255, 255, 255, 0.9),
|
|
inset 0 -2rpx 4rpx rgba(0, 0, 0, 0.02);
|
|
}
|
|
|
|
.tab-bar-item {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 8rpx 0;
|
|
position: relative;
|
|
transition: all 0.3s ease;
|
|
|
|
&.active {
|
|
.tab-icon-wrapper {
|
|
/* 选中状态 - Claymorphism 凸起效果 */
|
|
background: linear-gradient(145deg, #FF9500, #FF6B00);
|
|
box-shadow:
|
|
6rpx 6rpx 12rpx rgba(255, 107, 0, 0.2),
|
|
-6rpx -6rpx 12rpx rgba(255, 255, 255, 0.7),
|
|
inset 2rpx 2rpx 4rpx rgba(255, 255, 255, 0.4),
|
|
inset -2rpx -2rpx 4rpx rgba(0, 0, 0, 0.1);
|
|
transform: translateY(-4rpx);
|
|
}
|
|
|
|
.tab-text {
|
|
color: #FF6B00;
|
|
font-weight: 700;
|
|
}
|
|
}
|
|
|
|
&:active {
|
|
transform: scale(0.95);
|
|
}
|
|
}
|
|
|
|
/* 图标包装器 - Claymorphism 圆形徽章 */
|
|
.tab-icon-wrapper {
|
|
width: 64rpx;
|
|
height: 64rpx;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin-bottom: 6rpx;
|
|
background: linear-gradient(145deg, #f8f8f8, #e8e8e8);
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
/* 默认状态 - 凹陷效果 */
|
|
box-shadow:
|
|
inset 3rpx 3rpx 6rpx rgba(0, 0, 0, 0.08),
|
|
inset -3rpx -3rpx 6rpx rgba(255, 255, 255, 0.9);
|
|
}
|
|
|
|
.tab-icon {
|
|
width: 40rpx;
|
|
height: 40rpx;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.tab-text {
|
|
font-size: 22rpx;
|
|
color: #86868B;
|
|
transition: all 0.3s ease;
|
|
font-weight: 500;
|
|
}
|
|
|
|
/* 选中状态的图标颜色调整 */
|
|
.tab-bar-item.active .tab-icon {
|
|
filter: brightness(0) invert(1);
|
|
}
|
|
|
|
/* #endif */
|
|
</style>
|