product-group.vue
2.56 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<template>
<div class="product-group">
<div
class="product-item"
:class="{single}"
v-for="(product, inx) in data"
:key="inx">
<div class="product-content">
<ImageFormat :lazy="lazy" class="product-image" :src="product.productImage" :width="136" :height="180"></ImageFormat>
<div class="product-info">
<p class="product-name">{{product.productName}}</p>
<p class="price">¥{{product.salesPrice}}</p>
</div>
</div>
<div class="btn-fav hover-opacity" @click="onFav" :class="{'btn-is-fav': product.isFav}">{{product.isFav ? '已收藏' : '收藏'}}</div>
</div>
</div>
</template>
<script>
import {Button} from 'cube-ui';
export default {
name: 'ProductGroup',
props: {
data: {
type: Array,
default() {
return [];
}
},
lazy: {
type: Boolean,
default: true
}
},
computed: {
single() {
return this.data.length === 1;
},
},
methods: {
onFav() {
}
},
components: {Button}
};
</script>
<style lang="scss" scoped>
.product-group {
width: 100%;
overflow-x: auto;
overflow-y: hidden;
height: 276px;
padding-top: 40px;
padding-bottom: 40px;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
.product-item {
position: relative;
margin-top: 20px;
margin-right: 20px;
margin-left: 30px;
height: 180px;
width: 580px;
background-color: #fff;
box-shadow: 0 5px 10px 0 rgba(107, 95, 95, 0.2);
display: inline-block;
padding: 10px 20px;
white-space: initial;
&:last-child {
margin-right: 30px;
}
&.single {
width: 690px;
}
}
.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;
display: flex;
align-content: center;
}
.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>