17 .balance .token-icon {
22 .balance .token-amount {
23 display: inline-block;
25 .balance .token-amount .asset {
28 text-transform: uppercase;
48 background-image: url("../../assets/img/backgroundHead/transfer.svg");
49 background-size: 320px 80px;
54 background: rgba(255,255,255,0.1);
64 text-transform: uppercase;
67 .asset-option .asset-id{
74 background: rgba(247,247,247,1);
77 border-bottom: 1px solid #E0E0E0;
83 <div class="warp-chlid bg-gray">
84 <section class="header bg-header">
85 <i class="iconfont icon-back" @click="close"></i>
86 <p>{{ $t('main.send') }}</p>
89 <section class="balance transfer-header">
91 <i class="iconfont icon-wallet"></i>
94 <div class="token-amount">
96 <span v-if="selectAsset.symbol" class="asset">{{selectAsset.symbol}}</span>
98 <div class="small color-grey">
99 {{currentAccount.alias}}
104 <section class="form-container">
105 <div class="form bg-white">
106 <div class="form-item">
107 <label class="form-item-label">{{ $t('transfer.asset') }}</label>
108 <div class="form-item-content" >
109 <v-select :options="assets" v-bind:colorBlack="true" :clearable="false" :value="selectAsset" :onChange="assetChange" label="assetId">
110 <template slot="selected-option" slot-scope="asset">
111 <div class="asset-option">
112 <div>{{asset.symbol || 'Asset'}}</div>
113 <div class="color-grey asset-id">{{shortAddress(asset.assetId)}}</div>
116 <template slot="option" slot-scope="asset">
117 <div class="asset-option">
118 <div>{{asset.symbol || 'Asset'}}</div>
119 <div class="color-grey asset-id">{{shortAddress(asset.assetId)}}</div>
125 <div class="form-item">
126 <label class="form-item-label">{{ $t('transfer.address') }}</label>
127 <input class="form-item-content" type="text" v-model="transaction.to">
129 <div class="form-item">
130 <label class="form-item-label" for="tx-amount">
131 {{ $t('transfer.quantity') }}
133 <small class="float-right" style="margin-right: 8px;">{{formatCurrency(transaction.cost||0)}}</small>
135 <div class="form-item-content" style=" display: flex;">
136 <input type="number" id="tx-amount" v-model="transaction.amount" placeholder="0" @keypress="limitAmount">
137 <span class="color-grey" style="font-size: 15px;position: absolute;right: 0;text-transform: uppercase;">{{unit}}</span>
140 <div class="form-item">
141 <label class="form-item-label">{{ $t('transfer.fee') }}</label>
142 <div class="form-item-content" >
143 <!--<v-select :clearable="false" v-model="fee" style="height: 32px;" :options="feeTypeOptions"></v-select>-->
144 <input type="text" v-model="fee" disabled >
148 <a class="btn btn-primary" @click="send">{{ $t('transfer.send') }}</a>
154 import address from "@/utils/address";
155 import account from "@/models/account";
156 import transaction from "@/models/transaction";
157 import getLang from "@/assets/language/sdk";
158 import Confirm from "./transferConfirm";
159 import { BTM } from "@/utils/constants";
160 import { Number as Num } from "@/utils/Number"
161 import { mapActions, mapGetters, mapState } from 'vuex'
162 import * as Actions from '@/store/constants';
163 import _ from 'lodash'
165 const currencyInPrice = {
189 accountBalance: 0.00,
190 fee: this.$t("transfer.feeType"),
191 feeTypeOptions: [this.$t("transfer.feeType")],
204 if(this.netType === 'vapor'){
205 if(!this.currentAccount.vpBalances ||this.currentAccount.vpBalances.length == 0){
206 return [this.selectAsset]
208 return this.currentAccount.vpBalances.map(b=>b.asset)
211 if(!this.currentAccount.balances ||this.currentAccount.balances.length == 0){
212 return [this.selectAsset]
214 return this.currentAccount.balances.map(b=>b.asset)
219 return this.selectAsset.symbol;
232 "transaction.amount": function (newAmount) {
233 const singlePrice = this.selectAsset[currencyInPrice[this.currency]]||this.selectAsset[this.currency]||0
234 this.transaction.cost = Number( singlePrice * newAmount).toFixed(2);
236 account: function (newAccount) {
237 this.guid = newAccount.guid;
238 this.address = this.netType === 'vapor'? newAccount.vpAddress: newAccount.address;
240 address: function (newAddress) {
241 account.balance(newAddress).then(obj => {
242 const balances = obj.balances
244 if(balances.length >0 ) {
245 const balanceObject = balances.filter(b => b.asset.assetId === this.selectAsset.assetId)[0]
246 balance = Num.formatNue(balanceObject.balance, balanceObject.decimals)
248 this.accountBalance = balance;
255 shortAddress: function (add) {
256 return address.short(add)
258 formatCurrency: function (num) {
259 return Num.formatCurrency(num, this.currency)
261 limitAmount ($event) {
262 // restrict to 2 decimal places
263 if(this.transaction.amount!=null && this.transaction.amount.indexOf(".")>-1 && (this.transaction.amount.split('.')[1].length > (this.selectAsset.decimals-1))){
264 $event.preventDefault();
267 assetChange: function (val) {
269 if(val.assetId !== this.selectAsset.assetId){
270 this.transaction.asset = val.assetId;
271 const balances = this.netType === 'vapor'?this.currentAccount.vpBalances:this.currentAccount.balances
273 if(balances.length >0 ) {
274 console.log(balances)
275 const balanceObject = balances.filter(b => b.asset.assetId === val.assetId)[0]
276 balance = balanceObject.balance
278 this.accountBalance = balance;
280 transaction.asset(val.assetId).then(ret => {
282 this.selectAsset = Object.assign(ret,val)
283 this.transaction.cost = Number(ret[currencyInPrice[this.currency]] * this.transaction.amount).toFixed(2);
289 this.transaction.to = "";
290 this.transaction.amount = "";
291 if(this.$route.query.type == 'popup'){
296 if (this.transaction.to == "") {
298 body: this.$t("transfer.emptyTo")
303 if (this.transaction.amount <= 0) {
305 body: this.$t("transfer.noneBTM")
310 let loader = this.$loading.show({
311 // Optional parameters
314 onCancel: this.onCancel
316 transaction.build(this.address, this.transaction.to, this.transaction.asset, this.transaction.amount, this.transaction.fee, this.transaction.confirmations).then(result => {
319 if(!this.transaction.fee){
320 this.transaction.fee = Number( _.sumBy(result, 'tx.fee'));
322 this.$router.push({ name: 'transfer-confirm', params: { account: this.account, transaction: this.transaction, rawData: result, assetAlias: this.selectAsset.symbol, type: this.$route.query.type } })
326 body: getLang(error.message)
332 if(this.$route.query.type === 'popup'){
333 if (this.$route.query.from != undefined) {
334 this.address = this.$route.query.from
335 this.guid = this.currentAccount.guid
336 this.account = this.currentAccount
339 if (this.$route.query.asset != undefined) {
340 const currentAssetId = this.$route.query.asset
342 this.transaction.asset= currentAssetId
344 const assets = this.assets
345 this.selectAsset = assets.filter(b => b.assetId === currentAssetId.toLowerCase())[0]
347 if (this.$route.query.to != undefined) {
348 this.transaction.to = this.$route.query.to
350 if (this.$route.query.amount != undefined) {
351 this.transaction.amount = this.$route.query.amount
353 if (this.$route.query.gas != undefined) {
354 this.transaction.fee = this.$route.query.gas
356 if(this.$route.query.confirmations != undefined) {
357 this.transaction.confirmations = this.$route.query.confirmations
360 this.account = this.currentAccount
362 const currentAsset = this.netType === 'vapor'? this.currentAccount.vpBalances[0]: this.currentAccount.balances[0]
365 transaction.asset(currentAsset.asset.assetId).then(ret => {
366 this.selectAsset = Object.assign(ret,currentAsset)