|
@@ -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>
|