修改 app问题

This commit is contained in:
GGJ
2024-09-23 08:50:16 +08:00
parent 1dbecd890f
commit 56a2db2b48
9 changed files with 635 additions and 542 deletions

View File

@@ -30,6 +30,7 @@
</template>
<script>
import { getDevCount } from '../../common/api/device.js'
export default {
data() {
return {
@@ -37,8 +38,10 @@ export default {
userInfo: {},
messageCount: {},
timer: null,
devCount: {},
}
},
methods: {
init() {
this.userInfo = uni.getStorageSync('userInfo')
@@ -76,10 +79,58 @@ export default {
break
}
},
getDevCount() {
if (uni.getStorageSync('projectList')[1] != undefined) {
getDevCount(uni.getStorageSync('projectList')[1].engineeringId).then((res) => {
this.devCount = res.data
this.devCount.currentOffLineDevs.forEach((item) => {
item.runStatus = 1
})
this.devCount.offLineDevs.forEach((item) => {
item.runStatus = 1
})
uni.setStorage({
key: this.$cacheKey.messageCount,
data: this.devCount,
})
let messagePage =
this.devCount.runCount +
this.devCount.eventCount +
this.devCount.alarmCount +
this.devCount.harmonicCount
let minePage = this.devCount.feedBackCount
if (messagePage) {
uni.setTabBarBadge({
index: 1,
text:messagePage ? (messagePage > 99 ? '99+' : messagePage + '') : '',
})
} else {
uni.removeTabBarBadge({
index: 1,
})
}
if (minePage) {
uni.setTabBarBadge({
index: 2,
text: minePage + '',
})
} else {
uni.removeTabBarBadge({
index: 2,
})
}
// #ifdef APP-PLUS
plus.runtime.setBadgeNumber(messagePage + minePage)
// #endif
})
}
},
},
onLoad(options) {},
onShow() {
this.init()
this.getDevCount()
this.messageCount = uni.getStorageSync(this.$cacheKey.messageCount) || {}
this.timer = setInterval(() => {
this.messageCount = uni.getStorageSync(this.$cacheKey.messageCount) || {}