App.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div id="app">
  3. <transition name="fade">
  4. <keep-alive>
  5. <router-view v-if="$route.meta.keepAlive" />
  6. </keep-alive>
  7. </transition>
  8. <transition name="fade">
  9. <router-view v-if="!$route.meta.keepAlive" />
  10. </transition>
  11. </div>
  12. </template>
  13. <script>
  14. import { queryTeacherInfo } from "@/api/app";
  15. export default {
  16. name: "app",
  17. async created() {
  18. const whiteList = ["#/order"];
  19. // const routePath = this.$route.path;
  20. const locationHash = window.location.hash;
  21. // console.log(this.$route.path, locationHash);
  22. if (locationHash.indexOf('#/order') == -1) {
  23. try {
  24. let Authorization = this.getQueryVariable("Authorization") || null;
  25. if (window.location.hash.indexOf("+") >= 0) {
  26. Authorization = Authorization ? Authorization.split("+")[1] : null;
  27. Authorization = "bearer " + Authorization;
  28. } else {
  29. Authorization = decodeURI(Authorization);
  30. }
  31. if (Authorization && Authorization != "null") {
  32. localStorage.setItem("Authorization", Authorization);
  33. localStorage.setItem("userInfo", Authorization);
  34. }
  35. const auth = localStorage.getItem("Authorization") || "";
  36. const userInfo = localStorage.getItem("userInfo") || "";
  37. if (userInfo || auth) {
  38. await queryTeacherInfo().then((res) => {
  39. const result = res.data || null;
  40. const tenantId = result.data.tenantId || 0;
  41. sessionStorage.setItem("tenantId", tenantId);
  42. });
  43. }
  44. } catch (e) {
  45. console.log(e);
  46. }
  47. }
  48. },
  49. async mounted() {
  50. if (document.querySelector("#m_loading")) {
  51. document.querySelector("#m_loading").remove();
  52. }
  53. },
  54. methods: {
  55. getQueryVariable(variable) {
  56. if (window.location.hash.indexOf("?") < 0) {
  57. return null;
  58. }
  59. let query = window.location.hash.split("?")[1];
  60. let vars = query.split("&");
  61. for (let i = 0; i < vars.length; i++) {
  62. let pair = vars[i].split("=");
  63. if (pair[0] == variable) {
  64. return pair[1];
  65. }
  66. }
  67. return false;
  68. },
  69. },
  70. };
  71. </script>
  72. <style lang="less">
  73. @import url("./assets/commonLess/common");
  74. #app {
  75. font-family: "Avenir", Helvetica, Arial, sans-serif;
  76. -webkit-font-smoothing: antialiased;
  77. -moz-osx-font-smoothing: grayscale;
  78. background: #f3f4f8;
  79. // overflow-x: hidden;
  80. // overflow-y: auto;
  81. user-select: none;
  82. -webkit-text-size-adjust: none !important;
  83. }
  84. // /deep/.van-icon.van-icon-success{
  85. // }
  86. // .fade-enter-active,
  87. // .fade-leave-active {
  88. // transition: opacity 0.5s;
  89. // }
  90. // .fade-enter,
  91. // .fade-leave-active {
  92. // opacity: 0;
  93. // }
  94. body {
  95. -webkit-text-size-adjust: none !important;
  96. }
  97. </style>