AuctionOrderPage.vue 19 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 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
<template>
    <custom-nav-bar title="拍卖订单" :show-back="true" :status-bar-height="statusBarHeight" back-url="/pages/tabbar/ProfilePage"></custom-nav-bar>
    <view class="order-page" :style="{ paddingTop: statusBarHeight+44 + 'px'   }">
        <!-- 顶部导航栏 -->
        <!-- 搜索栏 -->
        <view class="search-bar">
            <uni-search-bar v-model="searchText" placeholder="请输入订单编号/车型名称/车源号" radius="60" @confirm="onSearch"
                            @input="handleInput" @clear="clearSearch" @cancel="clearSearch" bgColor="#F7F9FC"/>
        </view>
        <!-- 订单状态切换标签 -->
        <view class="order-tabs">
            <scroll-view scroll-x class="tabs-scroll">
                <uni-segmented-control class="state-segmented" :current="current" :values="tabs" style-type="text" active-color="#333" inActiveColor="#666" @clickItem="onClickItem"/>
            </scroll-view>
        </view>

        <!-- 订单列表 -->
        <scroll-view class="scroll-content" scroll-y :refresher-enabled="true" :refresher-triggered="loading" @scrolltolower="doInfinite()" @refresherrefresh="pageReload()">
            <view class="recharge-list">
                <!-- 待支付订单 -->
                <template v-if="contents.length>0" v-for="(order, index) in contents" :key="order.orderId">
                    <view class="recharge-item">
                        <view class="recharge-header">
                            <span class="order-id" @click="copyOrderCode(order)">订单编号:{{ order.orderCode }}</span>
                            <span class="order-status" :class="{ completed: order.orderState==='COMPLETED'||order.orderState==='CANCELED' }">
                                <template v-if="order.orderState!=='CANCELED'&&order.onAppeal">
                                    <span class="exception-text">申诉中</span>
                                </template>
                                 <template v-else-if="order.orderState==='UNPAID'">
                                     <span class="exception-text" v-if="order.auditState==='UNAUDITED'">付款审核中</span>
                                     <span class="exception-text" v-else-if="order.auditState==='REJECTED'">付款审核失败</span>
                                     <template v-else>{{ $t('enum.auctionOrder.orderState.' + order.orderState) }}</template>
                                 </template>
                                <template v-else-if="order.orderState==='TRANSFERRING'">
                                    <span class="exception-text" v-if="order.auditState==='UNAUDITED'">资料审核中</span>
                                     <span class="exception-text" v-else-if="order.auditState==='REJECTED'">资料审核失败</span>
                                     <template v-else>{{ $t('enum.auctionOrder.orderState.' + order.orderState) }}</template>
                                </template>
                                <template v-else>
                                     {{ $t('enum.auctionOrder.orderState.' + order.orderState) }}
                                </template>
                            </span>
                        </view>
                        <view class="payment-time">中拍时间:{{ order.createTime }}</view>
                        <view class="recharge-info" @click="viewAuctionOrder(order)">
                            <van-image class="car-image" radius="16rpx" use-error-slot width="200rpx" height="140rpx" fit="cover" :src="order.vehicle.cover?.url">
                                <text slot="error">加载失败</text>
                            </van-image>
                            <view class="recharge-details">
                                <view class="car-name">【{{ geCityName(order.vehicle) }}】{{ order.vehicle.baseInfo.carSeriesName }} {{ order.vehicle.baseInfo.carTypeName }}</view>
                                <view class="car-price">{{ $filters.formatNumber(order.orderPrice / 10000) }}
                                    <text class="price-unit">万</text>
                                </view>
                            </view>
                        </view>

                        <view class="recharge-footer">
                            <!-- <view class="warning-text" v-if="order.orderState==='CONTRACT_UNSIGNED'">
                                <template v-if="getRemainingBreachContract(order)>0">
                                    <van-count-down class="red-count-down" :time="getRemainingBreachContract(order)" format="HH:mm:ss 后将违约"/>
                                </template>
                                <template v-else>
                                    请尽快签署合同并付款
                                </template>
                            </view> -->
                            <view class="warning-text" v-if="order.orderState==='UNPAID'">
                                <template v-if="getRemainingBreachContract(order)>0">
                                    <template v-if="order.auditState!=='UNAUDITED'">
                                        <van-count-down class="red-count-down" :time="getRemainingBreachContract(order)" format="HH:mm:ss 后将违约"/>
                                    </template>
                                    <template v-else>
                                        支付审核中
                                    </template>
                                </template>
                                <template v-else-if="!order.auditState">
                                    请尽快付款
                                </template>
                            </view>
                            <view class="warning-text" v-if="order.orderState==='CANCELED'&&order.onAppeal">
                                申诉完成,可查看详情
                            </view>
                            <view v-else></view>

                            <view v-if="order.onAppeal" class="order-actions">
                                <van-button type="default" round @click="contactService(order)" size="small">联系客服</van-button>
                            </view>
                            <view v-else class="order-actions">
                                <van-button v-if="order.orderState!=='COMPLETED'&&order.orderState!=='CANCELED'" type="default" round @click="appealOrder(order)" size="small">申诉</van-button>
                                <van-button v-if="order.orderState!=='CONTRACT_UNSIGNED'&&order.orderState!=='UNPAID'" type="default" round @click="contactService(order)" size="small">联系客服</van-button>

                                <!-- <van-button v-if="order.orderState==='CONTRACT_UNSIGNED'" type="primary" hairline round @click="viewAuctionOrder(order)" size="small">立即签署</van-button> -->
                                <van-button v-if="order.orderState==='WAIT_PICKUP'" type="primary" hairline round @click="viewAuctionOrder(order)" size="small">确认提车</van-button>
                                <van-button v-if="order.orderState==='TRANSFERRING'" type="primary" hairline round @click="viewAuctionOrder(order)" size="small">
                                    <template v-if="order.auditState==='REJECTED'">
                                        重新提交
                                    </template>
                                    <template v-else-if="order.auditState==='UNAUDITED'">
                                        修改过户资料
                                    </template>
                                    <template v-else>
                                        上传过户资料
                                    </template>
                                </van-button>
                                <template v-if="order.orderState==='UNPAID'">
                                    <van-button v-if="!order.auditState" type="primary" hairline round @click="viewAuctionOrder(order)" size="small">立即付款</van-button>
                                    <van-button v-if="order.auditState==='UNAUDITED'" type="primary" hairline round
                                                @click="viewAuctionOrder(order)"
                                                size="small">撤销并修改
                                    </van-button>
                                    <van-button v-if="order.auditState==='REJECTED'||order.auditState==='EXCEPTION'" type="primary" hairline round
                                                @click="viewAuctionOrder(order)" size="small">重新付款
                                    </van-button>
                                </template>
                            </view>
                        </view>
                    </view>
                </template>
                <van-empty v-else image="https://img02.glsx.com.cn/aus/images/empty_2.png" style="margin-top: 100px" description="暂无订单"/>
                <view v-if="contents.length>0&&pagination.isLast()" class="empty-tip">
                    <text>-到底啦-</text>
                </view>
            </view>
        </scroll-view>
    </view>
