feat: 对接了权益中心的接口

This commit is contained in:
zoujing committed 2026-09-18 15:37:13 +08:00
1 parent db5e9453cd
commit dd0341d76f
15 files changed
+70 -8168

No files matched your search

+23 -3
View File
@@ -36,14 +36,32 @@ export const priceText = (val) => {
return Number.isInteger(n) ? String(n) : n.toFixed(2).replace(/0+$/, "").replace(/\.$/, "");
};
/** 折扣率文案(接口直给折扣,如 8 → 8 折;缺失或非法为空) */
/**
* 折扣文案:接口直给 `price.offer_label`(如「8折」),缺省回落到数字 `rate`(8 → 8 折)。
* 入参传整个 price 对象(推荐)或旧式数字。
*/
export const rateText = (val) => {
if (val === null || val === undefined || val === "") return "";
const n = Number(val);
const o = val && typeof val === "object" ? val : null;
const label = o ? String(o.offer_label || "").trim() : "";
if (label) return label;
const raw = o ? o.rate : val;
if (raw === null || raw === undefined || raw === "") return "";
const n = Number(raw);
if (Number.isNaN(n) || n <= 0) return "";
return `${priceText(n)} 折`;
};
/** 折扣前缀(「门市价」等):接口 `price.basis` 有值才展示,空则不显示 */
export const basisText = (price) => String((price && price.basis) || "").trim();
/** 分 → 元文案(接口 price.deal / price.original 的单位是分,15800 → 158) */
export const yuanText = (val) => {
if (val === null || val === undefined || val === "") return "";
const n = Number(val);
if (Number.isNaN(n)) return "";
return priceText(n / 100);
};
/**
* 手机号中间四位打码
* 接口只回 `phone_masked`(形如 `+86138****8000`),先去掉 +86 国码;
@@ -98,6 +116,8 @@ export default {
discountLabel,
priceText,
rateText,
basisText,
yuanText,
maskPhone,
cnDate,
uid,