<template>
  <div id="index">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="top">
          <top topType="1" @search="search"></top>
        </el-col>
        <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }">
          <van-tabs v-model="active">
            <van-tab title="文字">
              <list type="1" :list="oneList"></list>
            </van-tab>
            <van-tab title="图片">
              <list type="2" :list="twoList"></list>
            </van-tab>
            <van-tab title="科普视频">
              <list type="3" :list="thrList"></list>
            </van-tab>
            <van-tab title="培训视频">
              <list type="4" :list="fourList"></list>
            </van-tab>
          </van-tabs>
        </el-col>
        <el-col :span="24" class="foot">
          <page limit="5" :total="total" @search="search"></page>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import list from './parts/list.vue';
import top from '@/layout/common/top.vue';
import page from '@/layout/common/page.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'index',
  props: {},
  components: {
    top,
    page,
    list,
  },
  data: function() {
    return {
      clientHeight: '',
      // 文章菜单
      active: 0,
      // 文字
      oneList: [
        {
          title: '信息标题信息标题信息标题信息标题信息标题信息标题信息标题信息标题信息标题信息标题信息标题信息标题信息标题',
          origin: '信息来源',
          renew_time: '2021-03-30 10:00:00',
          read: 10000,
        },
        {
          title: '信息标题',
          origin: '信息来源',
          renew_time: '2021-03-30 10:00:00',
          read: 10,
        },
      ],
      // 图片
      twoList: [
        {
          title: '信息标题',
          origin: '信息来源',
          read: 10,
          imgUrl: require('@a/news1.jpg'),
        },
        {
          title: '信息标题',
          origin: '信息来源',
          read: 10,
        },
      ],
      // 科普
      thrList: [
        {
          title: '全球粮价波动将影响国内？商务部食用农产品间隔难以大幅度',
          fileUrl: require('@a/video1.mp4'),
          origin: '不知道',
          renew_time: '2021-03-25 21:12:44',
          read: 10000,
        },
      ],
      // 培训
      fourList: [
        {
          title: '全球粮价波动将影响国内？商务部食用农产品间隔难以大幅度',
          fileUrl: require('@a/video1.mp4'),
          origin: '不知道',
          renew_time: '2021-03-25 21:12:44',
          read: 10000,
        },
      ],
      // 总数
      total: 0,
    };
  },
  async created() {
    await this.search();
  },
  mounted() {
    let clientHeight = (document.documentElement.clientHeight || document.body.clientHeight) - 80;
    this.$set(this, `clientHeight`, clientHeight);
  },
  methods: {
    search({ skip = 0, limit = 10, searchName, ...info } = {}) {
      console.log();
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  .top {
    height: 40px;
    overflow: hidden;
    border-bottom: 1px solid #f1f1f1;
  }
  .info {
    overflow-x: hidden;
    overflow-y: auto;
    background-color: #f9f9f9;
  }
  .foot {
    height: 40px;
    overflow: hidden;
    border-top: 1px solid #f1f1f1;
  }
}
</style>
