App.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <div id="app" ref="app">
  3. <router-view></router-view>
  4. </div>
  5. </template>
  6. <script>
  7. import user from "@/http/api/user";
  8. import { setToken } from "@/utils/auth";
  9. import { encrypt } from "@/utils/jsencrypt";
  10. export default {
  11. name: "App",
  12. mounted() {
  13. // // INFO: 本地调试,自动登录
  14. if (process.env.NODE_ENV === 'development') {
  15. this.SubmitLogin();
  16. }
  17. },
  18. methods: {
  19. SubmitLogin() {
  20. const username = '50002100001';
  21. const password = '100001';
  22. const type = '2';
  23. sessionStorage.setItem('schoolType', type);
  24. user.loginEmailPass({
  25. username: username,
  26. password: encrypt(password),
  27. }).then((res) => {
  28. if (res.code === 200) {
  29. this.$store.dispatch("user/CLEAR_LOCAL_STORAGE");//清空本地存储
  30. setToken(res.data.tokenValue);
  31. this.$store.dispatch("user/SET_TOKEN", res.data.tokenValue);
  32. this.$store.dispatch("user/SET_SCHOOL_LOGO", res.data.schoolLogoUrl);//设置学校logo
  33. this.$store.dispatch("user/SET_SCHOOL_WEB_SITE_ID", res.data.cloudMonitorSiteId || '');//设置学校网站id
  34. this.$store.dispatch("user/getUserInfoByToken");//获取用户登录信息
  35. this.$router.push("/studentAnalysisReport/list");
  36. }
  37. });
  38. },
  39. }
  40. };
  41. </script>
  42. <style lang="scss">
  43. @use "@/styles/setting.scss";
  44. #app {
  45. height: 100%;
  46. width: 100%;
  47. }
  48. </style>