Files
2026-05-09 16:40:29 +08:00

26 lines
601 B
JavaScript

export const formatSpotPrice = (spot) => {
if (!spot) {
return { label: "", isFree: false };
}
if (spot.is_free) {
return { label: "免费", isFree: true };
}
const min = spot.price_min;
const max = spot.price_max;
if (min != null && max != null) {
if (Number(min) === Number(max)) {
return { label: `收费 ¥${min}`, isFree: false };
}
return { label: `收费 ¥${min} - ¥${max}`, isFree: false };
}
if (min != null || max != null) {
return { label: `收费 ¥${min ?? max}`, isFree: false };
}
return { label: "收费", isFree: false };
};