AbstractVehicleItem.ts
4.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
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
import {Component, Prop, Vue} from "vue-facing-decorator";
import {AuctionVehicle} from "lib/src/entity/auction/entity/AuctionVehicle";
import dayjs from "dayjs";
import {Vehicle} from "lib/src/entity/vehicle/entity/Vehicle";
import {BurialPoint} from "@/common/BurialPoint";
import {AuthService} from "@/common/AuthService";
import {maskNumberStr} from "@/common/CommonUtils";
@Component({})
export default class AbstractVehicleItem extends Vue {
@Prop({type: Object, required: true})
auctionVehicle: AuctionVehicle;
get productionYear(): number {
return dayjs(this.vehicle.coreSpecs.productionDate as string).year();
}
get mileage(): string {
return (this.vehicle.baseInfo.mileage / 10000).toFixed(2);
}
get vehicle(): Vehicle {
return this.auctionVehicle.vehicle;
}
get licensePlate(): string {
return this.vehicle.baseInfo?.licensePlate.substring(0, 2);
}
get cityName(): string {
if (this.vehicle.ownership.carCityName) {
return this.vehicle.ownership.carCityName.replace("市", "");
}
return this.vehicle.ownership.carCityName;
}
get ageLess1Year(): boolean {
return dayjs().add(-1, 'years').isBefore(dayjs(this.vehicle.coreSpecs.productionDate as string));
}
get efficient(): boolean {
return (this.vehicle.coreSpecs.vehicleClass === '小型车' || this.vehicle.coreSpecs.vehicleClass === '紧凑型车');
}
get hasBidPrivilege(): boolean {
const authService: AuthService = this.$auth as AuthService;
if (authService.isLogin() && authService.getAuthentication().accountType !== 'COMMON') {
return true;
} else {
return false;
}
}
get maskBidPrice(): string {
return maskNumberStr((this.vehicle.startingBidPrice / 10000).toFixed(2));
}
viewCarDetail() {
BurialPoint.burialPoint(this.$auth.getAuthentication(), 'auction_home_vehiclecard_click', this.auctionVehicle.aucvehId.toString(), '/module/auction/AuctionVehiclePage');
uni.navigateTo({url: '/module/auction/AuctionVehiclePage?aucvehId=' + this.auctionVehicle.aucvehId});
}
/**
* 是否小于24小时开拍
*/
get previewLessThen24h(): boolean {
// const now = dayjs();
// const startTime = dayjs(this.auctionVehicle.auctionStartTime as string);
// return (startTime.diff(now) <= 24 * 60 * 60 * 1000);
return (this.auctionVehicle.bidStartRemaining <= 24 * 60 * 60 * 1000);
}
/**
* 预览倒计时
*/
get previewCountDown(): number {
// const now = dayjs();
// const startTime = dayjs(this.auctionVehicle.auctionStartTime as string);
// return startTime.diff(now);
return this.auctionVehicle.bidStartRemaining;
}
/**
* 预览中显示状态信息
*/
get previewStatus(): string {
const now = dayjs();
const startTime = dayjs(this.auctionVehicle.auctionStartTime as string);
return startTime.format('YYYY/MM/DD HH:mm');
}
// /**
// * 拍卖中显示状态信息
// */
// get auctionStatus(): string {
// const now = dayjs();
// const endTime = dayjs(this.auctionVehicle.auctionEndTime as string);
// return '剩余 ' + dayjs.duration(endTime.diff(now)).format('HH:mm:ss');
// }
/**
* 是否只剩下5分钟拍卖结束
*/
get remaining5m(): boolean {
// const now = dayjs();
// const endTime = dayjs(this.auctionVehicle.auctionEndTime as string);
// return endTime.diff(now) < 5 * 60 * 1000;
return this.auctionVehicle.bidEndRemaining < 5 * 60 * 1000;
}
/**
* 只剩下5分钟拍卖结束倒计时
*/
get endRemaining() {
// const now = dayjs();
// const endTime = dayjs(this.auctionVehicle.auctionEndTime as string);
// return endTime.diff(now);
return this.auctionVehicle.bidEndRemaining;
}
countDownBidStart(): void {
this.auctionVehicle.auctionState = 'AUCTIONING';
}
countDownBidEnd(): void {
this.auctionVehicle.auctionState = 'SOLD';
}
}