You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.2 KiB

1 year ago
<template>
<view class="tabbar" @touchmove.stop.prevent="() => {}">
<view class="tabbar__content safe-area-inset-bottom">
<view class="tabbar__content__item"
v-for="item in pages"
:class="{ 'tabbar__content__item-active': pageUrl === item.pagePath }"
:key="item.pagePath"
@tap.stop="clickHandler(item)">
<view class="icon">
<img class="active-bkg" src="/static/tabbar/active-bkg.svg" alt="">
1 year ago
<img class="icon__inner" :src=" pageUrl === item.pagePath ? item.selectedMyIconPath : item.myIconPath" alt="" >
1 year ago
</view>
<text class="text">{{ item.text }}</text>
</view>
</view>
</view>
</template>
<script>
1 year ago
import pages from '@/pages.json'
1 year ago
export default {
data() {
return {
pageUrl: '',
1 year ago
pages: []
1 year ago
};
},
created() {
1 year ago
this.pages = pages.tabBar.list
1 year ago
uni.hideTabBar();
// 获取引入了u-tabbar页面的路由地址该地址没有路径前面的"/"
let curPages = getCurrentPages();
// 页面栈中的最后一个即为项为当前页面route属性为页面路径
this.pageUrl = curPages[curPages.length - 1].route;
},
methods: {
clickHandler (item) {
uni.switchTab({
url: '/' + item.pagePath
})
}
},
}
</script>
<style lang="scss">
.tabbar {
&__content {
height: 60px;
display: flex;
justify-content: center;
align-items: flex-end;
background: #fff;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
z-index: 998;
/* #ifndef APP-NVUE */
box-sizing: content-box;
/* #endif */
&__item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
padding-bottom: 12rpx;
.icon {
width: 40rpx;
height: 40rpx;
1 year ago
// overflow: hidden;
1 year ago
z-index: 2;
position: relative;
.active-bkg {
display: none;
position: absolute;
top: 0;
left: 0;
}
&__inner {
width: 40rpx;
height: 40rpx;
1 year ago
border-bottom: 40rpx solid transparent;
transform: translateZ(0);
// filter: drop-shadow(0 80rpx 0 #333);
1 year ago
}
}
.text {
font-size: 24rpx;
color: #333;
margin-top: 12rpx;
}
&-active {
filter: drop-shadow(0 0 4rpx #fff);
.icon {
$activeSize: 94rpx;
width: $activeSize;
height: $activeSize;
.active-bkg {
display: inherit;
width: $activeSize;
height: $activeSize;
}
&__inner {
$activeIcon: 50rpx;
width: $activeIcon;
height: $activeIcon;
1 year ago
transform: translateX(calc((#{$activeSize} - #{$activeIcon}) / 2)) translateY(calc((#{$activeSize} - #{$activeIcon}) / 2)) translateZ(0);
// filter: drop-shadow(calc((#{$activeSize} - #{$activeIcon}) / 2) calc((#{$activeSize} - #{$activeIcon}) / 2) 0 #fff);
// filter: drop-shadow(calc((#{$activeSize} - #{$activeIcon}) / 2) calc((#{$activeSize} - #{$activeIcon}) / 2 + 80rpx) 0 #fff);
1 year ago
}
}
.text {
color: #d05b58;
}
}
}
}
}
</style>