reserveCard.vue
4.18 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
<!--
* @Date: 2024-01-24 16:38:13
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-01-30 15:19:44
* @FilePath: /xyxBooking-weapp/src/components/reserveCard.vue
* @Description: 预约记录卡组件
-->
<template>
<view class="booking-list-item" @tap="goToDetail(reserve_info)">
<view class="booking-list-item-header">
<view>{{ reserve_info.booking_time }}</view>
<view :class="[formatStatus(reserve_info.status)?.key, 'status']">{{ formatStatus(reserve_info.status)?.value }}</view>
</view>
<view class="booking-list-item-body">
<view class="booking-num">
<view class="num-body van-ellipsis">预约人数:<text>{{ reserve_info.total_qty }} 人</text> <text>({{ reserve_info.person_name }})</text></view>
<view v-if="(reserve_info.status === CodeStatus.SUCCESS || reserve_info.status === CodeStatus.USED || reserve_info.status === CodeStatus.CANCEL)">
<IconFont name="rect-right" />
</view>
</view>
<view class="booking-price">支付金额:<text>¥ {{ reserve_info.total_amt }}</text></view>
<view class="booking-time">下单时间:<text>{{ reserve_info.order_time }}</text></view>
</view>
<view class="booking-list-item-footer">
<!-- 倒计时逻辑省略,如果需要可添加 -->
</view>
</view>
</template>
<script setup>
import { computed } from 'vue'
import { IconFont } from '@nutui/icons-vue-taro'
import { useGo } from '@/hooks/useGo'
const go = useGo();
const props = defineProps({
data: {
type: Object,
default: {},
},
});
const reserve_info = computed(() => props.data);
const CodeStatus = {
APPLY: '1',
PAYING: '2',
SUCCESS: '3',
CANCEL: '5',
CANCELED: '7',
USED: '9',
REFUNDING: '11'
}
const formatStatus = (status) => {
switch (status) {
case CodeStatus.APPLY:
return {
key: 'cancel',
value: '待支付'
}
case CodeStatus.PAYING:
return {
key: 'success',
value: '支付中'
}
case CodeStatus.SUCCESS:
return {
key: 'success',
value: '预约成功'
}
case CodeStatus.CANCEL:
return {
key: 'cancel',
value: '已取消'
}
case CodeStatus.CANCELED:
return {
key: 'cancel',
value: '已取消'
}
case CodeStatus.USED:
return {
key: 'used',
value: '已使用'
}
case CodeStatus.REFUNDING:
return {
key: 'cancel',
value: '退款中'
}
default:
return { key: '', value: '' }
}
}
const goToDetail = (item) => {
// 只有成功、已使用、已取消(退款成功)才跳转详情
if (item.status === CodeStatus.SUCCESS || item.status === CodeStatus.USED || item.status === CodeStatus.CANCEL) {
go('/bookingDetail', { pay_id: item.pay_id });
}
}
</script>
<style lang="less">
.booking-list-item {
background-color: #FFF;
border-radius: 16rpx;
padding: 32rpx;
margin-bottom: 32rpx;
box-shadow: 0 0 30rpx 0 rgba(106,106,106,0.1);
.booking-list-item-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 16rpx;
border-bottom: 2rpx dashed #E6E6E6;
margin-bottom: 16rpx;
font-size: 32rpx;
font-weight: bold;
color: #333;
.status {
font-size: 27rpx;
font-weight: normal;
padding: 4rpx 12rpx;
border-radius: 8rpx;
&.success {
color: #A67939;
background-color: #FBEEDC;
}
&.cancel {
color: #999;
background-color: #EEE;
}
&.used {
color: #477F3D;
background-color: #E5EFE3;
}
}
}
.booking-list-item-body {
.booking-num {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
color: #666;
.num-body {
span, text {
color: #A67939;
font-weight: bold;
}
}
}
.booking-price, .booking-time {
color: #999;
font-size: 29rpx;
margin-bottom: 10rpx;
text {
color: #333;
}
}
}
}
</style>