</template>
<script lang="ts">
import {Component} from "vue-facing-decorator";
import {onLoad, onShow} from "@dcloudio/uni-app";
import type {FilterOption} from "lib/src/core/page/Pagination";
import {Operator, Order} from "lib/src/core/page/Pagination";
// import {PaginationComponent} from "@/components/PaginationComponent";
import {AuctionOrder} from "lib/src/entity/auction/entity/AuctionOrder";
import {AuctionOrderController} from "@/api/AuctionOrderController";
import dayjs from "dayjs";
import CustomNavBar from "@/components/CustomNavBar.vue";
import {BurialPoint} from "@/common/BurialPoint";
import {PaginationComponent} from "@/components/PaginationComponent";
import {Vehicle} from "lib/src/entity/vehicle/entity/Vehicle";

@Component({
    components: {CustomNavBar}
})
export default class AuctionOrderPage extends PaginationComponent<AuctionOrder> {
    currentPath = 'module/order/AuctionOrderPage';
    // 用于接收头部总高度,设置内容区 padding
    statusBarHeight = 0;
    current = 0;
    searchText = "";
    tabs = ['全部订单', '待支付', '待提车', '待过户', '已完成', '已取消', '申诉中'];

    orderStates = ['', 'UNPAID', 'WAIT_PICKUP', 'TRANSFERRING', 'COMPLETED', 'CANCELED'];

