booking.vue
19.1 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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
<template>
<view class="booking-page">
<custom-navbar title="预约服务" bgColor="rgba(248,251,250,0.92)">
<template v-slot:right>
<view class="nav-record-btn" @click="goBookingRecord">
<text>预约记录</text>
</view>
</template>
</custom-navbar>
<scroll-view class="page-body" scroll-y :style="{ height: scrollHeight + 'px' }">
<view class="booking-hero">
<view class="booking-hero__badge"></view>
</view>
<view class="form-shell">
<view class="form-panel">
<view class="panel-head">
<text class="panel-head__title">预约信息</text>
</view>
<view class="field-card" @click="showProjectPicker = true">
<view class="field-card__main">
<text class="field-card__label">预约项目</text>
<text class="field-card__value" :class="{ 'field-card__value--selected': selectedRight }">
{{ selectedRight ? selectedRight.ItemName + '(剩余' + selectedRight.RemainingCount + '次)' : '请选择预约项目' }}
</text>
</view>
<view class="field-card__arrow"></view>
</view>
<view class="field-card" @click="showTechPicker = true">
<view class="field-card__main">
<text class="field-card__label">预约健康师</text>
<text class="field-card__value" :class="{ 'field-card__value--selected': selectedTech }">
{{ selectedTech ? selectedTech.name : '请选择健康师' }}
</text>
</view>
<view class="field-card__arrow"></view>
</view>
</view>
<view class="form-panel">
<view class="panel-head panel-head--spread">
<text class="panel-head__title">选择日期</text>
<view class="panel-head__action" @click="showAllDates = !showAllDates">
<text>{{ showAllDates ? '收起' : '更多日期' }}</text>
<view class="panel-head__arrow" :class="{ 'panel-head__arrow--up': showAllDates }"></view>
</view>
</view>
<scroll-view
v-if="!showAllDates"
class="date-scroll"
scroll-x
:scroll-into-view="'date-' + selectedDateIdx"
scroll-with-animation
>
<view class="date-scroll__inner">
<view
v-for="(d, idx) in visibleDates"
:key="idx"
:id="'date-' + idx"
class="date-chip"
:class="{ 'date-chip--active': selectedDateIdx === idx }"
@click="selectDate(idx)"
>
<text v-if="d.label" class="date-chip__label">{{ d.label }}</text>
<text class="date-chip__day">{{ d.dayStr }}</text>
<text class="date-chip__week">{{ d.weekStr }}</text>
</view>
</view>
</scroll-view>
<view class="date-grid" v-else>
<view
v-for="(d, idx) in dateList"
:key="idx"
class="date-grid__item"
:class="{ 'date-grid__item--active': selectedDateIdx === idx }"
@click="selectDate(idx)"
>
<text class="date-grid__day">{{ d.monthDay }}</text>
<text class="date-grid__week">{{ d.weekStr }}</text>
<text v-if="d.label" class="date-grid__label">{{ d.label }}</text>
</view>
</view>
</view>
<view class="form-panel">
<view class="panel-head">
<text class="panel-head__title">选择时间段</text>
</view>
<view class="time-grid">
<view class="time-card">
<text class="time-card__label">开始时间</text>
<picker mode="time" :value="startTime" @change="onStartTimeChange">
<view class="time-card__picker">
<text :class="{ 'time-card__picker--placeholder': !startTime }">{{ startTime || '请选择' }}</text>
<view class="time-card__arrow"></view>
</view>
</picker>
</view>
<view class="time-card">
<text class="time-card__label">结束时间</text>
<picker mode="time" :value="endTime" @change="onEndTimeChange">
<view class="time-card__picker">
<text :class="{ 'time-card__picker--placeholder': !endTime }">{{ endTime || '请选择' }}</text>
<view class="time-card__arrow"></view>
</view>
</picker>
</view>
</view>
</view>
</view>
<view class="bottom-spacer"></view>
</scroll-view>
<view class="bottom-bar">
<view class="bottom-bar__summary">
<view class="summary-item" v-if="selectedRight">
<view class="summary-item__dot"></view>
<text>{{ selectedRight.ItemName }}</text>
</view>
<view class="summary-item" v-if="selectedDateIdx !== null && startTime && endTime">
<view class="summary-item__dot summary-item__dot--orange"></view>
<text>{{ dateList[selectedDateIdx].monthDay }} {{ startTime }}-{{ endTime }}</text>
</view>
</view>
<view class="bottom-bar__btn" :class="{ 'bottom-bar__btn--disabled': !canSubmit }" @click="submitBooking">
<text>确认预约</text>
</view>
</view>
<view class="picker-mask" v-if="showProjectPicker" @click="showProjectPicker = false">
<view class="picker-sheet" @click.stop :style="{ paddingBottom: safeBottom + 'px' }">
<view class="picker-sheet__header">
<text class="picker-sheet__title">选择预约项目</text>
<view class="picker-sheet__close" @click="showProjectPicker = false">
<view class="ico-close"></view>
</view>
</view>
<scroll-view class="picker-sheet__body" scroll-y>
<view
v-for="(item, idx) in availableRights"
:key="idx"
class="option-card"
:class="{ 'option-card--active': selectedRight && selectedRight.ItemName === item.ItemName }"
@click="selectProject(item)"
>
<view>
<text class="option-card__title">{{ item.ItemName }}</text>
<text class="option-card__desc">剩余 {{ item.RemainingCount }} 次</text>
</view>
<view class="option-card__check" v-if="selectedRight && selectedRight.ItemName === item.ItemName">
<view class="ico-check"></view>
</view>
</view>
<view v-if="!availableRights.length" class="picker-empty">
<text>暂无可用权益</text>
</view>
</scroll-view>
</view>
</view>
<view class="picker-mask" v-if="showTechPicker" @click="showTechPicker = false">
<view class="picker-sheet" @click.stop :style="{ paddingBottom: safeBottom + 'px' }">
<view class="picker-sheet__header">
<text class="picker-sheet__title">选择健康师</text>
<view class="picker-sheet__close" @click="showTechPicker = false">
<view class="ico-close"></view>
</view>
</view>
<scroll-view class="picker-sheet__body" scroll-y>
<view
v-for="(tech, idx) in techList"
:key="idx"
class="option-card option-card--tech"
:class="{ 'option-card--active': selectedTech && selectedTech.id === tech.id }"
@click="selectTech(tech)"
>
<view class="option-card__avatar">{{ tech.name.slice(0, 1) }}</view>
<view class="option-card__content">
<text class="option-card__title">{{ tech.name }}</text>
<text class="option-card__desc">{{ tech.position }}</text>
</view>
<view class="option-card__check" v-if="selectedTech && selectedTech.id === tech.id">
<view class="ico-check"></view>
</view>
</view>
</scroll-view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
scrollHeight: 0,
safeBottom: 0,
selectedRight: null,
selectedTech: null,
selectedDateIdx: null,
startTime: '',
endTime: '',
showTechPicker: false,
showProjectPicker: false,
showAllDates: false,
rightsList: [],
techList: [],
dateList: []
}
},
computed: {
availableRights() {
return this.rightsList.filter(r => r.RemainingCount > 0)
},
visibleDates() {
return this.dateList.slice(0, 7)
},
canSubmit() {
return (
this.selectedRight !== null &&
this.selectedTech !== null &&
this.selectedDateIdx !== null &&
this.startTime &&
this.endTime
)
}
},
onLoad() {
this.calcLayout()
this.initMockData()
this.generateDates()
},
onShow() {
this.calcLayout()
},
methods: {
calcLayout() {
const sys = uni.getSystemInfoSync()
const tabBarH = 50
this.safeBottom = sys.safeAreaInsets ? sys.safeAreaInsets.bottom : 0
const navH = (sys.statusBarHeight || 0) + 44
this.scrollHeight = sys.windowHeight - navH - tabBarH
},
initMockData() {
this.rightsList = [
{ ItemName: '深层清洁护理', ItemPrice: 380, SourceType: '购买', TotalPurchased: 10, ConsumedCount: 6, RemainingCount: 4, Remark: '' },
{ ItemName: '胶原蛋白焕肤', ItemPrice: 580, SourceType: '购买', TotalPurchased: 5, ConsumedCount: 2, RemainingCount: 3, Remark: '' },
{ ItemName: '全身精油SPA', ItemPrice: 468, SourceType: '赠送', TotalPurchased: 3, ConsumedCount: 1, RemainingCount: 2, Remark: '' },
{ ItemName: '头皮深层养护', ItemPrice: 328, SourceType: '购买', TotalPurchased: 8, ConsumedCount: 7, RemainingCount: 1, Remark: '' },
{ ItemName: '草本艾灸调理', ItemPrice: 388, SourceType: '赠送', TotalPurchased: 2, ConsumedCount: 0, RemainingCount: 2, Remark: '' }
]
this.techList = [
{ id: '1', name: '林雅婷', position: '高级健康师', avatar: '' },
{ id: '2', name: '陈思颖', position: '资深健康师', avatar: '' },
{ id: '3', name: '王梦琪', position: '首席健康师', avatar: '' },
{ id: '4', name: '张晓薇', position: '高级健康师', avatar: '' },
{ id: '5', name: '刘佳宁', position: '健康师', avatar: '' }
]
},
generateDates() {
const list = []
const now = new Date()
const weekMap = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
for (let i = 0; i < 30; i++) {
const d = new Date(now.getFullYear(), now.getMonth(), now.getDate() + i)
const m = d.getMonth() + 1
const day = d.getDate()
let label = ''
if (i === 0) label = '今天'
else if (i === 1) label = '明天'
else if (i === 2) label = '后天'
list.push({
date: d,
dayStr: day + '日',
monthDay: m + '月' + day + '日',
weekStr: weekMap[d.getDay()],
label
})
}
this.dateList = list
},
selectProject(item) {
this.selectedRight = item
this.showProjectPicker = false
},
selectTech(tech) {
this.selectedTech = tech
this.showTechPicker = false
},
selectDate(idx) {
this.selectedDateIdx = idx
},
onStartTimeChange(e) {
this.startTime = e.detail.value
},
onEndTimeChange(e) {
this.endTime = e.detail.value
},
submitBooking() {
if (!this.canSubmit) {
uni.showToast({ title: '请完善预约信息', icon: 'none' })
return
}
const params = {
itemName: this.selectedRight.ItemName,
techId: this.selectedTech.id,
techName: this.selectedTech.name,
date: this.dateList[this.selectedDateIdx].monthDay,
time: this.startTime + '-' + this.endTime
}
uni.showModal({
title: '确认预约',
content: `项目:${params.itemName}\n健康师:${params.techName}\n时间:${params.date} ${params.time}`,
confirmText: '确认',
confirmColor: '#2DB48D',
success: (res) => {
if (res.confirm) {
uni.showToast({ title: '预约成功', icon: 'success' })
setTimeout(() => {
uni.navigateTo({ url: '/pagesA/booking-record/booking-record' })
}, 1200)
}
}
})
},
goBookingRecord() {
uni.navigateTo({ url: '/pagesA/booking-record/booking-record' })
}
}
}
</script>
<style lang="scss" scoped>
.booking-page {
min-height: 100vh;
background:
radial-gradient(circle at top left, rgba(45, 180, 141, 0.18), transparent 30%),
linear-gradient(180deg, #f8fbfa 0%, #f2f6f7 44%, #edf2f5 100%);
}
.page-body {
background: transparent;
}
.booking-hero {
height: 84rpx;
padding: 8rpx 24rpx 0;
}
.booking-hero__badge {
width: 100%;
height: 100%;
border-radius: 32rpx;
background: linear-gradient(135deg, rgba(34,177,138,0.18), rgba(111,218,185,0.06));
}
.form-shell {
padding: 0 24rpx;
}
.form-panel {
margin-top: 18rpx;
padding: 28rpx 24rpx;
border-radius: 32rpx;
background: rgba(255,255,255,0.96);
box-shadow: 0 22rpx 56rpx rgba(15,23,42,0.08);
}
.panel-head {
display: flex;
align-items: center;
margin-bottom: 20rpx;
}
.panel-head--spread {
justify-content: space-between;
}
.panel-head__title {
font-size: 32rpx;
font-weight: 700;
color: $text-primary;
}
.panel-head__action {
display: flex;
align-items: center;
gap: 8rpx;
padding: 10rpx 16rpx;
border-radius: 999rpx;
background: rgba(247,249,251,0.96);
font-size: 24rpx;
color: $text-secondary;
}
.panel-head__arrow {
width: 10rpx;
height: 10rpx;
border-right: 2rpx solid $text-tertiary;
border-bottom: 2rpx solid $text-tertiary;
transform: rotate(45deg);
transition: transform 0.2s ease;
}
.panel-head__arrow--up {
transform: rotate(-135deg);
}
.field-card {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx;
margin-bottom: 16rpx;
border-radius: 24rpx;
background: rgba(247,249,251,0.96);
}
.field-card:last-child {
margin-bottom: 0;
}
.field-card__main {
flex: 1;
min-width: 0;
}
.field-card__label {
display: block;
font-size: 24rpx;
color: $text-tertiary;
}
.field-card__value {
display: block;
margin-top: 10rpx;
font-size: 28rpx;
color: $text-tertiary;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.field-card__value--selected {
color: $text-primary;
font-weight: 600;
}
.field-card__arrow {
width: 12rpx;
height: 12rpx;
border-top: 2rpx solid $text-tertiary;
border-right: 2rpx solid $text-tertiary;
transform: rotate(45deg);
margin-left: 14rpx;
}
.date-scroll {
white-space: nowrap;
}
.date-scroll__inner {
display: inline-flex;
gap: 14rpx;
}
.date-chip {
display: inline-flex;
flex-direction: column;
align-items: center;
min-width: 128rpx;
padding: 18rpx 20rpx;
border-radius: 24rpx;
background: rgba(247,249,251,0.96);
}
.date-chip--active {
background: linear-gradient(135deg, #22b18a 0%, #6fdab9 100%);
box-shadow: 0 18rpx 36rpx rgba(45,180,141,0.24);
}
.date-chip__label {
font-size: 20rpx;
font-weight: 700;
color: $brand-primary;
}
.date-chip__day {
margin-top: 6rpx;
font-size: 30rpx;
font-weight: 700;
color: $text-primary;
}
.date-chip__week {
margin-top: 6rpx;
font-size: 22rpx;
color: $text-tertiary;
}
.date-chip--active .date-chip__label,
.date-chip--active .date-chip__day,
.date-chip--active .date-chip__week {
color: #fff;
}
.date-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12rpx;
}
.date-grid__item {
padding: 20rpx 12rpx;
border-radius: 22rpx;
background: rgba(247,249,251,0.96);
text-align: center;
}
.date-grid__item--active {
background: linear-gradient(135deg, #22b18a 0%, #6fdab9 100%);
box-shadow: 0 18rpx 36rpx rgba(45,180,141,0.24);
}
.date-grid__day,
.date-grid__week,
.date-grid__label {
display: block;
}
.date-grid__day {
font-size: 24rpx;
font-weight: 700;
color: $text-primary;
}
.date-grid__week {
margin-top: 6rpx;
font-size: 20rpx;
color: $text-tertiary;
}
.date-grid__label {
margin-top: 4rpx;
font-size: 18rpx;
font-weight: 600;
color: $brand-primary;
}
.date-grid__item--active .date-grid__day,
.date-grid__item--active .date-grid__week,
.date-grid__item--active .date-grid__label {
color: #fff;
}
.time-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 14rpx;
}
.time-card {
padding: 24rpx;
border-radius: 24rpx;
background: rgba(247,249,251,0.96);
}
.time-card__label {
display: block;
font-size: 24rpx;
color: $text-tertiary;
}
.time-card__picker {
margin-top: 14rpx;
height: 72rpx;
padding: 0 18rpx;
border-radius: 18rpx;
background: rgba(255,255,255,0.92);
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
color: $text-primary;
}
.time-card__picker--placeholder {
color: $text-tertiary;
}
.time-card__arrow {
width: 12rpx;
height: 12rpx;
border-right: 2rpx solid $text-tertiary;
border-bottom: 2rpx solid $text-tertiary;
transform: rotate(45deg);
}
.bottom-spacer {
height: 180rpx;
}
.bottom-bar {
position: fixed;
left: 16rpx;
right: 16rpx;
bottom: 16rpx;
padding: 18rpx;
border-radius: 32rpx;
background: rgba(255,255,255,0.84);
backdrop-filter: blur(22px);
-webkit-backdrop-filter: blur(22px);
box-shadow: 0 20rpx 42rpx rgba(15,23,42,0.12);
z-index: 50;
}
.bottom-bar__summary {
display: flex;
flex-wrap: wrap;
gap: 10rpx;
margin-bottom: 14rpx;
}
.summary-item {
display: flex;
align-items: center;
gap: 8rpx;
padding: 10rpx 14rpx;
border-radius: 999rpx;
background: rgba(247,249,251,0.96);
font-size: 22rpx;
color: $text-secondary;
}
.summary-item__dot {
width: 8rpx;
height: 8rpx;
border-radius: 50%;
background: $brand-primary;
}
.summary-item__dot--orange {
background: #F5A623;
}
.bottom-bar__btn {
height: 88rpx;
border-radius: 24rpx;
background: linear-gradient(135deg, #22b18a 0%, #6fdab9 100%);
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
font-weight: 700;
color: #fff;
}
.bottom-bar__btn--disabled {
opacity: 0.4;
}
.nav-record-btn {
padding: 10rpx 16rpx;
border-radius: 999rpx;
background: rgba(45,180,141,0.1);
font-size: 24rpx;
color: $brand-primary;
}
.picker-mask {
position: fixed;
inset: 0;
background: rgba(15,23,42,0.32);
display: flex;
align-items: flex-end;
z-index: 100;
}
.picker-sheet {
width: 100%;
padding: 22rpx 24rpx 0;
border-radius: 36rpx 36rpx 0 0;
background: rgba(255,255,255,0.98);
}
.picker-sheet__header {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 20rpx;
}
.picker-sheet__title {
font-size: 32rpx;
font-weight: 700;
color: $text-primary;
}
.picker-sheet__close {
width: 48rpx;
height: 48rpx;
border-radius: 50%;
background: rgba(134,144,156,0.1);
display: flex;
align-items: center;
justify-content: center;
}
.picker-sheet__body {
max-height: 56vh;
}
.option-card {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx;
margin-bottom: 12rpx;
border-radius: 24rpx;
background: rgba(247,249,251,0.96);
}
.option-card--active {
background: rgba(45,180,141,0.1);
}
.option-card--tech {
justify-content: flex-start;
gap: 16rpx;
}
.option-card__avatar {
width: 72rpx;
height: 72rpx;
border-radius: 50%;
background: linear-gradient(135deg, #22b18a 0%, #6fdab9 100%);
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
font-weight: 700;
color: #fff;
flex-shrink: 0;
}
.option-card__content {
flex: 1;
min-width: 0;
}
.option-card__title {
display: block;
font-size: 28rpx;
font-weight: 700;
color: $text-primary;
}
.option-card__desc {
display: block;
margin-top: 8rpx;
font-size: 24rpx;
color: $text-tertiary;
}
.option-card__check {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
background: rgba(45,180,141,0.14);
display: flex;
align-items: center;
justify-content: center;
margin-left: auto;
}
.picker-empty {
padding: 80rpx 0;
text-align: center;
font-size: 28rpx;
color: $text-tertiary;
}
.ico-close {
width: 16rpx;
height: 16rpx;
position: relative;
}
.ico-close::before,
.ico-close::after {
content: '';
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 3rpx;
background: $text-tertiary;
border-radius: 3rpx;
}
.ico-close::before { transform: rotate(45deg); }
.ico-close::after { transform: rotate(-45deg); }
.ico-check {
width: 14rpx;
height: 8rpx;
border-left: 3rpx solid $brand-primary;
border-bottom: 3rpx solid $brand-primary;
transform: rotate(-45deg);
}
</style>