删掉租期相关错误东西

This commit is contained in:
yml2213
2026-05-23 14:44:32 +08:00
parent e6cc9f1255
commit a6a1afb879
41 changed files with 127 additions and 312 deletions
+11 -27
View File
@@ -10,7 +10,6 @@ const route = useRoute();
const router = useRouter();
const loading = ref(false);
const ordering = ref(false);
const rentHours = ref(1);
const listing = ref<Listing | null>(null);
onMounted(async () => {
@@ -26,7 +25,7 @@ async function handleCreateOrder() {
if (!listing.value) return;
ordering.value = true;
try {
const order = await createOrder(listing.value.id, rentHours.value);
const order = await createOrder(listing.value.id);
ElMessage.success("订单已创建,账号已锁定");
await router.push(`/orders/${order.id}`);
} catch (error) {
@@ -44,6 +43,10 @@ function readError(error: unknown, fallback: string) {
}
return fallback;
}
function listingPrice(item: Listing) {
return Number(item.price_daily || item.price_hourly || 0).toFixed(2);
}
</script>
<template>
@@ -78,12 +81,8 @@ function readError(error: unknown, fallback: string) {
<strong>{{ listing.haf_coin_amount }}</strong>
</div>
<div class="metric-card">
<span>时租</span>
<strong>¥{{ listing.price_hourly }}</strong>
</div>
<div class="metric-card">
<span>日租</span>
<strong>¥{{ listing.price_daily }}</strong>
<span>价格</span>
<strong>¥{{ listingPrice(listing) }}</strong>
</div>
<div class="metric-card">
<span>押金</span>
@@ -93,27 +92,12 @@ function readError(error: unknown, fallback: string) {
</section>
<aside class="order-panel pc-order-card">
<h2>立即租用</h2>
<p class="order-safe-text">
平台托管订单与押金,租期 {{ listing.min_rent_hours }}-{{
listing.max_rent_hours
}}
小时。
</p>
<h2>立即下单</h2>
<p class="order-safe-text">平台托管订单与押金,按平台交接流程完成账号使用。</p>
<el-form label-position="top">
<el-form-item label="租用时长">
<el-input-number
v-model="rentHours"
:min="listing.min_rent_hours"
:max="listing.max_rent_hours"
class="full-control"
/>
</el-form-item>
<div class="order-total-box">
<span>预计租金</span>
<strong
>¥{{ (listing.price_hourly * rentHours).toFixed(2) }}</strong
>
<span>价格</span>
<strong>¥{{ listingPrice(listing) }}</strong>
<em>押金 ¥{{ listing.deposit_amount }}</em>
</div>
<el-button
+10 -9
View File
@@ -36,20 +36,20 @@ const filteredListings = computed(() => {
const matchCoin =
!filters.minCoin || item.haf_coin_amount >= filters.minCoin;
const matchPrice =
!filters.maxPrice || item.price_hourly <= filters.maxPrice;
!filters.maxPrice || listingPrice(item) <= filters.maxPrice;
return (
matchKeyword && matchRegion && matchPlatform && matchCoin && matchPrice
);
});
return [...result].sort((a, b) => {
if (sortBy.value === "price-asc") return a.price_hourly - b.price_hourly;
if (sortBy.value === "price-asc") return listingPrice(a) - listingPrice(b);
if (sortBy.value === "coin-desc")
return b.haf_coin_amount - a.haf_coin_amount;
if (sortBy.value === "deposit-asc")
return a.deposit_amount - b.deposit_amount;
return (
b.haf_coin_amount - a.haf_coin_amount || a.price_hourly - b.price_hourly
b.haf_coin_amount - a.haf_coin_amount || listingPrice(a) - listingPrice(b)
);
});
});
@@ -77,6 +77,10 @@ function resetFilters() {
function uniqueOptions(values: string[]) {
return [...new Set(values.filter(Boolean))];
}
function listingPrice(item: Listing) {
return Number(item.price_daily || item.price_hourly || 0);
}
</script>
<template>
@@ -145,7 +149,7 @@ function uniqueOptions(values: string[]) {
class="full-control"
/>
</el-form-item>
<el-form-item label="最高时租">
<el-form-item label="最高价格">
<el-input-number
v-model="filters.maxPrice"
:min="0"
@@ -203,12 +207,9 @@ function uniqueOptions(values: string[]) {
</div>
</div>
<div class="resource-price-box">
<span>时租</span>
<strong>¥{{ item.price_hourly }}</strong>
<span>价格</span>
<strong>¥{{ listingPrice(item).toFixed(2) }}</strong>
<em>押金 ¥{{ item.deposit_amount }}</em>
<small
>{{ item.min_rent_hours }}-{{ item.max_rent_hours }} 小时</small
>
</div>
</RouterLink>
</div>