Skip to content

Commit

Permalink
update]
Browse files Browse the repository at this point in the history
  • Loading branch information
webkonglong committed Jan 19, 2019
1 parent 2ddb753 commit b365f3b
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 25 deletions.
111 changes: 105 additions & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@
<!--<GlobalSpinner v-show="!globalProgressVisible && globalSpinnerVisible" />-->
<Loading v-show="!globalProgressVisible && globalSpinnerVisible" loadText="loading ..." />
<!--<div class="app-nav is-hidden-mobile" v-show="!tokenShow">-->
<myPortal v-if="portalShow" :portalList="portalList" @closeMyPortal="closeMyPortal" />
<div class="mylangd" v-if="isShowMylangd">
<div class="close-mylangd" @click="closeMylangd"><img src="./assets/icons/close.png" /></div>
<div
v-if="myLangdArr.length"
v-for="(item, index) in myLangdArr"
:key="index"
class="mylangd-item"
>
<p>{{$t('my_portal_name')}}: {{getCountryName(item.name.code)}}</p>
<p>{{$t('my_portal_price')}}: {{`${item.price / 10000} BOS`}}</p>
</div>
<div v-if="!myLangdArr.length" class="no-langd">
No
</div>
</div>
<div class="app-nav is-hidden-mobile">
<button :class="['nav-item', 'button', 'is-white', 'is-small', 'is-rounded', 'is-outlined', { 'is-loading': isScatterLoggingIn }]"
@click="loginScatterAsync"
Expand Down Expand Up @@ -150,6 +164,15 @@ import Loading from '@/components/Loading.vue';
// import GlobalProgress from '@/components/GlobalProgress.vue';
import InviteModal from '@/components/InviteModal.vue';
import myPortal from '@/components/landmark//myPortal.vue'
import * as CountryCode from 'i18n-iso-countries';
CountryCode.registerLocale(require('i18n-iso-countries/langs/en.json'));
CountryCode.registerLocale(require('i18n-iso-countries/langs/zh.json'));
CountryCode.registerLocale(require('i18n-iso-countries/langs/ko.json'));
CountryCode.registerLocale(require('i18n-iso-countries/langs/ja.json'));
CountryCode.registerLocale(require('i18n-iso-countries/langs/ru.json'));
// 繁体中文
CountryCode.registerLocale(require('./i18n/Country_zh_tw.json'));
export default {
name: 'App',
Expand All @@ -174,7 +197,9 @@ export default {
appLogin: false,
portalShow: false,
portalList: [],
i18nCode: ''
i18nCode: '',
isShowMylangd: false,
myLangdArr: []
}),
created() {
this.countdownUpdater = setInterval(() => {
Expand Down Expand Up @@ -206,6 +231,13 @@ export default {
},
methods: {
...mapActions(['getMyStakedInfo', 'getMyBalances', 'connectScatterAsync', 'updateLandInfoAsync', 'loginScatterAsync', 'logoutScatterAsync', 'updateMarketInfoAsync', 'getGlobalInfo']),
closeMylangd () {
this.isShowMylangd = false
},
getCountryName(countryCode) {
const locale = CountryCode.langs().includes(this.$i18n.locale) ? this.$i18n.locale : 'en';
return CountryCode.getName(countryCode, locale);
},
async vote (voteName, callback) {
try {
await API.voteAsync({to: voteName})
Expand Down Expand Up @@ -374,7 +406,7 @@ export default {
async buyCMU() {
let amount = window.prompt(this.$t('buy_cmu_alert'));
amount = parseFloat(amount).toFixed(4);
amount += ' EOS';
amount += ' BOS';
try {
await API.transferTokenAsync({
from: this.scatterAccount.name,
Expand Down Expand Up @@ -414,7 +446,7 @@ export default {
await API.transferTokenAsync({
from: this.scatterAccount.name,
to: 'cryptomeetup',
tokenContract: 'dacincubator',
tokenContract: 'ncldwqxpkgav',
memo: 'sell',
amount,
});
Expand Down Expand Up @@ -480,7 +512,7 @@ export default {
this.isInviteDialogActive = true;
},
taggleMyPortal () {
this.portalShow = !this.portalShow
this.isShowMylangd = !this.isShowMylangd
},
closeMyPortal () {
this.portalShow = false
Expand All @@ -494,10 +526,42 @@ export default {
i18nCode (val) {
this.$i18n.locale = val
localStorage.setItem('language', val)
},
landInfo (landInfo) {
if (!this.myLangdArr.length && landInfo && this.scatterAccount && this.scatterAccount.name) {
console.log(1)
var myLangdArr = []
for (let key in landInfo) {
if (landInfo[key].owner === this.scatterAccount.name) {
myLangdArr.push({
price: landInfo[key].price,
name: landInfo[key]
})
}
}
this.myLangdArr = myLangdArr
}
},
scatterAccount (scatterAccount) {
// console.log()
if (!this.myLangdArr.length && this.landInfo && scatterAccount && scatterAccount.name) {
console.log(2)
var myLangdArr = []
for (let key in this.landInfo) {
if (this.landInfo[key].owner === scatterAccount.name) {
myLangdArr.push({
price: this.landInfo[key].price,
name: this.landInfo[key]
})
}
}
this.myLangdArr = myLangdArr
}
}
},
computed: {
...mapState(['landInfoUpdateAt', 'isScatterConnected', 'scatterAccount', 'isScatterLoggingIn', 'balances', 'marketInfo', 'stakedInfo', 'globalInfo', 'dividendInfo', 'myCheckInStatus']),
...mapState(['landInfo','landInfoUpdateAt', 'isScatterConnected', 'scatterAccount', 'isScatterLoggingIn', 'balances', 'marketInfo', 'stakedInfo', 'globalInfo', 'dividendInfo', 'myCheckInStatus']),
...mapState('ui', ['navBurgerVisible', 'latestBuyerVisible', 'globalSpinnerVisible', 'globalProgressVisible', 'globalProgressValue']),
},
mounted() {
Expand Down Expand Up @@ -538,6 +602,41 @@ a:hover
</style>

<style lang="sass" scoped>
.mylangd
position: absolute
left: 20px
top: 100px
bottom: 100px
right: 20px
z-index: 999
background: rgb(25, 25, 25)
overflow-y: scroll
padding-top: 20px
.no-langd
text-align: center
font-size: 12px
padding: 50px 0
color: #fff
.mylangd-item
font-size: 12px
color: #fff
padding-left: 20px
margin-bottom: 20px
.close-mylangd
position: absolute
right: 20px
top: 20px
cursor: pointer
width: 24px
height: 24px
img
display: block
width: 24px
height: 24px
#app
position: absolute
left: 0
Expand Down
4 changes: 4 additions & 0 deletions src/components/landmark/myPortal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

<script>
import { getLocalStorage } from '@/util/storeUtil.js'
import { mapState } from 'vuex';
import Global from '@/Global.js'
export default {
Expand All @@ -49,6 +50,9 @@ export default {
des: '',
}
},
computed: {
...mapState(['landInfo', 'scatterAccount']),
},
methods: {
closeMyPortal() {
this.$emit('closeMyPortal')
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
buy_portal_error: 'Intelligent contract did not find this landmark',
buy_portal_success: 'Buy portal success',

my_portal_nav: 'My portal',
my_portal_nav: 'My land',
my_portal_title: 'My portal',
my_portal_no_time: 'No time',
my_portal_name: 'name',
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/jp.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
buy_portal_error: 'スマートな契約はこのマークが見つかりません',
buy_portal_success: '買い付けが成功する',

my_portal_nav: '私の地札',
my_portal_nav: '私のランド',
my_portal_title: '私の持っている地盤',
my_portal_no_time: '見送る',
my_portal_name: '名称',
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default {
buy_portal_error: '스마트 계약 찾을 수 없음',
buy_portal_success: '지표 구매가 성공하다',

my_portal_nav: '나의 지표',
my_portal_nav: '내 땅',
my_portal_title: '내가 가진 지표',
my_portal_no_time: '없다',
my_portal_name: '명칭.',
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
buy_portal_error: 'смартизированный договор не найден.',
buy_portal_success: 'покупка маяка',

my_portal_nav: 'мой ориентир.',
my_portal_nav: 'моя земля',
my_portal_title: ' У меня есть ориентир, который у меня есть',
my_portal_no_time: 'Пока нет',
my_portal_name: 'имя',
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default {
buy_portal_error: '未在区块链中找到地标',
buy_portal_success: '购买地标成功',

my_portal_nav: '我的地标',
my_portal_nav: '我的地产',
my_portal_title: '我拥有的地标',
my_portal_no_time: '暂无',
my_portal_name: '名称',
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/zh_tw.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
buy_portal_error: '智慧合約未找到此地標',
buy_portal_success: '購買地標成功',

my_portal_nav: '我的地標',
my_portal_nav: '我的地產',
my_portal_title: '我擁有的地標',
my_portal_no_time: '暫無',
my_portal_name: '名稱',
Expand Down
18 changes: 14 additions & 4 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Vue from 'vue';
import Vuex from 'vuex';
import { Toast } from 'buefy/dist/components/toast';
import Land from '@/util/land';
import { ajax } from '@/util/ajax';
import API, { currentEOSAccount } from '@/util/api';
import ui from './ui';
import Global from '@/Global.js';
Expand Down Expand Up @@ -89,7 +90,7 @@ export default new Vuex.Store({
commit('setIsScatterConnected', true);
if (currentEOSAccount()) {
commit('setScatterAccount', currentEOSAccount());
// dispatch('getMyBalances');
dispatch('getMyBalances');
// dispatch('getPortalInfo');
// dispatch('getMyStakedInfo');
// dispatch('getPlayerInfo');
Expand All @@ -98,14 +99,23 @@ export default new Vuex.Store({
}
},
async getMyBalances({ commit, state }) {
console.log(12121221)
const { name } = state.scatterAccount;
// ajax.post('https://hapi.bos.eosrio.io/v1/chain/get_currency_balance', {
// code: 'eosio.token',
// account: name,
// symbol: 'BOS'
// }).then(resp => {
// console.log(resp, 'resp')
// })
const balances = await Promise.all([
API.getBalancesByContract({ symbol: 'eos', accountName: name }),
API.getBalancesByContract({ symbol: 'cmu', accountName: name, tokenContract: 'dacincubator' }),
API.getBalancesByContract({ symbol: 'BOS', accountName: name }),
API.getBalancesByContract({ symbol: 'CMU', accountName: name, code: 'ncldwqxpkgav' }),
]);
console.log(balances, 'balances')
const eos = balances[0][0];
const cmu = balances[1][0];
commit('setMyBalance', { symbol: 'eos', balance: eos });
commit('setMyBalance', { symbol: 'bos', balance: eos });
commit('setMyBalance', { symbol: 'cmu', balance: cmu });
},
async updateLandInfoAsync({ commit }) {
Expand Down
6 changes: 3 additions & 3 deletions src/util/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ const API = {
});
return rows;
},
async getBalancesByContract({ tokenContract = 'eosio.token', accountName, symbol }) {
return eos().getCurrencyBalance(tokenContract, accountName, symbol);
async getBalancesByContract({ code = 'eosio.token', accountName, symbol }) {
return eos().getCurrencyBalance(code, accountName, symbol);
},
async getRefund(){
async getRefund() {
const { rows } = await eos().getTableRows({
json: true,
code: 'cryptomeetup',
Expand Down
8 changes: 4 additions & 4 deletions src/views/Token.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div style="padding: 0.5rem;">
<h3 class="title">{{$t('total_dividend')}}: <b style="color: #fff">{{totalDividend(globalInfo.total_staked, globalInfo.earnings_per_share)}}</b></h3>
<h3 v-if="scatterAccount" class="title">{{$t('my_dividend')}}: <b style="color: #fff">{{myDividend(globalInfo.earnings_per_share, stakedInfo.staked, stakedInfo.payout)}}</b></h3>
<h3 v-if="dividendInfo" class="title">{{$t('jackpot_income')}}: <b style="color: #fff">{{dividendInfo.game_profit ? `${dividendInfo.game_profit.div(10000).toDecimal(4)} EOS` : '0.0000 EOS'}}</b></h3>
<h3 v-if="dividendInfo" class="title">{{$t('jackpot_income')}}: <b style="color: #fff">{{dividendInfo.game_profit ? `${dividendInfo.game_profit.div(10000).toDecimal(4)} BOS` : '0.0000 BOS'}}</b></h3>
<h3 v-if="dividendInfo" class="title">{{$t('share_income')}}: <b style="color: #fff">{{dividendInfo.ref_profit ? `${dividendInfo.ref_profit.div(10000).toDecimal(4)} CMU` : '0.0000 CMU'}}</b></h3>
<h3 v-if="dividendInfo" class="title">{{$t('create_portal_income')}}: <b style="color: #fff">{{dividendInfo.fee_profit ? `${dividendInfo.fee_profit.div(10000).toDecimal(4)} CMU` : '0.0000 CMU'}}</b></h3>
</div>
Expand All @@ -31,7 +31,7 @@
</div>
</b-tab-item>
<b-tab-item v-if="scatterAccount" :label="$t('my_assets_tab')" icon="account">
<h3 class="title">{{$t('my_EOS')}}: <b style="color: #fff">{{balances.eos || '0 EOS'}}</b></h3>
<h3 class="title">{{$t('my_EOS')}}: <b style="color: #fff">{{balances.bos || '0 BOS'}}</b></h3>
<h3 class="title">{{$t('my_CMU')}}: <b style="color: #fff">{{balances.cmu || '0 CMU'}}</b></h3>
</b-tab-item>
<b-tab-item :label="$t('stake_tab')" icon="bank">
Expand Down Expand Up @@ -76,7 +76,7 @@
<div style="padding: 0.5rem;">
<h3 class="title">{{$t('total_dividend')}}: <b style="color: #fff">{{totalDividend(globalInfo.total_staked, globalInfo.earnings_per_share)}}</b></h3>
<h3 class="title" v-if="scatterAccount">{{$t('my_dividend')}}: <b style="color: #fff">{{myDividend(globalInfo.earnings_per_share, stakedInfo.staked, stakedInfo.payout)}}</b></h3>
<h3 v-if="dividendInfo" class="title">{{$t('jackpot_income')}}: <b style="color: #fff">{{dividendInfo.game_profit ? `${dividendInfo.game_profit.div(10000).toDecimal(4)} EOS` : '0.0000 EOS'}}</b></h3>
<h3 v-if="dividendInfo" class="title">{{$t('jackpot_income')}}: <b style="color: #fff">{{dividendInfo.game_profit ? `${dividendInfo.game_profit.div(10000).toDecimal(4)} BOS` : '0.0000 BOS'}}</b></h3>
<h3 v-if="dividendInfo" class="title">{{$t('share_income')}}: <b style="color: #fff">{{dividendInfo.ref_profit ? `${dividendInfo.ref_profit.div(10000).toDecimal(4)} CMU` : '0.0000 CMU'}}</b></h3>
<h3 v-if="dividendInfo" class="title">{{$t('create_portal_income')}}: <b style="color: #fff">{{dividendInfo.fee_profit ? `${dividendInfo.fee_profit.div(10000).toDecimal(4)} CMU` : '0.0000 CMU'}}</b></h3>
</div>
Expand All @@ -90,7 +90,7 @@
</div>
</b-tab-item>
<b-tab-item :label="$t('my_assets_tab')" v-if="scatterAccount" icon="account">
<h3 class="title">{{$t('my_EOS')}}: <b style="color: #fff">{{balances.eos || '0 EOS'}}</b></h3>
<h3 class="title">{{$t('my_EOS')}}: <b style="color: #fff">{{balances.bos || '0 BOS'}}</b></h3>
<h3 class="title">{{$t('my_CMU')}}: <b style="color: #fff">{{balances.cmu || '0 CMU'}}</b></h3>
</b-tab-item>
<b-tab-item :label="$t('stake_tab')" icon="bank">
Expand Down
3 changes: 1 addition & 2 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ module.exports = {
devServer: {
host: '0.0.0.0',
port: 8080,
https: true,
proxy: 'https://cryptomeetup.io',
https: true
},
};

0 comments on commit b365f3b

Please sign in to comment.