index.vue
4.57 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
<!--
* @Date: 2024-01-16 13:19:23
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-01-30 16:10:10
* @FilePath: /xyxBooking-weapp/src/pages/bookingDetail/index.vue
* @Description: 预约记录详情
-->
<template>
<view class="booking-detail-page">
<qrCode :status="qrCodeStatus" type="detail" :payId="pay_id"></qrCode>
<view v-if="billInfo.pay_id" class="detail-wrapper">
<view class="detail-item">
<view>参访时间:</view>
<view>{{ billInfo?.datetime }}</view>
</view>
<view class="detail-item">
<view>参访人数:</view>
<view>{{ billInfo?.total_qty }} 人</view>
</view>
<view class="detail-item">
<view>支付金额:</view>
<view>¥ {{ billInfo?.total_amt }}</view>
</view>
<view class="detail-item">
<view>下单时间:</view>
<view>{{ billInfo?.order_time }}</view>
</view>
<view class="detail-item">
<view>订单编号:</view>
<view>{{ billInfo?.pay_id }}</view>
</view>
<view class="detail-item">
<view>订单状态:</view>
<view>{{ qrCodeStatusText }}</view>
</view>
</view>
<view style="height: 160rpx;"></view>
<view v-if="billInfo.status === CodeStatus.SUCCESS && billInfo.show_cancel_reserve === 1" class="cancel-wrapper">
<view @tap="cancelBooking" class="cancel-btn ">取消预约</view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import Taro, { useDidShow, useRouter as useTaroRouter } from '@tarojs/taro'
import { useGo } from '@/hooks/useGo'
import qrCode from '@/components/qrCode';
import { billInfoAPI, icbcRefundAPI } from '@/api/index'
import { formatDatetime } from '@/utils/tools';
const router = useTaroRouter();
const go = useGo();
const pay_id = ref('');
const qrCodeStatus = ref('');
const billInfo = ref({});
const CodeStatus = {
APPLY: '1',
PAYING: '2',
SUCCESS: '3',
CANCEL: '5',
CANCELED: '7',
USED: '9',
REFUNDING: '11'
}
const qrCodeStatusText = computed(() => {
const status = billInfo.value?.status;
switch (status) {
case CodeStatus.SUCCESS: return '预约成功';
case CodeStatus.CANCEL: return '已取消';
case CodeStatus.USED: return '已使用';
case CodeStatus.REFUNDING: return '退款中';
default: return '未知状态';
}
})
const cancelBooking = async () => {
const { confirm } = await Taro.showModal({
title: '温馨提示',
content: '是否取消预约?',
confirmColor: '#A67939'
});
if (confirm) {
Taro.showLoading({ title: '取消中...' });
const { code, data } = await icbcRefundAPI({ pay_id: pay_id.value });
Taro.hideLoading();
if (code) {
Taro.showToast({ title: '取消成功' });
Taro.navigateBack();
} else {
Taro.showToast({ title: '取消失败', icon: 'none' });
}
}
}
useDidShow(async () => {
pay_id.value = router.params.pay_id;
if (pay_id.value) {
const { code, data } = await billInfoAPI({ pay_id: pay_id.value });
if (code) {
data.datetime = data && formatDatetime(data);
data.order_time = data.created_time ? data.created_time.slice(0, -3) : '';
billInfo.value = data;
}
}
})
</script>
<style lang="less">
.booking-detail-page {
min-height: 100vh;
background-color: #F6F6F6;
padding: 32rpx;
.detail-wrapper {
background-color: #FFF;
border-radius: 16rpx;
padding: 32rpx;
margin-top: 32rpx;
box-shadow: 0 0 29rpx 0 rgba(106,106,106,0.1);
.detail-item {
display: flex;
justify-content: space-between;
margin-bottom: 26rpx;
color: #333;
font-size: 30rpx;
&:last-child {
margin-bottom: 0;
}
view:first-child {
color: #999;
width: 160rpx;
}
view:last-child {
flex: 1;
text-align: right;
}
}
}
.cancel-wrapper {
position: fixed;
bottom: 0;
left: 0;
width: 750rpx;
background-color: #FFF;
padding: 32rpx;
box-sizing: border-box;
.cancel-btn {
background-color: #FFF;
color: #A67939;
border: 2rpx solid #A67939;
text-align: center;
padding: 26rpx 0;
border-radius: 16rpx;
font-size: 35rpx;
}
}
}
</style>