feat: 更新提现功能,优化错误处理逻辑,添加成功提示信息,改进界面交互
This commit is contained in:
@@ -14,7 +14,7 @@ function handleWithdraw() {
|
||||
router.push("/withdraw/index");
|
||||
}
|
||||
|
||||
onUpdated(() => {
|
||||
onMounted(() => {
|
||||
walletStore.updateBalances();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang='ts' setup>
|
||||
import type { WithdrawBody } from "@/api/types";
|
||||
import { toastController } from "@ionic/vue";
|
||||
import { client, safeClient } from "@/api";
|
||||
import { AssetCodeEnum, ChainEnum, WithdrawMethodEnum } from "@/api/enum";
|
||||
|
||||
@@ -15,11 +16,12 @@ const [form, resetForm] = useResetRef<WithdrawBody>({
|
||||
chain: "BEP20",
|
||||
});
|
||||
const walletStore = useWalletStore();
|
||||
const { balances } = storeToRefs(walletStore);
|
||||
const { balances, bankAccounts } = storeToRefs(walletStore);
|
||||
const maxAmount = computed(() => {
|
||||
const balance = balances.value?.find(item => item.assetCode === form.value.assetCode);
|
||||
return balance ? balance.available : "0";
|
||||
});
|
||||
const router = useRouter();
|
||||
|
||||
function markTouched() {
|
||||
amountInputInst.value?.$el.classList.add("ion-touched");
|
||||
@@ -42,7 +44,17 @@ function handleCurrentChange() {
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
const { data } = await safeClient(() => client.api.withdraw.post(form.value));
|
||||
await safeClient(() => client.api.withdraw.post(form.value));
|
||||
const toast = await toastController.create({
|
||||
message: t("withdraw.successMessage"),
|
||||
duration: 2000,
|
||||
position: "bottom",
|
||||
color: "success",
|
||||
});
|
||||
|
||||
await toast.present();
|
||||
resetForm();
|
||||
router.back();
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -93,15 +105,19 @@ async function onSubmit() {
|
||||
@ion-blur="markTouched"
|
||||
/>
|
||||
|
||||
<ui-input-label
|
||||
<ion-select
|
||||
v-if="form.withdrawMethod === WithdrawMethodEnum.BANK"
|
||||
v-model="form.bankAccountId"
|
||||
interface="action-sheet"
|
||||
toggle-icon=""
|
||||
label-placement="floating"
|
||||
:label="t('withdraw.bankAccountId')"
|
||||
:placeholder="t('withdraw.enterBankAccountId')"
|
||||
type="text"
|
||||
inputmode="text"
|
||||
:error-text="t('withdraw.validBankAccountError')"
|
||||
/>
|
||||
>
|
||||
<ion-select-option v-for="item in bankAccounts" :key="item.id" :value="item.id">
|
||||
{{ item.bankName }} - **** **** **** {{ item.accountName.slice(-4) }}
|
||||
</ion-select-option>
|
||||
</ion-select>
|
||||
<template v-else-if="form.withdrawMethod === WithdrawMethodEnum.CRYPTO">
|
||||
<ion-radio-group v-model="form.chain">
|
||||
<ion-label class="text-sm">
|
||||
|
||||
Reference in New Issue
Block a user