    created(): void {
        this.init(this.axios, AuctionOrderController.PAGE_AUCTION_ORDER);
        this.buildQueryForm({
            carTypeName: [null, {label: '实际时间', field: 'vehicle.baseInfo.carTypeName', operator: Operator.like}],
        });
        this.pagination.setDefaultSort('createTime', Order.desc);
        onLoad((option) => {
            this.statusBarHeight = uni.getWindowInfo().statusBarHeight;
            this.pagination.reload();
        });
        onShow(options => {
            this.pageRefresh();
        });
    }

    get contents(): AuctionOrder[] {
        return this.pagination.content;
    }

    dddddd(event: any) {
        console.log('dddddd');
        console.log(event.detail.scrollTop)
    }

    onClickItem(e: any) {
        if (this.current !== e.currentIndex) {
            this.current = e.currentIndex;
            if (this.current === 0) {
                this.pagination.removeDefaultFilter('orderState');
                this.pagination.removeDefaultFilter('onAppeal');
            } else if (this.current == (this.tabs.length - 1)) {
                this.pagination.removeDefaultFilter('orderState');
                this.pagination.addDefaultFilter('onAppeal', true);
            } else {
                this.pagination.addDefaultFilter('orderState', this.orderStates[this.current]);
                this.pagination.addDefaultFilter('onAppeal', false);
            }
            this.pageReload();
        }
    }


    viewAuctionOrder(order: AuctionOrder) {

        if (order.orderState === 'CANCELED') {
            BurialPoint.burialPoint(this.$auth.getAuthentication(), 'auction_orderlist_cancelview_click', order.orderId.toString(), this.currentPath);
            uni.navigateTo({url: '/module/order/OrderDetailPage?orderId=' + order.orderId + '&from=auctionOrder'});
            return;
        }
        if (order.onAppeal) {
            BurialPoint.burialPoint(this.$auth.getAuthentication(), 'auction_orderlist_appealview_click', order.orderId.toString(), this.currentPath);
            uni.navigateTo({url: '/module/order/appeal/ViewAppeal?orderId=' + order.orderId});
            return;
        }
        BurialPoint.burialPoint(this.$auth.getAuthentication(), 'auction_orderlist_pay_click', order.orderId.toString(), this.currentPath);
        uni.navigateTo({url: '/module/order/OrderDetailPage?orderId=' + order.orderId + '&from=auctionOrder'});
        // switch (order.orderState) {
        //     case 'CONTRACT_UNSIGNED':
        //         BurialPoint.burialPoint(this.$auth.getAuthentication(), 'auction_orderlist_sign_click', order.orderId.toString(), this.currentPath);
        //         uni.navigateTo({url: '/module/order/contract/ContractPage?orderId=' + order.orderId});
        //         break;
        //     case 'COMPLETED':
        //         uni.navigateTo({url: '/module/order/OrderComplete?orderId=' + order.orderId});
        //         break;
        //     case "UNPAID":
        //         BurialPoint.burialPoint(this.$auth.getAuthentication(), 'auction_orderlist_pay_click', order.orderId.toString(), this.currentPath);
        //         uni.navigateTo({url: '/module/order/payment/PaymentPage?orderId=' + order.orderId});
        //         break;
        //     case "WAIT_PICKUP":
        //         BurialPoint.burialPoint(this.$auth.getAuthentication(), 'auction_orderlist_pickup_click', order.orderId.toString(), this.currentPath);
        //         uni.navigateTo({url: '/module/order/pickup/PickUpVehiclePage?orderId=' + order.orderId});
        //         break;
        //     case "TRANSFERRING":
        //         if (order.auditState === 'REJECTED') {
        //             BurialPoint.burialPoint(this.$auth.getAuthentication(), 'auction_orderlist_resubmit_click', order.orderId.toString(), this.currentPath);
        //         }
        //         uni.navigateTo({url: '/module/order/transfer/UploadTransferPage?orderId=' + order.orderId});
        //         break;
        //     case "CANCELED":
        //         BurialPoint.burialPoint(this.$auth.getAuthentication(), 'auction_orderlist_cancelview_click', order.orderId.toString(), this.currentPath);
        //         break;
        // }
    }

