From 61cbcce579f1df74ce825545334de415945e30f5 Mon Sep 17 00:00:00 2001 From: Seven Date: Wed, 17 Dec 2025 15:59:11 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E9=AA=8C=E8=AF=81=E8=A7=84=E5=88=99=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7=E8=BE=93=E5=85=A5=E4=BD=93?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/en-US.json | 14 ++- src/locales/zh-CN.json | 14 ++- src/views/withdraw/index.vue | 229 ++++++++++++++++++++--------------- src/views/withdraw/rules.ts | 41 +++++++ 4 files changed, 197 insertions(+), 101 deletions(-) diff --git a/src/locales/en-US.json b/src/locales/en-US.json index fd2beb6..5e4efeb 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -40,7 +40,19 @@ "enterCryptoAddress": "Enter the crypto address", "validCryptoAddressError": "Please enter a valid crypto address.", "successMessage": "Withdrawal request submitted successfully!", - "submit": "Submit" + "submit": "Submit", + "validation": { + "assetCodeRequired": "Please select a currency", + "amountRequired": "Please enter an amount", + "amountInvalid": "Please enter a valid number format", + "amountExceedsBalance": "Amount cannot exceed available balance", + "amountTooSmall": "Amount must be greater than 0", + "methodRequired": "Please select a withdrawal method", + "bankAccountRequired": "Please select a bank account", + "chainRequired": "Please select a blockchain network", + "addressRequired": "Please enter a withdrawal address", + "addressTooShort": "Address format is incorrect, too short" + } }, "bankCard": { "management": "Bank Card Management", diff --git a/src/locales/zh-CN.json b/src/locales/zh-CN.json index e4593fb..ff742e8 100644 --- a/src/locales/zh-CN.json +++ b/src/locales/zh-CN.json @@ -40,7 +40,19 @@ "enterCryptoAddress": "请输入加密货币地址", "validCryptoAddressError": "请输入有效的加密货币地址。", "successMessage": "提现申请提交成功!", - "submit": "提交" + "submit": "提交", + "validation": { + "assetCodeRequired": "请选择货币", + "amountRequired": "请输入金额", + "amountInvalid": "请输入有效的数字格式", + "amountExceedsBalance": "金额不能超过可用余额", + "amountTooSmall": "金额必须大于0", + "methodRequired": "请选择提现方式", + "bankAccountRequired": "请选择银行账户", + "chainRequired": "请选择区块链网络", + "addressRequired": "请输入提现地址", + "addressTooShort": "地址格式不正确,长度过短" + } }, "bankCard": { "management": "银行卡管理", diff --git a/src/views/withdraw/index.vue b/src/views/withdraw/index.vue index 47b2a65..d8411b5 100644 --- a/src/views/withdraw/index.vue +++ b/src/views/withdraw/index.vue @@ -1,50 +1,35 @@ @@ -69,80 +53,127 @@ async function onSubmit() { -
- - - {{ t("withdraw.chooseCurrency") }} - - - - {{ item }} - - - +
+
+
+ + + + +
- - - {{ t("withdraw.chooseMethod") }} - - - - {{ item }} - - - +
+ + + + +
- + + + + +
+ + + + +
+ + + {{ t("withdraw.submit") }} + +
+
diff --git a/src/views/withdraw/rules.ts b/src/views/withdraw/rules.ts index e69de29..492e0ca 100644 --- a/src/views/withdraw/rules.ts +++ b/src/views/withdraw/rules.ts @@ -0,0 +1,41 @@ +import { toTypedSchema } from "@vee-validate/yup"; +import * as yup from "yup"; +import { WithdrawMethodEnum } from "@/api/enum"; + +export function createWithdrawSchema(t: (key: string, params?: any) => string, maxAmount: string) { + return toTypedSchema( + yup.object({ + assetCode: yup.string().required(t("withdraw.validation.assetCodeRequired")), + amount: yup + .string() + .required(t("withdraw.validation.amountRequired")) + .test("is-number", t("withdraw.validation.amountInvalid"), value => { + return /^\d+(\.\d+)?$/.test(value || ""); + }) + .test("max-amount", t("withdraw.validation.amountExceedsBalance"), value => { + if (!value || maxAmount === "0") return false; + return parseFloat(value) <= parseFloat(maxAmount); + }) + .test("min-amount", t("withdraw.validation.amountTooSmall"), value => { + if (!value) return false; + return parseFloat(value) > 0; + }), + withdrawMethod: yup.string().required(t("withdraw.validation.methodRequired")), + bankAccountId: yup.string().when("withdrawMethod", { + is: WithdrawMethodEnum.BANK, + then: (schema) => schema.required(t("withdraw.validation.bankAccountRequired")), + otherwise: (schema) => schema.optional(), + }), + chain: yup.string().when("withdrawMethod", { + is: WithdrawMethodEnum.CRYPTO, + then: (schema) => schema.required(t("withdraw.validation.chainRequired")), + otherwise: (schema) => schema.optional(), + }), + toAddress: yup.string().when("withdrawMethod", { + is: WithdrawMethodEnum.CRYPTO, + then: (schema) => schema.required(t("withdraw.validation.addressRequired")).min(10, t("withdraw.validation.addressTooShort")), + otherwise: (schema) => schema.optional(), + }), + }), + ); +} \ No newline at end of file