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;
48 .content .token-icon {
58 .content .token-amount {
62 .token-amount .asset {
68 vertical-align: middle;
75 justify-content: center;
77 .btn-send-transfer .btn {
86 border-radius:4px 0px 0px 0px;
89 .btn-received:hover,.btn-received:focus {
95 border-radius:0px 4px 0px 0px;
98 .btn-transfer:hover,.btn-transfer:focus {
102 .transaction-title h3 {
104 font-weight: inherit;
105 padding: 10px 0 10px 20px;
161 .btn-send-transfer .iconfont{
169 <section class="bg-image">
171 <div class="topbar-left">
172 <a class="btn-menu" @click="openMenu">
173 <i class="iconfont icon-menu"></i>
176 <div class="topbar-middle bg-secondary">
177 <select :value="netType" @change="netTypeToggle">
178 <option value="bytom">{{ $t('main.bytom') }}</option>
179 <option value="vapor">{{ $t('main.vapor') }}</option>
183 <div class="content">
184 <div v-if="address!=undefined" class="amount color-white">
185 <span class="alias color-grey">{{currentAccount.alias}}</span>
186 <div class="token-amount">
188 <span class="asset">BTM</span>
192 <p style="width: 250px; margin: 45px auto; text-align: center;">{{ $t('main.noAccount') }}</p>
196 <div v-if="netType =='vapor'" class="btn-send-transfer">
199 <a v-if="address!=undefined" class="btn btn-primary btn-received" @click="listVoteOpen">
202 <a v-if="address!=undefined " class="btn btn-primary btn-transfer" @click="crossChainOpen">
204 </a><a v-if="address!=undefined" class="btn btn-primary btn-received" @click="showQrcode">
205 {{ $t('main.receive') }}
207 <a v-if="address!=undefined" class="btn btn-primary btn-transfer" @click="transferOpen">
208 {{ $t('main.send') }}
211 <div v-else class="btn-send-transfer">
212 <a v-if="address!=undefined" class="btn btn-primary btn-received" @click="showQrcode">
213 <i class="iconfont icon-receive"></i>
214 {{ $t('main.receive') }}
216 <a v-if="address!=undefined" class="btn btn-primary btn-transfer" @click="transferOpen">
217 <i class="iconfont icon-send"></i>
218 {{ $t('main.send') }}
223 <section class="transaction-title">
224 <h3 class="bg-gray color-grey">{{ $t('main.record') }}</h3>
226 <section class="transactions">
227 <div v-if="address!=undefined">
228 <div v-if="transactions.length != 0">
229 <vue-scroll @handle-scroll="handleScroll">
231 <li class="list-item" v-for="(transaction, index) in transactions" :key="index" @click="$router.push({name: 'transfer-info', params: {transaction: transaction, address: currentAccount.address}})">
232 <div class="value">{{transaction.direct}} {{transaction.val.toFixed(2)}} BTM</div>
234 <div v-if="transaction.hasOwnProperty('block_timestamp')">
235 {{transaction.submission_timestamp | moment}}
238 {{ $t('main.unconfirmed') }}
240 <div class="addr color-grey">{{transaction.address}}</div>
247 <div class="bg-emptytx"></div>
249 <span class="color-lightgrey center-text no-record">{{$t('main.noRecord')}}</span>
254 <router-link :to="{name: 'menu-account-creation'}">
255 <div class="bg-emptytx"></div>
257 <span class="color-lightgrey center-text no-record">{{$t('main.noRecord')}}</span>
259 <a class="btn btn-primary btn-creation">{{ $t('main.create') }}</a>
265 <div class="mask" v-show="maskShow"></div>
266 <transition :enter-active-class="enterActive" :leave-active-class="leaveActive">
267 <router-view></router-view>
274 import address from "@/utils/address";
275 import account from "@/models/account";
276 import transaction from "@/models/transaction";
277 import { BTM } from "@/utils/constants";
278 import { mapActions, mapGetters, mapState } from 'vuex'
279 import * as Actions from '@/store/constants';
280 import _ from 'lodash';
283 const EnterActive = 'animated faster fadeInLeft';
284 const LeaveActive = 'animated faster fadeOutLeft';
293 enterActive: EnterActive,
294 leaveActive: LeaveActive,
299 if (to.name.startsWith('menu')) {
301 } else if (from.name.startsWith('menu')) {
302 this.maskShow = false
305 // remove transition for some page
306 this.enterActive = EnterActive
307 this.leaveActive = LeaveActive
308 if (to.name == 'transfer-confirm' || from.name == 'transfer-confirm') {
309 this.enterActive = ''
310 this.leaveActive = ''
312 if (from.name == 'transfer-confirm') {
314 this.refreshTransactions(this.currentAccount.guid, this.address).then(transactions => {
315 this.transactions = transactions
319 currentAccount(newVal, oldVal) {
320 if (newVal.guid == undefined){
325 if(this.netType === 'vapor'){
326 addr = newVal.vpAddress
328 addr = newVal.address
331 this.refreshTransactions(newVal.guid, addr).then(transactions => {
332 this.transactions = transactions
337 shortAddress: function () {
338 return address.short(this.address)
340 accountBalance: function () {
342 const balances = this.balances
343 if(balances && balances.length >0 ){
344 const balanceObject = balances.filter(b => b.asset === BTM)[0]
345 balance = balanceObject.balance/Math.pow(10,balanceObject.decimals)
347 return (balance != null && balance != 0) ? balance : '0.00'
350 if(this.netType === 'vapor'){
351 return this.currentAccount.vpAddress
353 return this.currentAccount.address
356 balances: function(){
357 if(this.netType === 'vapor'){
358 return this.currentAccount.vpBalances
360 return this.currentAccount.balances
374 setupRefreshTimer() {
376 this.refreshBalance(this.currentAccount.guid)
380 account.setupNet(`${this.net}${this.netType}`);
382 netTypeToggle: function (event) {
383 const newNetType = event.target.value
384 if( newNetType !== this.netType){
385 const bytom = this.bytom.clone();
387 bytom.settings.netType = newNetType;
389 account.setupNet(`${this.net}${newNetType}`)
390 if(newNetType === 'vapor'&& !this.currentAccount.vpAddress){
391 account.copy(this.currentAccount.guid).then(accounts => {
392 //update currentAccount
393 bytom.currentAccount = accounts
396 const objectIndex = bytom.accountList.findIndex(a => a.guid == this.currentAccount.guid)
397 bytom.accountList[objectIndex].vpAddress = accounts.vpAddress
399 this[Actions.UPDATE_STORED_BYTOM](bytom)
402 this[Actions.UPDATE_STORED_BYTOM](bytom)
404 this.refreshBalance(this.currentAccount.guid)
407 showQrcode: function () {
408 this.$router.push('received')
410 openMenu: function () {
411 this.$router.push('menu')
413 transferOpen: function () {
414 this.$router.push('transfer')
416 crossChainOpen: function () {
417 this.$router.push('crossChain')
419 listVoteOpen: function () {
420 this.$router.push('listVote')
422 handleScroll(vertical, horizontal, nativeEvent) {
423 if (vertical.process == 0) {
425 this.refreshTransactions(this.currentAccount.guid, this.address).then(transactions => {
426 this.transactions = transactions
431 if (vertical.process == 1) {
432 this.start += this.limit;
433 this.refreshTransactions(this.currentAccount.guid, this.address, this.start, this.limit).then(transactions => {
434 transactions.forEach(transaction => {
435 this.transactions.push(transaction);
440 refreshBalance: function (guid) {
441 account.balance(guid)
443 const balances = obj.balances
444 const votes = obj.votes
446 const balanceNotEqual = !_.isEqual(this.balances, balances)
447 const voteNotEqual = (this.netType === 'vapor' && !_.isEqual(this.currentAccount.votes, votes))
449 if(balanceNotEqual || voteNotEqual){
452 const bytom = this.bytom.clone();
454 const objectIndex = bytom.accountList.findIndex(a => a.guid == this.currentAccount.guid)
457 if(this.netType === 'vapor'){
458 bytom.currentAccount.vpBalances = balances;
459 bytom.accountList[objectIndex].vpBalances = balances
461 bytom.currentAccount.balances = balances;
462 bytom.accountList[objectIndex].balances = balances
467 bytom.currentAccount.votes = votes;
468 bytom.accountList[objectIndex].votes = votes
471 this[Actions.UPDATE_STORED_BYTOM](bytom)
478 refreshTransactions: function (guid, address, start, limit) {
479 return new Promise((resolve, reject) => {
480 transaction.list(guid, address, start, limit).then(transactions => {
481 if (transactions == null) {
485 const formattedTx = this.transactionsFormat(transactions);
493 transactionsFormat: function (transactions) {
494 const formattedTransactions = []
497 transactions.forEach(transaction => {
498 const balanceObject = transaction.balances
499 .filter(b => b.asset === assetID);
501 if(balanceObject.length ===1 ){
503 const inputAddresses = transaction.inputs
504 .filter(input => input.asset === assetID && input.address !== this.address)
505 .map(input => input.address)
507 const outputAddresses = transaction.outputs
508 .filter(output => output.asset === assetID && output.address !== this.address)
509 .map(output => output.address)
512 const val = assetID===BTM ? Number(balanceObject[0].amount)/ 100000000 : Number(balanceObject[0].amount);
515 transaction.direct = "+";
516 transaction.address = address.short(inputAddresses.pop());
518 transaction.direct = "-";
519 transaction.address = address.short(outputAddresses.pop());
522 transaction.val = Math.abs(val);
523 transaction.fee = transaction.fee / 100000000;
525 formattedTransactions.push(transaction);
528 return formattedTransactions;
531 Actions.UPDATE_STORED_BYTOM,
536 this.setupRefreshTimer();
537 this.refreshTransactions(this.currentAccount.guid, this.address).then(transactions => {
538 this.transactions = transactions