App.vue 596 B

123456789101112131415161718192021222324252627282930313233
  1. <script>
  2. import config from './config'
  3. import {getToken} from '@/utils/auth'
  4. export default {
  5. onLaunch: function () {
  6. this.initApp()
  7. },
  8. methods: {
  9. // 初始化应用
  10. initApp() {
  11. // 初始化应用配置
  12. this.initConfig()
  13. // 检查用户登录状态
  14. //#ifdef H5
  15. this.checkLogin()
  16. //#endif
  17. },
  18. initConfig() {
  19. this.globalData.config = config
  20. },
  21. checkLogin() {
  22. if (!getToken()) {
  23. this.$tab.reLaunch('/pages/login')
  24. }
  25. }
  26. }
  27. }
  28. </script>
  29. <style lang="scss">
  30. @import '@/static/scss/index.scss'
  31. </style>