<template>
  <div class="footer">
    <div class="inner">
      <div class="info">
        <div style="margin-right: 100px">
          <img class="m-b-20" src="@/assets/images/iasf.png" alt="">
          <p class="meta">Copyright ©2002- 2021</p>
          <p class="meta">Institute of Advanced Science Facilities, ShenzhenIASF</p>
          <p class="meta">Tel：400-0010-998</p>
        </div>
        <div v-for="(item, i) in columns" :key="i" class="column">
          <h6 @click="jump(item)">{{ item.columnName }}</h6>
          <ul v-if="item.children.length" class="children">
            <li v-for="(column, j) in item.children" :key="j" @click="jump(item)">{{ column.columnName }}</li>
          </ul>
        </div>
      </div>
      <a class="copyright">粤ICP备2020131940号  粤公安网34565432456765432号</a>
    </div>
  </div>
</template>
<script>
import Setting from '@/setting'
export default {
  data() {
    return {
      site: this.$store.state.content.site,
      columns: [],
      isIndex: this.$route.path !== '/login' && Setting.whiteList.some(e => e === this.$route.path) // 官网3个页面才能显示邮箱和版权号
    };
  },
  mounted(){
    this.getColumn()
  },
  methods: {
    // 资讯
    getColumn() {
      this.$post(this.api.listWithTreeMenuVisible, {
        siteId: this.$route.query.siteId || this.$store.state.content.site,
        columnName: '',
        templateId: '',
        typeId	: '',
        isSort: 1
      }).then(({ data }) => {
        this.columns = data.slice(0, 8)
      }).catch(err => {})
    },
    // 跳转
    jump(to) {
      const { id } = to
      this.active = to.id
      const { typeId } = to
      // 跳转链接
      if (typeId === 2) {
        let href = to.linkAddress
        const cType = to.connectionType
        if (cType !== 2) { // 非站外链接
          const ids = href.split('-') // 栏目文章是用-分割的，栏目是必选，文章不是必选。选择了文章则跳转到文章页，否则跳转到栏目页
          // 站点id：站内链接取当前站点，其他站点链接取siteSelection
          const site = cType === 1 ?
            (this.$route.query.siteId || this.site) :
            to.siteSelection
          if (ids[1]) { // 文章
            href = '/article?id=' + ids[1]
          } else { // 栏目
            const columnIds = ids[0].split(',')
            href = '/column?id=' + columnIds[columnIds.length - 1]
          }
          href = this.$router.resolve(href + '&siteId=' + site).href
        }
        // 是否新窗口打开
        if (to.isOpen) {
          window.open(href)
        } else {
          location.href = href
        }
      } else if (typeId !== 4 || (typeId === 4 && !to.children.length)) {
        // 常规栏目跳转到column页，长页栏目直接获取path
        this.$router.push(`/${typeId === 3 ? row.path : 'column'}?id=${id}`).catch(err => {})
      }
    }
  },
};
</script>
<style lang="scss" scoped>
.footer{
  padding: 64px 0 25px;
  color: #fff;
  background-color: #091733;
  .inner {
    width: 1500px;
    margin: 0 auto;
  }
  .info {
    display: flex;
    margin-bottom: 100px;
  }
  .meta {
    margin-bottom: 10px;
    font-size: 14px;
  }
  .column {
    margin: 0 20px;
    h6 {
      margin-bottom: 20px;
      font-size: 16px;
      white-space: nowrap;
    }
  }
  .children {
    li {
      margin: 12px 0;
      font-size: 14px;
      color: #6D7384;
      white-space: nowrap;
      cursor: pointer;
    }
  }
  .copyright {
    font-size: 14px;
    color: #6D7384;
  }
}
</style>