|
@@ -54,7 +54,7 @@
|
54
|
54
|
<span>优惠信息</span>
|
55
|
55
|
</div>
|
56
|
56
|
</div>
|
57
|
|
- <span>{{postData.CouponId == '' ? '暂未选择优惠券' : postData.CouponName}}</span>
|
|
57
|
+ <span>{{postData.customercouponid == '' ? '暂未选择优惠券' : '已选择优惠券'}}</span>
|
58
|
58
|
<i class="iconfont icon-jiantou-right"></i>
|
59
|
59
|
</div>
|
60
|
60
|
<div class="flex-h">
|
|
@@ -63,7 +63,7 @@
|
63
|
63
|
<span>优惠券</span>
|
64
|
64
|
</div>
|
65
|
65
|
</div>
|
66
|
|
- <span>{{columns.length > 1 ? (columns.length-1) + '张可用优惠券' : '暂无优惠券'}}</span>
|
|
66
|
+ <span>{{couponList.length ? couponList.length + '张可用优惠券' : '暂无优惠券'}}</span>
|
67
|
67
|
</div>
|
68
|
68
|
</div>
|
69
|
69
|
<div class="agreement">
|
|
@@ -98,14 +98,22 @@
|
98
|
98
|
</div>
|
99
|
99
|
<div class="layer" :class="{'show': showLayer}">
|
100
|
100
|
<div>
|
101
|
|
- <van-picker
|
102
|
|
- show-toolbar
|
103
|
|
- title="选择优惠券"
|
104
|
|
- :columns="columns"
|
105
|
|
- @cancel="onCancel"
|
106
|
|
- @confirm="onConfirm"
|
107
|
|
- value-key="value"
|
108
|
|
- />
|
|
101
|
+ <div class="top">
|
|
102
|
+ <i class="iconfont icon-guanbi"></i>
|
|
103
|
+ </div>
|
|
104
|
+ <div class="body flex-h">
|
|
105
|
+ <div class="flex-item">
|
|
106
|
+ <div>
|
|
107
|
+ <ul>
|
|
108
|
+ <li v-for="(item,index) in couponList" :key="index" @click="selectCouponItem(item)" :class="{'active':item.select}">
|
|
109
|
+ <i class="iconfont icon-gouxuan"></i>
|
|
110
|
+ <discounts :data="item"></discounts>
|
|
111
|
+ </li>
|
|
112
|
+ </ul>
|
|
113
|
+ </div>
|
|
114
|
+ </div>
|
|
115
|
+ </div>
|
|
116
|
+ <a @click="sureSelectCoupon">确定</a>
|
109
|
117
|
</div>
|
110
|
118
|
</div>
|
111
|
119
|
</div>
|
|
@@ -114,33 +122,28 @@
|
114
|
122
|
<script>
|
115
|
123
|
import { mapState, createNamespacedHelpers } from 'vuex'
|
116
|
124
|
const { mapActions: mapProjectActions, mapState: mapProjectState } = createNamespacedHelpers('majorProjects')
|
|
125
|
+const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
|
|
126
|
+import discounts from '../../../components/discounts/discounts'
|
117
|
127
|
|
118
|
128
|
export default {
|
119
|
129
|
name: '',
|
120
|
130
|
data () {
|
121
|
131
|
return {
|
|
132
|
+ couponList: [],
|
|
133
|
+ getCouponOff: false,
|
122
|
134
|
agreementOff: false, // 是否同意协议
|
123
|
135
|
courseTimeList: [],
|
124
|
136
|
postData: {
|
125
|
137
|
CouponId: '',
|
126
|
138
|
CouponName: '',
|
|
139
|
+ customercouponid: ''
|
127
|
140
|
},
|
128
|
141
|
showLayer: false, // 显隐选择优惠券弹窗
|
129
|
|
- columns: [{ // 优惠券列表
|
130
|
|
- value: '不选择优惠券',
|
131
|
|
- id: '',
|
132
|
|
- }, {
|
133
|
|
- value: '优惠券1',
|
134
|
|
- id: '1',
|
135
|
|
- }, {
|
136
|
|
- value: '优惠券2',
|
137
|
|
- id: '2',
|
138
|
|
- }, {
|
139
|
|
- value: '优惠券3',
|
140
|
|
- id: '3',
|
141
|
|
- }],
|
142
|
142
|
}
|
143
|
143
|
},
|
|
144
|
+ components: {
|
|
145
|
+ discounts,
|
|
146
|
+ },
|
144
|
147
|
computed: {
|
145
|
148
|
...mapState({
|
146
|
149
|
orgid: x => x.app.orgId,
|
|
@@ -156,14 +159,74 @@ export default {
|
156
|
159
|
}),
|
157
|
160
|
},
|
158
|
161
|
created () {
|
159
|
|
- this.getCourseDetailInfo({ id: this.$route.query.id }).then((res) => {
|
160
|
|
- var arr = res.CourseDetail
|
161
|
|
- this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
|
|
162
|
+ this.getCouponList().then((res) => {
|
|
163
|
+ this.getCourseDetailInfo({ id: this.$route.query.id }).then((res) => {
|
|
164
|
+ var arr = res.CourseDetail
|
|
165
|
+ this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
|
|
166
|
+ })
|
|
167
|
+ var id = this.$route.query.id, arr = [], nowDate = Date.now()
|
|
168
|
+ for (var n = 0; n < res.length; n++) {
|
|
169
|
+ if (res[n].Coupon.CouponType === 'coupon' && res[n].Status === 1) {
|
|
170
|
+ if (res[n].Coupon.IsAll) {
|
|
171
|
+ this.couponList.push({
|
|
172
|
+ title: res[n].Coupon.CouponName,
|
|
173
|
+ desc: res[n].Coupon.Share.UseInstruction,
|
|
174
|
+ time: this.toolClass.dateFormat(res[n].EndDate),
|
|
175
|
+ useType: '未使用',
|
|
176
|
+ tag: '课程',
|
|
177
|
+ id: res[n].CustomerCouponId,
|
|
178
|
+ select: false,
|
|
179
|
+ })
|
|
180
|
+ } else {
|
|
181
|
+ for (var a = 0; a < res[n].Coupon.Targets.length; a++) {
|
|
182
|
+ if (res[n].Coupon.Targets[a].TargetId === id && nowDate >= new Date(res[n].StartDate).getTime() && nowDate < new Date(res[n].EndDate).getTime()) {
|
|
183
|
+ this.couponList.push({
|
|
184
|
+ title: res[n].Coupon.CouponName,
|
|
185
|
+ desc: res[n].Coupon.Share.UseInstruction,
|
|
186
|
+ time: this.toolClass.dateFormat(res[n].EndDate),
|
|
187
|
+ useType: '未使用',
|
|
188
|
+ tag: '课程',
|
|
189
|
+ id: res[n].CustomerCouponId,
|
|
190
|
+ select: false,
|
|
191
|
+ })
|
|
192
|
+ }
|
|
193
|
+ }
|
|
194
|
+ }
|
|
195
|
+ }
|
|
196
|
+ }
|
|
197
|
+ this.getCouponOff = true
|
|
198
|
+ // console.log(JSON.stringify(this.couponList))
|
162
|
199
|
})
|
163
|
200
|
},
|
164
|
201
|
methods: {
|
|
202
|
+ ...caseTableActions([
|
|
203
|
+ 'getCouponList',
|
|
204
|
+ ]),
|
|
205
|
+ sureSelectCoupon () {
|
|
206
|
+ var bool = false
|
|
207
|
+ for (var n = 0; n < this.couponList.length; n++) {
|
|
208
|
+ if (this.couponList[n].select) {
|
|
209
|
+ bool = true
|
|
210
|
+ this.postData.customercouponid = this.couponList[n].id
|
|
211
|
+ }
|
|
212
|
+ }
|
|
213
|
+ if (!bool) {
|
|
214
|
+ this.postData.customercouponid = ''
|
|
215
|
+ }
|
|
216
|
+ this.showLayer = false
|
|
217
|
+ },
|
|
218
|
+ selectCouponItem (item) { // 选择优惠券
|
|
219
|
+ if (!item.select) {
|
|
220
|
+ for (var n = 0; n < this.couponList.length; n++) {
|
|
221
|
+ this.couponList[n].select = false
|
|
222
|
+ }
|
|
223
|
+ item.select = true
|
|
224
|
+ } else {
|
|
225
|
+ item.select = false
|
|
226
|
+ }
|
|
227
|
+ },
|
165
|
228
|
placeOrder () { // 下单
|
166
|
|
- if(!this.agreementOff){
|
|
229
|
+ if (!this.agreementOff) {
|
167
|
230
|
this.$toast('请先阅读服务协议并同意')
|
168
|
231
|
return false
|
169
|
232
|
}
|
|
@@ -174,7 +237,7 @@ export default {
|
174
|
237
|
CustomerId: this.user.CustomerId,
|
175
|
238
|
Price: this.courseDetail.Price
|
176
|
239
|
},
|
177
|
|
- coupons: []
|
|
240
|
+ customercouponid: this.postData.customercouponid
|
178
|
241
|
}).then((res) => {
|
179
|
242
|
// console.log(JSON.stringify(res))
|
180
|
243
|
this.$dialog.alert({
|
|
@@ -218,5 +281,5 @@ export default {
|
218
|
281
|
|
219
|
282
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
220
|
283
|
<style lang="scss" scoped>
|
221
|
|
-@import "page.scss";
|
|
284
|
+@import 'page.scss';
|
222
|
285
|
</style>
|