123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <template>
- <div id="detail">
- <login-Detail :topinfo="site" :menulist="menu" :bannerinfo="master.bannerinfo" :noticedetail="info" :footinfo="site"></login-Detail>
- </div>
- </template>
- <script>
- import loginDetail from '@publics/src/views/master/news/detail.vue';
- import { mapActions, mapState } from 'vuex';
- import { masterInfo } from '@/config/master-info';
- import _ from 'lodash';
- export default {
- name: 'detail',
- props: {},
- components: {
- loginDetail,
- },
- async created() {
- await this.getSite();
- await this.getMenu();
- this.masterData();
- await this.search();
- },
- data: () => ({
- site: {},
- master: { ...masterInfo },
- info: {},
- menu: [],
- jobList: [],
- }),
- computed: {
- type() {
- return this.$route.params.type;
- },
- id() {
- return this.$route.params.id;
- },
- },
- methods: {
- ...mapActions([
- 'siteOperation',
- 'columnOperation ',
- 'newsOperation',
- 'menuOperation',
- 'jobfairOperation',
- 'jobinfoOperation',
- 'postTalksInfo',
- 'postOperation',
- ]),
- //获取站点信息
- async getSite() {
- let site = sessionStorage.getItem('site');
- if (!site) {
- let result = await this.siteOperation({ type: 'search', data: { site: this.$site } });
- if (`${result.errcode}` === `0`) {
- sessionStorage.setItem('site', JSON.stringify(result.data));
- this.$set(this, `site`, result.data);
- }
- } else {
- this.$set(this, `site`, JSON.parse(site));
- }
- },
- //获取菜单
- async getMenu() {
- if (sessionStorage.getItem('menu')) {
- this.$set(this, `menu`, JSON.parse(sessionStorage.getItem('menu')));
- return;
- }
- //获取菜单
- let result = await this.menuOperation({ type: 'list', data: { site: this.site } });
- if (`${result.errcode}` === '0') {
- //获取菜单的栏目
- let allMenu = result.data;
- for (let item of allMenu) {
- 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;
- }
- }
- sessionStorage.setItem('menu', JSON.stringify(allMenu));
- this.$set(this, `menu`, allMenu);
- }
- },
- //将菜单完善至栏目级别
- async completeMenu(item) {
- let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id, site: item.site } });
- if (`${res.errcode}` === '0') {
- //组合path:res.data内容都为栏目.所以,点击这些栏目显示的列表应该是信息列表,需要用栏目的id作为查询信息的parten_id查出不同栏目的信息
- for (const col of res.data) {
- if (col.type === 'content') col.path = `/info/detail?id=${col.content_id}`;
- else if (col.type !== 'url') col.path = `/info/list/${col.id}`;
- }
- return res.data;
- }
- },
- //主站信息组合
- masterData() {
- this.$set(this.master, `bannerinfo`, { banner: this.site.banner });
- },
- async search() {
- if (this.type === 'jobinfo') this.getJobInfo();
- },
- //jobinfo部分
- async getJobInfo() {
- //1直接拿着参数发送请求
- let result = await this.jobinfoOperation({ type: 'search', data: { id: this.id } });
- if (`${result.errcode}` === '0') {
- //给this=>vue的实例下在中的list属性,赋予result.data的值
- this.$set(this, `info`, result.data);
- // this.searchCorpInfo();
- this.searchJobs();
- } else {
- this.$message.error(result.errmsg ? result.errmsg : 'error');
- }
- },
- async searchJobs() {
- let result;
- let jobIds = this.info.jobs.length > 0 ? this.info.jobs : [];
- let jobList = [];
- for (const item of jobIds) {
- result = await this.postOperation({ type: 'search', data: { id: item } });
- if (`${result.errcode}` === '0') {
- jobList.push(result.data);
- }
- }
- this.$set(this, `jobList`, jobList);
- },
- },
- };
- </script>
- <style lang="less" scoped></style>
|