OrderComplete.vue
9.92 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
<template>
<view class="page-container">
<view class="bg-image" :style="{ backgroundImage:`url(${backgroundImageUrl})` }"></view>
<custom-nav-bar title="交易完成" :show-back="true" :status-bar-height="statusBarHeight"></custom-nav-bar>
<view class="transaction-complete-container" :style="{ paddingTop: statusBarHeight+44 + 'px' }">
<!-- 交易成功提示 -->
<view class="success-container">
<view class="success-tip">
<text class="success-title">交易已圆满完成!</text>
<view class="success-desc">恭喜您,开启您的精彩旅程吧!</view>
</view>
<view>
<image class="success-icon" src="https://img02.glsx.com.cn/aus/images/order/complete.png" mode="aspectFill"></image>
</view>
</view>
<!-- 车辆信息卡片 -->
<view class="car-info-card">
<!-- 车辆信息 -->
<order-vehicle-item v-if="order" :order="order"></order-vehicle-item>
<view class="action-buttons">
<view class="contract-btn" @click="viewContract">电子合同</view>
<view class="certificate-btn" @click="viewCertificate">过户凭证</view>
</view>
</view>
<!-- 尊享服务 -->
<!-- <view class="service-section">-->
<!-- <view class="section-title">尊享服务</view>-->
<!-- <!– 车辆保险方案 –>-->
<!-- <view class="service-item" @click="viewInsurance">-->
<!-- <view class="service-icon ">-->
<!-- <image src="https://img02.glsx.com.cn/aus/images/order/baoxian.png" class="service-image"></image>-->
<!-- </view>-->
<!-- <view class="service-info">-->
<!-- <view class="service-name">车辆保险方案</view>-->
<!-- <view class="service-desc">为您甄选高性价比车险,一键投保</view>-->
<!-- </view>-->
<!-- <uni-icons type="right" size="16" color="#ccc"></uni-icons>-->
<!-- </view>-->
<!-- <!– 官方认证延保 –>-->
<!-- <view class="service-item" @click="viewWarranty">-->
<!-- <view class="service-icon ">-->
<!-- <image src="https://img02.glsx.com.cn/aus/images/order/yanbao.png" class="service-image"></image>-->
<!-- </view>-->
<!-- <view class="service-info">-->
<!-- <view class="service-name">官方认证延保</view>-->
<!-- <view class="service-desc">核心部件再享两年质保,用车无忧</view>-->
<!-- </view>-->
<!-- <uni-icons type="right" size="16" color="#ccc"></uni-icons>-->
<!-- </view>-->
<!-- </view>-->
</view>
</view>
</template>
<script lang="ts">
import {Component, Vue} from "vue-facing-decorator";
import OrderVehicleItem from "@/module/order/OrderVehicleItem.vue";
import {BACKGROUND_IMAGE_2} from "@/static/ResourceConstants";
import {onLoad, onShow} from "@dcloudio/uni-app";
import {AuctionOrder} from "lib/src/entity/auction/entity/AuctionOrder";
import {AuctionOrderController} from "@/api/AuctionOrderController";
import CustomNavBar from "@/components/CustomNavBar.vue";
@Component({
components: {CustomNavBar, OrderVehicleItem}
})
export default class OrderComplete extends Vue {
orderId: number;
order: AuctionOrder = null;
backgroundImageUrl = BACKGROUND_IMAGE_2;
statusBarHeight = 0;// 用于接收头部总高度,设置内容区 padding
created(): void {
onLoad((option) => {
this.statusBarHeight = uni.getWindowInfo().statusBarHeight;
this.orderId = option.orderId;
this.loadData();
});
// 每次都加载
onShow((option) => {
});
}
loadData(): void {
AuctionOrderController.getAuctionOrderDetailById(this.axios, this.orderId).then(res => {
this.order = res.data;
});
}
viewContract() {
// 查看电子合同的逻辑
AuctionOrderController.getContractsByOrderId(this.axios, this.orderId).then(res => {
const contracts = res.data.filter(item => item.templateType === 'AUCTION');
if (contracts.length > 0 && contracts[0].contractFiles.length > 0) {
this.openRemotePdf(contracts[0].contractFiles[0].url);
} else {
uni.showToast({title: '暂无电子合同', icon: 'none'});
}
});
}
// 查看过户凭证的逻辑
viewCertificate() {
uni.navigateTo({url: '/module/order/transfer/ViewTransferPage?orderId=' + this.orderId})
}
viewInsurance() {
// 查看车辆保险方案的逻辑
uni.showToast({
title: '查看车辆保险方案',
icon: 'none'
})
}
viewWarranty() {
// 查看官方认证延保的逻辑
uni.showToast({
title: '查看官方认证延保',
icon: 'none'
})
}
async openRemotePdf(pdfUrl: string) {
try {
// 1. 显示加载中提示
uni.showLoading({title: '加载中...'});
// 2. 下载 PDF 到临时路径(注意:微信小程序需配置 downloadFile 合法域名)
uni.downloadFile({
url: pdfUrl, // 远程 PDF 地址
success: function (res) {
var filePath = res.tempFilePath;
uni.openDocument({
fileType: "pdf", // 文档类型(必传)
filePath: filePath,
showMenu: true,
success: function (res) {
console.log("打开文档成功");
},
});
},
fail: function (res) {
uni.showToast({title: '下载失败,请重试', icon: 'none'});
},
});
// 3. 下载成功后,打开 PDF
// if (downloadRes.statusCode === 200) {
// await new Promise<any>(
// (resolve, reject) => {
// uni.openDocument({
// fileType: "pdf", // 文档类型(必传)
// filePath: downloadRes.tempFilePath, // 临时文件路径
// showMenu: true, // 显示右上角菜单(支持转发、保存)
// success: resolve,
// fail: reject,
// });
// }
// );
// uni.showToast({title: '打开成功', icon: 'none'});
// } else {
// uni.showToast({title: '下载失败', icon: 'none'});
// }
} catch (error) {
console.error("打开 PDF 失败:", error);
uni.showToast({title: '打开失败,请重试', icon: 'none'});
} finally {
// 关闭加载提示
uni.hideLoading();
}
}
}
</script>
<style lang="scss" scoped>
.transaction-complete-container {
padding-bottom: 20px;
position: relative;
}
.page-container {
background-color: #f5f5f5;
}
/* 交易成功提示 */
.success-container {
display: flex;
align-items: center;
justify-content: space-between;
}
.success-tip {
padding: 20px 16px;
text-align: left;
display: flex;
flex-direction: column;
margin-bottom: 2px;
}
.success-title {
font-size: 26px;
font-weight: 600;
color: #1989fa;
margin-bottom: 2px;
}
.success-icon {
margin-right: 12px;
width: 100px;
height: 100px;
}
.success-desc {
font-size: 13px;
color: #333;
}
.success-section {
display: flex;
flex-direction: column;
align-items: center;
padding-top: 12px;
padding-bottom: 30px;
background-color: #fff;
}
.success-subtitle {
font-size: 14px;
color: #666;
}
/* 车辆信息卡片 */
.car-info-card {
background-color: #fff;
margin: 12px;
border-radius: 12px;
}
.action-buttons {
display: flex;
justify-content: space-between;
padding: 0 16px 16px 16px;
}
.contract-btn,
.certificate-btn {
flex: 1;
height: 44px;
border-radius: 40px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
}
.contract-btn {
background-color: #F8F9FBFF;
color: #333;
margin-right: 8px;
}
.certificate-btn {
background-color: #185EFEFF;
color: #fff;
margin-left: 8px;
}
/* 尊享服务 */
.service-section {
background-color: #fff;
margin: 12px;
border-radius: 12px;
padding: 16px;
}
.section-title {
font-size: 16px;
font-weight: 500;
color: #333;
margin-bottom: 16px;
}
.service-item {
display: flex;
align-items: center;
padding: 12px 0;
border-bottom: 1px solid #f0f0f0;
}
.service-item:last-child {
border-bottom: none;
}
.service-icon {
width: 48px;
height: 48px;
border-radius: 8px;
border: 1px solid #E7EBF4FF;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12px;
}
.service-image {
height: 32px;
width: 32px;
}
.service-info {
flex: 1;
}
.service-name {
font-size: 15px;
color: #333;
margin-bottom: 4px;
}
.service-desc {
font-size: 13px;
color: #999;
}
</style>