<template>
  <div id="government">
    <government-detail
      :info="info"
      :photoNews="tpxwList"
      :zhengwu="zhengwu"
      :chuangxinList="chuangxinList"
      :guoneiList="guoneiList"
      :zhengwuList="zhengwuList"
      :meitiList="meitiList"
      :tongzhiList="tongzhiList"
      :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: {},
    // 图片新闻
    photoNews: {
      pic: require('@/assets/photoNews.jpg'),
      title: '标题',
    },
    chuangxinList: [
      {
        title: '创新吉林',
        date: '2019-03-06',
      },
      {
        title: '十条数据',
        date: '2019-03-06',
      },
    ],
    guoneiList: [
      {
        title: '国内动态',
        date: '2019-03-06',
      },
      {
        title: '十条数据',
        date: '2019-03-06',
      },
    ],
    zhengwuList: [
      {
        title: '政务活动',
        date: '2019-03-06',
      },
      {
        title: '十条数据',
        date: '2019-03-06',
      },
    ],
    meitiList: [
      {
        title: '媒体聚焦',
        date: '2019-03-06',
      },
      {
        title: '十条数据',
        date: '2019-03-06',
      },
    ],
    tongzhiList: [
      {
        title: '通知公告',
        date: '2019-03-06',
      },
      {
        title: '八条数据',
        date: '2019-03-06',
      },
    ],
    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'),
      },
    ],
    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'),
      },
    ],
    linkList: [],
    leftId: '',
    tzggList: [],
    mtjjList: [],
    zwhdList: [],
    gndtList: [],
    cxjlList: [],
    tpxwList: [],
  }),
  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) {
        // if (val.site == 'tpxw') {
        //   console.log(val.id);
        //   this.$set(this, `leftId`, val.id);
        //   this.tpxwSearch();
        // } else if (val.site == 'cxjl') {
        //   console.log(val.id);
        // } else if (val.site == 'gndt') {
        //   console.log(val.id);
        // } else if (val.site == 'zwhd') {
        //   console.log(val.id);
        // } else if (val.site == 'mtjj') {
        //   console.log(val.id);
        // } else if (val.site == 'tzgg') {
        //   console.log(val.id);
        // }
        this.tpxwSearch({ column_id: val.id, site: val.site });
      }
    },
    // 查询信息列表
    async tpxwSearch({ skip = 0, limit = 10, column_id, site } = {}) {
      console.log(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);
    },
  },
};
</script>

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