|
@@ -23,8 +23,8 @@
|
23
|
23
|
<div class="flex-item">
|
24
|
24
|
<div><span>选择商品券</span></div>
|
25
|
25
|
</div>
|
26
|
|
- <a class="active" @click="showSelect = true">
|
27
|
|
- <span>{{postData.ticketName === '' ? '1张饮品券' : postData.ticketName}}</span>
|
|
26
|
+ <a class="active" v-if="getCouponOff && couponList.length" @click="showSelectCouponLayer = true">
|
|
27
|
+ <span>{{postData.customercouponid === '' ? '有' + couponList.length + '张优惠券可选' : '已选择优惠券'}}</span>
|
28
|
28
|
<i class="iconfont icon-jiantou-right"></i>
|
29
|
29
|
</a>
|
30
|
30
|
</li>
|
|
@@ -45,16 +45,24 @@
|
45
|
45
|
<a @click="toPayer">确定</a>
|
46
|
46
|
</div>
|
47
|
47
|
</div>
|
48
|
|
- <div class="selectLayer" :class="{'show': showSelect}">
|
49
|
|
- <div>
|
50
|
|
- <van-picker
|
51
|
|
- show-toolbar
|
52
|
|
- title="选择优惠券"
|
53
|
|
- :columns="ticketList"
|
54
|
|
- @cancel="showSelect = false"
|
55
|
|
- @confirm="onConfirm"
|
56
|
|
- value-key="value"
|
57
|
|
- />
|
|
48
|
+ <div class="selectCouponLayer" :class="{'show': showSelectCouponLayer}">
|
|
49
|
+ <div class="flex-v">
|
|
50
|
+ <div>
|
|
51
|
+ <i class="iconfont icon-guanbi" @click="showSelectCouponLayer = false"></i>
|
|
52
|
+ </div>
|
|
53
|
+ <div class="flex-item">
|
|
54
|
+ <div class="flex-h">
|
|
55
|
+ <div class="flex-item" style="margin: 0 .2rem;">
|
|
56
|
+ <ul>
|
|
57
|
+ <li v-for="(item,index) in couponList" :key="index" @click="selectCouponItem(item)" :class="{'active':item.select}">
|
|
58
|
+ <i class="iconfont icon-gouxuan"></i>
|
|
59
|
+ <discounts :data="item"></discounts>
|
|
60
|
+ </li>
|
|
61
|
+ </ul>
|
|
62
|
+ </div>
|
|
63
|
+ </div>
|
|
64
|
+ </div>
|
|
65
|
+ <a @click="sureSelectCoupon">确定</a>
|
58
|
66
|
</div>
|
59
|
67
|
</div>
|
60
|
68
|
</div>
|
|
@@ -63,12 +71,16 @@
|
63
|
71
|
<script>
|
64
|
72
|
import { mapState, createNamespacedHelpers } from 'vuex'
|
65
|
73
|
const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
|
|
74
|
+import discounts from '../../../components/discounts/discounts'
|
66
|
75
|
|
67
|
76
|
export default {
|
68
|
77
|
name: '',
|
69
|
78
|
data () {
|
70
|
79
|
var _self = this
|
71
|
80
|
return {
|
|
81
|
+ showSelectCouponLayer: false,
|
|
82
|
+ getCouponOff: false,
|
|
83
|
+ couponList: [], // 优惠券列表
|
72
|
84
|
postData: {
|
73
|
85
|
info: {
|
74
|
86
|
CaseId: decodeURI(_self.$route.query.caseid),
|
|
@@ -81,21 +93,7 @@ export default {
|
81
|
93
|
Remark: '',
|
82
|
94
|
},
|
83
|
95
|
detail: [],
|
84
|
|
- coupon: [
|
85
|
|
- // {
|
86
|
|
- // OrdersCouponId: '',
|
87
|
|
- // OrdersId: '',
|
88
|
|
- // OrdersNo: '',
|
89
|
|
- // CouponId: '',
|
90
|
|
- // CouponName: '',
|
91
|
|
- // OrgId: '',
|
92
|
|
- // GoodsId: '',
|
93
|
|
- // GoodsName: '',
|
94
|
|
- // UsedAmount: '',
|
95
|
|
- // Status: '',
|
96
|
|
- // CreateDate: '',
|
97
|
|
- // }
|
98
|
|
- ],
|
|
96
|
+ customercouponid: ''
|
99
|
97
|
},
|
100
|
98
|
ticketList: [{
|
101
|
99
|
value: '优惠券1',
|
|
@@ -107,10 +105,12 @@ export default {
|
107
|
105
|
value: '优惠券3',
|
108
|
106
|
id: '3',
|
109
|
107
|
}],
|
110
|
|
- showSelect: false,
|
111
|
108
|
orderInfo: JSON.parse(_self.$route.query.info) || []
|
112
|
109
|
}
|
113
|
110
|
},
|
|
111
|
+ components: {
|
|
112
|
+ discounts,
|
|
113
|
+ },
|
114
|
114
|
computed: {
|
115
|
115
|
...mapState({
|
116
|
116
|
userInfo: x => x.userCenter.userInfo,
|
|
@@ -118,13 +118,63 @@ export default {
|
118
|
118
|
})
|
119
|
119
|
},
|
120
|
120
|
created () {
|
121
|
|
- // console.log(this.$route.query.info)
|
122
|
|
- // console.log(JSON.stringify(this.postData))
|
|
121
|
+ this.getCouponList().then((res) => {
|
|
122
|
+ // console.log(JSON.stringify(res))
|
|
123
|
+ var id = JSON.parse(this.$route.query.info)[0].id, arr = [], nowDate = Date.now()
|
|
124
|
+ for (var n = 0; n < res.length; n++) {
|
|
125
|
+ if (res[n].Coupon.CouponType === 'goods' && res[n].Status === 1) {
|
|
126
|
+ if (res[n].Coupon.IsAll) {
|
|
127
|
+ this.couponList.push(res[n])
|
|
128
|
+ } else {
|
|
129
|
+ for (var a = 0; a < res[n].Coupon.Targets.length; a++) {
|
|
130
|
+ if (res[n].Coupon.Targets[a].TargetId === id && nowDate >= new Date(res[n].StartDate).getTime() && nowDate < new Date(res[n].EndDate).getTime()) {
|
|
131
|
+ this.couponList.push({
|
|
132
|
+ title: res[n].Coupon.CouponName,
|
|
133
|
+ desc: res[n].Coupon.Share.UseInstruction,
|
|
134
|
+ time: this.toolClass.dateFormat(res[n].EndDate),
|
|
135
|
+ useType: '未使用',
|
|
136
|
+ tag: '商品',
|
|
137
|
+ id: res[n].CustomerCouponId,
|
|
138
|
+ select: false,
|
|
139
|
+ })
|
|
140
|
+ }
|
|
141
|
+ }
|
|
142
|
+ }
|
|
143
|
+ }
|
|
144
|
+ }
|
|
145
|
+ this.getCouponOff = true
|
|
146
|
+ // console.log(JSON.stringify(this.couponList))
|
|
147
|
+ })
|
123
|
148
|
},
|
124
|
149
|
methods: {
|
125
|
150
|
...caseTableActions([
|
126
|
151
|
'toPay',
|
|
152
|
+ 'getCouponList',
|
127
|
153
|
]),
|
|
154
|
+ sureSelectCoupon () {
|
|
155
|
+ var bool = false
|
|
156
|
+ for (var n = 0; n < this.couponList.length; n++) {
|
|
157
|
+ if (this.couponList[n].select) {
|
|
158
|
+ bool = true
|
|
159
|
+ this.postData.customercouponid = this.couponList[n].id
|
|
160
|
+ }
|
|
161
|
+ }
|
|
162
|
+ if (!bool) {
|
|
163
|
+ this.postData.customercouponid = ''
|
|
164
|
+ }
|
|
165
|
+ this.showSelectCouponLayer = false
|
|
166
|
+ },
|
|
167
|
+ selectCouponItem (item) { // 选择优惠券
|
|
168
|
+ // item.select = !item.select
|
|
169
|
+ if (!item.select) {
|
|
170
|
+ for (var n = 0; n < this.couponList.length; n++) {
|
|
171
|
+ this.couponList[n].select = false
|
|
172
|
+ }
|
|
173
|
+ item.select = true
|
|
174
|
+ } else {
|
|
175
|
+ item.select = false
|
|
176
|
+ }
|
|
177
|
+ },
|
128
|
178
|
returnAmount () { // 返回总金额
|
129
|
179
|
var amount = 0, num = 0, info = JSON.parse(this.$route.query.info)
|
130
|
180
|
for (var n = 0; n < info.length; n++) {
|
|
@@ -138,16 +188,11 @@ export default {
|
138
|
188
|
}
|
139
|
189
|
return [amount, num]
|
140
|
190
|
},
|
141
|
|
- onConfirm (value, index) {
|
142
|
|
- this.postData.coupon.CouponName = value.value
|
143
|
|
- this.postData.coupon.CouponId = value.id
|
144
|
|
- this.showSelect = false
|
145
|
|
- },
|
146
|
191
|
toPayer () { // 下单
|
147
|
192
|
this.postData.info.OrgId = this.orgId
|
148
|
193
|
this.postData.info.UserId = this.userInfo.CustomerId
|
149
|
194
|
this.postData.info.UserName = this.userInfo.customer.CustomerName
|
150
|
|
- this.postData.info.PayType = this.postData.coupon.length ? 'coupon' : 'vip'
|
|
195
|
+ this.postData.info.PayType = this.postData.customercouponid === '' ? 'coupon' : 'vip'
|
151
|
196
|
var orderInfo = JSON.parse(this.$route.query.info)
|
152
|
197
|
this.postData.detail = []
|
153
|
198
|
var amount = 0
|
|
@@ -159,10 +204,10 @@ export default {
|
159
|
204
|
SpecId: orderInfo[n].spec,
|
160
|
205
|
SpecName: orderInfo[n].specname,
|
161
|
206
|
Number: orderInfo[n].num - 0,
|
162
|
|
- Price: String(orderInfo[n].price-0),
|
|
207
|
+ Price: String(orderInfo[n].price - 0),
|
163
|
208
|
})
|
164
|
|
- amount += (orderInfo[n].price-0) * orderInfo[n].num
|
165
|
|
- num += orderInfo[n].num-0
|
|
209
|
+ amount += (orderInfo[n].price - 0) * orderInfo[n].num
|
|
210
|
+ num += orderInfo[n].num - 0
|
166
|
211
|
}
|
167
|
212
|
this.postData.info.Amount = String(amount)
|
168
|
213
|
this.postData.info.OrdersNum = num
|
|
@@ -170,7 +215,7 @@ export default {
|
170
|
215
|
this.toPay({
|
171
|
216
|
info: JSON.stringify(this.postData.info),
|
172
|
217
|
detail: JSON.stringify(this.postData.detail),
|
173
|
|
- coupon: JSON.stringify(this.postData.coupon)
|
|
218
|
+ customercouponid: this.postData.customercouponid
|
174
|
219
|
}).then((res) => {
|
175
|
220
|
this.$dialog.alert({
|
176
|
221
|
message: '下单成功!'
|