Browse Source

Merge branch 'v1.5' into v1.5_0711

year 1 week ago
parent
commit
7c1449be16

+ 8 - 4
src/app/[locale]/(TabBar)/deposit/component/deposit/index.module.scss

@@ -11,9 +11,9 @@
         padding-left: 0 !important;
     }
     :global(.adm-list-item-content-main) {
-        padding: 0.08rem 0;
-        display: flex;
-        align-items: center;
+        // padding: 0.08rem 0;
+        // display: flex;
+        // align-items: center;
     }
     :global(.adm-form-item-feedback-error) {
         font-size: 0.1rem;
@@ -21,6 +21,9 @@
     :global(.adm-list-item-content) {
         border: none !important;
     }
+    :global(.adm-form-item-required-asterisk) {
+        display: none;
+    }
     :global(.adm-list-item-content-prefix) {
         width: auto !important;
         padding-right: 0 !important;
@@ -135,8 +138,9 @@
 }
 
 .amontForm {
-    background-color: #1f2830;
+    background-color: #1f2830 !important;
     border-radius: 0.15rem;
+    // border-bottom: 1px solid #111;
 }
 .products {
     display: grid;

+ 47 - 4
src/app/[locale]/(TabBar)/deposit/component/deposit/index.tsx

@@ -13,7 +13,7 @@ import { useEventPoint } from "@/hooks/useEventPoint";
 import { useRouter } from "@/i18n/routing";
 import { useSystemStore } from "@/stores/useSystemStore";
 import { useWalletStore } from "@/stores/useWalletStore";
-import { goBlankPage } from "@/utils";
+import { goBlankPage, inputNumber } from "@/utils";
 import { Button, Dialog, Form, Input, Toast } from "antd-mobile";
 import BigNumber from "bignumber.js";
 import clsx from "clsx";
@@ -200,7 +200,13 @@ const Deposit = () => {
             if (!confirmRes) return;
         }
 
-        if (!amount) return Toast.show({ content: t("form.amount") });
+        if (new BigNumber(amount).isLessThan(shopType.condition.min)) {
+            let msg = t("form.amountMinReg", { amount: shopType.condition.min });
+            return Toast.show({ content: msg });
+        }
+        if (!amount) {
+            return Toast.show({ content: t("form.amount") });
+        }
 
         handleUserRecharge(false);
     };
@@ -256,6 +262,36 @@ const Deposit = () => {
         }
     };
 
+    const valuesChange = (data: any) => {
+        for (let key in data) {
+            switch (key) {
+                case "amount":
+                    {
+                        let curValue = data[key].trim();
+                        let max = shopType.condition.max;
+                        if (curValue > max) {
+                            curValue = new BigNumber(max).toFixed(0, BigNumber.ROUND_DOWN);
+                        }
+                        const toValue = inputNumber(curValue, { max });
+                        setAmount(toValue);
+                        formInstanceRef.current?.setFieldValue(key, toValue);
+                    }
+                    break;
+                case "passport":
+                    {
+                        let curValue = data[key].trim();
+                        const toValue = inputNumber(curValue, { length: 11, notNumber: true });
+                        formInstanceRef.current?.setFieldValue(key, toValue);
+                    }
+                    break;
+                default:
+                    let curValue = data[key].trim();
+                    formInstanceRef.current?.setFieldValue(key, curValue);
+                    break;
+            }
+        }
+    };
+
     return (
         <>
             <div className={styles.depositePage}>
@@ -296,7 +332,12 @@ const Deposit = () => {
                         ))}
                     </Swiper>
                 </div>
