wuhongyuq 5 år sedan
förälder
incheckning
eadbe07f21
2 ändrade filer med 19 tillägg och 7 borttagningar
  1. 8 1
      src/views/index.vue
  2. 11 6
      src/views/user/index.vue

+ 8 - 1
src/views/index.vue

@@ -20,8 +20,9 @@
 import topInfo from '@/layout/common/topInfo.vue';
 import footInfo from '@/layout/common/footInfo.vue';
 import mainData from '@/layout/index/mainData.vue';
-import { createNamespacedHelpers } from 'vuex';
 const { mapActions: lesson } = createNamespacedHelpers('lesson');
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapStudent } = createNamespacedHelpers('student');
 export default {
   name: 'index',
   props: {},
@@ -38,11 +39,17 @@ export default {
   created() {
     this.getDate();
     this.searchInfo();
+    this.searchSite();
   },
   computed: {},
   mounted() {},
   methods: {
     ...lesson({ lessionInfo: 'fetch', lessionlist: 'query' }),
+    ...mapStudent(['fetch']),
+    async searchSite() {
+      const res = await this.fetch('5e4f3d096a90e861b0f30871');
+      sessionStorage.setItem('site', JSON.stringify(res.data));
+    },
     async searchInfo({ ...info } = {}) {
       const res = await this.lessionlist({ ...info });
       for (const val of res.data) {

+ 11 - 6
src/views/user/index.vue

@@ -59,16 +59,21 @@ export default {
     },
   }),
   created() {
-    this.searchInfo();
+    this.searchSite();
   },
   computed: {},
   methods: {
     ...mapStudent(['fetch']),
-    async searchInfo() {
-      const res = await this.fetch('5e4f3d096a90e861b0f30871');
-      if (res.errcode === 0) {
-        sessionStorage.setItem('site', JSON.stringify(res.data));
-        this.$set(this, `info`, res.data);
+    async searchSite() {
+      let site = sessionStorage.getItem('site');
+      if (site) {
+        this.$set(this, `info`, JSON.parse(site));
+      } else {
+        const res = await this.fetch('5e4f3d096a90e861b0f30871');
+        if (res.errcode === 0) {
+          sessionStorage.setItem('site', JSON.stringify(res.data));
+          this.$set(this, `info`, res.data);
+        }
       }
     },
   },