<div class="form-item">
<label class="form-item-label">{{ $t('transfer.asset') }}</label>
<div class="form-item-content" >
- <v-select :options="assets" v-bind:colorBlack="true" :clearable="false" :value="selectAsset" :onChange="assetChange" label="asset">
+ <v-select :options="assets" v-bind:colorBlack="true" :clearable="false" :value="selectAsset" :onChange="assetChange" label="assetId">
<template slot="selected-option" slot-scope="asset">
<div class="asset-option">
<div>{{asset.symbol || 'Asset'}}</div>
- <div class="color-grey asset-id">{{shortAddress(asset.asset)}}</div>
+ <div class="color-grey asset-id">{{shortAddress(asset.assetId)}}</div>
</div>
</template>
<template slot="option" slot-scope="asset">
<div class="asset-option">
<div>{{asset.symbol || 'Asset'}}</div>
- <div class="color-grey asset-id">{{shortAddress(asset.asset)}}</div>
+ <div class="color-grey asset-id">{{shortAddress(asset.assetId)}}</div>
</div>
</template>
</v-select>
</div>
<div class="form-item">
<label class="form-item-label">{{ $t('transfer.address') }}</label>
- <div class="form-item-content" >
- <input type="text" v-model="transaction.to">
- </div>
+ <input class="form-item-content" type="text" v-model="transaction.to">
</div>
<div class="form-item">
- <label class="form-item-label">
+ <label class="form-item-label" for="tx-amount">
{{ $t('transfer.quantity') }}
<small class="float-right" style="margin-right: 8px;">{{formatCurrency(transaction.cost||0)}}</small>
</label>
<div class="form-item-content" style=" display: flex;">
- <input type="number" v-model="transaction.amount" placeholder="0" @keypress="limitAmount">
+ <input type="number" id="tx-amount" v-model="transaction.amount" placeholder="0" @keypress="limitAmount">
<span class="color-grey" style="font-size: 15px;position: absolute;right: 0;text-transform: uppercase;">{{unit}}</span>
</div>
</div>
import _ from 'lodash'
const currencyInPrice = {
- inCny: 'cny_price',
- inUsd: 'usd_price',
- inBtc:'btc_price'
+ in_cny: 'cnyPrice',
+ in_usd: 'usdPrice',
+ in_btc:'btcPrice',
+ inCny: 'cnyPrice',
+ inUsd: 'usdPrice',
+ inBtc:'btcPrice'
}
export default {
data() {
return {
selectAsset: {
- asset: BTM,
+ assetId: BTM,
symbol: "BTM",
decimals:8
},
show: false,
+ address: null,
guid: null,
account: {},
accountBalance: 0.00,
if(!this.currentAccount.vpBalances ||this.currentAccount.vpBalances.length == 0){
return [this.selectAsset]
}else{
- return this.currentAccount.vpBalances
+ return this.currentAccount.vpBalances.map(b=>b.asset)
}
}else{
if(!this.currentAccount.balances ||this.currentAccount.balances.length == 0){
return [this.selectAsset]
}else{
- return this.currentAccount.balances
+ return this.currentAccount.balances.map(b=>b.asset)
}
}
},
},
account: function (newAccount) {
this.guid = newAccount.guid;
+ this.address = this.netType === 'vapor'? newAccount.vpAddress: newAccount.address;
},
- guid: function (newGuid) {
- this.accountList.forEach(account => {
- if (account.guid == newGuid.guid) {
- this.account = account;
- return;
- }
- });
-
- account.balance(newGuid).then(obj => {
+ address: function (newAddress) {
+ account.balance(newAddress).then(obj => {
const balances = obj.balances
let balance = 0.00
if(balances.length >0 ) {
- const balanceObject = balances.filter(b => b.asset === this.selectAsset.asset)[0]
+ const balanceObject = balances.filter(b => b.asset.assetId === this.selectAsset.assetId)[0]
balance = Num.formatNue(balanceObject.balance, balanceObject.decimals)
}
this.accountBalance = balance;
}
},
assetChange: function (val) {
- if(val.asset !== this.selectAsset.asset){
- this.transaction.asset = val.asset;
+ console.log(val)
+ if(val.assetId !== this.selectAsset.assetId){
+ this.transaction.asset = val.assetId;
const balances = this.netType === 'vapor'?this.currentAccount.vpBalances:this.currentAccount.balances
let balance = 0.00
if(balances.length >0 ) {
- const balanceObject = balances.filter(b => b.asset === val.asset)[0]
- balance = Num.formatNue(balanceObject.balance, balanceObject.decimals)
+ console.log(balances)
+ const balanceObject = balances.filter(b => b.asset.assetId === val.assetId)[0]
+ balance = balanceObject.balance
}
this.accountBalance = balance;
- transaction.asset(val.asset).then(ret => {
+
+ transaction.asset(val.assetId).then(ret => {
+ console.log(ret)
this.selectAsset = Object.assign(ret,val)
this.transaction.cost = Number(ret[currencyInPrice[this.currency]] * this.transaction.amount).toFixed(2);
});
canCancel: true,
onCancel: this.onCancel
});
- transaction.build(this.account.guid, this.transaction.to, this.transaction.asset, Num.convertToNue(this.transaction.amount,this.selectAsset.decimals), this.transaction.fee, this.transaction.confirmations).then(result => {
+ transaction.build(this.address, this.transaction.to, this.transaction.asset, this.transaction.amount, this.transaction.fee, this.transaction.confirmations).then(result => {
+ console.log(result)
loader.hide();
if(!this.transaction.fee){
- this.transaction.fee = Number( _.sumBy(result, 'fee'));
+ this.transaction.fee = Number( _.sumBy(result, 'tx.fee'));
}
this.$router.push({ name: 'transfer-confirm', params: { account: this.account, transaction: this.transaction, rawData: result, assetAlias: this.selectAsset.symbol, type: this.$route.query.type } })
}).catch(error => {
}else{
this.account = this.currentAccount
- const currentAsset = this.currentAccount.balances[0]
+ const currentAsset = this.netType === 'vapor'? this.currentAccount.vpBalances[0]: this.currentAccount.balances[0]
if(currentAsset){
- transaction.asset(currentAsset.asset).then(ret => {
+ transaction.asset(currentAsset.asset.assetId).then(ret => {
this.selectAsset = Object.assign(ret,currentAsset)
});
}