productList.vue 1.99 KB
<template>
  <div class="bg">
    <div class="item" v-if="list.length" v-for="(product,index) in list" @click="goDetail(product)"
         :key="index" :class="(index) % 2 === 0 && 'magrin-right'">
      <div class="item-top">
        <div class="item-price">
          <span class="price-flag">{{product.price && '¥'}}</span><span>{{product.price || ' '}}</span>
        </div>
        <div class="item-sales">{{product.sales && product.sales + '人付款'}}</div>
      </div>
      <ImgSize class="item-imge" :src="product.default_images" :width="274" :height="274"/>
      <div class="item-name">{{product.product_name}}</div>
    </div>
  </div>
</template>

<script>
import {Scroll} from 'cube-ui';
import ImgSize from '../../../components/img-size';

export default {
  props: {
    list: Array,
  },
  methods: {
    goDetail(product) {
      this.$router.push({
        name: 'ProductDetail',
        params: {
          productId: product.id,
        }
      });
    }
  },
  components: {
    ImgSize,
    Scroll,
  }
};
</script>

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

  .item {
    border-radius: 16px;
    width: 344px;
    padding: 24px;
    height: 498px;
    background: #fff;
    margin-bottom: 16px;
  }

  .item-top {
    height: 40px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 38px;
    align-items: center;
  }

  .item-price {
    color: #d0021b;
    font-size: 32px;
    vertical-align: center;
  }

  .item-imge {
    width: 274px;
    height: 274px;
    margin: 0 10px;
  }

  .item-name {
    font-size: 24px;
    color: #000;
    letter-spacing: 0;
    line-height: 40px;
    margin-top: 14px;
    margin-bottom: 8px;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .item-sales {
    font-size: 22px;
    color: #999;
  }

  .price-flag {
    font-size: 24px;
  }

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