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;
41 .topbar-middle .lamp {
42 display: inline-block;
46 background-color: #02f823;
57 .content .token-icon {
67 .content .token-amount {
71 .token-amount .asset {
77 vertical-align: middle;
84 justify-content: center;
86 .btn-send-transfer .btn {
95 border-radius:4px 0px 0px 0px;
98 .btn-received:hover,.btn-received:focus {
104 border-radius:0px 4px 0px 0px;
106 .btn-transfer:active,
107 .btn-transfer:hover,.btn-transfer:focus {
111 .transaction-title h3 {
113 font-weight: inherit;
114 padding: 10px 0 10px 20px;
174 <section class="bg-image">
176 <div class="topbar-left">
177 <a class="btn-menu" @click="openMenu">
178 <i class="iconfont icon-menu"></i>
181 <div class="topbar-middle bg-secondary">
183 <select v-model="network" @change="networkToggle">
184 <option value="mainnet">{{ $t('main.mainNet') }}</option>
185 <option value="testnet">{{ $t('main.testNet') }}</option>
186 <option value="solonet">{{ $t('main.soloNet') }}</option>
190 <div class="content">
191 <div v-if="currentAccount.address!=undefined" class="amount color-white">
192 <span class="alias color-grey">{{currentAccount.alias}}</span>
193 <div class="token-amount">
195 <span class="asset">BTM</span>
199 <p style="width: 250px; margin: 45px auto; text-align: center;">{{ $t('main.noAccount') }}</p>
203 <div class="btn-send-transfer">
204 <a v-if="currentAccount.address!=undefined" class="btn btn-primary btn-received" @click="showQrcode">{{ $t('main.receive') }}</a>
205 <a v-if="currentAccount.address!=undefined" class="btn btn-primary btn-transfer" @click="transferOpen">{{ $t('main.send') }}</a>
209 <section class="transaction-title">
210 <h3 class="bg-gray color-grey">{{ $t('main.record') }}</h3>
212 <section class="transactions">
213 <div v-if="currentAccount.address!=undefined">
214 <div v-if="transactions.length != 0">
215 <vue-scroll @handle-scroll="handleScroll">
217 <li class="list-item" v-for="(transcation, index) in transactions" :key="index" @click="$router.push({name: 'transfer-info', params: {transcation: transcation, address: currentAccount.address}})">
218 <div class="value">{{transcation.direct}} {{transcation.val.toFixed(2)}} BTM</div>
220 <div v-if="transcation.is_confirmed" class="time">
221 <div v-if="transcation.block_timestamp === 0">
222 {{ $t('main.unconfirmed') }}
225 {{transcation.block_timestamp | moment}}
228 <div v-else class="time">
229 <div v-if="transcation.submission_timestamp === 0">
230 {{ $t('main.unconfirmed') }}
233 {{transcation.submission_timestamp | moment}}
236 <div class="addr color-grey">{{transcation.address}}</div>
243 <div class="bg-emptytx"></div>
245 <span class="color-lightgrey center-text no-record">{{$t('main.noRecord')}}</span>
250 <router-link :to="{name: 'menu-account-creation'}">
251 <div class="bg-emptytx"></div>
253 <span class="color-lightgrey center-text no-record">{{$t('main.noRecord')}}</span>
255 <a class="btn btn-primary btn-creation">{{ $t('main.create') }}</a>
261 <div class="mask" v-show="maskShow"></div>
262 <transition :enter-active-class="enterActive" :leave-active-class="leaveActive">
263 <router-view></router-view>
267 <Qrcode ref="qrcode"></Qrcode>
272 import ClipboardJS from "clipboard";
273 import Menu from "@/views/homeMenu";
274 import Qrcode from "@/views/qrcode";
275 import Transfer from "@/views/transfer";
276 import TxInfo from "@/views/transferDetail";
277 import address from "@/utils/address";
278 import account from "@/models/account";
279 import transaction from "@/models/transaction";
280 import { BTM } from "@/utils/constants";
282 const EnterActive = 'animated faster fadeInLeft';
283 const LeaveActive = 'animated faster fadeOutLeft';
292 clipboard: new ClipboardJS(".address-text"),
293 addressTitle: this.$t("main.copy"),
300 enterActive: EnterActive,
301 leaveActive: LeaveActive,
306 if (to.name.startsWith('menu')) {
308 } else if (from.name.startsWith('menu')) {
309 this.maskShow = false
312 //account toggle by the list from menu
313 if (to.name == 'home' && to.params.selectedAccount != undefined) {
314 this.currentAccount = to.params.selectedAccount
315 this.refreshAccounts();
318 // remove transition for some page
319 this.enterActive = EnterActive
320 this.leaveActive = LeaveActive
321 if (to.name == 'transfer-confirm' || from.name == 'transfer-confirm') {
322 this.enterActive = ''
323 this.leaveActive = ''
326 currentAccount(newVal, oldVal) {
327 if (newVal.guid == undefined){
328 localStorage.currentAccount = {}
331 localStorage.currentAccount = JSON.stringify(newVal);
333 this.refreshTransactions(newVal.guid, newVal.address).then(transactions => {
334 this.transactions = transactions
337 'currentAccount.guid'(guid) {
338 if (guid == undefined) return;
340 this.refreshBalance(guid);
344 shortAddress: function () {
345 return address.short(this.currentAccount.address)
347 accountBalance: function () {
348 return this.currentAccount.balance != 0 ? this.currentAccount.balance : '0.00'
353 this.clipboard.on("success", e => {
355 header: this.$t("dialog.header"),
356 body: this.$t("dialog.copy.success")
359 this.clipboard.on("error", e => {
361 header: this.$t("dialog.header"),
362 body: this.$t("dialog.copy.fail")
366 setupRefreshTimer() {
367 // todo refresh all accounts
370 this.refreshBalance(this.currentAccount.guid)
374 this.network = localStorage.bytomNet;
375 account.setupNet(this.network);
377 networkToggle: function (val) {
378 localStorage.bytomNet = this.network;
379 account.setupNet(this.network);
380 this.currentAccount = {}
381 this.refreshAccounts();
383 showQrcode: function () {
384 this.$refs.qrcode.open(this.currentAccount.address);
386 openMenu: function () {
387 this.$router.push({ name: 'menu', params: { accounts: this.accounts, selected: this.currentAccount } })
389 transferOpen: function () {
390 this.$router.push({ name: 'transfer', params: { account: this.currentAccount } })
392 handleScroll(vertical, horizontal, nativeEvent) {
393 if (vertical.process == 0) {
395 this.refreshTransactions(this.currentAccount.guid, this.currentAccount.address).then(transactions => {
396 this.transactions = transactions
401 if (vertical.process == 1) {
402 this.start += this.limit;
403 this.refreshTransactions(this.currentAccount.guid, this.currentAccount.address, this.start, this.limit).then(transactions => {
404 transactions.forEach(transaction => {
405 this.transactions.push(transaction);
410 refreshAccounts: function () {
411 account.list().then(accounts => {
412 this.accounts = accounts;
413 if (accounts.length == 0) {
417 if (this.currentAccount.guid == undefined) {
418 this.currentAccount = accounts[0];
422 refreshBalance: function (guid) {
423 account.balance(guid).then(balance => {
424 this.currentAccount.balance = balance;
425 this.currentAccount = Object.assign({}, this.currentAccount);
430 refreshTransactions: function (guid, address, start, limit) {
431 return new Promise((resolve, reject) => {
432 transaction.list(guid, address, start, limit).then(ret => {
433 let transactions = ret.result.data;
434 if (transactions == null) {
438 const formattedTx = this.transactionsFormat(transactions);
439 console.log("formatTx", formattedTx);
447 transactionsFormat: function (transactions) {
448 const formattedTransactions = []
451 transactions.forEach(transaction => {
452 const balanceObject = transaction.balances
453 .filter(b => b.asset === assetID);
455 if(balanceObject.length ===1 ){
457 const inputAddresses = transaction.inputs
458 .filter(input => input.asset === assetID && input.address !== this.currentAccount.address)
459 .map(input => input.address)
461 const outputAddresses = transaction.outputs
462 .filter(output => output.asset === assetID && output.address !== this.currentAccount.address)
463 .map(output => output.address)
466 const val = assetID===BTM ? Number(balanceObject[0].amount)/ 100000000 : Number(balanceObject[0].amount);
469 transaction.direct = "+";
470 transaction.address = address.short(inputAddresses.pop());
472 transaction.direct = "-";
473 transaction.address = address.short(outputAddresses.pop());
476 transaction.val = Math.abs(val);
477 transaction.fee = transaction.fee / 100000000;
479 formattedTransactions.push(transaction);
482 return formattedTransactions;
486 this.currentAccount = JSON.parse(localStorage.currentAccount);
488 this.setupClipboard();
489 this.setupRefreshTimer();
490 this.refreshAccounts();
493 this.clipboard.destroy();