Reception.vue
14 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
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
<template>
<view class="layout">
<wnCanvas
:canvasId="`c-${madiaId}`"
:drawStatus="penSwitch"
custom
:scaleSwitch="false"
ref="receptionCanvas"
>
<template slot="customContent">
<view class="layout-content">
<view class="select-box flex">
<view
class="select flex"
@click.stop="showSelect"
>
{{currentCarString}}
<view
class="sprite-icon icon-arrow-bottom"
v-if="carList.length > 1 && !change_disabled"
></view>
</view>
<view
class="pop-box"
v-show="isSelect"
>
<template v-for="(i,index) in carList">
<view
:key="i.carModelId"
:class="['type-item flex',{active:i.carModelId == currentCarId},{'has-line':showLine(i,index)},{'is-first':index == 0}]"
@click="changeCar(i)"
>{{i.carModelName}}</view>
</template>
</view>
</view>
<view
class="risk-informed flex"
@click="$refs.riskInformedPop.open()"
>
风险告知
<view class="sprite-icon icon-info_shield"></view>
</view>
<view
class="content-box flex"
v-show="tabIndex == 0"
>
<template v-if="currentItem && currentItem.modelDisplayPicurl">
<view
class="left-content"
:key="updateViewKey"
@click="showPicture(currentItem)"
>
<image
:src="currentItem.modelDisplayPicurl"
class="poster"
/>
<view
class="tips"
v-if="currentItem.detailPicurl"
>* 点击图片查看详情 ></view>
</view>
</template>
<view class="right-content">
<view :class="['sku-box',isPreview ? 'preview' : '']">
<sku-box
:currentCar="currentCarId"
:defaultTabId="tabId"
:show="show && tabIndex == 0"
@changePreView="changePreView"
ref="sku"
/>
</view>
<view
class="coupon-btn flex"
v-if="!isPreview"
@click="couponPopupRef.open(customerType, customerInfo)"
>{{couponText}}</view>
</view>
</view>
<optional-table
v-show="tabIndex == 1"
:currentCar="currentCarId"
:show="show && tabIndex == 1"
></optional-table>
<template v-if="hasOptionals">
<view class="tabs-box flex">
<template v-for="(i,index) in tabs">
<view
:class="['tab flex',{active:index==tabIndex}]"
:key="index"
@click="changeTab(index)"
>{{i}}</view>
</template>
<view :class="['block',{'block-right':tabIndex == 1}]"></view>
</view>
</template>
</view>
</template>
</wnCanvas>
<car-brands
ref="carBrandRef"
@select="handleSelect"
/>
<coupon-pop
:carInfo="carInfo"
ref="couponPopup"
@reception="reception"
:show="show"
@hideTool="$emit('hideTool')"
tips="微信扫码进入客户录单页"
:title="customerType == 1 ?'为客户发券' : '客户小程序码'"
/>
<risk-informed-box
ref="riskInformedPop"
:popupImg="popupImg"
/>
</view>
</template>
<script type='text/ecmascript-6'>
import SkuBox from './SkuBox.vue'
import CarBrands from '@/components/CarBrands.vue'
import CouponPop from './CouponPop.vue'
import RiskInformedBox from './RiskInformedBox.vue'
import OptionalTable from './OptionalTable.vue'
export default {
name: 'Reception',
components: { SkuBox, CarBrands, CouponPop, RiskInformedBox, OptionalTable },
props: {
customerType: Number,
show: Boolean,
tabId: Number,
propCarId: [Number, String],
type: String,
popupImg: String,
madiaId: Number,
penSwitch: Boolean,
},
data () {
return {
currentCarString: '',
customerInfo: {},
updateViewKey: Date.now(),
carInfo: {},
currentImgUrl: '',
currentItem: null,
tabs: ['加装', '选装'],
tabIndex: 0,
isSelect: false,
currentCarId: ''
}
},
watch: {
watchCustomerInfo: {
immediate: true,
handler (newval) {
this.customerInfo = newval
}
},
propCarId: {
immediate: true,
handler (newval) {
this.currentCarId = newval
this.currentCarString = this.carList.find(e => e.carModelId == newval)?.carModelName || ''
}
},
currentCarId: {
immediate: true,
handler (newval) {
if (!this.hasOptionals && this.tabIndex == 1) this.tabIndex = 0
if (this.show && newval && !this.isPreview && this.customerType == 1) {
uni.showLoading({
mask: true
})
let item = this.carList.find(e => e.carModelId == newval)
this.$refs.carBrandRef.selectCar(item, true, newval)
}
}
},
watchStatus: {
immediate: true,
handler (newval) {
this.tabIndex = 0
this.currentItem = null
this.closeAllPopup()
}
},
show: {
immediate: true,
handler (newval) {
if (newval) {
this.isSelect = false
if (newval && this.currentItem && this.tabIndex == 0) this.changePreView(this.currentItem, false, false)
}
}
}
},
computed: {
watchStatus () {
return this.$store.state.user.historyStatus;
},
watchCustomerInfo () {
return this.$store.state.user.customerInfo
},
isPreview () {
return this.type == 'preview'
},
couponText () {
return this.customerType == 0 ? '查看客户券码' : '为客户发券'
},
couponPopupRef () {
return this.$refs.couponPopup
},
change_disabled () {
return this.customerType == 0 || this.$refs?.couponPopup?.pageParams.QRURL
},
receptionTrack () {
return this.$store.state.user.receptionTrack
},
boutiqueMediaConfig () {
return this.$store.state.user.boutiqueMediaConfig
},
hasOptionals () {
let flag = false
if (this.show) flag = this.boutiqueMediaConfig[this.currentCarId].optionals && this.boutiqueMediaConfig[this.currentCarId].optionals.length
return flag
},
carList () {
return this.$store.state.user.boutiqueCarList
}
},
methods: {
changeCar (item) {
if (this.change_disabled || this.currentCarId == item.carModelId) return uni.hideLoading()
this.currentCarString = item.carModelName
this.currentCarId = item.carModelId
this.isSelect = false
this.updateViewKey = Date.now()
this.clearCanvas()
},
changePreView (e, leave = true, clearBoard = true) {
let { currentItem } = this,
{ id, carModelName, name, materialType } = e,
key = `${carModelName}_${id}`,
value = this.receptionTrack[key]
if (currentItem && leave) this.previewLeave(currentItem)
this.currentItem = e
this.updateViewKey = Date.now()
if (this.isPreview) return
if (clearBoard) this.clearCanvas()
if (value) {
value.openCount += 1
value.entryTime = Date.now()
} else {
value = {
openCount: 1,
materialName: name,
materialId: id,
stayDuration: 0,
entryTime: Date.now(),
materialType
}
}
this.$store.dispatch("setReceptionTrack", { key, value })
},
handleSelect (item) {
this.customerInfo.carModel = item.name || ''
this.customerInfo.carModelId = item.id || ''
Object.assign(this.customerInfo, {
carBrand: item.carChildsBrandName || '',
carBrandId: item.carChildsBrandId || '',
oneCarBrand: item.carBrand || '',
oneCarBrandId: item.carBrandId || ''
})
this.$store.dispatch('setCustomerInfo', this.customerInfo)
this.carInfo = item
uni.hideLoading()
},
showPicture (off = true) {
let { detailPicurl } = this.currentItem
this.currentImgUrl = off ? detailPicurl : ''
},
reception (e) {
this.clearCustomerReceivedTimer()
this.$emit('reception', e)
},
clearCustomerReceivedTimer () {
if (this.couponPopupRef?.pageParams?.qrTimer) {
clearInterval(this.couponPopupRef.pageParams.qrTimer)
this.couponPopupRef.pageParams.qrTimer = null
}
},
closeAllPopup () {
this.$refs.riskInformedPop?.close()
this.$refs.couponPopup?.close()
},
previewLeave (currentItem) {
if (this.isPreview) return
let key = `${currentItem.carModelName}_${currentItem.id}`,
value = this.receptionTrack[key]
value.stayDuration += Number(Date.now() - value.entryTime)
this.$store.dispatch("setReceptionTrack", { key, value })
},
clearSkuState () {
this.$refs.sku.requested = false
},
clearCanvas () {
this.$refs.receptionCanvas.clearBoard()
},
changeTab (index) {
if (this.tabIndex == index) return
this.tabIndex = index
if (index == 1) this.previewLeave(this.currentItem)
else this.$refs.sku.changeCar(this.currentCarId)
this.clearCanvas()
},
showSelect () {
if (this.carList.length == 1 || this.change_disabled) return
this.isSelect = !this.isSelect
},
showLine (item, index) {
let result = true,
{ carList } = this
if (index != 0 && item.id == carList[index - 1].id) result = false
return result
}
}
}
</script>
<style scoped lang='scss'>
.layout {
width: 100vw;
height: 100vh;
background-color: #fff;
position: absolute;
top: 0;
left: 0;
&-content {
height: 100%;
margin: $margin;
position: relative;
}
.risk-informed {
position: absolute;
right: toRpx(24);
top: toRpx(72);
font-weight: 500;
font-size: toRpx(32);
color: #333333;
line-height: toRpx(48);
z-index: 2;
.sprite-icon {
margin-left: toRpx(8);
}
}
.select-box {
padding-top: toRpx(66);
position: fixed;
left: 0;
top: 0;
width: 100%;
justify-content: center;
z-index: 2;
.select {
color: #333333;
font-size: toRpx(36);
font-weight: 500;
line-height: toRpx(44);
}
.pop-box {
width: toRpx(272);
border-radius: toRpx(16);
background: #ffffff;
box-shadow: 0 0 toRpx(16) 0 #99999933;
position: absolute;
top: toRpx(122);
left: 50%;
transform: translateX(-50%);
padding: toRpx(12) 0;
animation: show-view-opacity 0.15s forwards;
.type-item {
padding: 0 toRpx(24);
margin: toRpx(8) 0;
height: toRpx(56);
color: #292d33;
font-size: toRpx(28);
position: relative;
&:first-child {
margin-top: 0;
}
&:last-child {
margin-bottom: 0;
}
&.active {
background-color: #ecf1ff;
}
}
.has-line {
margin-top: toRpx(18);
&::after {
content: '';
width: calc(100% - #{toRpx(48)});
height: toRpx(2);
background: #f5f5f5;
position: absolute;
left: 50%;
top: toMinusRpx(10);
transform: translateX(-50%);
}
}
.is-first {
&::after {
display: none;
}
}
}
}
.content-box {
height: 100%;
padding: toRpx(144) 0 toRpx(64) toRpx(64);
animation: show-view-opacity 0.15s forwards;
.left-content {
width: toRpx(1328);
height: 100%;
position: relative;
.poster {
width: 100%;
height: 100%;
}
.tips {
position: absolute;
right: toRpx(32);
bottom: toRpx(32);
animation: tips-show 0.15s forwards;
font-size: toRpx(24);
color: #999999;
line-height: toRpx(36);
}
@keyframes tips-show {
0% {
transform: scale(0.1);
}
100% {
transform: scale(1);
}
}
.default {
width: 100%;
height: toRpx(664);
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
}
}
.right-content {
width: calc(100% - #{toRpx(1362)});
height: 100%;
display: flex;
flex-direction: column;
margin-left: auto;
.sku-box {
height: calc(100% - #{toRpx(116)});
}
.preview {
height: 100%;
}
.coupon-btn {
margin-top: auto;
width: calc(100% - #{toRpx(64)});
height: toRpx(96);
background-image: linear-gradient(180deg, #61c0ff 0%, #2c66f7 100%);
box-shadow: inset 0 0 toRpx(32) 0 #ffffff;
border-radius: toRpx(16);
font-weight: 500;
font-size: toRpx(36);
color: #ffffff;
justify-content: center;
}
}
}
.tabs-box {
position: absolute;
top: toRpx(156);
left: toRpx(80);
width: toRpx(212);
height: toRpx(64);
background: #f2f2f2;
border-radius: toRpx(40);
box-sizing: border-box;
border: toRpx(2) solid #f2f2f2;
.tab {
width: 50%;
height: 100%;
justify-content: center;
font-size: toRpx(28);
color: #666666;
line-height: toRpx(44);
position: relative;
z-index: 2;
transition: all 0.15s;
}
.active {
font-weight: 500;
color: #ffffff;
}
.block {
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
width: 50%;
height: 100%;
background: #333333;
border-radius: toRpx(40);
transition: all 0.15s;
}
.block-right {
left: 50%;
}
}
}
</style>