App.vue 862 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <script>
  2. import config from './config'
  3. import { getToken } from '@/utils/auth'
  4. import { showMessageTabRedDot } from "@/utils/common.js"
  5. export default {
  6. onLaunch: function () {
  7. this.initApp()
  8. // 在应用启动时为消息tab显示红点
  9. showMessageTabRedDot()
  10. },
  11. methods: {
  12. // 初始化应用
  13. initApp() {
  14. // 初始化应用配置
  15. this.initConfig()
  16. // 检查用户登录状态
  17. //#ifdef H5
  18. this.checkLogin()
  19. //#endif
  20. },
  21. initConfig() {
  22. this.globalData.config = config
  23. },
  24. checkLogin() {
  25. if (!getToken()) {
  26. this.$tab.reLaunch('/pages/login')
  27. }
  28. },
  29. }
  30. }
  31. </script>
  32. <style lang="scss">
  33. @import "uview-ui/index.scss";
  34. @import '@/static/scss/index.scss';
  35. uni-page-body {
  36. height: 100%;
  37. margin-bottom: 0 !important;
  38. padding-bottom: 0 !important;
  39. }
  40. </style>