App.vue 702 B

12345678910111213141516171819202122232425262728293031323334
  1. <script>
  2. export default {
  3. onLaunch: function () {
  4. },
  5. async onShow() {
  6. const getMessageCount = async () => {
  7. if(!this.$store.state.token) return
  8. let res = await this.$http.get('/message/getMessageCount')
  9. if (res.code == 200) {
  10. uni.setTabBarBadge({
  11. index: 2,//tabbar的索引
  12. text: res.data['999'] + ''
  13. })
  14. }
  15. }
  16. setInterval(() => {
  17. getMessageCount()
  18. }, 30000);
  19. },
  20. onHide: function () { }
  21. }
  22. </script>
  23. <style lang="scss">
  24. /* #ifndef APP-PLUS-NVUE */
  25. /*每个页面公共css */
  26. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  27. @import "uview-ui/index.scss";
  28. /* 公共样式库 */
  29. @import "/style/zcm-main.css";
  30. /* #endif */
  31. </style>