GoodsBox.vue
6.45 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<template>
<view class="goods-content">
<template v-if="goodsList.length">
<scroll-view scroll-y class="content-scroll-box" id="content-scroll" :style="{ height: contentHeight }"
:scroll-top="flagObject.scrollTop">
<template v-for="(i, index) in goodsList">
<view :class="['goods-item', goodsIndex == index ? 'active' : '', `status-${i.isMainPush}`]" :key="index"
@click="changeGoods(i, index)">
<view :class="['goods-status flex']">{{ statusText(i.isMainPush) }}</view>
<image class="goods-image" :src="i.thumbImageUrl"></image>
<view class="goods-title">{{ i.tabName }}</view>
<view class="goods-description">
<rich-text :nodes="i.tabDescription"></rich-text>
</view>
<view class="goods-price">
¥ {{ i.discountPrice }}
<view class="old-price">¥ {{ i.currentPrice }}</view>
</view>
</view>
</template>
</scroll-view>
</template>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'SkuBox',
props: {
currentCar: [Number, String],
show: Boolean,
activityData: Array,
tabIndex: Number,
hasBeforeActivity: Boolean,
hasAfterActivity: Boolean,
tabListId: Number,
},
data() {
return {
blockIndex: 0,
secondIndex: 0,
thirdlyIndex: 0,
goodsIndex: -1,
contentHeight: '0',
currentItem: {},
goodsList: [],
requested: false,
flagObject: {
goodsFlag: false,
scrollTop: 0
}
}
},
watch: {
/**切换车型 */
currentCar: {
immediate: true,
handler(newval) {
if (this.show && this.requested) this.changeCar(newval)
}
},
show: {
immediate: true,
handler(newval) {
if (newval && !this.requested) {
this.requested = true
this.init()
}
}
},
watchStatus: {
immediate: true,
handler(newval) {
}
},
},
computed: {
watchStatus() {
return this.$store.state.user.historyStatus;
},
},
mounted() {
},
methods: {
init() {
this.changeCar(this.currentCar)
},
changeCar(newval) {
this.goodsList = []
let { activityData, tabListId } = this,
list = activityData.find(e => e.marketingStage == tabListId)
if(!list) return
let carSeriesList = list.carSeriesList,
data = carSeriesList.find(e => e.carSeriesId == newval)
if (data) {
this.goodsIndex = -1
this.setGoodsList(data.productList)
this.$emit('noActivity', false)
} else this.$emit('noActivity', true)
},
setScrollHeight() {
this.$nextTick(() => {
let query = uni.createSelectorQuery()
query.select(`#content-scroll`).boundingClientRect(data => {
this.contentHeight = `calc(100% - ${data.top - 72}px)`
this.flagObject.scrollTop = 0
}).exec()
})
},
changeGoods(item, index, filter = true) {
if (filter && this.goodsIndex == index) return
this.goodsIndex = index
this.currentItem = item
this.changePreView()
},
setGoodsList(data) {
this.goodsList = []
this.flagObject.goodsFlag = false
data.map(e => {
if (e.tabDescription) e.tabDescription = e.tabDescription.replace(/<\/?br\s*\/?>|\\n|\n/g, '<br>')
})
this.goodsList = data
this.flagObject.goodsFlag = true
this.flagObject.scrollTop = -100
setTimeout(() => {
this.setScrollHeight()
this.changeGoods(data[0], 0, false)
}, 200)
},
changePreView() {
this.$emit('changePreView', this.currentItem)
},
statusText(status) {
return status == 1 ? '主推' : '次推'
},
}
}
</script>
<style scoped lang='scss'>
.goods-content {
width: 100%;
height: 100%;
.content-scroll-box {
.goods-item {
position: relative;
width: calc(100% - #{toRpx(64)});
border: toRpx(3) solid #292D3333;
min-height: toRpx(296);
border-radius: toRpx(16);
padding: toRpx(24) toRpx(32) toRpx(24) toRpx(232);
margin-bottom: toRpx(24);
transition: all 0.15s;
.goods-status {
position: absolute;
right: 0;
top: 0;
height: toRpx(36);
color: #FFFFFF;
font-size: toRpx(24);
justify-content: center;
background: linear-gradient(90deg, #5C8AFF 0%, #49B6FF 100%);
padding: 0 toRpx(20);
border-radius: 0 toRpx(16) 0 toRpx(16);
}
.goods-image {
position: absolute;
width: toRpx(176);
height: toRpx(240);
top: toRpx(24);
left: toRpx(32);
border-radius: toRpx(12);
overflow: hidden;
}
.goods-title {
font-weight: 500;
font-size: toRpx(30);
color: #1A1A2E;
line-height: toRpx(36);
word-break: break-all;
}
.goods-description {
margin-top: toRpx(8);
font-size: toRpx(26);
color: #6C6F75;
line-height: toRpx(36);
max-height: toRpx(144);
overflow: hidden;
word-break: break-all;
}
.goods-price {
margin-top: toRpx(8);
font-size: toRpx(36);
color: #F24724;
line-height: toRpx(44);
display: flex;
align-items: baseline;
.old-price {
font-size: toRpx(26);
color: #999EA8;
text-decoration: line-through;
margin-left: toRpx(12);
}
}
}
.status-1 {
.goods-status {
background: linear-gradient(270deg, #FF6748 0%, #F24724 100%);
}
&::after {
position: absolute;
content: '';
width: toRpx(296);
height: toRpx(228);
top: 0;
right: 0;
background: url('https://img02.glsx.com.cn/weapp/resource/app-tape/common/goods-status-1.webp') no-repeat center center;
background-size: 100% 100%;
z-index: -1;
}
}
.active {
border-color: #292D33;
.goods-description {
max-height: none;
overflow: auto;
}
}
}
.nothing {
flex-direction: column;
padding-top: toRpx(136);
font-size: toRpx(28);
color: #999999;
line-height: toRpx(40);
&-icon {
width: toRpx(676);
height: toRpx(284);
margin-bottom: toRpx(24);
background-image: url('@/assets/images/boutique/nothing.webp');
background-size: 100%;
}
}
}
</style>