lrf402788946 5 年之前
父節點
當前提交
756ee52076
共有 3 個文件被更改,包括 65 次插入12 次删除
  1. 1 1
      src/layout/index/naitve.vue
  2. 5 5
      src/views/index.vue
  3. 59 6
      src/views/newsList.vue

+ 1 - 1
src/layout/index/naitve.vue

@@ -2,7 +2,7 @@
   <div id="naitve">
     <el-row>
       <el-col :span="24" class="native">
-        <el-tabs v-model="activeName" type="card" :before-leave="handleClick">
+        <el-tabs v-model="activeName" type="card">
           <el-tab-pane disabled name="disabled">
             <span slot="label">网站导航</span>
           </el-tab-pane>

+ 5 - 5
src/views/index.vue

@@ -126,9 +126,9 @@ export default {
         let columns = result.data;
         for (const col of columns) {
           if (col.type === 'content') {
-            col.path = `/info/detail?id=${col.content_id}`;
+            col.path = `/detail/${col.content_id}`;
           } else if (col.type !== 'url') {
-            col.path = `/newsList/${col.id}`;
+            col.path = `/newsList/menu/${col.id}`;
           }
         }
         return columns;
@@ -173,13 +173,13 @@ export default {
         let columns = result.data;
         for (const col of columns) {
           if (col.type === `bugList`) {
-            col.path = `/newsList/${col.content_id}`;
+            col.path = `/newsList/module/${col.content_id}`;
             col.children = await this.completeColumn(col);
           } else if (col.type === `column`) {
-            col.path = `/newsList/${col.id}`;
+            col.path = `/newsList/module/${col.id}`;
             col.children = await this.completeColumn(col);
           } else if (col.type === `content`) {
-            col.path = `/info/detail?id=${col.content_id}`;
+            col.path = `/detail/${col.content_id}`;
           }
         }
         return columns;

+ 59 - 6
src/views/newsList.vue

@@ -7,7 +7,13 @@
 <script>
 import { mapActions, mapState } from 'vuex';
 import listDetail from '@/components/newsList.vue';
+import _ from 'lodash';
 export default {
+  metaInfo() {
+    return {
+      title: this.siteTitle ? this.siteTitle : '就业信息网',
+    };
+  },
   name: 'newsList',
   props: {},
   components: {
@@ -115,13 +121,48 @@ export default {
     ],
     menu: [],
     sideMenu: [],
+    site: {},
+    siteTitle: '',
   }),
-  created() {
+  async created() {
+    await this.toGetSite(); //获取主站信息
     this.loadMenu(); //获取菜单信息
   },
-  computed: {},
+  computed: {
+    type() {
+      return this.$route.params.type;
+    },
+    id() {
+      return this.$route.params.id;
+    },
+  },
+  watch: {
+    type: 'getSubMenu',
+  },
   methods: {
-    ...mapActions(['getMenu', 'getColumn']),
+    ...mapActions(['getSite', 'getMenu', 'getColumn']),
+    //站点信息
+    async toGetSite() {
+      let site = sessionStorage.getItem('site');
+      if (!site) {
+        let result = await this.getSite({ type: 'search' });
+        if (result.errcode === 0) {
+          sessionStorage.setItem('site', JSON.stringify(result.data));
+          if (_.get(result.data, `custom`)) {
+            let item = result.custom;
+          }
+          this.$set(this, `site`, result.data);
+          this.$set(this, `siteTitle`, this.site.name);
+        }
+      } else {
+        this.$set(this, `site`, JSON.parse(site));
+        this.$set(this, `siteTitle`, this.site.name);
+        let arr = this.site;
+        if (arr.custom) {
+          let item = arr.custom;
+        }
+      }
+    },
     //菜单
     async loadMenu() {
       let menu = sessionStorage.getItem('menu');
@@ -143,7 +184,7 @@ export default {
       let menus = JSON.parse(JSON.stringify(this.menu));
       for (const item of menus) {
         if (item.type === 'content') {
-          item.path = `/info/detail?id=${item.content_id}`;
+          item.path = `/detail/${item.content_id}`;
         } else if (item.type !== 'url') {
           let res = await this.completeMenu(item);
           item.children = res;
@@ -160,14 +201,26 @@ export default {
         let columns = result.data;
         for (const col of columns) {
           if (col.type === 'content') {
-            col.path = `/info/detail?id=${col.content_id}`;
+            col.path = `/detail/${col.content_id}`;
           } else if (col.type !== 'url') {
-            col.path = `/info/list/${col.id}`;
+            col.path = `/newsList/menu/${col.id}`;
           }
         }
         return columns;
       }
     },
+    //侧菜单
+    getSubMenu() {
+      console.log('in function:');
+      let data;
+      if (this.type === `module`) data = sessionStorage.getItem(`module`);
+      else {
+        for (const item of this.menu) {
+          let res = item.children.filter(fil => fil.id === this.id);
+          console.log(res);
+        }
+      }
+    },
   },
 };
 </script>