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! })