删掉租期相关错误东西
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user