-                <Form className="mt-[.1rem]" ref={formInstanceRef} onFinish={onFinish}>
+                <Form
+                    className="mt-[.1rem]"
+                    ref={formInstanceRef}
+                    onFinish={onFinish}
+                    onValuesChange={valuesChange}
+                >
                     {formProd && (
                         <Form.Item
                             name="amount"
@@ -315,7 +356,6 @@ const Deposit = () => {
                             <Input
                                 type={"text"}
                                 className={styles.amountInput}
-                                max={shopType?.condition?.max}
                                 onChange={inputChange}
                                 placeholder={`${shopType?.condition?.min}-${shopType?.condition?.max}`}
                             />
@@ -367,6 +407,7 @@ const Deposit = () => {
                                     name="name"
                                     label="Nome"
                                     className="mr-[.2rem] w-[1.5rem] border-b-[1px] border-[#3b4852]"
+                                    rules={[{ required: true }]}
                                 >
                                     <Input type={"text"} placeholder="Insira seu nome " />
                                 </Form.Item>
@@ -374,6 +415,7 @@ const Deposit = () => {
                                     name="lastname"
                                     label="Sobrenome"
                                     className="flex-1 border-b-[1px] border-[#3b4852]"
+                                    rules={[{ required: true }]}
                                 >
                                     <Input type={"text"} placeholder="Insira seu sobrenome" />
                                 </Form.Item>
@@ -382,6 +424,7 @@ const Deposit = () => {
                                 name="passport"
                                 label="CPF ID"
                                 className="border-b-[1px] border-[#3b4852]"
+                                rules={[{ required: true }]}
                             >
                                 <Input type={"text"} placeholder="Seu CPF(000.000.000-00)" />
                             </Form.Item>

+ 3 - 2
src/app/[locale]/(TabBar)/deposit/component/withdraw/index.module.scss

@@ -61,7 +61,7 @@
     }
 }
 .amontForm {
-    background-color: #1f2830;
+    background-color: #1f2830 !important;
     border-radius: 0.15rem;
 }
 .withdrawTitle {
@@ -130,7 +130,8 @@
     }
 }
 .todos {
-    height: 100%;
+    margin-top: 4%;
+    height: 90%;
     background-color: #11de68;
     border-radius: 0.1rem;
     display: flex;

+ 1 - 30
src/app/[locale]/(TabBar)/deposit/component/withdraw/index.tsx

@@ -9,7 +9,7 @@ import { useRouter } from "@/i18n/routing";
 import { useSystemStore } from "@/stores/useSystemStore";
 import { useUserInfoStore } from "@/stores/useUserInfoStore";
 import { useWalletStore } from "@/stores/useWalletStore";
-import { isEmail } from "@/utils";
+import { inputNumber, isEmail } from "@/utils";
 import { server } from "@/utils/client";
 import { percentage } from "@/utils/methods";
 import { Button, Form, Input, ProgressBar, Toast } from "antd-mobile";
@@ -166,35 +166,6 @@ const Withdraw = () => {
         }
     };
 
-    const inputNumber = (
-        value: string,
-        opts?: {
-            max?: number;
-            length?: number;
-            notNumber?: boolean;
-            fixed?: number;
-        }
-    ) => {
-        const toValue = value.replace(/[^0-9]/gi, "");
-        let toAmount = "";
-        let toFixedNum = opts?.fixed ? opts?.fixed : 0;
-        if (toValue && !opts?.notNumber) {
-            toAmount = new BigNumber(toValue).toFixed(toFixedNum, BigNumber.ROUND_DOWN);
-            if (opts?.max !== undefined && new BigNumber(toAmount).isGreaterThan(opts.max)) {
-                toAmount = new BigNumber(opts.max).toFixed(toFixedNum, BigNumber.ROUND_DOWN);
-            }
-        }
-        if (toValue && opts?.notNumber) {
-            toAmount = toValue;
-        }
-
-        if (opts?.length && toAmount.length > opts.length) {
-            toAmount = toAmount.slice(0, opts.length);
-        }
-
-        return toAmount;
-    };
-
     const ChannelValidator = (rules: any, value: string) => {
         if (!value) return Promise.reject(new Error(t("WithdrawPage.channel")));
         if (currentType.type === ChannelEnum.CPF) {

+ 10 - 4
src/dialog/auto.ts

@@ -132,6 +132,7 @@ const AutoShowDialog = () => {
 
         for (let i = startShow; i < data.length; i++) {
             const curData = data[i];
+            if (pathName !== "/") return;
             if (!checkIsCanShow(curData)) {
                 saveShowIndex(i);
                 continue;
@@ -142,18 +143,18 @@ const AutoShowDialog = () => {
             // await dialogManage.showDialog('SignInSection', curData);  //签到
             // await dialogManage.showDialog("SignInSection", curData);
             try {
+                let res: any = "";
                 switch (curData.content_type) {
                     // 图片展示
                     case 1:
-                        await dialogManage.showDialog("ImgDialog", curData);
+                        res = await dialogManage.showDialog("ImgDialog", curData);
                         break;
                     // 富文本展示
                     case 2:
-                        await dialogManage.showDialog("TextDialog", curData);
+                        res = await dialogManage.showDialog("TextDialog", curData);
                         break;
                     case 3:
                         // 轮盘特殊处理 dialogManage.showDialog('WheelSection')
-
                         if (curData?.action_params?.includes("WheelSection")) {
                             await wheelState.setWheel();
                             if (wheelState.status != 1) {
@@ -161,10 +162,15 @@ const AutoShowDialog = () => {
                             }
                         }
                         if (curData.action_type === 5) {
-                            curData?.action_params ? await eval(curData?.action_params || "") : "";
+                            res = curData?.action_params
+                                ? await eval(curData?.action_params || "")
+                                : "";
                         }
                         break;
                 }
+                if (res === "target") {
+                    return;
+                }
             } catch (err) {
                 saveShowIndex(i);
                 continue;

+ 8 - 1
src/dialog/img/index.tsx

@@ -71,7 +71,9 @@ const ImgDialog = () => {
                 if (data.activity_id) {
                     path = `${data.action_params}?activity_id=${data.activity_id}`;
                 }
-                if (path) router.push(path);
+                if (path) {
+                    router.push(path);
+                }
                 break;
             case 4:
                 if (data.action_params === ModalEnum.red_packet) {
@@ -87,6 +89,11 @@ const ImgDialog = () => {
             default:
                 break;
         }
+        setInnerVisible(false);
+        setTimeout(() => {
+            handler.hide();
+            dialogManage.goTarget(keyName);
+        }, 250);
     };
 
     return (

+ 8 - 2
src/dialog/manager.ts

@@ -13,7 +13,6 @@ class DialogManage {
         this._dialogs = new Map();
         this._resolves = new Map();
     }
-
     registerDialog({ key, show, hide }: RegisterParams) {
         this._dialogs.set(key, {
             key,
@@ -27,7 +26,6 @@ class DialogManage {
     showDialog(key: string, ...args: any[]) {
         return new Promise((resolve) => {
             const dialog = this._dialogs.get(key);
-
             if (dialog?.show) {
                 const res = dialog.show(...args);
                 if (res === "close") {
@@ -53,6 +51,14 @@ class DialogManage {
             this._resolves.delete(key);
         }
     }
+    goTarget(key: string) {
+        // const dialog = this._dialogs.get(key);
+        let resolveFun = this._resolves.get(key);
+        if (resolveFun && typeof resolveFun === "function") {
+            resolveFun("target");
+            this._resolves.delete(key);
+        }
+    }
 }
 
 const dialogManage = new DialogManage();

+ 4 - 0
src/dialog/text/index.tsx

@@ -60,6 +60,10 @@ const ImgDialog = () => {
             default:
                 break;
         }
+        setTimeout(() => {
+            handler.hide();
+            dialogManage.goTarget(keyName);
+        }, 250);
     };
 
     return (

+ 28 - 0
src/utils/index.ts

@@ -123,3 +123,31 @@ export const commonMask = {
         }
     },
 };
+export const inputNumber = (
+    value: string,
+    opts?: {
+        max?: number;
+        length?: number;
+        notNumber?: boolean;
+        fixed?: number;
+    }
+) => {
+    const toValue = value.replace(/[^0-9]/gi, "");
+    let toAmount = "";
+    let toFixedNum = opts?.fixed ? opts?.fixed : 0;
+    if (toValue && !opts?.notNumber) {
+        toAmount = new BigNumber(toValue).toFixed(toFixedNum, BigNumber.ROUND_DOWN);
+        if (opts?.max !== undefined && new BigNumber(toAmount).isGreaterThan(opts.max)) {
+            toAmount = new BigNumber(opts.max).toFixed(toFixedNum, BigNumber.ROUND_DOWN);
+        }
+    }
+    if (toValue && opts?.notNumber) {
+        toAmount = toValue;
+    }
+
+    if (opts?.length && toAmount.length > opts.length) {
+        toAmount = toAmount.slice(0, opts.length);
+    }
+
+    return toAmount;
+};