App.vue 738 B

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