App.vue 668 B

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