product-item.vue 1.63 KB
<template>
  <div class="product-item">
    <div class="product-content">
      <ImageFormat class="product-image" :src="src" width="136" height="180"></ImageFormat>
      <div class="product-info">
        <p class="product-name">{{name}}</p>
        <p class="price">¥{{price}}</p>
      </div>
    </div>
    <div class="btn-fav hover-opacity" v-if="!isFav">收藏</div>
    <div class="btn-fav btn-is-fav hover-opacity" v-else>已收藏</div>
  </div>
</template>

<script>
import {Button} from 'cube-ui';

export default {
  name: 'ProductItem',
  props: ['name', 'src', 'price', 'isFav'],
  components: {Button}
};
</script>

<style lang="scss" scoped>
.product-item {
  position: relative;
  margin-top: 20px;
  padding: 10px 20px;
  height: 180px;
  width: 670px;
  background-color: #fff;
  box-shadow: 0 5px 10px 0 rgba(107, 95, 95, 0.2);
  display: inline-block;
  white-space: initial;
}

.product-content {
  display: flex;
  width: 100%;
  height: 100%;
}

.product-image {
  width: 136px;
  height: 180px;
  margin-top: -30px;
}

.product-info {
  padding-left: 20px;
  flex: 1;

  .product-name {
    font-size: 24px;
    color: #9b9b9b;
    letter-spacing: -0.25PX;
    height: 104px;
  }

  .price {
    font-size: 32px;
    color: #d0021b;
    letter-spacing: -0.34PX;
  }
}

.btn-fav {
  position: absolute;
  bottom: 20px;
  right: -20px;
  width: 120px;
  height: 50px;
  padding: 0;
  font-size: 24px;
  background-color: #444;
  background-size: contain;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;

  &.btn-is-fav {
    background-color: #b0b0b0;
  }

  & /deep/ .iconfont {
    margin: 0;
  }
}
</style>