App.vue 765 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. },
  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 (!getAccessToken()) {
  26. this.$tab.reLaunch('/pages/login')
  27. }
  28. }
  29. }
  30. }
  31. </script>
  32. <style lang="scss">
  33. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  34. @import "uview-ui/index.scss";
  35. @import '@/static/scss/index.scss';
  36. @import "@/static/scss/global.scss";
  37. </style>