<template>
  <div id="index">
    <el-col :span="24" class="main">
      <el-col :span="24" class="info" style="padding:30px">
        <el-tabs>
          <el-tab-pane label="正在直播" name="0">
            <list :list="listNow" :total="nowTotal" status="1" @query="searchList"></list>
          </el-tab-pane>
          <el-tab-pane label="下期直播" name="1">
            <list :list="listPre" :total="preTotal" status="0" @query="searchList"></list>
          </el-tab-pane>
          <el-tab-pane label="已往直播" name="2">
            <list :list="listPast" :total="pastTotal" status="2" @query="searchList"></list>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-col>
  </div>
</template>

<script>
import _ from 'lodash';
import list from './parts/list.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: dock } = createNamespacedHelpers('dock');
export default {
  name: 'index',
  props: {},
  components: { list },
  data: () => ({
    squareImage: require('@/assets/live/square_big.png'),
    menuIndex: '0',
    menuName: '直播列表',
    menuColor: 'rgb(254, 149, 14)',
    pageSize: 10,
    limit: 10,
    hangyeList: [],
    listPre: [],
    preTotal: 0,
    listNow: [],
    nowTotal: 0,
    listPast: [],
    pastTotal: 0,
    liveIndex: '',
  }),
  created() {
    this.searchList({ status: '0' });
    this.searchList({ status: '1' });
    this.searchList({ status: '2' });
  },
  computed: {
    pageTitle() {
      return `${this.$route.meta.title}`;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },

  methods: {
    ...dock({ dockQuery: 'query' }),
    async searchList({ skip = 0, limit = 10, status, ...info } = {}) {
      let res = await this.dockQuery({ is_allowed: 1, skip, limit, status, ...info });
      if (res.errcode === 0) {
        if (status == '0') {
          console.log(res.total);
          this.$set(this, `preTotal`, res.total);
          this.$set(this, `listPre`, res.data);
        } else if (status == '1') {
          this.$set(this, `nowTotal`, res.total);
          this.$set(this, `listNow`, res.data);
        } else {
          console.log(res.data);

          this.$set(this, `pastTotal`, res.total);
          this.$set(this, `listPast`, res.data);
        }
      }
    },

    async initList({ name, skip = 0, limit = 10, ...info } = {}) {
      this.$set(this, `pageTotal`, res.total);
    },
    handleCurrentChange(val) {
      this.limit = 5;
      this.initList({ skip: (val - 1) * this.limit, limit: this.limit });
    },

    turnTo(item) {
      this.$router.push({ path: '/live/hallDetail', query: { id: item.id } });
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  // width: 80%;
  width: 1200px;
  margin: 0 auto;
  float: none;
}
.menu {
  float: left;
  height: 450px;
  width: 20%;
  background: no-repeat bottom right;
  background-image: url(../../assets/live/menu_back.jpg);
  margin: 30px 0;
  padding: 10px 0 0 10px;
  box-sizing: border-box;
  box-shadow: 0 0 10px #bbbaba;
}
.menu .el-image {
  width: 30px;
  display: inline-table;
  margin: 10px 5px;
}
.menu span {
  font-size: 24px;
  color: #92959a;
  font-weight: 600;
  margin-left: 3px;
  position: relative;
  top: 10px;
}
.menuList p {
  line-height: 60px;
  font-size: 18px;
  cursor: pointer;
  border-bottom: 1px solid #2d64b3;
  color: #044b79;
  font-weight: 600;
}
.info {
  width: 100%;
  float: right;
  margin: 30px 0 30px 2px;
  height: 585px;
  box-shadow: 0 0 10px #2d64b3;
  overflow: hidden;
  right: 0px;
  background: #ffffff;
}
.leftInfo {
  height: 500px;
  overflow: hidden;
}
.leftTop {
  font-size: 18px;
  width: 96%;
  height: 41px;
  line-height: 35px;
  border-bottom: 1px solid #e5e5e5;
  position: relative;
  bottom: 1px;
  margin: 10px;
  font-weight: 600;
  color: #22529a;
}
.page {
  text-align: center;
  margin: 10px 0;
}
</style>
