App.vue 650 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <script>
  2. import config from './config'
  3. import store from '@/store'
  4. import {
  5. getToken
  6. } from '@/utils/auth'
  7. export default {
  8. onLaunch: function() {
  9. this.initApp()
  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 "@/uni_modules/uview-ui/index.scss";
  34. @import '@/static/scss/index.scss'
  35. </style>