26 lines
601 B
JavaScript
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 };
|
|
};
|