CheckOrderReserve.vue
14.3 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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
<template>
<div id="checkOrder">
<div class="goods_data top_border">
<div class="top">
<img :src="showCourseData.course_img" alt="" />
<div>
<p class="goods_title">{{ showCourseData.course_name }}</p>
<p class="package_name">套餐名称:{{ TalentReserveGroupData.productSceneName }}</p>
<p class="count">数量:x{{ count }}{{ TalentReserveGroupData.UnitName }}</p>
</div>
</div>
<div class="bottom">
<p class="time">使用时间: {{ Moment(TalentReserveData.date).format('YYYY-MM-DD') }}</p>
<p class="price"><span>¥</span>{{ (TalentReserveData.actualPrice * 1000 * count) / 1000 }}</p>
</div>
</div>
<!-- <div class="card top_border" v-if="TalentReserveData.actualPrice > 0" @click="openCardBox">
<p>可用优惠券</p>
<div>
<span class="use_card" v-if="useCard">已使用红包抵扣{{ useCard.couponPrice }}</span>
<van-icon name="arrow" />
</div>
</div> -->
<div class="top_border">
<contact-box :limit="count" :people="TalentReserveGroupData.adultCount" :child="TalentReserveGroupData.childCount"></contact-box>
</div>
<div class="card top_border" @click="showRemark = true">
<p>其他要求</p>
<div class="remark">
<span>{{ remark }}</span>
<van-icon name="arrow" />
</div>
</div>
<!-- <div class="card top_border">
<p>服务承诺和保障</p>
<van-icon name="arrow" />
</div>
<div class="protocol">
<van-checkbox v-model="checked" shape="square" icon-size="16px" @change="protocolChange">我已阅读并同意 </van-checkbox>
<span style="text-decoration: underline" @click="goPayneed">购买须知</span>
<span style="text-decoration: underline" @click="goProtocol">用户协议</span>
</div> -->
<div class="Collection">
<div class="box box1">
<p>
<span>¥</span>{{ paymoney }} <del>{{ (TalentReserveData.productPrice * 1000 * count) / 1000 }}</del>
</p>
</div>
<div class="box box2" v-if="userInfo">
<span @click="createOrder()">提交信息</span>
</div>
</div>
<van-popup class="remark_box" v-model="showRemark" round>
<textarea class="remark_textarea" v-model="editRemark" placeholder="请输入" cols="30" rows="10"></textarea>
<span class="remark_btn" @click="EditRemarkConfirm">完成</span>
</van-popup>
</div>
</template>
<script>
import Axios from 'axios'
import wx from 'weixin-js-sdk'
import ContactBox from './component/c_ContactBox.vue'
import { parse } from 'qs'
export default {
name: 'ServiceCheckOrderReserve',
data() {
return {
date: '',
period: '',
count: 1,
checked: false,
useCard: '',
orderDetail: '',
TalentReserveGroupData: '',
TalentReserveData: '', //套餐
showCourseData: '', //当前课程的信息
publicName: '',
userInfo: '', //支付用
appId: 'wx1305e88d2bc74073',
CourseParentId: '', //学习中心途径购买课程对应参数
CourseParentIdBindCourseId: '', //学习中心途径购买课程对应参数
customizedOrder: '',
isSkipPay: false,
remark: '', //留言
editRemark: '', //留言
showRemark: false, //留言弹窗显示
businessId: '1614900216',
}
},
mounted() {
let userInfo = localStorage.getItem('userInfo')
if (userInfo) {
this.userInfo = JSON.parse(userInfo)
}
this.count = this.$route.query.count
this.period = this.$route.query.period
// 套餐
let TalentReserveGroupData = localStorage.getItem('TalentReserveGroupData')
if (TalentReserveGroupData) {
this.TalentReserveGroupData = JSON.parse(TalentReserveGroupData)
}
let TalentReserveData = localStorage.getItem('TalentReserveData')
if (TalentReserveData) {
this.TalentReserveData = JSON.parse(TalentReserveData)
}
// 如果有优惠券,就展示
let useCard = localStorage.getItem('useCard')
let showCourseData = localStorage.getItem('showCourseData')
if (useCard) {
this.useCard = JSON.parse(useCard)
}
if (showCourseData) {
this.showCourseData = JSON.parse(showCourseData)
}
// 留言恢复(防止跳转选择联系人后留言丢失)
let remark = localStorage.getItem('checkOrderRemark')
if (remark) {
this.remark = remark
}
// 协议同意状态恢复(防止跳转选择联系人后选中状态丢失)
let checked = localStorage.getItem('checkOrderProtocolChecked')
if (checked == 'true') {
this.checked = true
}
// 集体定制参数
// orderId 集体定制订单 isSkipPay 是否跳过支付 dateComboBindId 档期id
let customizedOrder = localStorage.getItem('customizedOrder')
if (customizedOrder) {
this.customizedOrder = JSON.parse(customizedOrder)
this.isSkipPay = this.customizedOrder.isSkipPay
if (this.isSkipPay) {
localStorage.removeItem('useCard')
this.useCard = ''
}
}
// 学习中心途径购买课程
this.CourseParentId = localStorage.getItem('CourseParentId')
this.CourseParentIdBindCourseId = localStorage.getItem('CourseParentIdBindCourseId')
},
computed: {
paymoney() {
let paymoney = (this.TalentReserveData.actualPrice * 1000 * this.count - (this.useCard?.couponPrice * 1000 || 0)) / 1000
if (paymoney < 0) paymoney = 0
return paymoney
},
},
methods: {
// 进入选择优惠券
openCardBox() {
this.$router.push({ name: 'ServiceCardSelect' })
},
//购买须知
goPayneed() {
this.$router.push({ name: 'payneed' })
},
// 前往查看协议
goProtocol() {
this.$router.push({ name: 'protocol' })
},
// 协议点击同意
protocolChange(checked) {
localStorage.setItem('checkOrderProtocolChecked', checked)
},
// 留言点击完成
EditRemarkConfirm() {
this.remark = this.editRemark
localStorage.setItem('checkOrderRemark', this.editRemark)
this.showRemark = false
},
// 创建订单
createOrder() {
// 出行人数量判断
let selectedContactArr = localStorage.getItem('selectedContactArr')
selectedContactArr = JSON.parse(selectedContactArr)
let selAdult = 0
let selChild = 0
for (let i in selectedContactArr) {
if (selectedContactArr[i].userType == 2) {
selAdult++
} else {
selChild++
}
}
// 判断选择成人和学生数量是否匹配
if (
selAdult != this.count * this.TalentReserveGroupData.adultCount ||
selChild != this.count * this.TalentReserveGroupData.childCount
) {
this.$toast.fail('请选择正确数量的出行人')
return
}
// 出行人字段格式
let selectedContact = []
for (let i in selectedContactArr) {
selectedContact.push(selectedContactArr[i].travelerNum)
}
// 集体订单参数
let orderId = '' //集体订单id
if (this.customizedOrder?.orderId != 0 && this.showCourseData.id == this.customizedOrder?.courseId) {
orderId = this.customizedOrder.orderId
console.log('集体订单:', orderId)
}
selectedContact = selectedContact.join(',')
// 如果跳过支付,就不使用优惠券
let couponId = this.useCard?.id || 0
if (this.isSkipPay) {
couponId = 0
}
let params = {
courseId: this.showCourseData.id,
paymoney: this.paymoney, //时段个数*单价*人数-优惠券
userId: this.userInfo?.centerNo, //升学汇和其他端接口字段不同
orderCount: this.count, //人数
// comboId: this.TalentReserveGroupData.id,
// dateBindComboId: localStorage.getItem('selectComboBindId'),
// orderTime: this.Moment(this.TalentReserveData.date).format('YYYY-MM-DD'), //时段集合 2018-10-15
couponId: couponId,
unionId: this.userInfo?.centerNo,
price: (this.TalentReserveData.actualPrice * 1000 * this.count) / 1000, //商品减掉优惠券之前的价格
travelNum: selectedContact, //出行人编号
appId: this.appId,
isSkipPay: this.isSkipPay, //集体定制是否跳过支付
remark: this.remark, //留言
// schoolShopName:'',//用户学校名称中文
detailId: this.TalentReserveData.detailId, //团期编号
productSceneId: this.TalentReserveGroupData.id, //行程id
schoolId: 0,
programComboId: this.TalentReserveData.programComboId,
orderBuyType: this.TalentReserveData.orderBuyType, //1独享2共享
baseId: this.showCourseData.baseId,
}
let schoolNamesChoose = localStorage.getItem('schoolNamesChoose')
if (schoolNamesChoose) {
params.schoolShopName = JSON.parse(schoolNamesChoose).schoolName
}
let inviteCode = localStorage.getItem('orderInviteCode')
if (inviteCode) {
params.RecommendUserNum = inviteCode
}
if (
this.CourseParentIdBindCourseId &&
this.CourseParentIdBindCourseId == this.showCourseData.id &&
this.CourseParentId != 'undefined'
) {
params.CourseParentId = this.CourseParentId //学习中心途径购买课程传参
}
this.$toast.loading({
message: '正在创建订单...',
duration: 0,
forbidClick: true,
})
this.yxAxios.post(`${this.yanxueUrl}/api/Order/AddOrderSingleReserve`, params).then((res) => {
if (res.data.data) {
this.$toast('提交成功')
setTimeout(() => {
this.$router.push({ name: 'Home' })
},1000)
} else {
this.$toast.fail(res.data?.result || res.data?.message)
}
})
},
},
components: {
ContactBox,
},
}
</script>
<style lang="scss" scoped>
#checkOrder {
padding-bottom: 260px;
.top_border {
border-top: 16px solid #f6f7fa;
}
.goods_data {
padding: 0 22px;
.top {
padding: 20px 0;
img {
display: inline-block;
width: 124px;
height: 124px;
border-radius: 8px;
}
div {
vertical-align: top;
display: inline-block;
margin-left: 20px;
width: 560px;
}
p {
margin: 0;
}
.goods_title {
font-size: 28px;
font-weight: bold;
}
.package_name {
font-size: 24px;
margin-top: 18px;
}
.count {
font-size: 24px;
}
}
.bottom {
display: flex;
justify-content: space-between;
align-items: center;
padding: 28px 0;
border-top: 2px solid #f2f4f9;
.time {
font-size: 28px;
}
.price {
font-size: 32px;
font-weight: bold;
span {
font-size: 20px;
}
}
}
}
.card {
padding: 0 22px;
height: 98px;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28px;
font-weight: bold;
.use_card {
font-size: 26px;
color: #f64c37;
// padding: 2px 24px;
// background: #ffecc0;
// border-radius: 8px;
margin-right: 10px;
font-weight: normal;
}
}
.remark {
// display: flex;
// align-items: center;
span {
font-size: 26px;
margin-right: 10px;
font-weight: normal;
color: #999;
max-width: 560px;
overflow: hidden;
display: inline-block;
white-space: nowrap;
vertical-align: middle;
text-overflow: ellipsis;
}
i {
vertical-align: middle;
}
}
.remark_box {
padding: 20px 20px 50px 20px;
width: 90%;
box-sizing: border-box;
background: #fff;
.remark_textarea {
background: rgb(248, 248, 248);
border-radius: 10px;
width: 100%;
height: 300px;
margin: 0 auto;
border: none;
resize: none;
color: #333;
font-size: 28px;
padding: 20px;
box-sizing: border-box;
}
.remark_btn {
display: block;
width: 100%;
margin: 0 auto;
margin-top: 50px;
line-height: 92px;
box-sizing: border-box;
border-radius: 100px;
color: white;
font-size: 32px;
background: #4092ff;
text-align: center;
box-shadow: 0px 10px 40px 0px #a0c9ff;
}
}
.protocol {
display: flex;
align-items: center;
padding: 0 22px;
font-size: 24px;
span {
color: #3f92ff;
margin: 0 4px;
}
}
.Collection {
background-color: white;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
padding: 28px 22px;
box-sizing: border-box;
padding-bottom: 50px;
z-index: 500;
box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.34);
.box {
display: inline-block;
vertical-align: middle;
color: #666666;
.icon {
display: inline-block;
width: 45%;
text-align: center;
font-size: 24px;
p {
// margin: 0;
color: #999999;
margin-top: 8px;
}
i {
font-size: 48px;
color: rgb(45, 45, 45);
font-weight: bold;
}
}
> span {
display: inline-block;
width: 100%;
line-height: 92px;
box-sizing: border-box;
border-radius: 100px;
color: white;
font-size: 32px;
background: #4092ff;
text-align: center;
box-shadow: 0px 10px 40px 0px #a0c9ff;
b {
display: inline-block;
vertical-align: middle;
margin-left: 20px;
color: white;
}
i {
vertical-align: middle;
font-size: 44px;
font-weight: bold;
}
}
}
.box1 {
width: 40%;
p {
font-size: 49px;
font-weight: bold;
color: #f64c37;
}
span {
font-size: 32px;
}
del {
font-size: 20px;
color: #999;
}
.coupon {
font-size: 24px;
color: #999;
}
.skip_pay_text {
font-size: 28px;
color: #999;
}
}
.box2 {
width: 60%;
}
}
}
::v-deep.van-calendar__bottom-info {
color: #f95555;
}
::v-deep.van-calendar__selected-day {
background: #ecf2fc !important;
border: 4px solid #79abff;
box-sizing: border-box;
color: #333;
}
.van-checkbox {
display: inline-flex;
}
</style>