itemSlot.vue
1.86 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
/**
单个商品组件
*/
<template>
<div class="itemSlot">
<div class="showImg" @click="toDetail">
<img v-if="data.image || data.productImage" :src="data.image || data.productImage" alt="">
<!-- 图片底部是否需要增加内容 配合absolute使用 -->
<slot name="extra"></slot>
</div>
<div class="footer">
<div class="title">{{ data.productName }}</div>
<div class="priceContainer">
<!-- 自定义Icon -->
<slot name="icon"></slot>
<div class="price">¥{{ data.price }}</div>
<span class="originalPrice">¥{{ data.originalPrice }}</span>
</div>
<!-- 自定义按钮 -->
<slot name="button"></slot>
</div>
</div>
</template>
<script>
export default {
props: {
data: {
type: Object,
default: () => {}
}
},
methods: {
// 图片点击回调
toDetail () {
this.$emit('toDetail')
}
}
}
</script>
<style lang="scss" scoped>
.itemSlot{
.showImg{
width: 100%;
height: 330px;
position: relative;
cursor: pointer;
img{
width: 100%;
height: 100%;
margin: auto;
}
}
.footer{
width: 100%;
.title{
width: 95%;
margin: 15px auto;
text-align: center;
font-size: 18px;
font-family: Microsoft YaHei;
color: #333333;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.priceContainer{
display: flex;
justify-content: center;
align-items: center;
.price{
min-width: 100px;
text-align: center;
font-size: 25px;
font-family: Microsoft YaHei;
font-weight: bold;
color: #C83732;
}
.originalPrice{
font-size: 18px;
font-family: Microsoft YaHei;
color: #CCCCCC;
text-decoration: line-through;
}
}
}
}
</style>