CardCourseList.vue
5.48 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
<template>
<div id="cardCourseList">
<div class="card_box">
<img src="../../assets/service/card_bg.png" alt="">
<p class="card_title">{{cardTitle}}</p>
<p class="card_tip">仅限相关活动产品使用</p>
<div class="right" @click="reCard">
<p class="card_price"><span>¥</span>{{couponPrice}}</p>
<span class="card_btn nobg" v-if="geted">已领取</span>
<span class="card_btn" v-else>立即抢券</span>
</div>
</div>
<p class="line">以/下/指/定/商/品/可/用</p>
<ServiceListSecond :list="proList" :notab="true"></ServiceListSecond>
</div>
</template>
<script>
import ServiceListSecond from '@/views/Service/component/ServiceListSecond.vue'
export default {
name: 'CardBoxXST',
data () {
return {
unionId: '',
cardTitle: '',
couponPrice: '',
cardId: '',
proId: '',
proName: '',
pics: '',
geted: false,
proList: []
}
},
mounted () {
this.cardTitle = localStorage.getItem('cardCousreCardTitle');
this.couponPrice = localStorage.getItem('cardCousreCardPrice');
this.cardId = localStorage.getItem('cardCousreCardId');
this.proId = localStorage.getItem('cardCousreProId');
this.proName = localStorage.getItem('cardCousreProName');
this.pics = localStorage.getItem('cardCousrePics');
this.geted = localStorage.getItem('cardCousreGeted') == 'true' ? true : false
this.getCourseList()
},
methods: {
// 获取优惠券对应的商品列表
getCourseList () {
this.$toast.loading({
message: "加载中...",
duration: 0,
forbidClick: true,
});
this.mgop({
api: 'mgop.sz.hswsy.CourseListByIdList', // 必须
host: 'https://mapi.zjzwfw.gov.cn/',
dataType: 'JSON',
type: 'POST',
appKey: 'fuxgnukl+2001895516+edccpx', // 必须
headers: {
// 'isTestUrl': '1'
},
data: {
idList: this.proId.split(',')
},
onSuccess: res => {
this.$toast.clear();
let proList = res.data.data;
for (let i in proList) {
proList[i].course_labels = proList[i].course_labels?.split(',');
proList[i].coverUrl = proList[i]?.coverList[0]?.cover_url
if (proList[i].startDate) {
proList[i].week = this.formatWeek(this.Moment(proList[i].startDate).format('d'));
proList[i].startDate = this.Moment(proList[i].startDate).format('YYYY.M.D');
proList[i].endDate = this.Moment(proList[i].endDate).format('YYYY.M.D');
}
}
console.log(proList)
this.proList = proList
},
onFail: err => {
console.log('err', err)
}
});
},
formatWeek (week) {
return week == 1 ? '周一' : week == 2 ? '周二' : week == 3 ? '周三' : week == 4 ? '周四' : week == 5 ? '周五' : week == 6 ? '周六' : week == 0 ? '周日' : '';
},
//领取优惠券
reCard () {
if (this.geted) return;
this.mgop({
api: 'mgop.sz.hswsy.CouponGet', // 必须
host: 'https://mapi.zjzwfw.gov.cn/',
dataType: 'JSON',
type: 'POST',
appKey: 'fuxgnukl+2001895516+edccpx', // 必须
headers: {
// 'isTestUrl': '1'
},
data: {
"unionId": localStorage.getItem('centerNo'),
"proId": this.proId,
"proName": this.proName,
"pic": this.pics,
"couponId": this.cardId,
},
onSuccess: res => {
if (res.data.code == 200) {
localStorage.setItem('cardCousreGeted', true)
this.geted = true;
this.$toast('领取成功!')
} else {
this.$toast.fail(res.data.message);
}
},
onFail: err => {
console.log('err', err)
}
});
},
onConfirm (item) {
this.showPicker = false;
this.enterAboradDetail(item.proId)
},
},
components: {
ServiceListSecond
}
}
</script>
<style lang="scss" scoped>
#cardCourseList {
width: 100%;
min-height: 100vh;
background: #fff;
background-image: url("../../assets/service/bg.png");
background-size: 100%;
background-repeat: no-repeat;
// padding-top: 36px;
overflow: hidden;
.card_box {
width: 704px;
height: 150px;
margin: 0 auto;
position: relative;
margin-top: 36px;
img {
width: 100%;
}
.card_title {
font-size: 40px;
font-weight: bold;
color: #7f5316;
position: absolute;
top: 22px;
left: 40px;
}
.card_tip {
font-size: 24px;
color: #7f5316;
position: absolute;
top: 94px;
left: 40px;
}
.right {
height: 100%;
position: absolute;
top: 0;
right: 2px;
padding-top: 20px;
box-sizing: border-box;
}
.card_price {
width: 160px;
font-size: 60px;
font-weight: bold;
text-align: center;
color: #000;
span {
font-size: 28px;
}
}
.card_btn {
display: block;
margin: 0 auto;
margin-top: 10px;
width: 134px;
line-height: 40px;
color: #7f5316;
font-size: 26px;
text-align: center;
font-weight: bold;
background: #fff;
border-radius: 4px;
&.nobg {
background: transparent;
}
}
}
.line {
font-size: 32px;
color: #fff;
letter-spacing: 4px;
text-align: center;
margin-top: 18px;
}
}
</style>