|
@@ -3,7 +3,7 @@
|
|
import {
|
|
import {
|
|
getUserInfo
|
|
getUserInfo
|
|
} from "@/common/utils/util"
|
|
} from "@/common/utils/util"
|
|
-
|
|
|
|
|
|
+ import api from '@/common/http/'
|
|
var getUserValTimeId = null
|
|
var getUserValTimeId = null
|
|
export default {
|
|
export default {
|
|
onLaunch: function() {
|
|
onLaunch: function() {
|
|
@@ -36,8 +36,12 @@
|
|
this.updateUserInfo();
|
|
this.updateUserInfo();
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ uni.$on('getSendMsg', () => {
|
|
|
|
+ this.getSendMsg();
|
|
|
|
+ });
|
|
|
|
+
|
|
if (this.$store.state.user.token) {
|
|
if (this.$store.state.user.token) {
|
|
- this.updateUserInfo();
|
|
|
|
|
|
+ this.getSendMsg();
|
|
}
|
|
}
|
|
|
|
|
|
uni.getSystemInfo({
|
|
uni.getSystemInfo({
|
|
@@ -68,16 +72,24 @@
|
|
|
|
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- async updateUserInfo() {
|
|
|
|
|
|
+ async getSendMsg() {
|
|
(function getUserVal() {
|
|
(function getUserVal() {
|
|
if (getUserValTimeId) {
|
|
if (getUserValTimeId) {
|
|
clearTimeout(getUserValTimeId)
|
|
clearTimeout(getUserValTimeId)
|
|
}
|
|
}
|
|
- getUserInfo().then(res => {
|
|
|
|
- getUserValTimeId = setTimeout(getUserVal, 2000)
|
|
|
|
- })
|
|
|
|
|
|
+ api.get('/user/talk/unread').then((res) => {
|
|
|
|
+ uni.setTabBarBadge({
|
|
|
|
+ index: 2,
|
|
|
|
+ text: res.data
|
|
|
|
+ })
|
|
|
|
+ getUserValTimeId = setTimeout(getUserVal, 2000)
|
|
|
|
+ })
|
|
|
|
+ .catch((error) => {});
|
|
})()
|
|
})()
|
|
},
|
|
},
|
|
|
|
+ async updateUserInfo() {
|
|
|
|
+
|
|
|
|
+ },
|
|
},
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
@@ -87,4 +99,4 @@
|
|
@import "uview-ui/index.scss";
|
|
@import "uview-ui/index.scss";
|
|
|
|
|
|
@import "styles/iconfont.css";
|
|
@import "styles/iconfont.css";
|
|
-</style>
|
|
|
|
|
|
+</style>
|