소스 검색

feat: 修改

year 17 시간 전
부모
커밋
b1ec36c9a0
1개의 변경된 파일8개의 추가작업 그리고 3개의 파일을 삭제
  1. 8 3
      src/utils/index.ts

+ 8 - 3
src/utils/index.ts

@@ -67,9 +67,14 @@ export const isInStandaloneMode = () =>
     document.referrer.includes("android-app://");
 
 export const formatAmount = (amount?: string | number, fixed = 2) => {
-    if (!amount) return new BigNumber(0).toFormat(fixed);
-
-    return new BigNumber(amount).toFormat(fixed);
+    let toAmount: number | string = 0;
+    if (!!amount) {
+        toAmount = amount;
+    }
+    const base = new BigNumber(toAmount).toFormat(fixed);
+    let [integerPart, fractionalPart] = base.split(".");
+    integerPart = integerPart.replace(/\,/gi, ".");
+    return `${integerPart},${fractionalPart}`;
 };
 export const goBlankPage = async (handler: Function | string, target = "_self") => {
     const isFunHanlder = typeof handler === "function";