|
@@ -1,12 +1,30 @@
|
|
|
<template>
|
|
|
<div id="memberList">
|
|
|
- <member-detail :info="info" :Color="Color" :backColor="backColor" :rightList="rightList"></member-detail>
|
|
|
+ <member-detail
|
|
|
+ :info="site"
|
|
|
+ :menuList="menu"
|
|
|
+ :sideMenu="sideMenu"
|
|
|
+ @search="toGetNews"
|
|
|
+ :Color="Color"
|
|
|
+ :backColor="backColor"
|
|
|
+ :newsList="newsList"
|
|
|
+ :total="total"
|
|
|
+ :title="title"
|
|
|
+ :listSpan="listSpan"
|
|
|
+ ></member-detail>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import memberDetail 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: {
|
|
@@ -27,10 +45,140 @@ export default {
|
|
|
content: '我省成功举办“创业有我•就在吉林我省成功举办“创业有我•就在吉林',
|
|
|
},
|
|
|
],
|
|
|
+ newsList: [],
|
|
|
+ total: 0,
|
|
|
+ menu: [],
|
|
|
+ sideMenu: [],
|
|
|
+ site: {},
|
|
|
+ siteTitle: '',
|
|
|
}),
|
|
|
- created() {},
|
|
|
- computed: {},
|
|
|
- methods: {},
|
|
|
+ async created() {
|
|
|
+ await this.toGetSite(); //获取主站信息
|
|
|
+ await this.loadMenu(); //获取菜单信息
|
|
|
+ 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', 'getNews']),
|
|
|
+ //站点信息
|
|
|
+ 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));
|
|
|
+ await this.finishedMenu();
|
|
|
+ } else this.toGetMenu();
|
|
|
+ this.getSubMenu();
|
|
|
+ },
|
|
|
+ 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/${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;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //侧菜单
|
|
|
+ getSubMenu() {
|
|
|
+ let data;
|
|
|
+ if (this.type === `module`) {
|
|
|
+ data = sessionStorage.getItem(`modules`);
|
|
|
+ this.$set(this, `sideMenu`, []);
|
|
|
+ } else {
|
|
|
+ let res = this.menu.filter(fil => {
|
|
|
+ if (fil.children) {
|
|
|
+ let res = fil.children.filter(filc => filc.id === this.id);
|
|
|
+ return res.length > 0;
|
|
|
+ } else return false;
|
|
|
+ });
|
|
|
+ this.$set(this, `sideMenu`, res.length > 0 ? res[0].children : []);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //请求数据
|
|
|
+ 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, `newsList`, result.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|
|
|
|