<template>
  <div id="index">
    <el-row>
      <el-col :span="24" class="index">
        <el-col :span="24" class="top">
          <topInfo :topTitle="pageTitle"></topInfo>
        </el-col>
      </el-col>
      <el-col :span="24" class="info">
        <liveList :list="list"></liveList>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import topInfo from '@/layout/public/top.vue';
import liveList from '@/layout/live/liveList.vue';
import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: room } = createNamespacedHelpers('room');
export default {
  name: 'index',
  props: {},
  components: {
    topInfo,
    liveList,
  },
  data: function() {
    return {
      list: [],
    };
  },
  created() {
    this.searchInfo();
    console.log(this.user);
  },
  methods: {
    ...room(['query', 'delete', 'update', 'fetch']),
    async searchInfo({ skip = 0, limit = 10, ...info } = {}) {
      let res = await this.query({ skip, limit, anchorid: this.user.uid, ...info });
      if (this.$checkRes(res)) {
        var arr = res.data.filter(item => item.status != '2');
        this.$set(this, `list`, arr);
      }
    },
  },
  computed: {
    ...mapState(['user']),
    pageTitle() {
      return `${this.$route.meta.title}`;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
};
</script>

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