Blame view

pc-master/src/components/base/productList.vue 2.6 KB
3f535f30   杨鑫   '初始'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  <template>
    <div class="product">
      <div class="productBox"
        v-for="(item, index) in productList"
        :key="index"
      >
        <img class="cur-poi" :src="item.image" alt="" @click="toProductDetail(item)" />
        <p class="productName">{{ item.productName }}</p>
        <!-- 简介 -->
        <p class="productDesc">
          <span v-if="$route.name=='store' || $route.name=='search'">{{ item.productBrief }}</span>
        </p>
        <div class="price">
          <span class="presentPrice">¥{{ item.price }}</span>
          <span class="originalPrice">¥{{ item.originalPrice }}</span>
        </div>
        <p class="shopName cur-poi"
          v-if="$route.name=='category'"
          @click.stop="toStore(item.shopId)"
        >
          {{ item.shopName }}
        </p>
      </div>
    </div>
  </template>
  <script>
  export default {
    props: ['productList'],
    data  () {
      return {}
    },
    methods: {
      toProductDetail (item) {
        let data = {
          productId: item.productId,
          skuId: item.skuId,
          shopId: item.shopId
        }
        this.$router.push({
          path: '/productDetail',
          query: {
            proData: JSON.stringify(data)
          }
        })
      },
      // 跳转到店铺
      toStore (id) {
        this.$router.push({
          path: '/store',
          query: {
            shopId: id
          }
        })
      }
    }
  }
  </script>
  <style lang="scss" scoped>
  .product {
    width: 100%;
    display: flex;
    flex-flow: wrap;
    margin-bottom: 30px;
    .productBox {
      width: 23%;
      margin: 10px 1%;
      transition: all 0.3s linear;
      text-align: center;
      img {
        width: 100%;
        height: 282px;
        margin-bottom: 27px;
      }
      .productName {
        font-weight: bold;
        margin-bottom: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .price {
        margin-bottom: 12px;
        .presentPrice {
          font-size: 18px;
          font-weight: bold;
          color: #C83732;
        }
        .originalPrice {
          font-size: 16px;
          text-decoration: line-through;
          margin-left: 10px;
        }
      }
      .productDesc,.shopName {
        margin-top: 20px;
        color: #999999;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 30px;
      }
      .productDesc{
        span{
          max-width: 200px;
          height: 20px;
          margin: auto;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
      }
      .shopName{
        cursor: pointer;
      }
    }
    // .productBox:nth-of-type(4n){
    //   margin-right: 0;
    // }
    .productBox:hover{
      box-shadow:0 0 20px #cccccc;
    }
  }
  </style>