<template>
  <ul class="con">
    <li class="item" v-for="(item,i) in list"  @click="handleClick(item)" :key="i">
      <div class="card-img">
        <img class="full" :src="$serverName+item.thumb" alt="" />
        <img class="real" :src="$serverName+item.thumb" alt="" />
      </div>
      <div class="card-txt">
        <div class="title">
          <span :title="item.name">{{ item.name||'名字' }}</span>
          <span class="tag">{{$type[item.type]||'暂无类别'}}</span>
        </div>
      </div>
    </li>
    <div v-if="list.length<=0" class="no-record">
      <img class="bg" :src="require('@/assets/images/icon/norecoedbg.png')" alt="">
      <div class="rccon">
        <img :src="require('@/assets/images/icon/ic_error_24px.png')" alt="">
        <span>暂无数据</span>
      </div>
    </div>
  </ul>
</template>


<script>
export default {
  props: ["data"],
  data() {
    return {
    };
  },
  computed:{
    list(){
      return this.data
    }
  },
  methods:{
    handleClick(item){
      this.$showBroadcast({item})
      this.$bus.$emit('fadeCollect',false)
    }
  }
};
</script>


<style lang="less" scoped>
@margin: 36px;

.item {
  text-align: center;
  display: inline-block;
  width: calc((100% - @margin * 3) / 4);
  margin-right: @margin;
  margin-bottom: @margin;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  &:nth-of-type(4n) {
    margin-right: 0;
  }
  .card-img {
    position: relative;
    max-height: 190px;
    overflow: hidden;
    background: linear-gradient(180deg, #AAAAAA 0%, #D1D1D1 100%);
    img {
      height: 100%;
    }
    .full {
      opacity: 1;
      width: 100%;
      height: 100%;
      filter: blur(0px);
    }
    .real {
      position: absolute;
      z-index: 99;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
  }
  .card-txt {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #333;
    background: #C2C2C2;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    >div{
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      span{
        overflow: hidden;
        padding: 8px 10px;
        text-overflow:ellipsis;
        white-space: nowrap;
        &:first-of-type{
          flex: 3;
        }
      }
      .tag{
        flex: 1;
        background: #A01C26;
        color: rgba(255, 255, 255, 0.5);
      }
    }
  }
}

.no-record{
  position: relative;
  margin: 10vh auto 0!important;
  .bg{
    width: 300px;
  }
  .rccon{
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%,-50%);
      >span{
        display: block;
        margin-top: 10px;
      }
    }
}

@media screen and (min-width: 500px) and (max-width: 1400px) {
  .item {
    width: calc((100% - @margin * 2) / 3);
    &:nth-of-type(3n) {
      margin-right: 0;
    }
    &:nth-of-type(4n){
      margin-right: @margin;
    }
    .card-img{
      max-height: 150px;
    }
  }
}


@media screen and (max-width: 500px) {
  @gap:15px;
  .con{
    width: 100%;
    .item{
      width: calc((100% - @gap) / 2);
      margin-right: @gap;
      margin-bottom: @gap;

      &:nth-of-type(2n) {
        margin-right: 0;
      }
      .card-img{
        max-height: 107px;
      }
    }
  }
 
}

</style>
