<template>
  <div id="servicedetail">
    <servicedetail-detail
      :info="info"
      :liebiaoList="liebiaoList"
      :columnName="columnName"
      :contentList="contentList"
      :total="total"
      :columnTitle="columnTitle"
      :policyInfo="policyInfo"
    ></servicedetail-detail>
  </div>
</template>

<script>
import servicedetailDetail from '@/components/service/servicedetail.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: mapSite } = createNamespacedHelpers('site');
const { mapActions: mapColumn } = createNamespacedHelpers('serveColumn');
const { mapActions: mapNews } = createNamespacedHelpers('serveNews');
export default {
  name: 'servicedetail',
  props: {},
  components: {
    servicedetailDetail,
  },
  data: () => ({
    info: {},
    liebiaoList: [],

    columnName: '',
    contentList: [],
    total: 1,
    leftId: '',
    columnTitle: '',
    policyInfo: {},
  }),
  created() {
    this.searchSite();
    this.searchColumn();
    this.searchInfo();
  },
  computed: {},
  methods: {
    ...mapSite(['showInfo']),
    ...mapColumn({ columnList: 'query', columnInfo: 'fetch' }),
    ...mapNews({ newsList: 'query', newsInfo: 'fetch' }),
    // 查询站点信息
    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 searchColumn({ ...info } = {}) {
      const res = await this.columnList({ ...info });
      this.$set(this, `liebiaoList`, res.data);
      console.log(res);
      // for (const val of res.data) {
      //   this.tpxwSearch({ column_id: val.id, site: val.site });
      // }
    },
    async searchInfo() {
      let detailId = this.$route.query.id;
      const res = await this.newsInfo(detailId);
      const result = await this.columnInfo(res.data.column_id);
      this.$set(this, `columnTitle`, result.data.name);
      this.$set(this, `policyInfo`, res.data);
    },
  },
};
</script>

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