Quellcode durchsuchen

党员之家列表页更新

guhongwei vor 5 Jahren
Ursprung
Commit
8ef2fa559e

+ 0 - 3
src/components/member.vue

@@ -9,9 +9,6 @@
       </el-col>
       <el-col :span="24" class="main">
         <div class="w_1270">
-          <!-- <el-col :span="24" class="main_1">
-            <meesage :messageInfo="messageInfo"></meesage>
-          </el-col> -->
           <el-col :span="24" class="main_2">
             <gaoceng :carouselList="carouselList" :newsList="newsList"></gaoceng>
           </el-col>

+ 6 - 10
src/components/memberList.vue

@@ -5,17 +5,12 @@
         <top :info="info"></top>
       </el-col>
       <el-col :sapn="24" class="menu">
-        <menuInfos></menuInfos>
+        <menuInfos :menuList="menuList" :backColor="backColor"></menuInfos>
       </el-col>
       <el-col :sapn="24" class="main">
         <div class="w_1270">
-          <el-col :span="5" class="mainLeft">
-            <el-col :span="24" class="listMenu">
-              <listMenus></listMenus>
-            </el-col>
-          </el-col>
-          <el-col :span="19" class="mainRight">
-            <mainRight :rightList="rightList" :backColor="backColor"></mainRight>
+          <el-col :span="24" class="mainRight">
+            <mainRight :rightList="rightList" :backColor="backColor" :Color="Color" :title="title" v-on="$listeners" v-bind="$attrs"></mainRight>
           </el-col>
         </div>
       </el-col>
@@ -29,20 +24,21 @@
 <script>
 import top from '@/layout/member/top.vue';
 import menuInfos from '@/layout/index/menuInfos.vue';
