|
@@ -72,7 +72,8 @@ import {
|
|
|
setMessageRead,
|
|
|
deleteMessage,
|
|
|
deleteMessageRead,
|
|
|
- setMessageAllRead
|
|
|
+ setMessageAllRead,
|
|
|
+ sendUnreadCount
|
|
|
} from '@/api/message'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
export default {
|
|
@@ -94,7 +95,7 @@ export default {
|
|
|
},
|
|
|
loading: false,
|
|
|
items: [],
|
|
|
- timer: null,
|
|
|
+ // timer: null,
|
|
|
readState: null,
|
|
|
unreadTotal: 0
|
|
|
}
|
|
@@ -104,18 +105,18 @@ export default {
|
|
|
},
|
|
|
created () {
|
|
|
this.getUnread()
|
|
|
- if (this.timer) {
|
|
|
- clearInterval(this.timer)
|
|
|
- }
|
|
|
- this.timer = setInterval(() => {
|
|
|
- this.getUnread()
|
|
|
- }, 3000)
|
|
|
- },
|
|
|
- beforeDestroy () {
|
|
|
- if (this.timer) {
|
|
|
- clearInterval(this.timer)
|
|
|
- }
|
|
|
+ // if (this.timer) {
|
|
|
+ // clearInterval(this.timer)
|
|
|
+ // }
|
|
|
+ // this.timer = setInterval(() => {
|
|
|
+ // this.getUnread()
|
|
|
+ // }, 3000)
|
|
|
},
|
|
|
+ // beforeDestroy () {
|
|
|
+ // if (this.timer) {
|
|
|
+ // clearInterval(this.timer)
|
|
|
+ // }
|
|
|
+ // },
|
|
|
methods: {
|
|
|
onCommand (index) {
|
|
|
this.menuActive = index
|
|
@@ -137,17 +138,12 @@ export default {
|
|
|
},
|
|
|
async getUnread () {
|
|
|
try {
|
|
|
- const { data } = await getMessage({
|
|
|
- userId: this.userInfo.id,
|
|
|
- readState: 0,
|
|
|
- page: {
|
|
|
- size: 1,
|
|
|
- current: 1
|
|
|
- }
|
|
|
- })
|
|
|
+ const { data } = await sendUnreadCount()
|
|
|
this.unreadTotal = data.total
|
|
|
} catch (error) {
|
|
|
this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.getUnread()
|
|
|
}
|
|
|
},
|
|
|
async onInit () {
|