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
<template>
<div class="sale-buy" v-if="salePop.show">
<div :style="{backgroundImage:`url(${saleUrl})`}" class="sale-block" v-for="data in goodsList" @click="chooseSale(data);buttonClick('优惠券','选择优惠券')">
<div class="money"><span class="price-icon">¥</span>{{data.money/100}}</div>
<div class="tips">不可重复使用</div>
<div class="btn" >立即使用</div>
</div>
<div class="noLesson" v-if="noSale">
<img :src="errorUrl"/>
<br>
暂无优惠券
</div>
<div @click="cleanSale();buttonClick('优惠券','取消选择')" class="cleanBtn">取消</div>
</div>
</template>
<script>
import {getCouponListApi} from "../../service/api";
import saleUrl from '../../assets/shop/saleblock.png'
import errorUrl from '../../assets/error.png'
export default {
name: "sale",
props:[
"salePop"
],
data(){
return {
saleUrl:saleUrl,
noSale:false,
errorUrl:errorUrl,
goodsList:[]
}
},
mounted(){
getCouponListApi(this.salePop.id).then(res=>{
this.goodsList = res;
this.noSale = !!res.length<1
})
},
methods:{
chooseSale(data){
this.$emit('chooseSale',data);
this.salePop.show = false
},
buttonClick(buttonType,buttonName){
this.$sa.track('buttonClick',{
tabTitle:'商品',
moduleTitle:'购买页',
buttonType:buttonType,
buttonName:buttonName
});
},
cleanSale(){
this.$emit('chooseSale',0);
this.salePop.show = false;
}
},
watch:{
'salePop.show'(value){
if(value === true && this.salePop.id){
this.goodsList = [];
getCouponListApi(this.salePop.id).then(res=>{
this.goodsList = res;
this.noSale = !!res.length<1
})
}
}
}
}
</script>
<style scoped lang="less">
@import "../../util/public";
.noLesson{
text-align: center;
img{
width: 50%;
margin: 20*@toVw 0;
}
font-size: 18*@toVw;
color: #666666;
}
.sale-buy{
position: fixed;
top: 0;
bottom: 0;
padding: 10 * @toVw;
left: 0;
right: 0;
z-index: 2;
background: #eee;
.sale-block{
width: 342 * @toVw;
height: 129 * @toVw;
background-size: 100% 100%;
color: white;
margin-bottom: 15 * @toVw;
position: relative;
.money{
.price-icon{
font-size: 30 * @toVw;
}
height:67 * @toVw;
font-size:48 * @toVw;
font-family:PingFang-SC-Bold;
color:rgba(255,255,255,1);
line-height:67* @toVw;
position: absolute;
top: 20 * @toVw;
right: 179* @toVw;
}
.tips{
width:100* @toVw;
height:22* @toVw;
font-size:16* @toVw;
font-family:PingFang-SC-Medium;
font-weight:500;
color:rgba(255,255,255,1);
line-height:22* @toVw;
position: absolute;
top: 33 * @toVw;
right: 15 * @toVw;
}
.btn{
width: 106 * @toVw;
height: 32 * @toVw;
border-radius: 1000* @toVw;
background: white;
color: #F24364;
text-align: center;
line-height: 32 * @toVw;
position: absolute;
top: 72 * @toVw;
right: 16 * @toVw;
}
}
.cleanBtn{
position: absolute;
text-align: center;
width: 350 * @toVw;
height: 40 * @toVw;
line-height: 40 * @toVw;
background: white;
border-radius: 4px;
bottom: 20 * @toVw;
color: #666666;
}
}
</style>