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="(asset, index) in balances" :key="index" @click="assetOpen(asset)">
208 <div class="float-right text-align-right">
209 <div class="value">{{ itemBalance(asset) }}</div>
210 <div class="addr color-grey">{{ formatCurrency(asset[ currency ]) }}</div>
212 <div v-if="asset.symbol!== 'Asset'">
213 <div class="uppercase">
217 <div class="addr color-grey">{{asset.name}}</div>
224 <div class="addr color-grey uppercase">{{ shortAddress(asset.asset) }}</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.symbol!== 'Asset'">
238 <div class="uppercase">
242 <div class="addr color-grey">{{asset.name}}</div>
249 <div class="addr color-grey uppercase">{{shortAddress(asset.asset)}}</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 { BTM } from "@/utils/constants";
281 import { mapActions, mapGetters, mapState } from 'vuex'
282 import * as Actions from '@/store/constants';
283 import _ from 'lodash';
284 import { Number as Num } from "@/utils/Number"
287 const EnterActive = 'animated faster fadeInLeft';
288 const LeaveActive = 'animated faster fadeOutLeft';
297 enterActive: EnterActive,
298 leaveActive: LeaveActive,
316 if (to.name.startsWith('menu')) {
318 } else if (from.name.startsWith('menu')) {
319 this.maskShow = false
322 // remove transition for some page
323 this.enterActive = EnterActive
324 this.leaveActive = LeaveActive
325 if (to.name == 'transfer-confirm' || from.name == 'transfer-confirm') {
326 this.enterActive = ''
327 this.leaveActive = ''
329 if (from.name == 'transfer-confirm') {
333 currentAccount(newVal, oldVal) {
334 if (newVal.guid == undefined){
339 if(this.netType === 'vapor'){
340 addr = newVal.vpAddress
342 addr = newVal.address
347 accountBalance: function () {
349 const balances = this.balances
351 if(balances && balances.length >0 ){
352 const currency = this.currency
353 balance = _.sumBy(balances, function(o) { return Number(o[currency]); })
355 return Num.formatCurrency( (balance != null && balance != 0)? balance : '0.00', this.currency)
358 if(this.netType === 'vapor'){
359 return this.currentAccount.vpAddress
361 return this.currentAccount.address
364 balances: function(){
365 if(this.netType === 'vapor'){
366 return this.currentAccount.vpBalances
368 return this.currentAccount.balances
383 shortAddress: function (add) {
384 return address.short(add)
386 formatCurrency: function (num) {
387 return Num.formatCurrency(num, this.currency)
389 itemBalance: function(asset){
390 if(asset.asset === BTM){
391 return Num.formatNue(asset.balance,8)
393 return Num.formatNue(asset.balance,asset.decimals)
396 setupRefreshTimer() {
398 this.refreshBalance(this.currentAccount.guid)
402 account.setupNet(`${this.net}${this.netType}`);
404 netTypeToggle: function (event) {
405 const newNetType = event.target.value ==='bytom'? '' :event.target.value;
407 if( newNetType !== this.netType){
408 const bytom = this.bytom.clone();
410 bytom.settings.netType = newNetType;
412 account.setupNet(`${this.net}${newNetType}`)
413 if(newNetType === 'vapor'&& !this.currentAccount.vpAddress){
414 account.copy(this.currentAccount.guid).then(accounts => {
415 //update currentAccount
416 bytom.currentAccount = accounts
419 const objectIndex = bytom.accountList.findIndex(a => a.guid == this.currentAccount.guid)
420 bytom.accountList[objectIndex].vpAddress = accounts.vpAddress
422 this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
423 this.refreshBalance(this.currentAccount.guid)
426 if(e.message == 'Error: wallet has exist'){
427 account.listVapor(this.currentAccount.guid).then(accounts => {
428 //update currentAccount
429 bytom.currentAccount = accounts
431 const objectIndex = bytom.accountList.findIndex(a => a.guid == this.currentAccount.guid)
432 bytom.accountList[objectIndex].vpAddress = accounts.vpAddress
434 this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
435 this.refreshBalance(this.currentAccount.guid)
442 this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
443 this.refreshBalance(this.currentAccount.guid)
448 showQrcode: function () {
449 this.$router.push('received')
451 openMenu: function () {
452 this.$router.push('menu')
454 transferOpen: function () {
455 this.$router.push('transfer')
457 crossChainOpen: function () {
458 this.$router.push('crossChain')
460 listVoteOpen: function () {
461 this.$router.push('listVote')
463 assetOpen: function (asset) {
464 this[Actions.SET_CURRENT_ASSET](asset)
465 this.$router.push('asset')
467 refreshBalance: function (guid) {
469 account.balance(guid)
471 const balances = obj.balances
472 const votes = obj.votes
474 const balanceNotEqual = !_.isEqual(this.balances, balances)
476 const voteNotEqual = (this.netType === 'vapor' && !_.isEqual(this.currentAccount.votes, votes))
478 if(balanceNotEqual || voteNotEqual){
481 const bytom = this.bytom.clone();
483 const objectIndex = bytom.accountList.findIndex(a => a.guid == this.currentAccount.guid)
486 if(this.netType === 'vapor'){
487 bytom.currentAccount.vpBalances = balances;
488 bytom.accountList[objectIndex].vpBalances = balances
490 bytom.currentAccount.balances = balances;
491 bytom.accountList[objectIndex].balances = balances
496 bytom.currentAccount.votes = votes;
497 bytom.accountList[objectIndex].votes = votes
500 this[Actions.UPDATE_STORED_BYTOM](bytom)
509 Actions.UPDATE_STORED_BYTOM,
510 Actions.SET_CURRENT_ASSET,
515 this.setupRefreshTimer();
516 this.refreshBalance(this.currentAccount.guid)