10 .topbar .topbar-left {
13 text-overflow: ellipsis;
18 .topbar-left .btn-menu {
22 .topbar-left .btn-menu i {
31 .topbar .topbar-middle {
34 border: 2px solid #fff;
52 .content .token-amount {
60 justify-content: space-evenly;
68 box-shadow: 0px 2px 16px rgba(0, 0, 0, 0.08);
78 .transaction-title h3 {
81 padding: 10px 0 10px 20px;
93 border-bottom: solid 1px rgba(0, 0, 0, 0.04)
97 text-transform: capitalize;
127 .icon-crosschain-svg{
128 background-image: url('../assets/img/icon/crosschain.svg');
131 background-image: url('../assets/img/icon/vote.svg');
134 background-image: url('../assets/img/icon/receive.svg');
137 background-image: url('../assets/img/icon/send.svg');
144 <section class="bg-image">
146 <div class="topbar-left">
147 <a class="btn-menu" @click="openMenu">
148 <i class="iconfont icon-menu"></i>
151 <div class="topbar-middle bg-secondary">
152 <select class="network-select" :value="netType||'bytom'" @change="netTypeToggle">
153 <option value="bytom">{{ $t('main.bytom') }} {{net}}</option>
154 <option value="vapor">{{ $t('main.vapor') }} {{net}}</option>
158 <div class="content">
159 <div v-if="address!=undefined" class="amount color-white">
160 <span class="alias color-grey">{{currentAccount.alias}}</span>
161 <div class="token-amount">
166 <p style="width: 250px; margin: 45px auto; text-align: center;">{{ $t('main.noAccount') }}</p>
170 <div v-if="netType =='vapor' && address!=undefined" class="btn-send-transfer">
172 <a @click="listVoteOpen">
173 <div class="icon icon-vote-svg"></div>
174 <div>{{ $t('main.vote') }}</div>
176 <a @click="crossChainOpen">
177 <div class="icon icon-crosschain-svg"></div>
178 <div>{{ $t('main.crossChain') }}</div>
180 <a @click="showQrcode">
181 <div class="icon icon-receive-svg"></div>
182 <div>{{ $t('main.receive') }}</div>
184 <a @click="transferOpen">
185 <div class="icon icon-send-svg"></div>
186 <div>{{ $t('main.send') }}</div>
189 <div v-else-if="address!=undefined" class="btn-send-transfer">
190 <a @click="showQrcode">
191 <div class="icon icon-receive-svg"></div>
192 <div>{{ $t('main.receive') }}</div>
194 <a @click="transferOpen">
195 <div class="icon icon-send-svg"></div>
196 <div>{{ $t('main.send') }}</div>
200 <section v-if="address!=undefined" class="transaction-title">
201 <h3 class="color-black">{{ $t('main.asset') }}</h3>
203 <section class="transactions">
204 <div v-if="address!=undefined">
205 <div v-if="balances && balances.length > 0">
207 <li class="list-item" v-for="(balance, index) in balances" :key="index" @click="assetOpen(balance)">
208 <div class="float-right text-align-right">
209 <div class="value">{{ itemBalance(balance) }}</div>
210 <div class="addr color-grey">{{ formatCurrency(currentBalanceAmount(balance)) }}</div>
212 <div v-if="balance.asset.symbol!== 'Asset'">
213 <div class="uppercase">
214 {{balance.asset.symbol}}
217 <div class="addr color-grey">{{balance.asset.name}}</div>
224 <div class="addr color-grey uppercase">{{ shortAddress(balance.asset.assetId) }}</div>
232 <li class="list-item" v-for="(asset, index) in defaultBalances" :key="index" @click="assetOpen(asset)">
233 <div class="float-right text-align-right">
234 <div class="value">{{ itemBalance(asset) }}</div>
235 <div class="addr color-grey">{{ formatCurrency(asset[ currency ]) }}</div>
237 <div v-if="asset.asset.symbol!== 'Asset'">
238 <div class="uppercase">
239 {{asset.asset.symbol}}
242 <div class="addr color-grey">{{asset.asset.name}}</div>
249 <div class="addr color-grey uppercase">{{shortAddress(asset.asset.assetId)}}</div>
257 <router-link :to="{name: 'menu-account-creation'}">
258 <div class="bg-emptytx"></div>
260 <span class="color-lightgrey center-text no-record">{{$t('main.noAssetRecord')}}</span>
262 <a class="btn btn-primary btn-creation">{{ $t('main.create') }}</a>
268 <div class="mask" v-show="maskShow"></div>
269 <transition :enter-active-class="enterActive" :leave-active-class="leaveActive">
270 <router-view></router-view>
277 import address from "@/utils/address";
278 import account from "@/models/account";
279 import transaction from "@/models/transaction";
280 import { camelize } from "@/utils/utils";
281 import { BTM } from "@/utils/constants";
282 import { mapActions, mapGetters, mapState } from 'vuex'
283 import * as Actions from '@/store/constants';
284 import _ from 'lodash';
285 import { Number as Num } from "@/utils/Number"
288 const EnterActive = 'animated faster fadeInLeft';
289 const LeaveActive = 'animated faster fadeOutLeft';
298 enterActive: EnterActive,
299 leaveActive: LeaveActive,
319 if (to.name.startsWith('menu')) {
321 } else if (from.name.startsWith('menu')) {
322 this.maskShow = false
325 // remove transition for some page
326 this.enterActive = EnterActive
327 this.leaveActive = LeaveActive
328 if (to.name == 'transfer-confirm' || from.name == 'transfer-confirm') {
329 this.enterActive = ''
330 this.leaveActive = ''
332 if (from.name == 'transfer-confirm') {
336 currentAccount(newVal, oldVal) {
337 if (newVal.guid == undefined){
342 if(this.netType === 'vapor'){
343 addr = newVal.vpAddress
345 addr = newVal.address
350 accountBalance: function () {
352 const balances = this.balances
354 if(balances && balances.length >0 ){
355 const currency = camelize(this.currency)
356 balance = _.sumBy(balances, function(o) { return Number(o[currency]); })
358 return Num.formatCurrency( (balance != null && balance != 0)? balance : '0.00', this.currency)
361 if(this.netType === 'vapor'){
362 return this.currentAccount.vpAddress
364 return this.currentAccount.address
367 balances: function(){
368 if(this.netType === 'vapor'){
369 return this.currentAccount.vpBalances
371 return this.currentAccount.balances
386 currentBalanceAmount: function (balance) {
387 return balance[ camelize(this.currency) ]
389 shortAddress: function (add) {
390 return address.short(add)
392 formatCurrency: function (num) {
393 return Num.formatCurrency(num, this.currency)
395 itemBalance: function(assetObj){
396 const asset = assetObj.asset
397 if(asset.assetId === BTM){
398 return Num.formatNue(assetObj.availableBalance,8)
400 return assetObj.availableBalance
403 setupRefreshTimer() {
405 this.refreshBalance(this.address)
409 account.setupNet(`${this.net}${this.netType}`);
411 netTypeToggle: function (event) {
412 const newNetType = event.target.value ==='bytom'? '' :event.target.value;
414 if( newNetType !== this.netType){
415 const bytom = this.bytom.clone();
417 bytom.settings.netType = newNetType;
419 account.setupNet(`${this.net}${newNetType}`)
420 if(newNetType === 'vapor'&& !this.currentAccount.vpAddress){
421 account.copy(this.currentAccount.guid).then(accounts => {
422 //update currentAccount
423 bytom.currentAccount = accounts
426 const objectIndex = bytom.accountList.findIndex(a => a.guid == this.currentAccount.guid)
427 bytom.accountList[objectIndex].vpAddress = accounts.vpAddress
429 this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
430 this.refreshBalance(this.currentAccount.vpAddress)
433 if(e.message == 'Error: wallet has exist'){
434 account.listVapor(this.currentAccount.guid).then(accounts => {
435 //update currentAccount
436 bytom.currentAccount = accounts
438 const objectIndex = bytom.accountList.findIndex(a => a.guid == this.currentAccount.guid)
439 bytom.accountList[objectIndex].vpAddress = accounts.vpAddress
441 this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
442 this.refreshBalance(this.currentAccount.vpAddress)
449 this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
450 this.refreshBalance(this.currentAccount.address)
455 showQrcode: function () {
456 this.$router.push('received')
458 openMenu: function () {
459 this.$router.push('menu')
461 transferOpen: function () {
462 this.$router.push('transfer')
464 crossChainOpen: function () {
465 this.$router.push('crossChain')
467 listVoteOpen: function () {
468 this.$router.push('listVote')
470 assetOpen: function (asset) {
471 this[Actions.SET_CURRENT_ASSET](asset)
472 this.$router.push('asset')
474 refreshBalance: function (address) {
476 account.balance(address)
478 const balances = obj.balances
479 const votes = obj.votes
481 const balanceNotEqual = !_.isEqual(this.balances, balances)
483 const voteNotEqual = (this.netType === 'vapor' && !_.isEqual(this.currentAccount.votes, votes))
485 if(balanceNotEqual || voteNotEqual){
488 const bytom = this.bytom.clone();
489 const objectIndex = bytom.accountList.findIndex(a => a.guid == this.currentAccount.guid)
492 if(this.netType === 'vapor'){
493 bytom.currentAccount.vpBalances = balances;
494 bytom.accountList[objectIndex].vpBalances = balances
496 bytom.currentAccount.balances = balances;
497 bytom.accountList[objectIndex].balances = balances
502 bytom.currentAccount.votes = votes;
503 bytom.accountList[objectIndex].votes = votes
506 this[Actions.UPDATE_STORED_BYTOM](bytom)
515 Actions.UPDATE_STORED_BYTOM,
516 Actions.SET_CURRENT_ASSET,
521 this.setupRefreshTimer();
522 this.refreshBalance(this.address)