<template>
  <div
    class="item-list-con"
    @click="goGoods(data.goodsId, data.type, data.salesType)"
  >
    <div class="con-wrapper flex-default">
      <div class="left-img">
        <img class="thumb" :src="data.thumb" />
        <div class="goods-stock" :style="{'background':goodStatus.bgColor}">
          <m-icon :icon="goodStatus.icon" :size="10" />
          <span>{{goodStatus.name}}</span>
        </div>
      </div>
      <div class="right-con flex-default">
        <div class="title">
          {{ data.name }}
        </div>
        <div class="circulationCount flex-default">
          <div class="label">限量</div>
          <div class="num">{{ data.circulationCount }}份</div>
        </div>
        <div class="value">
          <span class="yen">￥</span>{{ data.defaultPrice || 0 }}
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { formatTimeDuring } from "@/utils";
export default {
  props: {
    data: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  computed:{
    goodStatus(){
      let obj={
        name:"",
        icon:"",
        bgColor:""
      }
      
      if(this.data.preheatEndTime&&this.data.preheatEndTime>this.currentTime){
        let time=formatTimeDuring(this.data.preheatEndTime - this.currentTime)
        let dayhours=parseInt(time.day) * 24 + parseInt(time.hour)
        if(dayhours<9){
          dayhours='0'+dayhours
        }
        if(dayhours<1){
          dayhours="00"
        }
        obj={
          name:`即将开售 ${dayhours} : ${time.min} : ${time.sec}`,
          icon:"icon-clocks-and-watches",
          bgColor:"#4CC16D"
        }
      }else{
        if(this.data.stockCount){
          obj={
            name:"热销中",
            icon:"icon-hot-goods",
            bgColor:"rgba(0, 0, 0, 0.2)"
          }
        }else{
          obj={
            name:"已售罄",
            icon:"icon-sell-out",
            bgColor:"rgba(0, 0, 0, 0.2)"
          }
        }
      }
      return obj
    },
  },
};
</script>
<style lang="less" scoped>
.item-list-con {
  padding: 25px 0 0 0;
  .con-wrapper {
    background: url(~@/assets/img/blind-card.png) no-repeat;
    background-size: 100% 100%;
    margin-bottom: 10px;
    padding: 28px;
    height: 160px;
  }
  .left-img {
    position: relative;
    width: 120px;
    height: 146px;
    border-radius: 10px;
    // overflow: hidden;
    .thumb {
      width: 120px;
      height: 146px;
      border-radius: 10px;
      object-fit: cover;
      margin-top: -25px;
    }
    .goods-stock {
      position: absolute;
      background: rgba(0, 0, 0, 0.2);
      border-radius: 0 0 10px 10px;
      width: 120px;
      height: 18px;
      bottom: 25px;
      left: 0;
      line-height: 18px;
      text-align: center;
      span {
        font-size: 11px;
        color: #ffffff;
        margin-left: 2px;
      }
    }
  }
  .right-con {
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-around;
    height: 130px;
    padding: 5px 10px 10px;
    .title {
      width: 170px;
      font-size: 15px;
      font-weight: 500;
      color: #030711;
      line-height: 21px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .circulationCount {
      width: 86px;
      height: 16px;
      line-height: 16px;
      font-size: 10px;
      overflow: hidden;
      border-radius: 2px;
      margin-bottom: 22px;
      .label {
        width: 35px;
        height: 16px;
        text-align: center;
        background: #f3e0bc;
        color: #030711;
      }
      .num {
        // width: 51px;
        padding:0 8px;
        min-width: 51px;
        height: 16px;
        background: #4b4b4c;
        color: #f3e0bc;
        text-align: center;
      }
    }
    .value {
      font-size: 22px;
      color: #f78706;
      .yen {
        display: inline-block;
        font-size: 14px;
        transform: scale(0.8);
        font-weight: normal;
        width: 14px;
      }
    }
  }
}
</style>