<template>
  <div class="goods" @click="goToDetailPage(item.goods)">
    <div v-if="showSimilar" class="goods-close" @click.stop="closeProduct">
      <cr-icon type="close" size="12px" color="#c8c9cc" />
    </div>
    <div class="goods-image">
      <cr-image lazy-load fit="contain" :src="item.goods.goodsImage | Img2Thumb" />
      <div v-if="showSimilar" class="goods-image-similar" @click.stop="goSimilar(item.goods)">
        <span>
          看相似
        </span>
      </div>
    </div>
    <div class="goods-info">
      <div class="goods-info-title">
        <!-- <span v-if="+item.goods.goodsType === 1" class="goods-info-title__icon">自营</span> -->
        <cr-image
          v-if="item.goods.goodsTypeImage"
          class="goods-info-title__img"
          :src="item.goods.goodsTypeImage"
        />
        {{ item.goods.goodsName }}
      </div>
      <div v-if="(item.goods.serviceTypeList || []).length" class="goods-info-border">
        <span
          v-for="(sItm, sInd) in item.goods.serviceTypeList"
          :key="sInd"
          class="goods-info-border__span"
        >
          {{ sItm }}
        </span>
      </div>
      <div v-if="item.goods.tagList.length" class="goods-info-tag">
        <span v-for="(tItm, tInd) in item.goods.tagList" :key="tInd" class="goods-info-tag__coupon">
          {{ tItm.name }}
        </span>
        <!-- <span class="goods-info-tag__top">TOP</span>
        <span class="goods-info-tag__quality">正品</span>
        <span class="goods-info-tag__coupon2">¥10</span> -->
      </div>
      <div class="goods-info-price">{{ item.goods.goodsSalePrice }}</div>
      <div v-if="item.goods.commentCnt" class="goods-info-evaluate">
        {{ item.goods.commentCnt }}
      </div>
    </div>
    <div class="goods-shopcar" @click.stop="addSkuToCart(item.goods)" />
  </div>
</template>
<script>
const CLOSE_PRODUCT = 'close';
import productMixin from '../mixins/product.mixin';
export default {
  mixins: [productMixin],
  props: {
    status: {
      type: Number,
      default: 0
    },
    item: {
      type: Object,
      default: () => ({
        goods: {
          serviceTypeList: []
        },
        shareInfo: {}
      })
    }
  },
  data() {
    return {};
  },
  computed: {
    showSimilar() {
      return this.status === 0;
    }
  },
  methods: {
    closeProduct() {
      this.$emit(CLOSE_PRODUCT, this.item);
    }
  }
};
</script>
<style lang="less" scoped>
.goods {
  width: 172px;
  background: @white;
  border-radius: 8px;
  overflow: hidden;
  position: relative;

  &-close {
    position: absolute;
    right: 0px;
    top: 0px;
    z-index: 1;
    padding: 8px;
    display: flex;
    // display: flex;
    // align-items: center;
    // justify-content: center;
  }

  &-image {
    height: 174px;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    &-similar {
      color: @gray-5;
      position: absolute;
      bottom: 0px;
      right: 0;
      padding: 8px 0 8px 8px;
      span {
        font-size: 10px;
        width: 40px;
        height: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px 0px 0px 8px;
        background-color: @grey-border;
      }
    }
  }
  &-info {
    padding: 6px 8px 8px 8px;
    color: @black;
    box-sizing: border-box;
    &-title {
      .text-size(13);
      .mx_multline_overwrite();
      &__icon {
        .text-size(9);
        color: @white;
        width: 22px;
        height: 13px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(270deg, #ff4b00 0%, #ff7705 100%),
          linear-gradient(270deg, #ff5d00 0%, #ff1900 100%);
        border-radius: 2px;
        transform: translateY(-1px);
      }
      &__img {
        width: 28px !important;
        height: 14px !important;
        transform: translateY(3px);
      }
    }

    &-border {
      font-size: 12px;
      color: @gray-5;
      display: flex;
      margin-top: 3px;
      .mx_multline_overwrite(1);
      &__span {
        padding-right: 5px;
        padding-left: 8px;
        border-right: 1px solid #dcdee0;
        &:first-child {
          padding-left: 0;
        }
      }
    }
    &-tag {
      .text-size(8);
      display: flex;
      margin-top: 8px;
      span {
        height: 12px;
        line-height: 12px;
        border-style: solid;
        border-width: 0.5px;
        border-radius: 2px;
        margin-right: 3px;
        position: relative;
        overflow: hidden;
        &:last-child {
          margin-right: 0;
        }
      }
      &__top {
        color: #ffe4af;
        height: 13px;
        padding-left: 12px;
        padding-right: 2px;
        background-image: @gradient-red;
        &::before {
          content: '';
          position: absolute;
          left: 0;
          top: 0;
          width: 12px;
          height: 100%;
          background: url(~@/assets/images/browse/delete.png) no-repeat center center;
          background-size: 8px 8px;
        }
      }
      &__quality {
        color: #ffe4af;
        width: 26px;
        border-color: #212145;
        background-color: #212145;
        text-align: center;
      }
      &__coupon {
        color: @red;
        border-color: @red;
        padding: 0 5px;
      }
      &__coupon2 {
        color: @red;
        border-color: @red;
        padding-left: 16px;
        padding-right: 2px;

        &::before {
          content: '劵';
          color: @white;
          position: absolute;
          left: 0;
          top: 0;
          width: 14px;
          text-align: center;
          background-color: @red;
        }
      }
    }
    &-price {
      .text-size(18);
      color: @red;
      font-weight: 500;
      padding-top: 12px;
      &::before {
        content: '¥';
        font-size: 0.7em;
        font-weight: bold;
      }
    }
    &-evaluate {
      font-size: 10px;
      color: @gray-4;
    }
  }

  &-shopcar {
    position: absolute;
    bottom: 14px;
    right: 11px;
    width: 26px;
    height: 26px;
    background: url(~@/assets/images/browse/shop.png) no-repeat center center;
    background-size: 14px 13px;
    border: solid 0.5px @gray-3;
    border-radius: 50%;
  }
}
</style>
