<template>
  <div id="government">
    <government-detail
      :info="info"
      :photoNews="tpxwList"
      :chuangxinList="cxjlList"
      :guoneiList="gndtList"
      :zhengwuList="zwhdList"
      :meitiList="mtjjList"
      :tongzhiList="tzggList"
      :zhengwu="zhengwu"
      :gongzhongList="gongzhongList"
      :linkList="linkList"
    ></government-detail>
  </div>
</template>

<script>
import governmentDetail from '@/components/government/government.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: mapSite } = createNamespacedHelpers('site');
const { mapActions: mapLink } = createNamespacedHelpers('link');
const { mapActions: mapColumn } = createNamespacedHelpers('affairsColumn');
const { mapActions: mapNews } = createNamespacedHelpers('affairsNews');
export default {
  name: 'government',
  props: {},
  components: {
    governmentDetail,
  },
  data: () => ({
    info: {},
    leftId: '',
    // 图片新闻
    tpxwList: [],
    // 创新吉林
    cxjlList: [],
    // 国内动态
    gndtList: [],
    // 媒体聚焦
    mtjjList: [],
    // 通知公告
    tzggList: [],
    // 政务活动
    zwhdList: [],
    // 公众参与
    gongzhongList: [
      {
        url: 'http://kjt.jl.gov.cn/gzcy/tzxx/',
        pic: require('@/assets/gk1.png'),
        title: '厅长信箱',
      },
      {
        url: 'http://kjt.jl.gov.cn/gzcy/zxzx/',
        pic: require('@/assets/gk2.png'),
        title: '在线咨询',
      },
      {
        url: 'http://kjt.jl.gov.cn/gzcy/jdts/',
        pic: require('@/assets/gk3.png'),
        title: '监督投诉',
      },
      {
        url: 'http://kjt.jl.gov.cn/gzcy/jyxc/',
        pic: require('@/assets/gk4.png'),
        title: '建言献策',
      },
      {
        url: 'http://kjt.jl.gov.cn/gzcy/wsdc/',
        pic: require('@/assets/gk5.png'),
        title: '网上调查',
      },
      {
        title: '党政资料',
        url: 'http://139.210.167.203/free-technological-management/PersonalFiles/getPersonalFileList?pageNumber=1',
        pic: require('@/assets/gk6.png'),
      },
    ],
    // 政务公开
    zhengwu: [
      {
        title: '高企认定',
        url: 'http://kjt.jl.gov.cn/bsfw/gxjsqyrd/',
        pic: require('@/assets/zw1.png'),
      },
      {
        title: '成果登记',
        url: 'http://kjt.jl.gov.cn/bsfw/kjcgdj/',
        pic: require('@/assets/zw2.png'),
      },
      {
        title: '合同登记',
        url: 'http://kjt.jl.gov.cn/bsfw/jshtdj/',
        pic: require('@/assets/zw3.png'),
      },
      {
        title: '计划管理',
        url: 'http://kjt.jl.gov.cn/bsfw/kjjhxmsb/',
        pic: require('@/assets/zw4.png'),
      },
      {
        title: '奖励申报',
        url: 'http://kjt.jl.gov.cn/bsfw/kjjlsb/',
        pic: require('@/assets/zw5.png'),
      },
      {
        title: '专利申请',
        url: 'http://kjt.jl.gov.cn/bsfw/zlsq/',
        pic: require('@/assets/zw6.png'),
      },
      {
        title: '相关下载',
        url: 'http://kjt.jl.gov.cn/bsfw/xzzx/',
        pic: require('@/assets/zw7.png'),
      },
      {
        title: '政务信息公开',
        url: 'http://kjt.jl.gov.cn/xxgk/',
        pic: require('@/assets/zw8.png'),
      },
    ],
    // 友情链接
    linkList: [],
  }),
  created() {
    this.searchSite();
    this.searchLink();
    this.searchColumn();
  },
  computed: {},
  methods: {
    ...mapSite(['showInfo']),
    ...mapLink({ linksList: 'query' }),
    ...mapColumn({ columnList: 'query', columnInfo: 'fetch' }),
    ...mapNews({ newsList: 'query' }),
    // 查询站点信息
    async searchSite() {
      let res = await this.showInfo();
      let object = JSON.parse(JSON.stringify(res.data));
      if (object) {
        this.$set(this, `info`, res.data);
      } else {
        this.$message.error(res.errmsg ? res.errmsg : 'error');
      }
    },
    //查询标题
    async searchLink({ ...info } = {}) {
      const res = await this.linksList({ ...info });
      if (this.$checkRes(res)) {
        this.$set(this, `linkList`, res.data);
      }
    },
    // 查询科技政务栏目
    async searchColumn({ ...info } = {}) {
      const res = await this.columnList({ ...info });
      for (const val of res.data) {
        this.tpxwSearch({ column_id: val.id, site: val.site });
      }
    },
    // 查询信息列表
    async tpxwSearch({ skip = 0, limit = 10, column_id, site } = {}) {
      const res = await this.newsList({ skip, limit, column_id: column_id });
      for (const val of res.data) {
        const result = await this.columnInfo(val.column_id);
        val.column_name = result.data.name;
      }
      this.$set(this, `${site}List`, res.data);
      console.log(res.data);
    },
  },
};
</script>

<style lang="scss" scoped></style>
