sell-second-list.vue 4.59 KB
<template>
  <div class="bg" v-if="list.length">
    <div class="second-list-item" v-for="(item,index) in list" @click="goDetail(item, index)"
         :key="index" :class="(index) % 2 === 0 && 'magrin-right'">

      <div class="second-image-div">
        <image-format
          :class="item.status === 100 ? 'dim-imge' : 'second-image'"
          :src="item.image"
          :width="180"
          :height="180"/>
        <div v-if="item.status === 100" class="dim-out"></div>
      </div>

      <div class="item-bottom">
        <div class='flag-wrapper'>
          <span class='price-flag'>{{item.price && '¥'}}{{item.price || ' '}}</span>
          <span class='type-flag' v-if="item.sechondHandTypeName">{{item.sechondHandTypeName}}</span>
        </div>
        <div class="size-flag">{{item.sizeName}}</div>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  props: {
    list: Array,
    yasParams: Object,
    yasEventName: {
      type: String,
      default: 'XY_UFO_PRD_LIST_C'
    },
  },
  data: function() {
    return {
      yasFirstId: 0,
      itemHeight: 0
    };
  },
  methods: {
    goDetail(product, index) {
      if (this.yasParams && Object.keys(this.yasParams).length) {
        this.yasDetail(product, index);
      }

      this.$router.push({
        name: 'SecondProductDetail',
        params: {
          skup: product.skup,
          yasParams: { ...this.yasParams },
        }
      });
    },

    yasShowEvent: function(height) {
      if (!this.itemHeight) {
        let item = document.querySelector('.second-list-item');

        this.itemHeight = item && item.offsetHeight || 0;
      }

      if (!this.itemHeight) {
        return;
      }

      // 获取列表单个元素高度
      let index = 0;

      if (Number(height) > 0) {
        // 获取第一个曝光元素

        let row = Math.floor((height - 12) / this.itemHeight) + 1;

        index = row * 2 - 2;
      }

      // 获取曝光列表
      let list = [];

      for (let i = 0; i < 6; i++) {
        if (this.list[i + index]) {
          list.push(this.list[i + index]);
        }
      }

      // 判断是否是重复曝光
      if (list.length && list[0].skup !== this.yasFirstId) {
        this.yasFirstId = list[0].skup;
        let DATA = [];

        list.map((value, i) => {
          const prdType = value.sechondHandTypeName === '全新瑕疵' ? 2 : 1;
          DATA.push({...this.yasParams, I_INDEX: i + index + 1, PRD_ID: value.product_id, PRD_TYPE: prdType});
        });

        this.$store.dispatch('reportYas', {
          params: {
            param: { DATA },
            appop: 'XY_UFO_SHOW_EVENT'
          }
        });
      }
    },

    yasDetail(product, index) {
      let { product_id, sechondHandTypeName } = product;
      let PRD_TYPE = sechondHandTypeName === '全新瑕疵' ? 2 : 1;

      this.$store.dispatch('reportYas', {
        params: {
          param: {...this.yasParams, I_INDEX: index + 1, PRD_ID: product_id, PRD_TYPE },
          appop: this.yasEventName
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
  .magrin-right {
    margin-right: 14px;
  }

  .second-list-item {
    border-radius: 16px;
    width: 344px;
    background: #fff;
    margin-bottom: 16px;
  }

  .second-image-div {
    display: flex;
    overflow: hidden;
    align-items: center;
    justify-content: center;
    position: relative;
  }

  .second-image {
    height: 344px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
  }

  .dim-imge {
    height: 344px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    opacity: 0.4;
    filter: alpha(opacity=40);
  }

  .dim-out {
    width: 200px;
    height: 200px;
    background: url(~statics/image/list/Group@2x.png) no-repeat;
    background-size: contain;
    position: absolute;
    top: 71.5px;
    left: 71.5px;
  }

  .item-bottom {
    padding: 20px 14px 30px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    vertical-align: middle;
  }

  .flag-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .price-flag {
    color: #000;
    font-size: 32px;
    font-weight: bold;
    line-height: 40px;

    @include num;
  }

  .type-flag {
    margin-left: 5px;
    color: #fff;
    background: #000;
    text-align: center;
    font-size: 22px;
    line-height: 40px;
    padding: 4px 8px;
    line-height: 30px;
    border-radius: 4px;
  }

  .size-flag {
    font-size: 22px;
    color: #000;
    line-height: 40px;
    letter-spacing: 0;
  }

  .bg {
    padding: 24px 24px 8px;
    display: flex;
    flex-wrap: wrap;
  }
</style>