增加兑换游戏币前的输入框
This commit is contained in:
parent
acf9a2cf97
commit
dc280a3344
@ -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!
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user