AuctionSessionPage.vue
6.9 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
<template>
<view class="page-container">
<view class="bg-image" :style="{ backgroundImage:`url(${backgroundImageUrl})` }"></view>
<custom-nav-bar :title="auction?.auctionName" :show-back="true" :status-bar-height="statusBarHeight"></custom-nav-bar>
<view class="header" :style="{ top: statusBarHeight+44 + 'px' }">
<!-- 筛选和排序区域 -->
<van-dropdown-menu>
<van-dropdown-item title="排序" :value="sortOption" :options="sortOptions" @change="onTimeSortChange"/>
<van-dropdown-item title="品牌" use-before-toggle @before-toggle="filterByBrand"/>
<van-dropdown-item title="车价" id="priceFilterItem" :style="{display: priceShow?'block' : 'none'}" @open="priceShow=true" @close="priceShow=false">
<vehicle-price-range-filter @priceChange="onPriceChange"></vehicle-price-range-filter>
</van-dropdown-item>
<van-dropdown-item title="筛选" use-before-toggle @before-toggle="moreFilter"/>
</van-dropdown-menu>
<search-query-filter :search-query="searchQuery" @clear-all="clearAllFilters" @change="pageFilterReload"></search-query-filter>
</view>
<view class="auction-session-container" :style="{ paddingTop: statusBarHeight+filterHeight + 'px' }">
<!-- 车辆列表 -->
<scroll-view class="scroll-content" scroll-y :refresher-enabled="true" :refresher-triggered="loading" @scrolltolower="doInfinite()" @refresherrefresh="pageReload">
<view class="car-list">
<template v-if="contents.length>0" v-for="(car, index) in contents" :key="index">
<auction-vehicle-item :auction-vehicle="car" @emitLoadList="pageReload"></auction-vehicle-item>
</template>
<van-empty class="search-empty" v-else image="https://img02.glsx.com.cn/aus/images/empty_2.png" width="100" height="100" description="未找到相关车源,为你推荐以下车源"/>
</view>
</scroll-view>
</view>
</view>
</template>
<script lang="ts">
import {Component, Hook} from "vue-facing-decorator";
import {onLoad, onShow} from "@dcloudio/uni-app";
import {Auction} from "lib/src/entity/auction/entity/Auction";
import {AuctionController} from "@/api/AuctionController";
// import {PaginationComponent} from "@/components/PaginationComponent";
import {Order} from "lib/src/core/page/Pagination";
import AuctionVehicleItem from "@/components/AuctionVehicleItem.vue";
import CustomNavBar from "@/components/CustomNavBar.vue";
import {BACKGROUND_IMAGE_1} from "@/static/ResourceConstants";
import AuctionVehicleFilter from "@/components/filter/AuctionVehicleFilter";
import SearchQueryFilter from "@/components/filter/SearchQueryFilter.vue";
import VehiclePriceRangeFilter from "@/components/filter/VehiclePriceRangeFilter.vue";
import {AuctionVehicle} from "lib/src/entity/auction/entity/AuctionVehicle";
@Component({
components: {VehiclePriceRangeFilter, SearchQueryFilter, CustomNavBar, AuctionVehicleItem}
})
export default class AuctionSessionPage extends AuctionVehicleFilter {
auctionId: number;
auction: Auction = null;
statusBarHeight = 0;// 用于接收头部总高度,设置内容区 padding
backgroundImageUrl = BACKGROUND_IMAGE_1;
sortOptions = [
{text: '上架时间由近到远', value: 0},
{text: '里程由短到长', value: 1},
{text: '里程由长到短', value: 2},
{text: '车龄由小到大', value: 3},
{text: '车龄由大到小', value: 4},
];
sortOption = 0;
created(): void {
this.init(this.axios, AuctionController.PAGE_LIGHT_AUCTION_VEHICLE);
onLoad((option) => {
this.auctionId = option.auctionId;
this.statusBarHeight = uni.getWindowInfo().statusBarHeight;
this.loadAuctionVehicles();
this.initSearch(option);
// this.pagination.setDefaultSort('createTime', Order.desc);
this.pagination.addDefaultFilter("auction.auctionId", this.auctionId);
this.pageFilterReload();
});
onShow(options => {
this.pageFilterReload();
});
}
onTimeSortChange(detail: any): void {
console.log(detail);
this.sortOption = detail.detail;
switch (this.sortOption) {
case 0:
this.pagination.setDefaultSort('auctionStartTime', Order.desc);
break;
case 1:
this.pagination.setDefaultSort('vehicle.baseInfo.mileage', Order.asc);
break;
case 2:
this.pagination.setDefaultSort('vehicle.baseInfo.mileage', Order.desc);
break;
case 3:
this.pagination.setDefaultSort('vehicle.coreSpecs.productionDate', Order.desc);
break;
case 4:
this.pagination.setDefaultSort('vehicle.coreSpecs.productionDate', Order.asc);
break;
}
this.pageReload();
}
get filterHeight(): number {
return this.searchQuery != null ? 120 : 85;
}
get contents(): AuctionVehicle[] {
const list = (this.pagination.content || []).map(item => {
const vehicleObj = item.vehicle || {};
return { ...item, auctionState: vehicleObj.vehicleState || item.auctionState }
});
return list;
}
loadAuctionVehicles() {
AuctionController.getAuctionById(this.axios, this.auctionId).then(res => {
this.auction = res.data;
uni.setNavigationBarTitle({title: this.auction.auctionName});
});
}
@Hook('onShareAppMessage')
onShareAppMessage(res: any) {
console.debug('分享来源:', res.from);
const title = `${this.auction.auctionName}`;
return {
title: title,
path: '/module/auction/AuctionSessionPage?auctionId=' + this.auctionId,
imageUrl: 'https://dj-oss-fastdfs-release.oss-cn-shenzhen.aliyuncs.com/auction/f0e4f6add8afa743af09294e791c2f9b.png', // 分享图片(建议尺寸 5:4,默认使用页面截图)
};
}
}
</script>
<style lang="scss" scoped>
.auction-session-container {
background-color: #ffffff;
}
.filter-sort-bar {
display: flex;
background-color: #fff;
padding: 6px 16px;
height: 56px;
border-bottom: 1px solid #eee;
}
.filter-item {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
font-size: 14px;
color: #333;
}
.filter-item text {
margin-right: 4px;
}
.car-list {
padding: 10px;
display: flex;
flex-direction: column;
gap: 10px;
}
.separator {
margin: 0 8px;
}
.countdown {
font-size: 12px;
color: #666;
}
.countdown-label {
margin-right: 4px;
}
.countdown-time {
color: #FF5722;
}
.scroll-content {
height: calc(100vh - 180px);
}
</style>