diff --git a/src/api/home.js b/src/api/home.js index 527138e..1e54c12 100644 --- a/src/api/home.js +++ b/src/api/home.js @@ -32,6 +32,18 @@ class Home { static online(){ return server.get('/online',{config:{loading:false}}) } + /* + * 获取未读消息 + */ + static chat(){ + return server.get('/user/chat',{config:{loading:false}}) + } + /* + * 已读消息 + */ + static chatRead(){ + return server.get('/user/chatRead',{config:{loading:false}}) + } } export default Home; \ No newline at end of file diff --git a/src/components/CommonFooter.vue b/src/components/CommonFooter.vue index f2c7b63..6a81cfa 100644 --- a/src/components/CommonFooter.vue +++ b/src/components/CommonFooter.vue @@ -4,6 +4,7 @@
+ {{newscount>=100?'99+':newscount}}
@@ -283,6 +284,7 @@ import College from "@/api/college"; import ContactUs from "@/api/contactUs"; import Member from "@/api/member"; +import Home from "@/api/home"; import { mapState } from "vuex"; export default { data() { @@ -359,7 +361,8 @@ export default { url: require("../assets/img/tw.jpg"), }, ], - showMenu: false + showMenu: false, + newscount:0 }; }, computed: { @@ -452,6 +455,7 @@ export default { this.ifurl ="https://cs.btcaholic.com/chat/?toid="+rfres.username+"&room_id="+user.account+"&usid="+user.user_id; // show popup this.ispopup = ! this.ispopup + this.chatRead() }) } @@ -461,7 +465,6 @@ export default { // this.$router.push({ path: '/sign-in' }); } - }, // close closebox(){ @@ -469,14 +472,28 @@ export default { this.ispopup = false } this.ispopup =false - } - + }, + chat(){ + Home.chat().then(res => { + this.newscount = res.count; + }) + }, + chatRead(){ + Home.chatRead().then(res => { + console.log(res,'已读'); + }) + } }, created() { this.getCollegeLinks(); this.getServiceLink(); // console.log(this.service); this.getEmial(); + if(this.isLogin){ + this.chatcount = setInterval(()=>{ + this.chat() + },2000) + } }, }; @@ -730,5 +747,19 @@ export default { } } +.circle-pulse1 { + background: red; + display: flex; + justify-content: center; + align-items: center; + min-width: 20px; + height: 20px; + font-size: 12px; + border-radius: 50%; + position: absolute; + right: -20%; + top: -10px; + color: #fff; +} \ No newline at end of file