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.
 
 
 
 

131 lines
2.6 KiB

<template>
<view class="tab_bar">
<view class="tabbarBox">
<view class="handleBox" v-for="(item,index) in tabBarList" :key="index">
<view class="menuBox" @click="goPages(item.pageIndex)">
<view class="menuIcon">
<image v-if="item.type!=selectIndex" class="img" :src="item.iconPath"></image>
<image v-else class="img" :src="item.selectIconPath"></image>
</view>
<view class="menuName">
<text :class="item.type==selectIndex?'TextColor':'Text'">{{item.tabbarName}}</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import urlConfig from '@/utils/config.js'
export default {
props: {
page: {
type: String,
default: "homeIndex"
}
},
watch: {
page: {
handler(value) {
this.selectIndex = value;
},
immediate: true,
deep: true
}
},
data() {
return {
selectIndex: "",
tabBarList: [],
}
},
//uniapp子组件不支持应用生命周期,所以只能用vue生命周期
created() {
//tabbar数据,这儿也支持后台定义通过接口获取数据
// this.tabBarList = [{
// "tabbarName":"", //tababr名称
// "iconPath":"", //tabbar icon
// "selectIconPath":"", //tabbar 选择icon
// "pageIndex":"" //页面路径
// }]
this.listTabbar();
},
methods: {
listTabbar() {
this.$api.listTabbar({})
.then(res => {
for (var i = 0; i < res.data.length; i++) {
if (res.data[i].hide == 1) {
this.tabBarList.push({
"tabbarName": res.data[i].title,
"iconPath": urlConfig+res.data[i].iconPath,
"selectIconPath": urlConfig+res.data[i].selectedIconPath,
"pageIndex": res.data[i].pagePath,
"type": res.data[i].type
});
}
}
}).catch((e) => console.log(e)); //捕获异常
},
//进入tabble页
goPages(pageIndex) {
uni.switchTab({
url: "/" + pageIndex
})
},
},
}
</script>
<style lang="scss">
.tab_bar {
width: 100vw;
height: 90rpx;
position: fixed;
bottom: 30rpx;
/* 模糊大小就是靠的blur这个函数中的数值大小 */
// backdrop-filter: blur(10px);
border-radius: 60rpx;
.tabbarBox {
display: flex;
margin-top: 10rpx;
justify-content: space-evenly;
.handleBox {
width: 20vw;
height: 110rpx;
.menuBox {
padding: 0rpx 20rpx;
width: 120rpx;
height: 98%;
text-align: center;
.img {
width: 50rpx;
height: 50rpx;
}
}
}
}
}
.Text {
font-size: 24rpx;
font-family: Cochin, serif;
font-weight: 900;
color: #969696;
}
.TextColor {
@extend .Text;
color: #2d78ff;
}
</style>