uni-admission-fee/components/my-tabbar/my-tabbar.vue

90 lines
2.0 KiB
Vue
Raw Normal View History

2023-10-27 05:40:47 +00:00
<template>
2023-10-28 08:56:32 +00:00
<view>
<u-tabbar :value="current"
@change="changeTab"
2023-10-27 08:43:30 +00:00
:fixed="true"
:placeholder="false"
2023-10-28 08:56:32 +00:00
:safeAreaInsetBottom="true"
:border="false"
activeColor="#FFC748"
inactiveColor="#1D1D1D">
<u-tabbar-item v-for="(item,index) in tabBarList"
:key="index"
:text="item.text">
<image class="u-page__item__slot-icon"
2023-10-27 08:43:30 +00:00
slot="inactive-icon"
2023-10-28 08:56:32 +00:00
:src="item.iconPath"></image>
<image class="u-page__item__slot-icon"
2023-10-27 08:43:30 +00:00
slot="active-icon"
2023-10-28 08:56:32 +00:00
:src="item.selectedIconPath"></image>
2023-10-27 05:40:47 +00:00
</u-tabbar-item>
</u-tabbar>
2023-10-28 08:56:32 +00:00
2023-10-27 05:40:47 +00:00
</view>
</template>
<script>
export default {
2023-10-28 08:56:32 +00:00
props: {
currentPage: String
},
2023-10-27 08:43:30 +00:00
data () {
2023-10-27 05:40:47 +00:00
return {
2023-10-28 08:56:32 +00:00
current: 0,
tabBarList: [{
pagePath: "pages/ticket/index",
iconPath: "../../static/tabbar/icon-ticket.png",
selectedIconPath: "../../static/tabbar/icon-ticket-active.png",
text: '场馆',
customIcon: false,
},
{
pagePath: "pages/my/my",
iconPath: "../../static/tabbar/icon-mine.png",
selectedIconPath: "../../static/tabbar/icon-mine-active.png",
text: '我的',
customIcon: false,
}
]
};
2023-10-27 05:40:47 +00:00
},
methods: {
2023-10-28 08:56:32 +00:00
changeTab (e) {
let page = '/' + this.tabBarList[e].pagePath
console.log(page);
uni.switchTab({
url: page,
success: () => {
},
fail: (e) => {
console.log(e);
}
})
2023-10-27 08:43:30 +00:00
}
2023-10-28 08:56:32 +00:00
},
created () {
//隐藏原生tabbar
uni.hideTabBar();
// 当前选中的菜单
this.tabBarList.forEach((i, index) => {
if (i.pagePath == this.currentPage) {
this.current = index
}
})
},
2023-10-27 05:40:47 +00:00
}
</script>
2023-10-28 08:56:32 +00:00
<style lang="scss" scoped>
.u-page__item__slot-icon {
width: 76rpx;
height: 76rpx;
}
.u-tabbar /deep/ .u-tabbar--fixed {
width: 100%;
height: 88rpx;
padding: 20px 0;
background: #ffffff;
}
</style>