InspectionPreview.vue
3.12 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
<template>
<view>
<web-view :src="h5Url" />
</view>
</template>
<script lang="ts">
import { Component, Hook, Vue } from "vue-facing-decorator";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { AuctionController } from "@/api/AuctionController";
import { AuthService } from "@/common/AuthService";
@Component({ components: {} })
export default class InspectionPreview extends Vue {
h5Url: string = '';
vehicleId: string = '';
aucvehId: string = '';
imageUrl: string = '';
vehicleData: any = {};
created(): void {
onLoad((option) => {
const that = this;
that.vehicleId = option.vehicleId;
that.aucvehId = option.aucvehId;
that.getReportVehicleData(option.vehicleId);
that.getVehicleDetail(option.aucvehId);
});
// 每次都加载
onShow(() => {
const that = this;
setTimeout(() => {
that.toLoginPage();
}, 1600);
});
}
toLoginPage() {
const that = this;
const authService: AuthService = that.$auth;
if (!authService.isLogin()) {
uni.showToast({
title: '请先登录', icon: 'none', duration: 2000, complete: function () {
setTimeout(() => {
uni.navigateTo({ url: '/pages/LoginPage?vehicleId=' + that.vehicleId + '&aucvehId=' + that.aucvehId });
}, 1200);
}
});
}
}
getVehicleDetail(aucvehId: string) {
AuctionController.getAuctionVehicleDetailById(this.axios, aucvehId).then(res => {
const data = res.data || {};
this.imageUrl = data?.vehicle?.cover?.url || '';
this.vehicleData = data?.vehicle || {};
});
}
getReportVehicleData(vehicleId: string): void {
AuctionController.reportVehicleData(this.axios, vehicleId).then(res => {
this.h5Url = res.data.data?.h5Url || '';
});
}
// 定义分享内容(必写)
@Hook('onShareAppMessage')
onShareAppMessage(res: any) {
// res.from 可判断分享触发来源:'button'(按钮触发)、'menu'(右上角菜单)
const name = this.vehicleData?.baseInfo?.carSeriesName + this.vehicleData?.baseInfo?.carTypeName;
let title = '优加二手车:专业检测报告[' + name + ']';
return {
title: title,
path: '/module/auction/InspectionPreview?vehicleId=' + this.vehicleId + '&aucvehId=' + this.aucvehId,
imageUrl: this.imageUrl || '', // 分享图片(建议尺寸 5:4,默认使用页面截图)
};
}
@Hook('onShareTimeline')
onShareTimeline() {
const name = this.vehicleData?.baseInfo?.carSeriesName + this.vehicleData?.baseInfo?.carTypeName;
let title = '优加二手车:专业检测报告[' + name + ']';
return {
title: title,
query: 'vehicleId=' + this.vehicleId + '&aucvehId=' + this.aucvehId, // 分享参数
imageUrl: this.imageUrl || '',
};
}
}
</script>
<style lang="scss" scoped></style>