App.uvue 794 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. //#ifdef H5
  18. this.checkLogin()
  19. //#endif
  20. },
  21. initConfig() {
  22. this.globalData.config = JSON.parseObject(JSON.stringify(globalConfig)) as UTSJSONObject
  23. },
  24. checkLogin() {
  25. const token=getToken()
  26. if (token!=null&&token!="") {
  27. uni.reLaunch({
  28. url: '/pages/login'
  29. });
  30. }
  31. }
  32. }
  33. }
  34. </script>
  35. <style lang="scss">
  36. @import '@/static/scss/index.scss';
  37. @import '@/uni_modules/uview-plus/index.scss';
  38. </style>