<template>
  <!--
    	作者：luoyiming
    	时间：2020-06-20
    	描述：diy组件-模拟显示-限时拼团
    -->
  <div class="drag optional" :class="{ selected: index === selectedIndex }"
    @click.stop="$parent.$parent.onEditer(index)">
    <div class="diy-sharpproduct" style="background: #ffffff">
      <div class="sharpproduct-head d-b-c">
        <img v-img-url="item.style.background_image" />
      </div>
      <ul class="product-list assemble" :class="['column__3']" :style="getUlwidth(item)">
        <li class="product-item" v-for="(product, index) in item.data" :key="index">
          <div class="product-cover">
            <img v-img-url="product.image" />
            <div class="desc-situation product-sale">
              <span class="">2人团</span>
            </div>
          </div>
          <div class="product-info p-0-10">
            <div v-if="item.style.show.productName == '1'" class="product-title">{{ product.product_name }}</div>
            <div class="price d-b-c f12">
              <div>
                <div>
                  <span v-if="item.style.show.assemblePrice == '1'" style="color:#f6220c;" class="f12">¥</span><span
                    style="color:#f6220c;" class="f16 fb" v-if="item.style.show.assemblePrice == '1'">233.00</span>
                  <span v-if="item.style.show.linePrice == '1'" class="text-d-line-through gray9">¥233</span>
                </div>
              </div>
            </div>
          </div>
          <div class="assemble_btns">去开团</div>
        </li>
      </ul>
    </div>
    <div class="btn-edit-del">
      <div class="btn-del" @click.stop="$parent.$parent.onDeleleItem(index)">删除</div>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        /*商品列表*/
        tableData: [],
        /*分类id*/
        category_id: 0
      };
    },
    created() {},
    props: ['item', 'index', 'selectedIndex'],
    methods: {
      /*计算宽度*/
      getUlwidth(item) {
        if (item.style.display == 'slide') {
          let total = 0;
          if (item.params.source == 'choice') {
            total = item.data.length;
          } else {
            total = item.defaultData.length;
          }
          let w = 0;
          if (item.style.column == 2) {
            w = total * 150;
          } else {
            w = total * 100;
          }
          return 'width:' + w + 'px;';
        }
      }
    }
  };
</script>

<style>
  .diy-sharpproduct {
    padding: 0 10px;
  }

  .diy-sharpproduct .product-list.assemble {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .diy-sharpproduct .product-list.assemble .product-title {
    margin-top: 4px;
    height: 40px;
    line-height: 20px;
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
  }

  .diy-sharpproduct .product-list.assemble .price {
    margin: 0 auto;
    margin-top: 10px;
    margin-bottom: 15px;
    width: 100%;
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    text-align: center;
  }

  .diy-sharpproduct .display__list .column__3 {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .diy-sharpproduct .product-list.assemble.column__3 .product-item {
    width: 150px;
    margin-right: 10px;
    overflow: hidden;
    margin-bottom: 10px;
    background: #ffffff;
  }

  .diy-sharpproduct .product-list.assemble.column__3 .product-item .product-cover {
    width: 122px;
    height: 113px;
    border-radius: 6px;
    background-color: #f6f6f6;
    overflow: hidden;
    position: relative;
  }

  .diy-sharpproduct .product-list.assemble.column__3 .product-item .product-cover img {
    width: 122px;
    height: 113px;
  }

  .diy-sharpproduct .product-list.assemble.column__3 .product-item .product-cover .desc-situation {
    position: absolute;
    bottom: 0;
    left: 0;
    background: #fd5356;
    color: #FFFFFF !important;
    padding: 0 3px;
    border-top-right-radius: 6px;
  }

  .diy-sharpproduct .product-list.assemble.column__3 .product-title {
    margin: 0 auto;
    margin-top: 16px;
    width: 80%;
    height: 15px;
    line-height: 15px;
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    font-size: 15px;
  }

  .sharpproduct-head {
    height: 40px;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
  }

  .sharpproduct-head .name.assemble_name {
    font-size: 18px;
    font-weight: bold;
    color: #333333;
  }

  .sharpproduct-head .datetime {
    margin-left: 20px;
  }

  .sharpproduct-head .datetime>span {
    display: inline-block;
  }

  .sharpproduct-head .datetime .text {
    padding: 0 2px;
  }

  .sharpproduct-head .datetime .box {
    padding: 2px;
    background: #000000;
    color: #ffffff;
  }

  .diy-sharpproduct .product-list.assemble .assemble_btns {
    width: 100px;
    background: linear-gradient(90deg, #FF4545 0%, #F6220C 100%);
    height: 25px;
    line-height: 25px;
    font-size: 13px;
    text-align: center;
    color: #FFFFFF;
    margin: 0 auto;
    border-radius: 13px;
  }
</style>
