兼容接入订单租期字段

This commit is contained in:
yml
2026-05-24 18:24:39 +08:00
parent e69d08ca9f
commit 778e08a261
9 changed files with 211 additions and 85 deletions
+2
View File
@@ -12,6 +12,8 @@ export interface Order {
title: string
server_region: string
login_platform: string
rented_at?: string
estimated_duration_hours: number
rent_start_at?: string
rent_end_at?: string
rent_amount: number
+15 -2
View File
@@ -282,6 +282,19 @@ function readError(error: unknown, fallback: string) {
return fallback
}
function orderRentedAt() {
return order.value?.rented_at || order.value?.rent_start_at
}
function orderEstimatedEndAt() {
if (!order.value) return undefined
if (order.value.rent_end_at) return order.value.rent_end_at
const rentedAt = orderRentedAt()
const durationHours = Number(order.value.estimated_duration_hours || 0)
if (!rentedAt || durationHours <= 0) return undefined
return new Date(new Date(rentedAt).getTime() + durationHours * 60 * 60 * 1000).toISOString()
}
function hydrateCounterForm() {
if (!order.value?.checkout) return
const checkout = order.value.checkout
@@ -327,8 +340,8 @@ function linesToList(value: string) {
</div>
<div v-if="order" class="order-panel">
<p>开始{{ formatDateTime(order.rent_start_at, '未开始') }}</p>
<p>预计截止{{ formatDateTime(order.rent_end_at, '未设置') }}</p>
<p>开始{{ formatDateTime(orderRentedAt(), '未开始') }}</p>
<p>预计截止{{ formatDateTime(orderEstimatedEndAt(), '未设置') }}</p>
<p v-if="order.status === 'pending_payment'">订单待支付支付后账号进入交接流程</p>
<el-button v-if="order.status === 'pending_payment' && isRenter" type="primary" :loading="paying" @click="handlePay">
支付订单
@@ -63,6 +63,19 @@ function readError(error: unknown, fallback: string) {
}
return fallback
}
function orderRentedAt() {
return order.value?.rented_at || order.value?.rent_start_at
}
function orderEstimatedEndAt() {
if (!order.value) return undefined
if (order.value.rent_end_at) return order.value.rent_end_at
const rentedAt = orderRentedAt()
const durationHours = Number(order.value.estimated_duration_hours || 0)
if (!rentedAt || durationHours <= 0) return undefined
return new Date(new Date(rentedAt).getTime() + durationHours * 60 * 60 * 1000).toISOString()
}
</script>
<template>
@@ -106,8 +119,8 @@ function readError(error: unknown, fallback: string) {
<h2>用户信息</h2>
<p>租客{{ order.renter_phone || order.renter_id }}</p>
<p>号主{{ order.owner_phone || order.owner_id }}</p>
<p>开始{{ formatDateTime(order.rent_start_at, '未开始') }}</p>
<p>预计截止{{ formatDateTime(order.rent_end_at, '未设置') }}</p>
<p>开始{{ formatDateTime(orderRentedAt(), '未开始') }}</p>
<p>预计截止{{ formatDateTime(orderEstimatedEndAt(), '未设置') }}</p>
</div>
<div class="order-panel dashboard-panel">