删掉租期相关错误东西

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
@@ -18,7 +18,6 @@ import {
getListingSubtitle,
getListingTitle,
getLoginMethod,
getRentDays,
getServerRegion,
readAssetNumber,
readAssetString,
@@ -29,14 +28,12 @@ const router = useRouter();
const session = useSessionStore();
const loading = ref(false);
const ordering = ref(false);
const rentHours = ref(1);
const listing = ref<Listing | null>(null);
onMounted(async () => {
loading.value = true;
try {
listing.value = await fetchListing(String(route.params.id));
rentHours.value = Math.max(listing.value.min_rent_hours || 1, 1);
} catch {
showToast({ message: "加载失败", icon: "warning-o" });
} finally {
@@ -44,10 +41,9 @@ onMounted(async () => {
}
});
/* 预计租金 */
const totalRent = computed(() => {
const orderTotal = computed(() => {
if (!listing.value) return "0.00";
return (listing.value.price_hourly * rentHours.value).toFixed(2);
return getListingDisplayPrice(listing.value).toFixed(2);
});
const detailMetrics = computed(() => {
@@ -136,7 +132,7 @@ async function handleCreateOrder() {
ordering.value = true;
try {
const order = await createOrder(listing.value.id, rentHours.value);
await createOrder(listing.value.id);
showToast({ message: "订单已创建,账号已锁定", icon: "passed" });
await router.push(`/m/orders`);
} catch (error) {
@@ -255,10 +251,6 @@ function isNavActive(path: string) {
<span class="info-label">M单价</span>
<span class="info-text">{{ formatRatio(listing) }}</span>
</div>
<div class="info-line">
<span class="info-label">租期</span>
<span class="info-text">{{ getRentDays(listing) }}</span>
</div>
<div class="info-line">
<span class="info-label">常用登录地</span>
<span class="info-text">{{ assetRegions(listing).join("、") || "--" }}</span>
@@ -316,26 +308,9 @@ function isNavActive(path: string) {
<!-- 底部下单栏固定 -->
<div class="order-bar">
<div class="order-bar-left">
<div class="rent-control">
<button
class="rent-btn"
:disabled="rentHours <= listing.min_rent_hours"
@click="rentHours--"
>
</button>
<span class="rent-value">{{ rentHours }}小时</span>
<button
class="rent-btn"
:disabled="rentHours >= listing.max_rent_hours"
@click="rentHours++"
>
+
</button>
</div>
<div class="order-price">
<span class="price-label">租金</span>
<span class="price-amount">¥{{ totalRent }}</span>
<span class="price-label">价格</span>
<span class="price-amount">¥{{ orderTotal }}</span>
</div>
</div>
<van-button
@@ -528,7 +503,7 @@ function isNavActive(path: string) {
color: #ff5f00;
}
/* ========== 租期信息 ========== */
/* ========== 账号资料 ========== */
.info-line {
display: flex;
justify-content: space-between;
@@ -676,38 +651,6 @@ function isNavActive(path: string) {
gap: 2px;
}
.rent-control {
display: flex;
align-items: center;
gap: 6px;
}
.rent-btn {
width: 28px;
height: 28px;
display: grid;
place-items: center;
border: 1px solid #ddd;
border-radius: 6px;
background: #f5f7fa;
color: #333;
font-size: 16px;
font-weight: 700;
cursor: pointer;
}
.rent-btn:disabled {
opacity: 0.3;
cursor: not-allowed;
}
.rent-value {
font-size: 14px;
font-weight: 700;
min-width: 48px;
text-align: center;
}
.order-price {
display: flex;
align-items: baseline;
@@ -35,7 +35,7 @@ async function loadOrders() {
const statusTabs = [
{ key: "all", label: "全部" },
{ key: "pending_handoff", label: "待交接" },
{ key: "renting", label: "租赁中" },
{ key: "renting", label: "使用中" },
{ key: "pending_return_confirm", label: "待归还" },
{ key: "completed", label: "已完成" },
];
@@ -64,7 +64,7 @@ function statusColor(status: string) {
function statusLabel(status: string) {
const map: Record<string, string> = {
pending_handoff: "待交接",
renting: "租赁中",
renting: "使用中",
overdue: "已逾期",
pending_return_confirm: "待归还",
completed: "已完成",
@@ -138,11 +138,7 @@ function goDetail(id: number) {
<h3 class="order-title">{{ order.title }}</h3>
<div class="info-grid">
<div class="info-item">
<span class="info-label">租期</span>
<span class="info-value">{{ order.rent_hours }}小时</span>
</div>
<div class="info-item">
<span class="info-label">租金</span>
<span class="info-label">订单金额</span>
<span class="info-value price">¥{{ order.rent_amount }}</span>
</div>
<div class="info-item">
@@ -133,9 +133,6 @@ const calculatedFinalPrice = computed(() =>
const calculatedRatioText = computed(() =>
calculatedRatio.value > 0 ? `1:${formatNumber(calculatedRatio.value)}` : ""
);
const calculatedRentDays = computed(() =>
coinMAmount.value > 0 ? calculateRentDays(coinMAmount.value) : 0
);
onMounted(() => {
restoreDraft();
@@ -356,8 +353,7 @@ async function handleSubmit() {
loading.value = true;
try {
const title = `${form.server_region} ${form.rank_level} ${form.haf_coin_amount}M哈夫币`;
const rentDays = Math.max(calculatedRentDays.value, 1);
const dailyPrice = roundMoney(calculatedFinalPrice.value / rentDays);
const dailyPrice = calculatedFinalPrice.value;
const hourlyPrice = Math.max(roundMoney(dailyPrice / 24), 0.01);
await createListing({
@@ -373,8 +369,6 @@ async function handleSubmit() {
price_daily: dailyPrice,
price_weekly: roundMoney(dailyPrice * 7),
deposit_amount: Number(form.deposit_amount),
min_rent_hours: 24,
max_rent_hours: rentDays * 24,
});
localStorage.removeItem(draftKey);
showToast({ message: "发布成功", icon: "passed" });
@@ -402,7 +396,7 @@ function validateForm() {
if (form.deposit_amount === "" || Number(form.deposit_amount) < 0) {
return "请填写押金";
}
if (!calculatedFinalPrice.value || !calculatedRentDays.value) {
if (!calculatedFinalPrice.value) {
return "请完善币数、保险、体力和负重后再发布";
}
for (const item of screenshotSlots.value) {
@@ -426,6 +420,7 @@ function buildAssetSummary() {
face_owner: form.face_owner,
secret_kd: form.secret_kd,
fire_level: Number(form.fire_level),
publish_ratio: calculatedRatio.value,
season_insurance: form.season_insurance,
stamina_level: form.stamina_level,
load_level: form.load_level,
@@ -535,12 +530,6 @@ function getCoinCorrection(coinM: number) {
.find((item) => coinM > item.threshold_m)?.correction || 0;
}
function calculateRentDays(coinM: number) {
return [...ratioConfig.value.rent_rules]
.sort((a, b) => b.threshold_m - a.threshold_m)
.find((item) => coinM >= item.threshold_m)?.days || 1;
}
function formatNumber(value: number) {
return Number.isInteger(value) ? `${value}` : `${Math.round(value * 10) / 10}`;
}
@@ -795,7 +784,7 @@ function readError(error: unknown, fallback: string) {
/>
</div>
<p class="field-hint">
此在线时间指的是百分百能够联系上您的时间若是在此期间联系不上您导致无法上号会扣除您的部分租金或上架押金在线时长太短可能无法上架请预留充足时间用于扫码以及冻结人脸请谨慎填写
此在线时间指的是百分百能够联系上您的时间若是在此期间联系不上您导致无法上号会扣除您的部分订单金额或上架押金在线时长太短可能无法上架请预留充足时间用于扫码以及冻结人脸请谨慎填写
</p>
<van-field label="封禁记录" required class="publish-field">
+7 -23
View File
@@ -27,38 +27,24 @@ export function formatHafCoinM(amountWan: number) {
}
export function getListingDisplayPrice(item: Listing) {
const rentDays = getRentDays(item);
if (rentDays > 0 && item.price_daily > 0) {
return roundMoney(item.price_daily * rentDays);
}
return Number(item.price_daily || item.price_hourly || 0);
}
export function getRentDays(item: Listing) {
if (item.max_rent_hours >= 24) return Math.max(Math.round(item.max_rent_hours / 24), 1);
return 1;
}
export function getRatioValue(item: Listing) {
const ratio = readAssetNumber(item, "publish_ratio");
if (ratio > 0) return ratio;
const price = getListingDisplayPrice(item);
if (price <= 0) return 0;
return getCoinWan(item) / price;
}
export function formatRatio(item: Listing) {
const pricePerM = getPricePerM(item);
return pricePerM > 0 ? `1M=¥${formatMoney(pricePerM)}` : "--";
const ratio = getRatioValue(item);
return ratio > 0 ? `1:${formatRatioNumber(ratio)}` : "--";
}
export function getValuePerYuanText(item: Listing) {
const pricePerM = getPricePerM(item);
return pricePerM > 0 ? `1M=¥${formatMoney(pricePerM)}` : "";
}
export function getPricePerM(item: Listing) {
const coinM = getCoinM(item);
if (coinM <= 0) return 0;
return roundMoney(getListingDisplayPrice(item) / coinM);
return formatRatio(item);
}
export function getLoginMethod(item: Listing) {
@@ -83,9 +69,7 @@ export function getListingTitle(item: Listing) {
}
export function getListingSubtitle(item: Listing) {
return [getValuePerYuanText(item), `租期${getRentDays(item)}`]
.filter(Boolean)
.join(" ");
return getValuePerYuanText(item);
}
export function getListingChips(item: Listing): ListingDisplayChip[] {
@@ -225,7 +209,7 @@ function roundMoney(value: number) {
return Math.round(value * 100) / 100;
}
function formatMoney(value: number) {
function formatRatioNumber(value: number) {
const rounded = roundMoney(value);
return Number.isInteger(rounded) ? `${rounded}` : rounded.toFixed(2);
}