Browse Source

feat: 修改

year 10 hours ago
parent
commit
b1ec36c9a0
1 changed files with 8 additions and 3 deletions
  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";