top-list.vue
2.11 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
<template>
<div class="associated-products">
<div class="header">
<div class="title">相关商品</div>
<div @click="onAllClick">全部 <i class="cubeic-arrow"></i></div>
</div>
<div class="row">
<div class="col" v-for="(product, idx) in list" :key="idx">
<div class="product-item" @click="onItemClick(product)">
<square-img :src="product.default_images" :width="300" :height="300" />
<div class="name"><span>{{product.product_name}}</span></div>
<div class="price"><i>¥</i>{{product.price}}</div>
</div>
</div>
</div>
</div>
</template>
<script>
import SquareImg from './square-img';
export default {
name: 'TopList',
components: {
SquareImg,
},
props: {
list: {
type: Array,
default: [],
},
},
methods: {
onItemClick(item) {
this.$emit('itemClick', item);
},
onAllClick() {
this.$emit('allClick');
},
},
};
</script>
<style lang="scss" scoped>
@import "../product-detail";
.associated-products {
margin-top: 30px;
.header {
padding: 20px 0;
display: flex;
justify-content: space-between;
width: 100%;
font-size: 24px;
color: #999;
line-height: 50px;
}
.title {
font-size: 36px;
font-weight: bold;
color: #000;
}
.row {
overflow: hidden;
margin: 0 -8px;
.col {
width: 33.3333%;
padding: 0 8px;
float: left;
}
}
.product-item {
margin-top: 10px;
text-align: center;
overflow: hidden;
}
.name {
height: 64px;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
span {
display: block;
font-size: 20px;
line-height: 32px;
max-height: 64px;
word-break: break-all;
overflow: hidden;
}
}
.price {
font-weight: bold;
font-size: 24px;
color: #d0021b;
i {
font-style: normal;
font-size: 0.9em;
vertical-align: baseline;
}
}
}
</style>