1 <style lang="scss" scoped>
9 justify-content: space-between;
11 .topbar .topbar-left {
14 text-overflow: ellipsis;
19 .topbar-left .btn-menu {
23 .topbar-left .btn-menu i {
33 .topbar .topbar-right {
43 .content .token-amount {
48 .token-amount:first-letter {
49 color: rgba(255, 255, 255, 0.56);
54 justify-content: space-evenly;
64 a:hover .icon, a:focus .icon, a:active .icon{
65 background: rgba(255, 255, 255, 0.2);
74 .transaction-title h3 {
76 padding: 12px 0 16px 0px;
87 text-transform: capitalize;
113 background: rgba(255, 255, 255, 0.04);
115 display: inline-flex;
117 justify-content: center;
125 background: linear-gradient(228.34deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.1) 100%), #1A1A1A;
130 background: linear-gradient(228.34deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.16) 100%), #0A42D0;
134 color: rgba(255, 255, 255, 0.72);
139 /* The switch - the box around the slider */
142 display: inline-block;
147 /* Hide default HTML checkbox */
162 background-color: #F5F5F5;
163 -webkit-transition: .4s;
174 background-color: white;
175 box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.04);
176 -webkit-transition: .4s;
180 /*input:checked + .slider {*/
181 /*background-color: #2196F3;*/
184 /*input:focus + .slider {*/
185 /*box-shadow: 0 0 1px #2196F3;*/
188 input:checked + .slider:before {
189 -webkit-transform: translateX(67px);
190 -ms-transform: translateX(67px);
191 transform: translateX(67px);
194 /* Rounded sliders */
199 .slider.round:before {
205 justify-content: space-around;
210 color: rgba(0, 0, 0, 0.24);
213 .slider-label>div.active{
214 color: rgba(0, 0, 0, 0.64);
226 flex-direction: column;
229 @media screen and (min-width: 768px) {
247 .token-amount:first-letter {
253 margin-right: inherit;
263 border-radius: 16px 0px 0px 16px;
265 color: rgba(0, 0, 0, 0.88);
273 vertical-align: middle;
278 <div class="warp-menu">
281 <div v-if="address!=undefined" >
282 <span class="alias color-black">{{currentAccount.alias}}</span>
284 <div class="topbar-right">
285 <label class="switch">
286 <input type="checkbox" v-model="isVapor" @change="netTypeToggle">
287 <span class="slider round"></span>
288 <div class="d-flex slider-label">
289 <div :class="{ active: !isVapor }" >{{ $t('main.bytom') }}</div>
290 <div :class="{ active: isVapor }">{{ $t('main.vapor') }}</div>
295 <div :class="['content balance-bg',{ 'vapor-bg': isVapor }]">
296 <div class="amount color-white">
297 <div class="total-asset">{{ $t('main.totalAsset') }}</div>
298 <div class="token-amount">
302 <div class="btn-send-transfer">
304 <a @click="transferOpen">
305 <i class="icon iconfont icon_send"></i>
306 <div>{{ $t('main.send') }}</div>
308 <a @click="showQrcode">
309 <i class="icon iconfont icon_recvice"></i>
310 <div>{{ $t('main.receive') }}</div>
312 <a class="color-white" href="https://ofmf.bymov.io/cross-chain" target="_blank">
313 <i class="icon iconfont icon_cross"></i>
314 <div>{{ $t('main.crossChain') }}</div>
320 <section v-if="address!=undefined" class="transaction-title">
321 <h3 class="color-black">{{ $t('main.asset') }}</h3>
322 <!-- <a class="delay-btn" @click="delayOpen"><i class="iconfont icon_SBell"></i>{{ $t('delayTx.title') }}</a> -->
324 <section class="assets">
325 <div v-if=" currentBalances && currentBalances.length > 0">
327 <li class="list-item" v-for="(balance, index) in currentBalances" :key="index" @click="assetOpen(balance)">
328 <div class="symbol" v-if="balance.asset.symbol!== 'Asset'">
329 <img :src="img(balance.asset.symbol)" alt="" class="c-icon" v-on:error="onImgError">
330 <div class="uppercase">
331 {{balance.asset.symbol}}
339 <div class="addr color-grey uppercase">{{ shortAddress(balance.asset.assetId) }}</div>
342 <div class="text-align-right">
343 <div class="value">{{ itemBalance(balance) }}</div>
344 <div class="addr color-grey">{{ formatCurrency(currentBalanceAmount(balance)) }}</div>
352 <li class="list-item" v-for="(asset, index) in defaultBalances" :key="index" @click="assetOpen(asset)">
355 <img :src="img(asset.asset.symbol)" alt="" class="c-icon" v-on:error="onImgError">
357 <div class="uppercase">
358 {{asset.asset.symbol}}
363 <div class=" text-align-right">
364 <div class="value">{{ itemBalance(asset) }}</div>
365 <div class="addr color-grey">{{ formatCurrency(asset[ currency ]) }}</div>
374 <div class="mask" v-show="maskShow"></div>
375 <transition :enter-active-class="enterActive" :leave-active-class="leaveActive">
376 <router-view></router-view>
383 import address from "@/utils/address";
384 import account from "@/models/account";
385 import { camelize } from "@/utils/utils";
386 import { BTM } from "@/utils/constants";
387 import { mapActions, mapGetters, mapState } from 'vuex'
388 import * as Actions from '@/store/constants';
389 import _ from 'lodash';
390 import { Number as Num } from "@/utils/Number"
391 import BigNumber from "bignumber.js"
392 import getLang from "@/assets/language/sdk";
395 const EnterActive = 'animated faster fadeInLeft';
396 const LeaveActive = 'animated faster fadeOutLeft';
403 enterActive: EnterActive,
404 leaveActive: LeaveActive,
425 this.refreshBalance(this.address)
426 if (to.name.startsWith('menu')) {
428 } else if (from.name.startsWith('menu')) {
429 this.maskShow = false
432 // remove transition for some page
433 this.enterActive = EnterActive
434 this.leaveActive = LeaveActive
435 if (to.name == 'transfer-confirm' || from.name == 'transfer-confirm') {
436 this.enterActive = ''
437 this.leaveActive = ''
439 if (from.name == 'transfer-confirm') {
443 currentAccount(newVal, oldVal) {
444 if (newVal.guid == undefined){
449 // if(this.netType === 'vapor'){
450 // addr = newVal.vpAddress
452 // addr = newVal.address
454 // this.refreshBalance(addr)
458 accountBalance: function () {
460 const balances = this.currentBalances
462 if(balances && balances.length >0 ){
463 const currency = camelize(this.currency)
464 const arr = balances.map(o => o[currency])
465 balance = BigNumber.sum.apply(null, arr)
467 return Num.formatCurrency( (balance != null && balance != 0)? balance : '0.00', this.currency)
470 if(this.netType === 'vapor'){
471 const vpAddress = this.currentAccount.vpAddress
473 const bytom = this.bytom.clone();
474 return account.copy(this.currentAccount.bytom1.guid).then(accounts => {
475 //update currentAccount
476 bytom.currentAccount.vpAddress = accounts.address
478 bytom.keychain.pairs[this.net][bytom.currentAccount.alias].vpAddress = accounts.address
480 this[Actions.UPDATE_STORED_BYTOM](bytom).then(() => {
481 // this.setupRefreshTimer()
484 return accounts.address
486 }else return vpAddress
489 return this.currentAddress
490 // return this.currentAccount.address
493 // balances: function(){
494 // if(this.netType === 'vapor'){
495 // return this.currentAccount.vpBalances
496 // }else if (this.chainType === 'bytom1'){
497 // return this.currentAccount.bytom1.balances
499 // return this.currentAccount.balances
517 img:function (symbol) {
518 let _symbol = symbol.toLowerCase();
519 if (_symbol === 'btm') {
522 if(this.netType === 'vapor'){
523 return `https://cdn.blockmeta.com/resources/logo/vapor/${_symbol}.png`
525 return `https://cdn.blockmeta.com/resources/logo/bytom/${_symbol}.png`
528 onImgError: function(event) {
529 event.target.src = require(`@/assets/img/asset/${this.netType}.png`)
531 currentBalanceAmount: function (balance) {
532 return balance[ camelize(this.currency) ]
534 shortAddress: function (add) {
535 return address.short(add)
537 formatCurrency: function (num) {
538 return Num.formatCurrency(num, this.currency)
540 itemBalance: function(assetObj){
541 const asset = assetObj.asset
542 if(asset.assetId === BTM){
543 return Num.formatNue(assetObj.balance,8)
545 return assetObj.balance
548 setupRefreshTimer() {
550 clearInterval(this.t)
552 this.t = setInterval(() => {
553 this.refreshBalance(this.address)
556 netTypeToggle: function () {
557 const bytom = this.bytom.clone();
558 const newNetType = this.isVapor ? 'vapor' : bytom.settings.chainType === 'bytom2' ? 'bytom' : 'bytom1'
560 bytom.settings.netType = newNetType;
562 account.setupNet(`${this.net}${newNetType}`)
563 if(this.isVapor && !this.currentAccount.vpAddress){
564 account.copy(this.currentAccount.bytom1.guid).then(accounts => {
565 //update currentAccount
566 bytom.currentAccount.vpAddress = accounts.address
568 bytom.keychain.pairs[this.net][bytom.currentAccount.alias].vpAddress = accounts.address
570 this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
571 this.refreshBalance(this.address)
576 e = this.$t(`error.${error.code}`)
577 }else if(error.message){
578 e = getLang(error.message, this.language)
580 this.$toast.error(e);
583 this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
584 this.refreshBalance(this.address)
585 // this.setupRefreshTimer()
589 showQrcode: function () {
590 this.$router.push('received')
592 openMenu: function () {
593 this.$router.push('menu')
595 transferOpen: function () {
596 this.$router.push('transfer')
598 delayOpen: function () {
599 this.$router.push('delayTx')
601 crossChainOpen: function () {
602 this.$router.push('crossChain')
604 listVoteOpen: function () {
605 this.$router.push('listVote')
607 assetOpen: function (asset) {
608 this[Actions.SET_CURRENT_ASSET](asset)
609 this.$router.push('asset')
611 refreshBalance: function (address) {
613 account.balance(this.currentAddress, this)
620 Actions.UPDATE_STORED_BYTOM,
621 Actions.SET_CURRENT_ASSET,
625 this.setupRefreshTimer();
626 this.refreshBalance(this.address)
628 this.isVapor = this.netType =='vapor'
633 clearInterval(this.t)