App.uvue 748 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <script lang="uts">
  2. import {globalConfig} from './config'
  3. import { getToken } from '@/utils/auth'
  4. export default {
  5. globalData: {
  6. config:{}
  7. },
  8. onLaunch() {
  9. this.initApp()
  10. },
  11. methods: {
  12. // 初始化应用
  13. initApp() {
  14. // 初始化应用配置
  15. this.initConfig()
  16. // 检查用户登录状态
  17. this.checkLogin()
  18. },
  19. initConfig() {
  20. this.globalData.config = JSON.parseObject(JSON.stringify(globalConfig)) as UTSJSONObject
  21. },
  22. checkLogin() {
  23. const token=getToken()
  24. if (token!="") {
  25. uni.reLaunch({
  26. url: '/pages/login'
  27. });
  28. }
  29. }
  30. }
  31. }
  32. </script>
  33. <style lang="scss">
  34. @import '@/static/scss/index.scss';
  35. //@import '@/static/scss/colorui.css';
  36. </style>