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.
|
|
|
|
|
<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="">
|
|
|
|
|
|
<img class="icon__inner" :src=" pageUrl === item.pagePath ? item.selectedMyIconPath : item.myIconPath" alt="" >
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<text class="text">{{ item.text }}</text>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import pages from '@/pages.json'
|
|
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
pageUrl: '',
|
|
|
|
|
|
pages: []
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
created() {
|
|
|
|
|
|
this.pages = pages.tabBar.list
|
|
|
|
|
|
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;
|
|
|
|
|
|
// overflow: hidden;
|
|
|
|
|
|
z-index: 2;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
|
|
|
|
.active-bkg {
|
|
|
|
|
|
display: none;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&__inner {
|
|
|
|
|
|
width: 40rpx;
|
|
|
|
|
|
height: 40rpx;
|
|
|
|
|
|
border-bottom: 40rpx solid transparent;
|
|
|
|
|
|
transform: translateZ(0);
|
|
|
|
|
|
// filter: drop-shadow(0 80rpx 0 #333);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.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;
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.text {
|
|
|
|
|
|
color: #d05b58;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|