roamfuding-xcx/components/tab-bar/tab-bar.vue

150 lines
4.4 KiB
Vue
Raw Permalink Normal View History

<template>
2024-01-23 19:15:52 +08:00
<view class="cont">
2024-01-24 11:55:35 +08:00
<div class="tab" @tap.stop="changeTabbar(0)">
2025-11-08 11:21:57 +08:00
<image src="https://api.ccttiot.com/smartmeter/img/static/uescnTiBJhayN9AUEmvG" mode="" v-show="indexs==0"></image>
<image src="https://api.ccttiot.com/smartmeter/img/static/u0lb7lEv0LgQ1h9VUQX2" mode="" v-show="indexs!=0"></image>
<!-- <div class="txt" :class="indexs==0?'act1':''">福鼎</div> -->
2024-01-24 11:55:35 +08:00
</div>
<div class="tab" @tap.stop="changeTabbar(1)">
2025-11-08 11:21:57 +08:00
<image src="https://api.ccttiot.com/smartmeter/img/static/uJjpY9EgnrL3GAVNIYLK" mode="" v-show="indexs==1"></image>
<image src="https://api.ccttiot.com/smartmeter/img/static/uuNay7ZcwsWnEkvTmwrl" mode="" v-show="indexs!=1"></image>
<!-- <div class="txt" :class="indexs==1?'act1':''">资讯</div> -->
2024-01-24 11:55:35 +08:00
</div>
2025-11-08 11:21:57 +08:00
<div class="tab" style="width: 102rpx;" @tap.stop="changeTabbar(2)">
<image src="https://api.ccttiot.com/smartmeter/img/static/uJg4j3G5wVwDYTpH42ch" mode="" v-show="indexs!=2" style="width:140rpx;height:146rpx;position: absolute;top: -100rpx;"></image>
<image src="https://api.ccttiot.com/smartmeter/img/static/uJg4j3G5wVwDYTpH42ch" mode="" v-show="indexs==2" style="width:140rpx;height:146rpx;position: absolute;top: -100rpx;"></image>
<!-- <div class="txt" :class="indexs==2?'act1':''">玩福鼎</div> -->
</div>
<div class="tab" @tap.stop="changeTabbar(3)">
<image src="https://api.ccttiot.com/smartmeter/img/static/uY8pw6ac2zJ7grOuObf7" mode="" v-show="indexs==3"></image>
<image src="https://api.ccttiot.com/smartmeter/img/static/umBHTrq1utATDu9hjf65" mode="" v-show="indexs!=3"></image>
<!-- <div class="txt" :class="indexs==3?'act1':''">广场</div> -->
</div>
<div class="tab" @tap.stop="changeTabbar(4)">
<image src="https://api.ccttiot.com/smartmeter/img/static/unlRxZXtzF2lgS5fRKRX" mode="" v-show="indexs==4"></image>
<image src="https://api.ccttiot.com/smartmeter/img/static/ujNFJW7KqlyWwIHpMrg0" mode="" v-show="indexs!=4"></image>
<!-- <div class="txt" :class="indexs==4?'act1':''">我的</div> -->
2024-01-24 11:55:35 +08:00
</div>
</view>
</template>
<script>
export default {
2024-01-23 19:15:52 +08:00
props: {
indexs: [Number, String], //题目id
},
data() {
2024-01-23 19:15:52 +08:00
return {
currentTabbarIndex: 0,
// 自定义底栏对应页面的加载情况
tabberPageLoadFlag: [],
ispop: false,
}
},
2024-01-23 19:15:52 +08:00
mounted() {
this.currentTabbarIndex = this.indexs
// const index = Number(this.indexs || 0)
// // 根据底部tabbar菜单列表设置对应页面的加载情况
// for (let i = 0; i < 5; i++) {
// this.tabberPageLoadFlag.push(i === index)
// }
// this.changeTabbar(index)
},
2024-01-24 11:55:35 +08:00
methods:{
changeTabbar(index) {
if (this.currentTabbarIndex === index) return
// this._switchTabbarPage(index)
if(index==0){
uni.switchTab({
url:'/pages/index/index',
2024-01-27 16:37:52 +08:00
routeType: 'wx://modal',
2024-01-24 11:55:35 +08:00
success() {
this.currentTabbarIndex = index
}
})
console.log('点击了',index);
}else if(index==1){
uni.switchTab({
url:'/pages/tj',
2024-01-27 16:37:52 +08:00
routeType: 'wx://modal',
2024-01-24 11:55:35 +08:00
success() {
this.currentTabbarIndex = index
}
})
}else if(index==2){
2025-11-08 11:21:57 +08:00
uni.reLaunch({
url:'/pages/myorder/returned/index',
routeType: 'wx://modal',
success() {
this.currentTabbarIndex = index
}
})
}else if(index==3){
uni.switchTab({
url:'/pages/myorder/index',
routeType: 'wx://modal',
success() {
this.currentTabbarIndex = index
}
})
}else if(index==4){
2024-01-24 11:55:35 +08:00
uni.switchTab({
url:'/pages/my',
2024-01-27 16:37:52 +08:00
routeType: 'wx://modal',
2024-01-24 11:55:35 +08:00
success() {
this.currentTabbarIndex = index
}
})
}
},
}
}
</script>
<style lang="scss" scoped>
2025-11-08 11:21:57 +08:00
::v-deep.u-tabbar__content__item__button {
top: 20rpx !important;
}
2024-01-23 19:15:52 +08:00
2025-11-08 11:21:57 +08:00
::v-deep.u-tabbar {
2024-01-23 19:15:52 +08:00
.u-tabbar__content__item:nth-child(2) {
.u-tabbar__content__item__button {
width: 32rpx !important;
}
}
}
.cont {
position: fixed;
2025-11-08 11:21:57 +08:00
left: 0;
bottom: 0;
width: 100%;
height: 170rpx;
2024-01-23 19:15:52 +08:00
background: #FFFFFF;
2025-11-08 11:21:57 +08:00
box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(53, 140, 255, 0.1);
2024-01-24 11:55:35 +08:00
display: flex;
align-items: center;
justify-content: space-around;
.tab{
2025-11-08 11:21:57 +08:00
width: 60rpx;
2024-01-24 11:55:35 +08:00
display: flex;
flex-wrap: wrap;
justify-content: center;
2025-11-08 11:21:57 +08:00
position: relative;
2024-01-24 11:55:35 +08:00
image{
2025-11-08 11:21:57 +08:00
width: 56rpx;
height: 94rpx;
2024-01-24 11:55:35 +08:00
}
.txt{
margin-top: 10rpx;
2025-11-08 11:21:57 +08:00
font-size: 28rpx;
color: #7C7C7C;
2024-01-24 11:55:35 +08:00
}
.act1{
color: #8883F0;
}
}
}
</style>