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 v-model="network" @change="networkToggle">
178 <option value="mainnet">{{ $t('main.mainNet') }}</option>
179 <option value="testnet">{{ $t('main.testNet') }}</option>
183 <div class="content">
184 <div v-if="currentAccount.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 class="btn-send-transfer">
197 <a v-if="currentAccount.address!=undefined" class="btn btn-primary btn-received" @click="showQrcode">
198 <i class="iconfont icon-receive"></i>
199 {{ $t('main.receive') }}
201 <a v-if="currentAccount.address!=undefined" class="btn btn-primary btn-transfer" @click="transferOpen">
202 <i class="iconfont icon-send"></i>
203 {{ $t('main.send') }}
208 <section class="transaction-title">
209 <h3 class="bg-gray color-grey">{{ $t('main.record') }}</h3>
211 <section class="transactions">
212 <div v-if="currentAccount.address!=undefined">
213 <div v-if="transactions.length != 0">
214 <vue-scroll @handle-scroll="handleScroll">
216 <li class="list-item" v-for="(transaction, index) in transactions" :key="index" @click="$router.push({name: 'transfer-info', params: {transaction: transaction, address: currentAccount.address}})">
217 <div class="value">{{transaction.direct}} {{transaction.val.toFixed(2)}} BTM</div>
219 <div v-if="transaction.hasOwnProperty('block_timestamp')">
220 {{transaction.submission_timestamp | moment}}
223 {{ $t('main.unconfirmed') }}
225 <div class="addr color-grey">{{transaction.address}}</div>
232 <div class="bg-emptytx"></div>
234 <span class="color-lightgrey center-text no-record">{{$t('main.noRecord')}}</span>
239 <router-link :to="{name: 'menu-account-creation'}">
240 <div class="bg-emptytx"></div>
242 <span class="color-lightgrey center-text no-record">{{$t('main.noRecord')}}</span>
244 <a class="btn btn-primary btn-creation">{{ $t('main.create') }}</a>
250 <div class="mask" v-show="maskShow"></div>
251 <transition :enter-active-class="enterActive" :leave-active-class="leaveActive">
252 <router-view></router-view>
259 import address from "@/utils/address";
260 import account from "@/models/account";
261 import transaction from "@/models/transaction";
262 import { BTM } from "@/utils/constants";
264 const EnterActive = 'animated faster fadeInLeft';
265 const LeaveActive = 'animated faster fadeOutLeft';
277 enterActive: EnterActive,
278 leaveActive: LeaveActive,
283 if (to.name.startsWith('menu')) {
285 } else if (from.name.startsWith('menu')) {
286 this.maskShow = false
289 //account toggle by the list from menu
290 if (to.name == 'home' && to.params.selectedAccount != undefined) {
291 this.currentAccount = to.params.selectedAccount
292 this.refreshAccounts();
295 // remove transition for some page
296 this.enterActive = EnterActive
297 this.leaveActive = LeaveActive
298 if (to.name == 'transfer-confirm' || from.name == 'transfer-confirm') {
299 this.enterActive = ''
300 this.leaveActive = ''
303 currentAccount(newVal, oldVal) {
304 if (newVal.guid == undefined){
305 localStorage.currentAccount = {}
308 localStorage.currentAccount = JSON.stringify(newVal);
310 this.refreshTransactions(newVal.guid, newVal.address).then(transactions => {
311 this.transactions = transactions
314 'currentAccount.guid'(guid) {
315 if (guid == undefined) return;
317 this.refreshBalance(guid);
321 shortAddress: function () {
322 return address.short(this.currentAccount.address)
324 accountBalance: function () {
325 return (this.currentAccount.balance != null && this.currentAccount.balance != 0) ? this.currentAccount.balance : '0.00'
329 setupRefreshTimer() {
331 this.refreshBalance(this.currentAccount.guid)
335 this.network = localStorage.bytomNet;
336 account.setupNet(this.network);
338 networkToggle: function (val) {
339 localStorage.bytomNet = this.network;
340 account.setupNet(this.network);
341 this.currentAccount = {}
342 this.refreshAccounts();
344 showQrcode: function () {
345 this.$router.push({ name: 'received', params: { address: this.currentAccount.address } })
347 openMenu: function () {
348 this.$router.push({ name: 'menu', params: { accounts: this.accounts, selected: this.currentAccount } })
350 transferOpen: function () {
351 this.$router.push({ name: 'transfer', params: { account: this.currentAccount } })
353 handleScroll(vertical, horizontal, nativeEvent) {
354 if (vertical.process == 0) {
356 this.refreshTransactions(this.currentAccount.guid, this.currentAccount.address).then(transactions => {
357 this.transactions = transactions
362 if (vertical.process == 1) {
363 this.start += this.limit;
364 this.refreshTransactions(this.currentAccount.guid, this.currentAccount.address, this.start, this.limit).then(transactions => {
365 transactions.forEach(transaction => {
366 this.transactions.push(transaction);
371 refreshAccounts: function () {
372 account.list().then(accounts => {
373 this.accounts = accounts;
374 if (accounts.length == 0) {
378 if (this.currentAccount.guid == undefined) {
379 this.currentAccount = accounts[0];
383 refreshBalance: function (guid) {
384 account.balance(guid).then(balances => {
386 if(balances.length >0 ){
387 const balanceObject = balances.filter(b => b.asset === BTM)[0]
388 balance = balanceObject.balance/Math.pow(10,balanceObject.decimals)
390 this.currentAccount.balance = balance;
391 this.currentAccount = Object.assign({}, this.currentAccount);
396 refreshTransactions: function (guid, address, start, limit) {
397 return new Promise((resolve, reject) => {
398 transaction.list(guid, address, start, limit).then(transactions => {
399 if (transactions == null) {
403 const formattedTx = this.transactionsFormat(transactions);
411 transactionsFormat: function (transactions) {
412 const formattedTransactions = []
415 transactions.forEach(transaction => {
416 const balanceObject = transaction.balances
417 .filter(b => b.asset === assetID);
419 if(balanceObject.length ===1 ){
421 const inputAddresses = transaction.inputs
422 .filter(input => input.asset === assetID && input.address !== this.currentAccount.address)
423 .map(input => input.address)
425 const outputAddresses = transaction.outputs
426 .filter(output => output.asset === assetID && output.address !== this.currentAccount.address)
427 .map(output => output.address)
430 const val = assetID===BTM ? Number(balanceObject[0].amount)/ 100000000 : Number(balanceObject[0].amount);
433 transaction.direct = "+";
434 transaction.address = address.short(inputAddresses.pop());
436 transaction.direct = "-";
437 transaction.address = address.short(outputAddresses.pop());
440 transaction.val = Math.abs(val);
441 transaction.fee = transaction.fee / 100000000;
443 formattedTransactions.push(transaction);
446 return formattedTransactions;
450 if(localStorage.currentAccount !== undefined){
451 this.currentAccount = JSON.parse(localStorage.currentAccount);
454 this.refreshAccounts();
455 this.setupRefreshTimer();