App.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 = '500072347220704';
  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. deviceType: "PC"
  32. }).then((res) => {
  33. if (res.code === 200) {
  34. this.$store.dispatch("user/CLEAR_LOCAL_STORAGE");//清空本地存储
  35. setToken(res.data.tokenValue);
  36. this.$store.dispatch("user/SET_TOKEN", res.data.tokenValue);
  37. this.$store.dispatch("user/SET_SCHOOL_LOGO", res.data.schoolLogoUrl);//设置学校logo
  38. this.$store.dispatch("user/SET_SCHOOL_WEB_SITE_ID", res.data.cloudMonitorSiteId || '');//设置学校网站id
  39. this.$store.dispatch("user/getUserInfoByToken");//获取用户登录信息
  40. this.$router.push("/jointStudentAnalysisReport/list");
  41. }
  42. });
  43. },
  44. }
  45. };
  46. </script>
  47. <style lang="scss">
  48. @use "@/styles/setting.scss";
  49. #app {
  50. height: 100%;
  51. width: 100%;
  52. }
  53. </style>