    onSearch(): void {
        const filterOption: FilterOption = {
            field: 'searchText', operator: Operator.like, value: this.searchText, filters: [
                {field: 'vehicle.baseInfo.sourceNo', operator: Operator.like, value: this.searchText},
                {field: 'vehicle.baseInfo.carTypeName', operator: Operator.like, value: this.searchText},
                {field: 'orderCode', operator: Operator.like, value: this.searchText}
            ], logic: 'or'
        };
        this.pagination.addFilterOption(filterOption, true);
        this.pageReload();
    }

    handleInput(): void {

    }

    clearSearch(): void {
        this.pageReset();
        this.pageReload();
    }

    navigateTo(url: string) {
        uni.navigateTo({url: url});
    }

    getRemainingBreachContract(order: AuctionOrder): number {
        const remaining = dayjs(order.createTime).add(24, 'hours').diff(dayjs());
        return remaining;
    }

    appealOrder(order: AuctionOrder): void {
        BurialPoint.burialPoint(this.$auth.getAuthentication(), 'auction_orderlist_appeal_click', order.orderId.toString(), this.currentPath);
        uni.navigateTo({url: '/module/order/appeal/AppealForm?orderId=' + order.orderId});
    }

    contactService(order: AuctionOrder) {
        BurialPoint.burialPoint(this.$auth.getAuthentication(), 'auction_orderlist_contactcs_click', order.orderId.toString(), this.currentPath);
        // 这里应该跳转到客服页面或打开客服聊天窗口
        console.log(order.auction.user.mobile);
        uni.makePhoneCall({
            phoneNumber: order.auction.user.mobile, fail: function (res) {
            }
        });
    }

    getLicensePlate(order: AuctionOrder): string {
        return order.vehicle.baseInfo?.licensePlate.substring(0, 2);
    }

    geCityName(vehicle: Vehicle): string {
        if (vehicle.ownership.carCityName) {
            return vehicle.ownership.carCityName.replace("市", "");
        }
        return vehicle.ownership.carCityName;
    }


    copyOrderCode(order: AuctionOrder) {
        uni.setClipboardData({
            data: order.orderCode,
            success: () => uni.showToast({title: '订单号已复制', icon: 'none'})
        });
    }
}
</script>

<style lang="scss" scoped>
/* 全局样式 */
.order-page {
    //min-height: 100vh;
    padding-bottom: 20rpx;
    background: rgba(248, 249, 251, 1);
}

/* 搜索栏样式 */
.search-bar {
    background-color: #fff;
    padding: 1px 4px;
}

/* 订单状态切换标签 */
.order-tabs {
    background-color: #fff;
    border-bottom: 1rpx solid #eee;
    padding: 0 20rpx 10rpx 20rpx;
}

.tabs-scroll {
    white-space: nowrap;
    width: 100%;
    //display: flex;
}

.scroll-content {
    height: calc(100vh - 180px);
}


/* 订单列表 */
.recharge-list {
    margin-top: 20rpx;

}

/* 订单项 */
.recharge-item {
    background-color: #fff;
    margin: 20rpx;
    padding: 24rpx 30rpx;
    border-radius: 12px;
}

.recharge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6rpx;
}

.order-id {
    font-size: 16px;
    font-weight: 400;
    color: #333;
}

.order-status {
    //padding: 4rpx 16rpx;
    color: rgba(24, 94, 254, 1);
    font-size: 14px;
    font-weight: 400;
}

.order-status.completed {
    color: #999999FF;
}

.payment-time {
    font-size: 12px;
    color: #999;
    margin-bottom: 24rpx;
}

/* 车辆信息 */
.recharge-info {
    display: flex;
    margin-bottom: 24rpx;
}

.car-image {
    width: 200rpx;
    height: 140rpx;
    border-radius: 16rpx;
    margin-right: 20rpx;
}

.recharge-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.car-name {
    font-size: 28rpx;
    color: #333;
    line-height: 42rpx;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.car-price {
    font-size: 32rpx;
    font-weight: bold;
    color: #ff4d4f;
}

.price-unit {
    font-size: 26rpx;
    font-weight: normal;
}


/* 订单底部 */
.recharge-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.warning-text {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    font-size: 26rpx;
    color: #EE3040FF;

    :deep(.red-count-down) {
        display: inline-flex;
        align-items: center;
    }

    :deep(.red-count-down .van-count-down) {
        font-size: 26rpx;
        line-height: 1.4;
    }
}

.exception-text {
    color: #EE3040FF;
}

.order-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 修复按钮样式 */
.order-actions button:first-child {
    margin-left: 0;
}
</style>