shop.vue
11.5 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
<template>
<!-- 商城 -->
<view class="shop">
<!-- 封面 -->
<view class="shopCarousel">
<img v-if="getShop.advertiseList" :src="getShop.advertiseList[3].pic" alt="">
</view>
<!-- 描述 -->
<view class="describe">
<view class="describeBox">
<!-- 余额 -->
<view class="balance">
<span>幸运石余额</span>
<image class="lucky" :src="require('@/static/Bitmap.png')" mode=""></image>
<span>{{integration||0}}</span>
</view>
<!-- 商品倒计时 -->
<view class="countDown">
<p>
<span>商品更新倒计时</span>
3天15:03:52
</p>
</view>
</view>
</view>
<!-- 滚动条 -->
<u-notice-bar bg-color="#FFFDEE" color="#97702D" type="warning" :list="listScroll"></u-notice-bar>
<!-- 商品 -->
<view class="goodsListbox">
<view class="goodsList">
<view class="good" v-for="el in getShop.hotProductList" :key="el.id" @click="commodityDetails(el.id)">
<view class="goodImg">
<!-- <img :src="el.pic" alt=""> -->
<u-lazy-load class="lazyImg" :image="el.pic"></u-lazy-load>
</view>
<span class="goodDescribe">
{{el.name}}
</span>
<view class="goodPriceOrNum">
<span class="price"><span class="small">¥</span>{{el.price}}</span>
<view class="number">
<image class="numberImg" :src="require('@/static/Bitmap.png')" mode=""></image>
<span class="numberPrice">{{el.price*510}}</span>
</view>
</view>
</view>
</view>
<u-divider margin-bottom="35" bg-color="#F7F7F7" fontSize="35" border-color="gray">盲盒陆续上新</u-divider>
</view>
<!-- 下拉物品 -->
<view class="Details">
<u-popup v-model="show" mode="bottom" :mask="true" width="750rpx" close-icon-color="#FFFFFF"
:closeable="true" close-icon-size="60" close-icon="close-circle">
<!-- 详细物品内容 -->
<view class="DetailsContent">
<!-- 确认兑换 -->
<view class="confirm">
<span>确认兑换</span>
</view>
<!-- 物品信息 -->
<view class="message">
<!-- 商品图片 -->
<view class="messagePicture">
<img :src="NumIdGoods.pic" alt="">
</view>
<!-- 商品标题 -->
<view class="messageTitle">
<!-- 文字信息 -->
<view class="messageTitleFont">
<p class="headerFont">{{NumIdGoods.name}}</p>
<span>兑换商品不支持7天无理由退换</span>
</view>
<!-- 价钱 -->
<view class="price">
<image class="DetailsLucky" :src="require('@/static/Bitmap.png')" mode=""></image>
<span class="priceFont">{{NumIdGoods.price*510}}</span>
</view>
</view>
</view>
<!-- 购买须知 -->
<view class="stipulate">
<view class="stipulateYes">
<span>我已阅读并同意</span>
<p class="">
《幸运星球买家须知》
</p>
</view>
<u-icon @click="consent" name="checkmark-circle-fill" :color="consentBtn?'red':'#DBDBDB'"
size="50"></u-icon>
</view>
<!-- 支付 -->
<view class="payment" v-if="NumIdGoods.price*510<=(integration||0)">
<view class="paymentBtn" @click="exchangeBtn(NumIdGoods.id,NumIdGoods.price*510)">
去支付{{NumIdGoods.price*510}}幸运石
</view>
</view>
<!-- 余额不足 -->
<view class="lacking" v-if="NumIdGoods.price*510>(integration||0)">
<view class="lackingBtn">
当前幸运石不足
</view>
</view>
</view>
</u-popup>
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
//辅助函数
import {
mapGetters
} from "vuex";
export default {
data() {
return {
// 滚动条
listScroll: [
'滚动信息条',
'产品送达时间请参考个人中心物流时间'
],
// 下拉物品
show: false,
// 购买须知按钮状态
consentBtn: false,
};
},
methods: {
// 商品详情显示 获取商城对应物品数据
commodityDetails(numId) {
this.show = !this.show
this.$store.dispatch("gainGoods", numId)
},
// 购买须知同意
consent() {
this.consentBtn = !this.consentBtn
},
// 点击兑换
async exchangeBtn(isId, num) {
if (this.consentBtn) {
try {
// 兑换物品
await this.$store.dispatch("gainExchange", {
integration: num,
productId: isId,
isToken: uni.getStorageSync("isToken")
})
this.$store.dispatch("gainInfo", uni.getStorageSync("isToken"))
this.$refs.uToast.show({
title: '兑换成功',
type: 'success',
})
} catch (e) {
this.$refs.uToast.show({
title: e.msg,
type: 'error',
})
}
} else {
this.$refs.uToast.show({
title: '请勾选购买须知',
type: 'error',
})
}
}
},
created() {
// 获取商城数据
this.$store.dispatch("gainShopGoods")
},
onShow() {
// 更新个人信息
this.$store.dispatch("gainInfo", uni.getStorageSync("isToken"))
},
computed: {
// 商城数据
getShop() {
return this.$store.state.shop.shopGoods
},
//商城对应物品数据
...mapGetters(["NumIdGoods"]),
// 幸运石
integration() {
return this.$store.state.code.integration
}
}
}
</script>
<style lang="scss" scoped>
page {
background-color: #F7F7F7;
}
* {
margin: 0;
padding: 0;
}
//封面
.shopCarousel {
width: 750rpx;
height: 400rpx;
img {
width: 750rpx;
height: 400rpx;
}
}
// 描述
.describe {
width: 750rpx;
height: 120rpx;
display: flex;
justify-content: center;
align-items: center;
background-color: white;
.describeBox {
width: 690rpx;
display: flex;
justify-content: space-between;
align-items: center;
.balance {
display: flex;
align-items: center;
span {
font-size: 15px;
}
.lucky {
width: 20rpx;
height: 40rpx;
margin: 0 14rpx;
}
}
.countDown {
p {
font-size: 13px;
span {
font-size: 12px;
color: darkgray;
margin-right: 15rpx;
}
}
}
}
}
// 商品列表
.goodsListbox {
width: 750rpx;
display: flex;
flex-direction: column;
align-items: center;
background-color: #F7F7F7;
padding-top: 20rpx;
.goodsList {
width: 688rpx;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
margin-bottom: 20rpx;
.good {
width: 336rpx;
overflow: hidden;
border-radius: 15rpx;
background-color: white;
margin-bottom: 15rpx;
display: flex;
align-items: center;
flex-direction: column;
.goodImg {
width: 300rpx;
height: 300rpx;
margin-bottom: 30rpx;
// img{
// width: 100%;
// height: 330rpx;
// }
.lazyImg {
max-height: 300rpx !important;
background-color: white !important;
}
}
.goodDescribe {
width: 320rpx;
margin: auto;
overflow: hidden;
/* 设置元素为弹性伸缩盒 */
display: -webkit-box;
/* 设置弹性盒纵向排列 */
-webkit-box-orient: vertical;
/* 你要显示多少行 而且设置这个属性后,不需要单独设置ellipsis就可以显示为省略号*/
-webkit-line-clamp: 2;
font-size: 13px;
}
.goodPriceOrNum {
width: 320rpx;
margin: auto;
display: flex;
justify-content: space-between;
align-items: center;
margin: 20rpx 0;
.price {
font-weight: 700;
color: #EF4F3F;
font-size: 20px;
.small {
font-weight: 200;
font-size: 13px;
}
}
.number {
display: flex;
align-items: center;
margin-top: 5px;
.numberPrice {
color: darkgray;
font-size: 13px;
}
.numberImg {
width: 20rpx;
height: 40rpx;
margin-right: 12rpx;
}
}
}
}
// 到底了
.divider {
margin-top: 500rpx;
}
}
}
// 下拉商品内容
// 下拉商品
.Details {
// 关闭按钮
::v-deep .u-drawer-content {
// background-color: red!important;
.u-close {
top: -85rpx !important;
right: 35rpx !important;
}
}
// 上边框颜色
::v-deep .u-drawer-content-visible {
// overflow: hidden;
.u-drawer__scroll-view {
border-top: 25rpx solid #CA81F7 !important;
// border-image: linear-gradient(#CA81F7, #79ECFF, #FFE7BE) 250 50 20 20 !important;
}
}
// 详细物品内容
.DetailsContent {
width: 750rpx;
display: flex;
flex-direction: column;
align-items: center;
// 确认兑换
.confirm {
width: 690rpx;
height: 90rpx;
line-height: 100rpx;
text-align: left;
font-size: 19px;
margin-top: 10rpx;
}
// 商品信息
.message {
width: 690rpx;
height: 380rpx;
display: flex;
justify-content: space-between;
align-items: center;
//商品图片
.messagePicture {
width: 300rpx;
height: 300rpx;
display: flex;
justify-content: center;
align-items: center;
background-color: #F4F4F4;
img {
width: 100%;
height: 280rpx;
}
}
// 商品标题
.messageTitle {
width: 360rpx;
height: 300rpx;
// 文字详细
.messageTitleFont {
width: 360rpx;
.headerFont {
font-size: 15px;
overflow: hidden;
/* 设置元素为弹性伸缩盒 */
display: -webkit-box;
/* 设置弹性盒纵向排列 */
-webkit-box-orient: vertical;
/* 你要显示多少行 而且设置这个属性后,不需要单独设置ellipsis就可以显示为省略号*/
-webkit-line-clamp: 2;
margin-bottom: 12rpx;
}
span {
font-size: 11px;
color: darkgray
}
}
// 价钱
.price {
width: 360rpx;
height: 60rpx;
margin-top: 100rpx;
display: flex;
align-items: center;
.DetailsLucky {
width: 30rpx;
height: 60rpx;
margin-right: 20rpx;
}
.priceFont {
font-size: 23px;
font-weight: 700;
}
}
}
}
// 购买须知
.stipulate {
width: 690rpx;
height: 100rpx;
background-color: white;
display: flex;
justify-content: space-between;
align-items: center;
padding-right: 30rpx;
.stipulateYes {
display: flex;
font-size: 13px;
span {
color: darkgray;
}
}
}
// 支付
.payment {
width: 750rpx;
height: 160rpx;
display: flex;
justify-content: center;
align-items: center;
.paymentBtn {
width: 690rpx;
height: 100rpx;
background-image: linear-gradient(to bottom right, #FFCB93, #F72934);
border-radius: 10px;
font-size: 17px;
color: white;
line-height: 100rpx;
text-align: center;
}
}
// 余额不足
.lacking {
width: 750rpx;
height: 160rpx;
display: flex;
justify-content: center;
align-items: center;
.lackingBtn {
width: 690rpx;
height: 100rpx;
background-color: gray;
border-radius: 10px;
font-size: 17px;
color: white;
line-height: 100rpx;
text-align: center;
}
}
}
}
</style>