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.

183 lines
4.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<view class="tabbar-container">
<block>
<view class="tabbar-item" v-for="(item, index) in tabbarList"
:class="[currentItem == item.id ? ' center-item' : '']" @click="changeItem(item)">
<view class="item-top">
<image :style="{width:item.width+'rpx',height:item.height+'rpx'}"
:src="currentItem == item.id ? item.selectedIconPath : item.iconPath"></image>
</view>
<view class="item-bottom" :class="[currentItem == item.id ? 'item-active' : '']">
<text>{{ item.text }}</text>
</view>
</view>
</block>
</view>
</template>
<script>
export default {
props: {
currentPage: {
type: Number,
default: 0
}
},
data() {
return {
currentItem: 0,
tabbarList: [{
id: 0,
centerItem: false,
width: 71,
height: 58,
"text": "首页",
"pagePath": "/pages/home/home",
"iconPath": require("@/static/icon1.png"),
"selectedIconPath": require("@/static/icon1-cur.png")
},
// {
// id: 1,
// centerItem: false,
// width: 72,
// height: 65,
// "text": "抗战",
// "pagePath": "/pages/line/war",
// "iconPath": require("@/static/icon5.png"),
// "selectedIconPath": require("@/static/icon5-cur.png")
// },
{
id: 2,
centerItem: false,
width: 47,
height: 76,
"text": "书房",
"pagePath": "/pages/book/house",
"iconPath": require("@/static/icon6.png"),
"selectedIconPath": require("@/static/icon6-cur.png")
},
{
id: 3,
centerItem: false,
width: 54,
height: 60,
"text": "我的",
"pagePath": "/pages/me/me",
"iconPath": require("@/static/icon3.png"),
"selectedIconPath": require("@/static/icon3-cur.png")
}
]
};
},
mounted() {
this.currentItem = this.currentPage;
// #ifndef H5
// 小程序端隐藏系统tabbar使用自定义tabbar
uni.hideTabBar();
// #endif
},
methods: {
changeItem(item) {
let _this = this;
console.log(item.pagePath)
//_this.currentItem = item.id;
// #ifndef H5
uni.switchTab({
url: item.pagePath
});
// #endif
// #ifdef H5
// H5端使用uni.navigateTo或uni.reLaunch进行页面跳转
uni.reLaunch({
url: item.pagePath
});
// #endif
}
}
};
</script>
<style scoped>
view {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.tabbar-container {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 135rpx;
display: flex;
align-items: center;
padding: 10rpx 0;
color: #6E6E6E;
z-index: 9999;
background: #fff;
background: #fff;
border-top:10rpx solid #dbd0ba;
}
.tabbar-container .tabbar-item {
width: 50%;
/* height: 100rpx; */
display: flex;
flex-direction: column;
/* justify-content: center; */
align-items: center;
text-align: center;
}
.tabbar-container .item-active {
color: #73685c;
}
.tabbar-container .center-item {
/* display: block;
position: relative; */
}
.tabbar-container .tabbar-item .item-top {
/* width: 56rpx;
height: 44rpx; */
margin: 10rpx 0;
position: relative;
width: 120rpx;
height: 61rpx;
}
.tabbar-container .tabbar-item .item-top image {
vertical-align: middle;
position: relative;
z-index:999999;
}
.tabbar-container .tabbar-item .item-bottom {
font-size: 28rpx;
width: 100%;
}
.tabbar-container .center-item .item-bottom {
/* position: absolute;
bottom: 5rpx; */
}
.tabbar-container .center-item .item-top::before {
content:'';
width: 120rpx;
height: 80rpx;
position: absolute;
/* top: -50rpx;
left: calc(50% - 50rpx); */
top:5%;
left:50%;
transform: translate(-50%,-50%);
border-radius: 60rpx 60rpx 0 0;
box-shadow: 0 -6rpx 12rpx rgba(0, 0, 0, 0.1);
z-index:99999;
background-color: #fff;
/* background-color: #ffffff; */
}
</style>