coupon-popup.vue
13.7 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
<template>
<view class="coupon-popup" :class="showActivity && 'show'" >
<global-loading />
<view class="mask" @click="closePopup"></view>
<view class="couponShow-box" id="popupInner">
<view class="tabsbox">
<u-tabs
:list="activeTypeList"
bar-width="0"
bar-height="0"
:bold="false"
active-color="#2ca638"
inactive-color="#999999"
:is-scroll="false"
:current="activeTypeFlag"
@change="activeTypeActive"
></u-tabs>
</view>
<view v-show="activeTypeFlag === 1">
<view class="couponShow">
<view class="title-box">
<image class="close-btn" @click="onActivityClose" src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/images/close.png"></image>
</view>
<view class="shopCouponBox" :class="markTools.length === 0 && 'flex'">
<view class="list" v-if="markTools.length > 0">
<view class="item"
v-for="(item, index) in markTools"
:key="index"
:class="{received: item.state === 1}"
>
<view class="info-box">
<view class="discoun" v-if="item.couponType == 1"><text style="font-size: 28rpx">¥</text>{{item.reduceMoney}}</view>
<view class="discoun" v-if="item.couponType == 2">{{item.reduceMoney}}折</view>
<view class="info-date">{{getDate(item.startTime)}}-{{getDate(item.endTime)}}</view>
<view class="info-condition mar-top-30">{{item.content}}</view>
<!-- <view class="info-condition" v-if="item.couponType == 2">{{item.reduceMoney}}折优惠</view>-->
<wx-send-coupon @success="success" v-if="item.state === 3" :couponList="[item]">
<view class="use-btn mar-top-10"
v-if="item.state === 3">
立即领取
</view>
</wx-send-coupon>
<view class="use-btn mar-top-10" v-if="item.state === 0">已领取</view>
<view class="use-btn mar-top-10" v-if="item.state === 1">已使用</view>
</view>
</view>
</view>
<view v-else class="emptyOrder-box flex-items-plus flex-column">
<image class="emptyOrder-img" src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/img//bgnull.png"></image>
<label class="font-color-999 fs26 mar-top-30">你还没有优惠券哦~</label>
</view>
</view>
</view>
</view>
<view v-show="activeTypeFlag === 0">
<view class="couponShow">
<view class="title-box">
<image class="close-btn" @click="onActivityClose" src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/images/close.png"></image>
</view>
<view class="shopCouponBox" :class="shopMarkTools.length === 0 && 'flex'">
<view class="list" v-if="shopMarkTools.length > 0">
<view
class="item"
v-for="(item, index) in shopMarkTools"
:key="index"
:class="{received: item.state === 1}"
>
<view class="info-box">
<view class="discoun" v-if="item.couponType === 1"><text
style="font-size: 28rpx">¥</text>{{item.reduceMoney}}</view>
<view class="discoun" v-if="item.couponType === 2">{{item.reduceMoney}}折</view>
<view class="info-date">{{getDate(item.startTime)}}-{{getDate(item.endTime)}}</view>
<view class="info-condition" v-if="item.couponType === 1">
满{{item.fullMoney}}元减{{item.reduceMoney}}元</view>
<view class="info-condition" v-if="item.couponType === 2">{{item.reduceMoney}}折优惠
</view>
<view class="use-btn" @click="receiveTap(item,1)" v-if="item.state === 3">立即领取
</view>
<view class="use-btn" v-if="item.state === 0">已领取</view>
</view>
</view>
</view>
<view v-else class="emptyOrder-box flex-items-plus flex-column">
<image class="emptyOrder-img" src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/img//bgnull.png"></image>
<label class="font-color-999 fs26 mar-top-30">你还没有优惠券哦~</label>
</view>
</view>
</view>
</view>
<view class="receive-success" v-if="isShowSuccess">
<view class="success-box">
<image class="success-img" src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/images/success_tu.png"></image>
<view class="text">领取成功</view>
</view>
</view>
</view>
</view>
</template>
<script>
import WxSendCoupon from "@/components/wx/wxSendCoupon";
const NET = require('../../utils/request')
const API = require('../../config/api')
export default {
name: "coupon-popup",
components: {
WxSendCoupon,
},
props: {
markTools: {
type: Array,
default: ()=>[]
},
shopMarkTools: {
type: Array,
default: ()=>[]
},
setTop: {
type: Number,
default: 0,
},
currentActive: {
type: Number,
default: 0
}
},
data () {
return {
showActivity: false,
isShowSuccess: false,
// activeTypeFlag: this.currentActive,
activeTypeFlag:0,
// activeTypeList: [ {
// name: '店铺活动'
// }]
activeTypeList: [
// {
// name: '平台活动'
// },
{
name: '店铺活动'
}],
}
},
methods:{
activeTypeActive(index) {
console.log(index)
this.activeTypeFlag = index
},
//关闭优惠券弹窗
onActivityClose() {
this.showActivity = false
},
// 时间格式化
getDate(time) {
if (!time) return '';
return time.split(' ')[0].split('-').join('.');
},
// 领取优惠券
receiveTap(couponItemInfo, type) {
// uni.showLoading({
// mask: true,
// title: '领取中...',
// })
this.$showLoading("领取中...")
let ReceiveCoupon
if (type === 0) {
ReceiveCoupon = {
couponId: couponItemInfo.couponId,
shopId:this.shopId
}
} else {
ReceiveCoupon = {
shopCouponId: couponItemInfo.shopCouponId,
shopId:this.shopId
}
}
NET.request(API.ReceiveCoupon, ReceiveCoupon, 'POST').then(res => {
// uni.hideLoading()
this.isShowSuccess = true
setTimeout(() => {
this.isShowSuccess = false
// this.showActivity = false;
// this.queryProductDetail()
}, 1500);
// setTimeout(() => {
// this.showActivity = false
// }, 3000);
}).catch(res => {
// uni.hideLoading()
uni.showToast({
title: res.msg,
icon: 'none'
})
})
},
success(){
this.isShowSuccess = true
setTimeout(() => {
this.isShowSuccess = false
}, 1500);
},
closePopup(){
this.showActivity = false;
}
}
}
</script>
<style lang="scss" scoped>
.coupon-popup{
display: block;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
// background-color: rgba(0, 0, 0, 0.6);
z-index: -1;
opacity: 0;
&.show{
z-index: 1000;
opacity: 1;
.couponShow-box{
/*transform: translate3D(0px, 0px, 0px);*/
bottom: 0;
}
}
.mask{
display: block;
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
background-color: rgba(0, 0, 0, 0.6);
z-index:1001;
}
.couponShow-box{
.couponShow {
height: 1000rpx;
z-index: 333;
}
width: 100%;
height: auto;
/*transform: translate3d(0px, 100%, 0px);*/
transition: all 0.3s ease-in-out 0s;
background-color: #fff;
position: absolute;
left: 0;
right: 0;
bottom: -100%;
z-index: 1002;
.tabsbox{
padding:0 20rpx;
/deep/ .u-tab-item{
height: 100rpx !important;
line-height: 100rpx !important;
}
}
.title-box .close-btn {
width: 50upx;
height: 50upx;
box-sizing: border-box;
position: absolute;
top: 20upx;
right: 20upx;
}
// #ifdef MP-ALIPAY
.title-box .close-btn {
width: 30upx;
height: 30upx;
top: 10upx;
right: 10upx;
}
// #endif
.shopCouponBox {
height: 100%;
overflow: auto;
position: relative;
&.flex{
display: flex;
justify-content: center;
align-items: center;
}
.emptyOrder-box {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
margin: auto;
// padding-top: 80upx;
.emptyOrder-img {
width: 225upx;
height: 196upx;
}
}
.list {
display: flex;
flex-wrap: wrap;
}
.item {
width: 50%;
height: 291rpx;
background: url("https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/images/couponsIcon.png") no-repeat center top;
border-radius: 10rpx;
margin-top: 20rpx;
display: flex;
flex-direction: row;
position: relative;
background-size: contain;
padding: 0 50rpx;
margin-bottom: 30rpx;
}
.received {
background: url("https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/images/couponsIcon1.png") no-repeat center top;
background-size: contain;
.discoun {
color: #999999;
padding-top: 35rpx;
}
.use-btn {
height: 48rpx;
border: 2rpx solid #CCCCCC;
line-height: 48rpx;
text-align: center;
font-size: 24rpx;
font-weight: 400;
background-color: #CCCCCC;
color: #FFFFFF;
margin: 50rpx auto 0 auto;
padding: 0 10rpx;
}
}
/*.item:last-child {*/
/*margin-bottom: 100rpx;*/
/*}*/
.discoun {
display: flex;
flex-direction: row;
align-items: baseline;
font-size: 40rpx;
color: #2ca637;
margin: 0 auto;
padding-top: 40rpx;
}
.discoun text {
display: inline-block;
}
.info-box {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.info-condition {
font-size: 20rpx;
font-weight: 400;
color: #999999;
margin:0 auto;
}
.info-date {
font-size: 20rpx;
font-family: PingFang SC;
font-weight: 400;
color: #999999;
margin: 10rpx auto;
line-height: 20rpx;
}
.use-btn {
height: 48rpx;
border: 2rpx solid #2ca637;
line-height: 48rpx;
text-align: center;
font-size: 24rpx;
font-weight: 400;
background-color: #2ca637;
color: #FFFFFF;
margin: 50rpx auto 0 auto;
padding: 0 10rpx;
}
}
}
}
.receive-success {
width: 100%;
position: fixed;
top: 0;
bottom: 0;
left: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 8888;
.success-box {
width: 380upx;
height: 280upx;
background: rgba(0, 0, 0, 0.5);
border-radius: 10upx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.success-img {
width: 200upx;
height: 130upx;
}
.text {
font-size: 28upx;
margin-top: 50upx;
font-weight: 400;
color: rgba(255, 255, 255, 1);
}
}
}
</style>