From dc280a334499f5f956529e3c83bab037cdbd6742 Mon Sep 17 00:00:00 2001 From: cebgcontract <99630598+cebgcontract@users.noreply.github.com> Date: Fri, 18 Mar 2022 16:58:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=91=E6=8D=A2=E6=B8=B8?= =?UTF-8?q?=E6=88=8F=E5=B8=81=E5=89=8D=E7=9A=84=E8=BE=93=E5=85=A5=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/market/wallet/WalletPanel.vue | 41 +++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/components/market/wallet/WalletPanel.vue b/src/components/market/wallet/WalletPanel.vue index 95c080d..1df3351 100644 --- a/src/components/market/wallet/WalletPanel.vue +++ b/src/components/market/wallet/WalletPanel.vue @@ -213,9 +213,48 @@ export default class WalletPanel extends Vue { async onCardClicked(data: ICoinData) { console.log('on coin card clicked: ', data) + let value + try { + const msgData: any = await this.$prompt('Please input amount to deposit', 'Info', { + confirmButtonText: 'CONFIRM', + cancelButtonText: 'CANCEL', + inputPattern: /\d/, + inputErrorMessage: 'coin amount', + inputValidator: (val: any) => { + if (isNaN(val)) { + return 'amount should be number' + } else if (parseInt(val) > parseInt(data.amount + '')) { + return `amount must lower than ${data.amount}` + } + return true + } + }) + value = msgData.value + } catch (err) { + this.$message({ + type: 'info', + message: 'User cancel' + }) + } + if (!value) { + return + } + + try { + await this.beginTransfer(data, parseInt(value)) + } catch (err) { + console.log(err) + this.$message({ + type: 'info', + message: 'error transfer' + }) + } + } + + async beginTransfer(data: ICoinData, amount: number) { const res = await this.chainManager.transferToAccount({ to: '0x42448C6a38c08637218D8327b748F213fC2c0231', - amount: 1, + amount: amount, chainId: data.chain!, address: data.address! })