App.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <div id="app" ref="app">
  3. <router-view :key="$route.fullPath"></router-view>
  4. </div>
  5. </template>
  6. <script>
  7. import user from "@/http/api/user";
  8. import { setToken, getToken } 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 = '4305962347220710';
  21. const password = '123456';
  22. // const type = '1';
  23. const schoolType = sessionStorage.getItem('schoolType');
  24. if (getToken() && schoolType) {
  25. return
  26. }
  27. sessionStorage.setItem('schoolType', schoolType || 2);
  28. user.loginEmailPass({
  29. username: username,
  30. password: encrypt(password),
  31. }).then((res) => {
  32. if (res.code === 200) {
  33. this.$store.dispatch("user/CLEAR_LOCAL_STORAGE");//清空本地存储
  34. setToken(res.data.tokenValue);
  35. this.$store.dispatch("user/SET_TOKEN", res.data.tokenValue);
  36. this.$store.dispatch("user/SET_SCHOOL_LOGO", res.data.schoolLogoUrl);//设置学校logo
  37. this.$store.dispatch("user/SET_SCHOOL_WEB_SITE_ID", res.data.cloudMonitorSiteId || '');//设置学校网站id
  38. this.$store.dispatch("user/getUserInfoByToken");//获取用户登录信息
  39. this.$router.push("/jointStudentAnalysisReport/list");
  40. }
  41. });
  42. },
  43. }
  44. };
  45. </script>
  46. <style lang="scss">
  47. @use "@/styles/setting.scss";
  48. #app {
  49. height: 100%;
  50. width: 100%;
  51. }
  52. </style>