<template>
  <div id="index">
    <index-detail
      :info="info"
      :map="map"
      :zixunList="zixunList"
      :noticeList="noticeList"
      :lawList="lawList"
      :xinpinList="xinpinList"
      :chuangxinList="chuangxinList"
      :linkList="linkList"
    ></index-detail>
  </div>
</template>

<script>
import indexDetail from '@/components/index.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: mapSite } = createNamespacedHelpers('site');
const { mapActions: mapLink } = createNamespacedHelpers('link');
export default {
  name: 'index',
  props: {},
  components: {
    indexDetail,
  },
  data: () => ({
    info: {},
    map: require('@/assets/map.jpg'),
    zixunList: [
      {
        title: '尼日利亚传统领袖：尼应学习借鉴中国自贸区建设经验',
        date: '2019-12-25',
      },
      {
        title: '八条数据',
        date: '2019-12-25',
      },
    ],
    noticeList: [
      {
        title: '尼日利亚传统领袖：尼应学习借鉴中国自贸区建设经验',
        date: '2019-12-25',
      },
      {
        title: '八条数据',
        date: '2019-12-25',
      },
    ],
    lawList: [
      {
        title: '尼日利亚传统领袖：尼应学习借鉴中国自贸区建设经验',
        date: '2019-12-25',
      },
      {
        title: '八条数据',
        date: '2019-12-25',
      },
    ],
    linkList: [],
    xinpinList: [
      {
        title: '尼日利亚传统领袖：尼应学习借鉴中国自贸区建设经验',
        date: '2019-12-25',
      },
      {
        title: '六条数据',
        date: '2019-12-25',
      },
    ],
    chuangxinList: [
      {
        title: '尼日利亚传统领袖：尼应学习借鉴中国自贸区建设经验',
        date: '2019-12-25',
      },
      {
        title: '六条数据',
        date: '2019-12-25',
      },
    ],
  }),
  created() {
    this.searchSite();
    this.searchLink();
  },
  computed: {},
  methods: {
    ...mapSite(['showInfo']),
    ...mapLink(['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.query({ ...info });
      if (this.$checkRes(res)) {
        this.$set(this, `linkList`, res.data);
      }
    },
  },
};
</script>

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