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="asset">
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.asset)}}</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.asset)}}</div>
125 <div class="form-item">
126 <label class="form-item-label">{{ $t('transfer.address') }}</label>
127 <div class="form-item-content" >
128 <input type="text" v-model="transaction.to">
131 <div class="form-item">
132 <label class="form-item-label">
133 {{ $t('transfer.quantity') }}
135 <small class="float-right" style="margin-right: 8px;">{{formatCurrency(transaction.cost||0)}}</small>
137 <div class="form-item-content" style=" display: flex;">
138 <input type="number" v-model="transaction.amount" placeholder="0" @keypress="limitAmount">
139 <span class="color-grey" style="font-size: 15px;position: absolute;right: 0;text-transform: uppercase;">{{unit}}</span>
142 <div class="form-item">
143 <label class="form-item-label">{{ $t('transfer.fee') }}</label>
144 <div class="form-item-content" >
145 <!--<v-select :clearable="false" v-model="fee" style="height: 32px;" :options="feeTypeOptions"></v-select>-->
146 <input type="text" v-model="fee" disabled >
150 <a class="btn btn-primary" @click="send">{{ $t('transfer.send') }}</a>
156 import address from "@/utils/address";
157 import account from "@/models/account";
158 import transaction from "@/models/transaction";
159 import getLang from "@/assets/language/sdk";
160 import Confirm from "./transferConfirm";
161 import { BTM } from "@/utils/constants";
162 import { Number as Num } from "@/utils/Number"
163 import { mapActions, mapGetters, mapState } from 'vuex'
164 import * as Actions from '@/store/constants';
165 import _ from 'lodash'
167 const currencyInPrice = {
187 accountBalance: 0.00,
188 fee: this.$t("transfer.feeType"),
189 feeTypeOptions: [this.$t("transfer.feeType")],
202 if(this.netType === 'vapor'){
203 if(!this.currentAccount.vpBalances ||this.currentAccount.vpBalances.length == 0){
204 return [this.selectAsset]
206 return this.currentAccount.vpBalances
209 if(!this.currentAccount.balances ||this.currentAccount.balances.length == 0){
210 return [this.selectAsset]
212 return this.currentAccount.balances
217 return this.selectAsset.symbol;
230 "transaction.amount": function (newAmount) {
231 const singlePrice = this.selectAsset[currencyInPrice[this.currency]]||this.selectAsset[this.currency]||0
232 this.transaction.cost = Number( singlePrice * newAmount).toFixed(2);
234 account: function (newAccount) {
235 this.guid = newAccount.guid;
237 guid: function (newGuid) {
238 this.accountList.forEach(account => {
239 if (account.guid == newGuid.guid) {
240 this.account = account;
245 account.balance(newGuid).then(obj => {
246 const balances = obj.balances
248 if(balances.length >0 ) {
249 const balanceObject = balances.filter(b => b.asset === this.selectAsset.asset)[0]
250 balance = Num.formatNue(balanceObject.balance, balanceObject.decimals)
252 this.accountBalance = balance;
259 shortAddress: function (add) {
260 return address.short(add)
262 formatCurrency: function (num) {
263 return Num.formatCurrency(num, this.currency)
265 limitAmount ($event) {
266 // restrict to 2 decimal places
267 if(this.transaction.amount!=null && this.transaction.amount.indexOf(".")>-1 && (this.transaction.amount.split('.')[1].length > (this.selectAsset.decimals-1))){
268 $event.preventDefault();
271 assetChange: function (val) {
272 if(val.asset !== this.selectAsset.asset){
273 this.transaction.asset = val.asset;
274 const balances = this.netType === 'vapor'?this.currentAccount.vpBalances:this.currentAccount.balances
276 if(balances.length >0 ) {
277 const balanceObject = balances.filter(b => b.asset === val.asset)[0]
278 balance = Num.formatNue(balanceObject.balance, balanceObject.decimals)
280 this.accountBalance = balance;
281 transaction.asset(val.asset).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.account.guid, this.transaction.to, this.transaction.asset, Num.convertToNue(this.transaction.amount,this.selectAsset.decimals), this.transaction.fee, this.transaction.confirmations).then(result => {
318 if(!this.transaction.fee){
319 this.transaction.fee = Number( _.sumBy(result, 'fee') / 100000000);
321 this.$router.push({ name: 'transfer-confirm', params: { account: this.account, transaction: this.transaction, rawData: result, assetAlias: this.selectAsset.symbol, type: this.$route.query.type } })
325 body: getLang(error.message)
331 if(this.$route.query.type === 'popup'){
332 if (this.$route.query.from != undefined) {
333 this.guid = this.$route.query.from
334 this.account = this.accountList.filter(e => e.guid === this.guid)[0]
337 if (this.$route.query.asset != undefined) {
338 const currentAssetId = this.$route.query.asset
340 this.transaction.asset= currentAssetId
342 const assets = this.assets
343 this.selectAsset = assets.filter(b => b.asset === 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 /100000000
353 if (this.$route.query.gas != undefined) {
354 this.transaction.fee = this.$route.query.gas /100000000
356 if(this.$route.query.confirmations != undefined) {
357 this.transaction.confirmations = this.$route.query.confirmations
360 this.account = this.currentAccount
362 const currentAsset = this.currentAccount.balances[0]
365 transaction.asset(currentAsset.asset).then(ret => {
366 this.selectAsset = Object.assign(ret,currentAsset)