detection-business/components/tabBar/tabBar.vue

224 lines
4.2 KiB
Vue
Raw Normal View History

2024-09-11 15:55:28 +08:00
<template>
<view class="bottoms">
<view class="box" @click="getgogo(1)">
<view class="imgs">
2025-04-11 17:55:17 +08:00
<image src="../../static/tabBar/homex.png" v-show="aindex == 1"></image>
<image src="../../static/tabBar/home.png" v-show="aindex != 1"></image>
2024-09-11 15:55:28 +08:00
</view>
<view class="xzz" v-show="aindex == 1">首页</view>
2025-04-11 17:55:17 +08:00
<view class="wxz" v-show="aindex != 1">首页</view>
2024-09-11 15:55:28 +08:00
</view>
2025-04-11 17:55:17 +08:00
<view class="box" @click="getgogo(2)">
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
<view class="imgs" style="position: relative;">
<view class="hongdian" v-if=" chuan != 0">
{{chuan}}
</view>
2025-03-03 15:32:31 +08:00
<image src="../../static/tabBar/noticex.png" v-show="aindex == 2"></image>
<image src="../../static/tabBar/notice.png" v-show="aindex != 2"></image>
2024-09-11 15:55:28 +08:00
</view>
<view class="xzz" v-show="aindex == 2">通知</view>
2025-04-11 17:55:17 +08:00
<view class="wxz" v-show="aindex != 2">通知</view>
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
</view>
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
<view class="box" @click="getgogo(3)">
<view class="imgs">
2025-04-11 17:55:17 +08:00
<image src="../../static/tabBar/myx.png" v-show="aindex == 3"></image>
<image src="../../static/tabBar/my.png" v-show="aindex != 3"></image>
2024-09-11 15:55:28 +08:00
</view>
<view class="xzz" v-show="aindex == 3">我的</view>
2025-04-11 17:55:17 +08:00
<view class="wxz" v-show="aindex != 3">我的</view>
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
</view>
</view>
</template>
<script>
2025-04-11 17:55:17 +08:00
const innerAudioContext = uni.createInnerAudioContext();
2024-09-11 15:55:28 +08:00
import request from '../../utils/request';
2025-04-11 17:55:17 +08:00
export default {
data() {
return {
aindex: 1,
chuan: 0,
arr: [{
text: '首页'
},
{
text: '个人中心'
},
2024-09-11 15:55:28 +08:00
],
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
},
2025-04-11 17:55:17 +08:00
props: {
msg: String
2024-09-11 15:55:28 +08:00
},
onLoad() {
this.aindex = this.msg
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
},
onShow() {
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
},
mounted() {
this.aindex = this.msg
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
},
2024-11-11 11:25:51 +08:00
2025-04-11 17:55:17 +08:00
methods: {
2024-11-11 11:25:51 +08:00
dianyidain() {
innerAudioContext.src = 'https://www.nuoyunr.com/lananRsc/rescue/msgV.mp3';
// 设置播放次数和计数器
const playCount = 5;
let currentCount = 0;
2024-11-11 13:18:56 +08:00
2024-11-11 11:25:51 +08:00
// 监听音频播放结束事件
innerAudioContext.onEnded(() => {
// 播放计数加一
currentCount++;
2024-11-11 13:18:56 +08:00
2024-11-11 11:25:51 +08:00
// 判断是否达到播放次数上限
if (currentCount < playCount) {
// 继续播放
innerAudioContext.play();
} else {
// 播放完成,可以在这里添加额外的逻辑
console.log('播放完成');
}
});
2024-11-11 13:18:56 +08:00
2024-11-11 11:25:51 +08:00
// 初次播放
innerAudioContext.play();
2024-11-11 13:18:56 +08:00
2024-11-11 11:25:51 +08:00
},
msgInfo() {
console.log(this.msgSocket, 'msgSocket')
if (this.msgSocket) {
console.log('消息回调启动成功')
this.msgSocket.onMessage(res => {
console.log("发出提示音");
2024-11-11 13:18:56 +08:00
2024-11-11 11:25:51 +08:00
this.dianyidain()
})
}
2024-11-11 13:18:56 +08:00
2024-11-11 11:25:51 +08:00
},
2025-04-11 17:55:17 +08:00
async getbottom() {
2024-09-11 15:55:28 +08:00
let data = {
2025-04-11 17:55:17 +08:00
partnerId: uni.getStorageSync('partnerId')
2024-09-11 15:55:28 +08:00
}
let res = await request({
2025-04-11 17:55:17 +08:00
url: '/appInspection/news/newMsgNum',
2024-09-11 15:55:28 +08:00
method: 'get',
2025-04-11 17:55:17 +08:00
params: data
2024-11-11 13:18:56 +08:00
})
2025-04-11 17:55:17 +08:00
if (res.code == 200) {
2024-09-11 15:55:28 +08:00
this.chuan = res.data
}
},
2025-04-11 17:55:17 +08:00
getgogo(index) {
2024-09-11 15:55:28 +08:00
2025-04-11 17:55:17 +08:00
if (index == 1) {
2024-09-11 15:55:28 +08:00
this.aindex = index
uni.reLaunch({
2025-04-11 17:55:17 +08:00
url: '/pages/index/newindex'
2024-09-11 15:55:28 +08:00
});
// uni.navigateTo({
// url:'/pages/index/index'
// })
}
2025-04-11 17:55:17 +08:00
if (index == 2) {
2024-09-11 15:55:28 +08:00
this.aindex = index
2025-04-11 17:55:17 +08:00
uni.reLaunch({
url: '/pages/xiaoxi/notice'
})
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
2025-04-11 17:55:17 +08:00
if (index == 3) {
2024-09-11 15:55:28 +08:00
this.aindex = index
2025-04-11 17:55:17 +08:00
uni.reLaunch({
url: '/pages/my/my'
})
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
2025-04-11 17:55:17 +08:00
if (index == 4) {
2024-09-11 15:55:28 +08:00
this.aindex = index
2025-04-11 17:55:17 +08:00
uni.showToast({
title: '此功能暂未开发',
icon: 'none'
})
2024-09-11 15:55:28 +08:00
}
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
},
2025-04-11 17:55:17 +08:00
beforeDestroy() {
clearInterval(this.interval);
},
2024-09-11 15:55:28 +08:00
}
</script>
<style scoped lang="scss">
2025-04-11 17:55:17 +08:00
.bottoms {
2024-09-11 15:55:28 +08:00
width: 100%;
height: 50px;
position: fixed;
bottom: 0px;
background: white;
display: flex;
justify-content: space-between;
font-size: 14px;
font-weight: 400;
2025-04-11 17:55:17 +08:00
z-index: 99999;
2024-09-11 15:55:28 +08:00
}
2025-04-11 17:55:17 +08:00
.box {
2024-09-11 15:55:28 +08:00
width: 50%;
text-align: center;
font-size: 12px;
// background-color: white;
}
2025-04-11 17:55:17 +08:00
.hongdian {
2024-09-11 15:55:28 +08:00
width: 12px;
height: 12px;
background-color: crimson;
border-radius: 50%;
overflow: hidden;
position: absolute;
top: -5px;
right: -8px;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 2px;
}
2025-04-11 17:55:17 +08:00
.imgs {
margin: 0 auto;
margin-top: 10px;
2025-03-03 15:32:31 +08:00
width: 22px;
height: 20px;
2025-04-11 17:55:17 +08:00
image {
2024-09-11 15:55:28 +08:00
width: 100%;
height: 100%;
}
}
2025-04-11 17:55:17 +08:00
.xzz {
2024-09-11 15:55:28 +08:00
color: #0D2E8D;
}
2025-04-11 17:55:17 +08:00
.wxz {
2024-09-11 15:55:28 +08:00
color: #AAAAAA;
}
2025-04-11 17:55:17 +08:00
</style>