App.vue 701 B

123456789101112131415161718192021222324252627282930313233
  1. <script>
  2. export default {
  3. onLaunch: function () {
  4. const getMessageCount = async () => {
  5. if(!this.$store.state.token) return
  6. let res = await this.$http.get('/message/getMessageCount')
  7. if (res.code == 200) {
  8. uni.setTabBarBadge({
  9. index: 2,//tabbar的索引
  10. text: res.data['999'] + ''
  11. })
  12. }
  13. }
  14. setInterval(() => {
  15. getMessageCount()
  16. }, 30000);
  17. },
  18. async onShow() {
  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>