-import listMenus from '@/layout/list/listMenus.vue';
 import mainRight from '@/layout/list/mainRight.vue';
 import down from '@/layout/index/down.vue';
 export default {
   name: 'memberList',
   props: {
+    Color: null, //字体颜色
     backColor: null, //背景颜色
     info: null, //站点信息
+    menuList: null, //菜单
     rightList: null, //右侧列表
+    title: null, //标题
   },
   components: {
     top, //头部信息
     menuInfos, //菜单
-    listMenus, //列表左侧导航
     mainRight, //列表页右侧列表
     down, //底部
   },

+ 9 - 0
src/components/newsList.vue

@@ -6,6 +6,9 @@
           <top :info="info" :Color="Color"></top>
         </div>
       </el-col>
+      <el-col :sapn="24" class="banner">
+        <banner :info="info"></banner>
+      </el-col>
       <el-col :span="24" class="menu">
         <menuInfo :menuList="menuList" :backColor="backColor"></menuInfo>
       </el-col>
@@ -28,6 +31,7 @@
 
 <script>
 import top from '@/layout/index/top.vue';
+import banner from '@/layout/index/banner.vue';
 import menuInfo from '@/layout/index/menuInfo.vue';
 import listLeft from '@/layout/list/listLeft.vue';
 import newsInfo from '@/layout/list/newsInfo.vue';
@@ -46,6 +50,7 @@ export default {
   },
   components: {
     top, //头部
+    banner, //banner
     menuInfo, //导航
     listLeft, //二级左侧导航
     newsInfo, //二级右侧新聞列表(帶有圖片)
@@ -67,6 +72,10 @@ export default {
   height: 120px;
   overflow: hidden;
 }
+.banner {
+  height: 300px;
+  overflow: hidden;
+}
 .menu {
   height: 50px;
   overflow: hidden;

+ 50 - 28
src/layout/list/mainRight.vue

@@ -2,26 +2,29 @@
   <div id="mainRight">
     <el-row style="border:1px solid #e6e6e6;">
       <el-col :span="24" class="top">
-        <span :style="`background:${backColor}`">{{ title }}</span>
+        <span :style="`background:${backColor}`">{{ topTitile }}</span>
       </el-col>
       <el-col :span="24" class="info">
         <el-col :span="24" class="list" v-for="(item, index) in rightList" :key="index">
-          <el-col :span="21" class="title">
-            <p class="textOver"><i class="el-icon-caret-right icon"></i>{{ item.title }}</p>
+          <el-col :span="5" class="images">
+            <el-image style="width:150px;height:95px;" :src="item.pic"></el-image>
           </el-col>
-          <el-col :span="3" class="date">
-            {{ item.date }}
+          <el-col :span="19" class="right">
+            <el-col :span="24" class="rightTop">
+              <el-col :span="20" class="title">
+                <p class="textOver">{{ item.title }}</p>
+              </el-col>
+              <el-col :span="4" class="date">
+                {{ item.meta && item.meta.createdAt ? new Date(item.meta.createdAt).toLocaleDateString() : '' || '' }}
+              </el-col>
+            </el-col>
+            <el-col :span="24" class="content">
+              <p v-html="item.content"></p>
+            </el-col>
           </el-col>
         </el-col>
         <el-col :span="24" class="page">
-          <el-pagination
-            @size-change="handleSizeChange"
-            @current-change="handleCurrentChange"
-            :current-page="currentPage"
-            :page-size="100"
-            layout="total, prev, pager, next, jumper"
-            :total="1"
-          >
+          <el-pagination @current-change="search" :current-page="currentPage" :page-size="pageSize" layout="total, prev, pager, next, jumper" :total="total">
           </el-pagination>
         </el-col>
       </el-col>
@@ -35,20 +38,23 @@ export default {
   props: {
     rightList: null,
     backColor: null,
+    total: { type: Number, defaultl: 0 },
   },
   components: {},
   data: () => ({
-    title: '就业动态',
     currentPage: 1,
+    pageSize: 8,
   }),
   created() {},
-  computed: {},
-  methods: {
-    handleSizeChange(val) {
-      console.log(`每页 ${val} 条`);
+  computed: {
+    topTitile() {
+      return this.$route.query.title;
     },
-    handleCurrentChange(val) {
-      console.log(`当前页: ${val}`);
+  },
+  methods: {
+    search(page) {
+      let skip = (page - 1) * this.pageSize;
+      this.$emit('search', { skip: skip, limit: this.pageSize });
     },
   },
 };
@@ -85,18 +91,34 @@ p {
 }
 .list {
   padding: 8px 10px;
+  border-bottom: 1px dashed #ccc;
 }
-.list .title {
-  font-size: 16px;
-  color: #333;
+.list .images {
+  width: 150px;
+  height: 95px;
 }
-.list .title .icon {
-  padding: 0 5px 0 0;
+.list .rightTop .title {
+  padding: 10px;
 }
-.list .date {
-  font-size: 16px;
-  color: #333;
+.list .rightTop .date {
   text-align: center;
+  font-size: 16px;
+  color: #4f4f4f;
+  padding: 10px 0;
+}
+/deep/.list .content {
+  padding: 0 8px;
+}
+/deep/.list .content p {
+  padding: 0;
+  margin: 0;
+  text-indent: 2rem;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  -webkit-line-clamp: 2;
+  word-break: break-all;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
 }
 .list:hover {
   cursor: pointer;

+ 196 - 15
src/views/memberList.vue

@@ -1,13 +1,19 @@
 <template>
   <div id="memberList">
-    <member-lists :backColor="backColor" :info="info" :rightList="rightList"></member-lists>
+    <member-lists :backColor="backColor" :info="site" :menuList="menu" :rightList="rightList" @search="toGetNews" :total="total" :title="title"></member-lists>
   </div>
 </template>
 
 <script>
 import memberLists from '@/components/memberList.vue';
-
+import { mapActions, mapState } from 'vuex';
+import _ from 'lodash';
 export default {
+  metaInfo() {
+    return {
+      title: this.siteTitle ? this.siteTitle : '就业信息网',
+    };
+  },
   name: 'memberList',
   props: {},
   components: {
@@ -20,20 +26,195 @@ export default {
       banner: require('@/assets/memberBg.jpg'),
       copyright: '吉ICP备09006292号-1 Copyright 2019 版权所有 吉林省高等学校毕业生就业指导中心 All Rights Reserved',
     },
-    rightList: [
-      {
-        title: '省教育厅成功举办吉林省高校服务地方经济发展“双对接”专项行动推进会暨 “生根吉林 ”应用型人才招聘会',
-        date: '2019-12-11',
-      },
-      {
-        title: '十二条数据显示',
-        date: '2019-12-11',
-      },
-    ],
+    rightList: [],
+    site: {}, //站点信息
+    siteTitle: '', //站点标题
+    menu: [], //菜单
+    modules: [], //模块
+    total: 0,
   }),
-  created() {},
-  computed: {},
-  methods: {},
+  async created() {
+    await this.toGetSite(); //获取主站信息
+    this.loadMenu(); //获取菜单信息
+    this.toGetModule(); //获取模块信息
+    this.toGetNews(); //获取数据
+  },
+  computed: {
+    type() {
+      return this.$route.params.type;
+    },
+    id() {
+      return this.$route.params.id;
+    },
+    title() {
+      return this.$route.query.title;
+    },
+    listSpan() {
+      return this.type === 'menu' ? 18 : 24;
+    },
+  },
+  watch: {
+    type: 'getSubMenu',
+    id: 'toGetNews',
+    title: 'getSubMenu',
+  },
+  methods: {
+    ...mapActions(['getSite', `getMenu`, 'getColumn', 'getModule', 'getNews', 'getJobInfo', 'getPosts', 'getLink']),
+    //站点信息
+    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');
+      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 = `/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 = `/detail/${col.content_id}`;
+          } else if (col.type !== 'url') {
+            col.path = `/newsList/menu/${col.id}?title=${col.title}`;
+            if (col.parent.includes('党员')) {
+              col.path = `/memberList/menu/${col.id}?title=${col.title}`;
+            }
+          }
+        }
+        return columns;
+      }
+    },
+    //模块
+    async loadModule() {
+      let modules = sessionStorage.getItem('modules');
+      for (const item of modules) {
+        if (item.category === 'member') {
+          this.$set(this, `modules`, JSON.parse(modules));
+          return;
+        }
+      }
+      this.toGetMenu();
+    },
+    async toGetModule() {
+      let result = await this.getModule({ type: `list` });
+      if (result.errcode === 0) {
+        sessionStorage.setItem('modules', JSON.stringify(result.data));
+        this.$set(this, `modules`, result.data);
+        this.finishedModule();
+      }
+    },
+    async finishedModule() {
+      let modules = JSON.parse(JSON.stringify(this.modules));
+      let object = {};
+      for (const item of modules) {
+        if (item.category === 'member') {
+          if (`${item.is_use}` === `0`) {
+            let res = await this.completeModules(item);
+            item.children = res;
+            object = item;
+          }
+        }
+      }
+      for (const item of object.children) {
+        this.$set(this, `${item.category}List`, item);
+      }
+    },
+    async completeModules(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 === `bugList`) {
+            col.path = `/memberList/module/${col.content_id}`;
+            col.children = await this.completeColumn(col);
+          } else if (col.type === `column`) {
+            col.path = `/memberList/module/${col.id}`;
+            col.children = await this.completeColumn(col);
+          } else if (col.type === `content`) {
+            col.path = `/detail/${col.content_id}`;
+          }
+        }
+        return columns;
+      }
+    },
+    async completeColumn(item) {
+      let data = { skip: 0, limit: 8 };
+      if (item.type === `bugList`) {
+        data.news_type = `0`;
+        data.parent_id = item.content_id;
+      } else {
+        data.news_type = `1`;
+        data.parent_id = item.id;
+      }
+      let result = await this.getNews({ type: 'bugList', data: data });
+      if (result.errcode === 0) {
+        return result.data;
+      }
+    },
+    //请求数据
+    async toGetNews({ skip = 0, limit = 8 } = {}) {
+      let result = await this.getNews({ type: 'list', data: { parent_id: this.id, skip: skip, limit: limit } });
+      if (result.errcode === 0) {
+        let data = result.data;
+        for (const item of data) {
+          let info = await this.getNews({ type: 'fetch', data: { id: item.id } });
+          if (info.errcode === 0) item.content = info.data.content;
+          this.$set(this, `total`, result.total);
+        }
+        this.$set(this, `rightList`, result.data);
+      }
+    },
+  },
 };
 </script>