1
1
<template >
2
- <div @click.stop =" openDetail(props.spuId)" style =" cursor : pointer ;" >
3
- <div >
4
- <slot name =" top" ></slot >
2
+ <div class =" product-warp" style =" cursor : pointer " @click.stop =" openDetail(spuId)" >
3
+ <!-- 左侧商品图片-->
4
+ <div class =" product-warp-left mr-24px" >
5
+ <el-image
6
+ :initial-index =" 0"
7
+ :preview-src-list =" [picUrl]"
8
+ :src =" picUrl"
9
+ class =" product-warp-left-img"
10
+ fit =" contain"
11
+ preview-teleported
12
+ @click.stop
13
+ />
5
14
</div >
6
- <div
7
- :style =" [{ borderRadius: radius + 'px', marginBottom: marginBottom + 'px' }]"
8
- class =" ss-order-card-warp flex items-stretch justify-between bg-white"
9
- >
10
- <div class =" img-box mr-24px" >
11
- <el-image
12
- :initial-index =" 0"
13
- :preview-src-list =" [picUrl]"
14
- :src =" picUrl"
15
- class =" order-img"
16
- fit =" contain"
17
- preview-teleported
18
- @click.stop
19
- />
15
+ <!-- 右侧商品信息 -->
16
+ <div class =" product-warp-right" >
17
+ <div class =" description" >{{ title }}</div >
18
+ <div class =" my-5px" >
19
+ <span class =" mr-20px" >库存: {{ stock || 0 }}</span >
20
+ <span >销量: {{ salesCount || 0 }}</span >
20
21
</div >
21
- <div
22
- :style =" [{ width: titleWidth ? titleWidth + 'px' : '' }]"
23
- class =" box-right flex flex-col justify-between"
24
- >
25
- <div v-if =" title" class =" title-text ss-line-2" >{{ title }}</div >
26
- <div v-if =" skuString" class =" spec-text mt-8px mb-12px" >{{ skuString }}</div >
27
- <div class =" groupon-box" >
28
- <slot name =" groupon" ></slot >
29
- </div >
30
- <div class =" flex" >
31
- <div class =" flex items-center" >
32
- <div
33
- v-if =" price && Number(price) > 0"
34
- :style =" [{ color: priceColor }]"
35
- class =" price-text flex items-center"
36
- >
37
- ¥{{ fenToYuan(price) }}
38
- </div >
39
- <div v-if =" num" class =" total-text flex items-center" >x {{ num }}</div >
40
- <slot name =" priceSuffix" ></slot >
41
- </div >
42
- </div >
43
- <div class =" tool-box" >
44
- <slot name =" tool" ></slot >
45
- </div >
46
- <div >
47
- <slot name =" rightBottom" ></slot >
48
- </div >
22
+ <div class =" flex justify-between items-center" >
23
+ <span class =" price" >¥{{ fenToYuan(price) }}</span >
24
+ <el-button size =" small" text type =" primary" >详情</el-button >
49
25
</div >
50
26
</div >
51
27
</div >
@@ -57,7 +33,7 @@ import { fenToYuan } from '@/utils'
57
33
const { push } = useRouter ()
58
34
59
35
defineOptions ({ name: ' ProductItem' })
60
- const props = defineProps ({
36
+ defineProps ({
61
37
spuId: {
62
38
type: Number ,
63
39
default: 0
@@ -70,134 +46,70 @@ const props = defineProps({
70
46
type: String ,
71
47
default: ' '
72
48
},
73
- titleWidth: {
74
- type: Number ,
75
- default: 0
76
- },
77
- skuText: {
78
- type: [String , Array ],
79
- default: ' '
80
- },
81
49
price: {
82
50
type: [String , Number ],
83
51
default: ' '
84
52
},
85
- priceColor: {
86
- type: [String ],
87
- default: ' '
88
- },
89
- num: {
53
+ salesCount: {
90
54
type: [String , Number ],
91
- default: 0
92
- },
93
- score: {
94
- type: [String , Number ],
95
- default: ' '
96
- },
97
- radius: {
98
- type: [String ],
99
55
default: ' '
100
56
},
101
- marginBottom : {
102
- type: [String ],
57
+ stock : {
58
+ type: [String , Number ],
103
59
default: ' '
104
60
}
105
61
})
106
62
107
- /** SKU 展示字符串 */
108
- const skuString = computed (() => {
109
- if (! props .skuText ) {
110
- return ' '
111
- }
112
- if (typeof props .skuText === ' object' ) {
113
- return props .skuText .join (' ,' )
114
- }
115
- return props .skuText
116
- })
117
-
118
63
/** 查看商品详情 */
119
64
const openDetail = (spuId : number ) => {
120
- console .log (props .spuId )
121
65
push ({ name: ' ProductSpuDetail' , params: { id: spuId } })
122
66
}
123
67
</script >
124
68
125
69
<style lang="scss" scoped>
126
- .ss-order-card-warp {
127
- padding : 20px ;
128
- border-radius : 10px ;
129
- border : 1px var (--el-border-color ) solid ;
130
- background-color : var (--app-content-bg-color );
131
-
132
- .img-box {
133
- width : 80px ;
134
- height : 80px ;
135
- border-radius : 10px ;
136
- overflow : hidden ;
70
+ .button {
71
+ background-color : #007bff ;
72
+ color : white ;
73
+ border : none ;
74
+ padding : 5px 10px ;
75
+ cursor : pointer ;
76
+ }
137
77
138
- .order-img {
139
- width : 80px ;
140
- height : 80px ;
78
+ .product-warp {
79
+ width : 100% ;
80
+ background-color : rgba (128 , 128 , 128 , 0.5 ); // 透明色,暗黑模式下也能体现
81
+ border-radius : 8px ;
82
+ display : flex ;
83
+ align-items : center ;
84
+ padding : 10px ;
85
+
86
+ & -left {
87
+ width : 70px ;
88
+
89
+ & -img {
90
+ width : 100% ;
91
+ height : 100% ;
92
+ border-radius : 8px ;
141
93
}
142
94
}
143
95
144
- .box -right {
96
+ & -right {
145
97
flex : 1 ;
146
- position : relative ;
147
98
148
- .tool-box {
149
- position : absolute ;
150
- right : 0 ;
151
- bottom : -10px ;
99
+ .description {
100
+ width : 100% ;
101
+ font-size : 16px ;
102
+ font-weight : bold ;
103
+ display : -webkit-box ;
104
+ -webkit-line-clamp : 1 ; /* 显示一行 */
105
+ -webkit-box-orient : vertical ;
106
+ overflow : hidden ;
107
+ text-overflow : ellipsis ;
152
108
}
153
- }
154
-
155
- .title-text {
156
- font-size : 13px ;
157
- font-weight : 500 ;
158
- line-height : 20px ;
159
- }
160
-
161
- .spec-text {
162
- font-size : 10px ;
163
- font-weight : 400 ;
164
- color : #999999 ;
165
- min-width : 0 ;
166
- overflow : hidden ;
167
- text-overflow : ellipsis ;
168
- display : -webkit-box ;
169
- -webkit-line-clamp : 1 ;
170
- -webkit-box-orient : vertical ;
171
- }
172
-
173
- .price-text {
174
- font-size : 11px ;
175
- font-weight : 500 ;
176
- font-family : OPPOSANS;
177
- }
178
-
179
- .total-text {
180
- font-size : 10px ;
181
- font-weight : 400 ;
182
- line-height : 16px ;
183
- color : #999999 ;
184
- margin-left : 8px ;
185
- }
186
- }
187
109
188
- .ss-line {
189
- min-width : 0 ;
190
- overflow : hidden ;
191
- text-overflow : ellipsis ;
192
- display : -webkit-box ;
193
- -webkit-box-orient : vertical ;
194
-
195
- & -1 {
196
- -webkit-line-clamp : 1 ;
197
- }
198
-
199
- & -2 {
200
- -webkit-line-clamp : 2 ;
110
+ .price {
111
+ color : #ff3000 ;
112
+ }
201
113
}
202
114
}
203
115
</style >
0 commit comments