|
|
|
|
|
<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="item.iconPath" alt="" >
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<text class="text">{{ item.text }}</text>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
pageUrl: '',
|
|
|
|
|
|
pages: [
|
|
|
|
|
|
{
|
|
|
|
|
|
"pagePath": "pages/index/index",
|
|
|
|
|
|
"text": "首页",
|
|
|
|
|
|
"iconPath": "/static/tabbar/home.svg",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"pagePath": "pages/order/order",
|
|
|
|
|
|
"text": "订单",
|
|
|
|
|
|
"iconPath": "/static/tabbar/order.svg",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"pagePath": "pages/me/me",
|
|
|
|
|
|
"text": "我的",
|
|
|
|
|
|
"iconPath": "/static/tabbar/me.svg",
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
created() {
|
|
|
|
|
|
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;
|
|
|
|
|
|
transform: translateY(-80rpx);
|
|
|
|
|
|
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;
|
|
|
|
|
|
//background: linear-gradient(to right, #b5261a, #d05b58 26%, #d66766);
|
|
|
|
|
|
//clip-path: polygon(50% 0%, 96% 20%, 96% 80%, 50% 100%, 4% 80%, 4% 20%);
|
|
|
|
|
|
.active-bkg {
|
|
|
|
|
|
display: inherit;
|
|
|
|
|
|
width: $activeSize;
|
|
|
|
|
|
height: $activeSize;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&__inner {
|
|
|
|
|
|
$activeIcon: 50rpx;
|
|
|
|
|
|
width: $activeIcon;
|
|
|
|
|
|
height: $activeIcon;
|
|
|
|
|
|
filter: drop-shadow(calc((#{$activeSize} - #{$activeIcon}) / 2) calc((#{$activeSize} - #{$activeIcon}) / 2 + 80rpx) 0 #fff);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.text {
|
|
|
|
|
|
color: #d05b58;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|