Sprinkler-app/components/tab-bar/tab-bar.vue

139 lines
3.9 KiB
Vue
Raw 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)">
2024-10-09 16:52:44 +08:00
<image src="https://api.ccttiot.com/smartmeter/img/static/upJM8VILTPn0Oa398g7L" mode="" v-show="indexs!=0"></image>
<image src="https://api.ccttiot.com/smartmeter/img/static/uS7VHOhENrnwJYI0vL4A" mode="" v-show="indexs==0"></image>
2024-01-24 11:55:35 +08:00
<div class="txt" :class="indexs==0?'act1':''">首页</div>
</div>
2024-10-09 16:52:44 +08:00
<div @tap.stop="changeTabbar(1)">
<image style="width: 90rpx;height: 90rpx;position: fixed;left: 50%;transform: translateX(-50%);bottom:110rpx;" src="https://api.ccttiot.com/smartmeter/img/static/u3o5HsEKiDwIQroCz6DM" mode="" v-show="indexs!=1"></image>
<image style="width: 90rpx;height: 90rpx;position: fixed;left: 50%;transform: translateX(-50%);bottom:110rpx;" src="https://api.ccttiot.com/smartmeter/img/static/u3o5HsEKiDwIQroCz6DM" mode="" v-show="indexs==1"></image>
<div class="txt" style="margin-top: 44rpx;color: #3D3D3D;font-size: 28rpx;" :class="indexs==1?'act1':''">AI识图</div>
</div>
2024-01-24 11:55:35 +08:00
<div class="tab" @tap.stop="changeTabbar(2)">
2024-10-09 16:52:44 +08:00
<image src="https://api.ccttiot.com/smartmeter/img/static/uk8KlKhorxKWvBtJE2j8" mode="" v-show="indexs!=2"></image>
<image src="https://api.ccttiot.com/smartmeter/img/static/u3sPW0uZjzlB4GkcauI9" mode="" v-show="indexs==2"></image>
2024-01-24 11:55:35 +08:00
<div class="txt" :class="indexs==2?'act1':''">我的</div>
</div>
2024-10-09 16:52:44 +08:00
<image class="botimg" src="https://api.ccttiot.com/smartmeter/img/static/uV7nJgKVc4tgTuSqB699" mode=""></image>
2024-01-23 19:15:52 +08:00
<!-- <view class="u-page">
</view> -->
<!-- 与包裹页面所有内容的元素u-page同级且在它的下方 -->
2024-01-23 19:15:52 +08:00
<!-- <u-tabbar v-model="current" :list="list" icon-size='40rpx' active-color='#3996fd' inactive-color="#c8c7cb"></u-tabbar> -->
</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){
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>
2024-01-23 19:15:52 +08:00
/deep/.u-tabbar__content__item__button {
top: 20rpx !important;
}
2024-01-23 19:15:52 +08:00
/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;
}
}
}
2024-10-09 16:52:44 +08:00
.botimg{
width: 100%;
height: 144rpx;
position: fixed;
left: 0;
bottom: 0;
z-index: -1;
box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3);
}
2024-01-23 19:15:52 +08:00
.cont {
position: fixed;
2024-10-09 16:52:44 +08:00
left: 0;
bottom: 0;
width:100%;
background-color: #eee;
height: 144rpx;
2024-01-23 19:15:52 +08:00
box-shadow: 0rpx 16rpx 40rpx 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{
2024-10-09 16:52:44 +08:00
width: 60rpx;
2024-01-24 11:55:35 +08:00
display: flex;
flex-wrap: wrap;
justify-content: center;
image{
2024-10-09 16:52:44 +08:00
width: 40rpx;
height: 40rpx;
2024-01-24 11:55:35 +08:00
}
.txt{
margin-top: 10rpx;
2024-10-09 16:52:44 +08:00
font-size: 24rpx;
2024-01-24 11:55:35 +08:00
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
2024-10-09 16:52:44 +08:00
color: #808080;
2024-01-24 11:55:35 +08:00
}
.act1{
2024-10-09 16:52:44 +08:00
color: #48893B;
2024-01-24 11:55:35 +08:00
}
}
}
</style>