App.vue 718 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!-- @format -->
  2. <script>
  3. import config from "./config";
  4. import store from "@/store";
  5. import {
  6. getToken
  7. } from "@/utils/auth";
  8. export default {
  9. onLaunch: function() {
  10. this.initApp();
  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 (!getToken()) {
  27. this.$tab.reLaunch("/pages/login");
  28. }
  29. },
  30. },
  31. };
  32. </script>
  33. <style lang="scss">
  34. @import "@/uni_modules/uview-ui/index.scss";
  35. @import "@/static/scss/index.scss";
  36. </style>