lrf402788946 5 lat temu
rodzic
commit
775b9d4a57
3 zmienionych plików z 57 dodań i 6 usunięć
  1. 2 1
      src/components/newsList.vue
  2. 0 2
      src/views/index.vue
  3. 55 3
      src/views/newsList.vue

+ 2 - 1
src/components/newsList.vue

@@ -7,7 +7,7 @@
         </div>
         </div>
       </el-col>
       </el-col>
       <el-col :span="24" class="menu">
       <el-col :span="24" class="menu">
-        <menuInfo :backColor="backColor"></menuInfo>
+        <menuInfo :menuList="menuList" :backColor="backColor"></menuInfo>
       </el-col>
       </el-col>
       <el-col :span="24" class="main">
       <el-col :span="24" class="main">
         <div class="w_1200">
         <div class="w_1200">
@@ -39,6 +39,7 @@ export default {
     Color: null, //头部电话字体颜色
     Color: null, //头部电话字体颜色
     backColor: null, //导航菜单背景颜色
     backColor: null, //导航菜单背景颜色
     newsList: null, //列表信息
     newsList: null, //列表信息
+    menuList: null, //菜单
   },
   },
   components: {
   components: {
     top, //头部
     top, //头部

+ 0 - 2
src/views/index.vue

@@ -74,7 +74,6 @@ export default {
           sessionStorage.setItem('site', JSON.stringify(result.data));
           sessionStorage.setItem('site', JSON.stringify(result.data));
           if (_.get(result.data, `custom`)) {
           if (_.get(result.data, `custom`)) {
             let item = result.custom;
             let item = result.custom;
-            // this.getfloating(item);
           }
           }
           this.$set(this, `site`, result.data);
           this.$set(this, `site`, result.data);
           this.$set(this, `siteTitle`, this.site.name);
           this.$set(this, `siteTitle`, this.site.name);
@@ -85,7 +84,6 @@ export default {
         let arr = this.site;
         let arr = this.site;
         if (arr.custom) {
         if (arr.custom) {
           let item = arr.custom;
           let item = arr.custom;
-          // this.getfloating(item);
         }
         }
       }
       }
     },
     },

+ 55 - 3
src/views/newsList.vue

@@ -1,10 +1,11 @@
 <template>
 <template>
   <div id="newsList">
   <div id="newsList">
-    <list-detail :info="info" :backColor="backColor" :Color="Color" :newsList="newsList"></list-detail>
+    <list-detail :menuList="menu" :info="info" :backColor="backColor" :Color="Color" :newsList="newsList"></list-detail>
   </div>
   </div>
 </template>
 </template>
 
 
 <script>
 <script>
+import { mapActions, mapState } from 'vuex';
 import listDetail from '@/components/newsList.vue';
 import listDetail from '@/components/newsList.vue';
 export default {
 export default {
   name: 'newsList',
   name: 'newsList',
@@ -112,10 +113,61 @@ export default {
         content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
         content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
       },
       },
     ],
     ],
+    menu: [],
   }),
   }),
-  created() {},
+  created() {
+    this.loadMenu(); //获取菜单信息
+  },
   computed: {},
   computed: {},
-  methods: {},
+  methods: {
+    ...mapActions(['getMenu', 'getColumn']),
+    //菜单
+    async loadMenu() {
+      let menu = sessionStorage.getItem('menu');
+      if (menu) {
+        this.$set(this, `menu`, JSON.parse(menu));
+        this.finishedMenu();
+        return;
+      } else this.toGetMenu();
+    },
+    async toGetMenu() {
+      let result = await this.getMenu({ type: `list` });
+      if (result.errcode === 0) {
+        sessionStorage.setItem('menu', JSON.stringify(result.data));
+        this.$set(this, `menu`, result.data);
+        this.finishedMenu();
+      }
+    },
+    async finishedMenu() {
+      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}`;
+        } else if (item.type !== 'url') {
+          let res = await this.completeMenu(item);
+          item.children = res;
+        }
+      }
+      this.$set(this, `menu`, menus);
+    },
+    async completeMenu(item) {
+      let result = await this.getColumn({
+        type: `list`,
+        data: { parent_id: item.id },
+      });
+      if (result.errcode === 0) {
+        let columns = result.data;
+        for (const col of columns) {
+          if (col.type === 'content') {
+            col.path = `/info/detail?id=${col.content_id}`;
+          } else if (col.type !== 'url') {
+            col.path = `/info/list/${col.id}`;
+          }
+        }
+        return columns;
+      }
+    },
+  },
 };
 };
 </script>
 </script>