associated-item.vue
2.52 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
<template>
<div class="horizontal-slide">
<ul class="list-warp">
<li
:class="items.length === 1 ? 'list-item one-item' : 'list-item'"
v-for="(item, index) in items"
:key="index"
@click="goToDetail(item, index)">
<ImageFormat
class="image"
:src="item.productImage" alt="加载失败"
:width="136" :height="180"
@error="imageformatError"/>
<div class="info">
<p class="title">{{item.productName}}</p>
<div class="bottom">
<span class='icon-ufo'></span>
<span class="price">¥{{item.salesPrice}}</span>
<span class="icon-goumai"></span>
</div>
</div>
</li>
</ul>
</div>
</template>
<script>
export default {
name: 'horizontalSlide',
props: {
items: {
type: Array,
default() {
return [];
}
}
},
methods: {
imageformatError() {
console.log(6666);
},
goToDetail(item) {
this.$router.push({
name: 'ProductDetail',
params: {
productId: item.productSkn,
}
});
}
},
mounted() {
}
};
</script>
<style lang="scss" scoped>
.horizontal-slide {
overflow: hidden;
overflow-x: scroll;
-webkit-overflow-scrolling: touch;
-webkit-overscroll-behavior-x: contain;
scroll-behavior: smooth;
}
.horizontal-slide::-webkit-scrollbar {
display: none;
width: 0 !important;
}
.list-warp {
overflow-x: scroll;
width: max-content;
font-size: 0;
}
.list-item {
display: inline-flex;
width: 600px;
height: 180px;
margin-right: 24px;
border-radius: 8px;
.image {
min-width: 136px;
min-height: 180px;
max-width: 136px;
max-height: 180px;
border-radius: 8px 0 0 8px;
filter: contrast(0.9);
}
.title {
font-size: 24px;
color: #999;
line-height: 34px;
word-break: break-all;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.bottom {
display: flex;
align-items: center;
justify-content: space-between;
}
.info {
padding: 20px;
display: flex;
flex-direction: column;
justify-content: space-between;
border: 1px solid #F0F0F0;
border-radius: 0 8px 8px 0;
width: 100%;
}
.price {
margin-left: 16px;
font-size: 28px;
font-family: 'BrownStd-Regular';
vertical-align: middle;
flex: 1 1 auto;
}
.icon-goumai {
float: right;
}
}
.one-item {
width: 700px;
}
</style>