<template>
  <div id="list">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="one" v-if="type == '1'">
          <el-col :span="24" class="list" v-for="(item, index) in list" :key="index" @click.native="detailBtn(item.id, '0')">
            <el-col :span="24" class="text">
              <el-col :span="1" class="i">
                <i class="el-icon-caret-right"></i>
              </el-col>
              <el-col :span="18" class="title textOver">
                {{ item.title }}
              </el-col>
              <el-col :span="5" class="date"> [{{ item.release_time }}] </el-col>
            </el-col>
          </el-col>
        </el-col>
        <el-col :span="24" class="one" v-else-if="type == '2'">
          <el-col :span="24" class="list" v-for="(item, index) in list" :key="index" @click.native="detailBtn(item.id, '1')">
            <el-col :span="24" class="text">
              <el-col :span="1" class="i">
                <i class="el-icon-caret-left"></i>
              </el-col>
              <el-col :span="18" class="title textOver">
                {{ item.title }}
              </el-col>
              <el-col :span="5" class="date"> [{{ item.release_time }}] </el-col>
            </el-col>
          </el-col>
        </el-col>
        <el-col :span="24" class="thr" v-else-if="type == '3'">
          <el-col :span="12" class="list" v-for="(item, index) in list" :key="index" @click.native="detailBtn(item.id, '2')">
            <el-col :span="24" class="image">
              <el-carousel height="135px" arrow="never" indicator-position="none" :interval="2000" v-if="item.image.length > 0">
                <el-carousel-item v-for="(tag, index) in item.image" :key="index">
                  <el-image :src="tag.url"></el-image>
                </el-carousel-item>
              </el-carousel>
              <el-image :src="noImage" v-else></el-image>
            </el-col>
            <el-col :span="24" class="title">
              {{ item.title }}
            </el-col>
            <el-col :span="24" class="date">
              {{ item.release_time }}
            </el-col>
          </el-col>
        </el-col>
        <el-col :span="24" class="one" v-else-if="type == '4'">
          <el-col :span="24" class="list" v-for="(item, index) in list" :key="index" @click.native="detailBtn(item.id, '3')">
            <el-col :span="24" class="text">
              <el-col :span="1" class="i">
                <i class="el-icon-caret-left"></i>
              </el-col>
              <el-col :span="18" class="title textOver">
                {{ item.title }}
              </el-col>
              <el-col :span="5" class="date"> [{{ item.release_time }}] </el-col>
            </el-col>
          </el-col>
        </el-col>
        <el-col :span="24" class="five" v-else-if="type == '5'">
          <el-col :span="12" class="fiveList" v-for="(item, index) in list" :key="index" @click.native="detailBtn(item.id, '4')">
            <el-col :span="24" class="text">
              <el-col :span="1" class="i">
                <i class="el-icon-caret-right"></i>
              </el-col>
              <el-col :span="18" class="title textOver">
                {{ item.title }}
              </el-col>
              <el-col :span="5" class="date"> [{{ item.release_time }}] </el-col>
            </el-col>
          </el-col>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'list',
  props: {
    type: {
      type: String,
    },
    list: {
      type: Array,
    },
  },
  components: {},
  data: function () {
    return {
      noImage: require('@a/noImg.jpg'),
    };
  },
  created() {},
  methods: {
    detailBtn(id, index) {
      this.$emit('detail', { id: id, index: index });
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  padding: 5px;
  .one {
    height: 430px;
    overflow: hidden;
    .list {
      height: 39px;
      line-height: 39px;
      overflow: hidden;
      .text {
        .i {
          text-align: center;
        }
        .title {
          font-size: 16px;
        }
        .date {
          font-size: 16px;
          text-align: right;
        }
      }
    }
    .list:hover {
      cursor: pointer;
      .text {
        .title {
          color: #6495ed;
        }
      }
    }
  }
  .thr {
    height: 430px;
    overflow: hidden;
    .list {
      width: 49.1%;
      height: 208px;
      margin: 0 10px 10px 0;
      box-shadow: 0 0 5px #ccc;
      border-radius: 5px;
      .image {
        height: 135px;
        overflow: hidden;
        border-top-left-radius: 5px;
        border-top-right-radius: 5px;
        /deep/.el-image__inner {
          height: 135px;
          border-top-left-radius: 5px;
          border-top-right-radius: 5px;
        }
      }
      .title {
        font-size: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-line-clamp: 2;
        word-break: break-all;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        text-align: center;
        padding: 0px 5px;
        margin: 5px 0;
      }
      .date {
        font-size: 12px;
        color: #666;
        padding: 0px 5px;
      }
    }
    .list:nth-child(2n) {
      margin: 0 0 10px 0;
    }
    .list:hover {
      cursor: pointer;
      .title {
        color: #6495ed;
      }
    }
  }
  .five {
    height: 430px;
    overflow: hidden;
    .fiveList {
      height: 39px;
      line-height: 39px;
      overflow: hidden;
      padding: 0 5px 0 0;
      border-right: 1px solid #ccc;
      .text {
        .i {
          text-align: center;
        }
        .title {
          font-size: 16px;
        }
        .date {
          font-size: 16px;
          text-align: right;
        }
      }
    }
    .fiveList:nth-child(2n) {
      border-right: none;
    }
    .fiveList:hover {
      cursor: pointer;
      .text {
        .title {
          color: #6495ed;
        }
      }
    }
  }
}
</style>
