update numbergame bapp

This commit is contained in:
elegant651
2020-03-26 15:16:54 +09:00
parent 6a95428c6b
commit c1e2973803
21 changed files with 4853 additions and 3141 deletions

View File

@@ -0,0 +1,66 @@
<template>
<div>
<Wallet />
<BettingComponent v-on:complete-choose-number="onCompleteChooseNum" />
</div>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
import KlaytnService from '@/klaytn/klaytnService'
import Wallet from '@/components/wallet'
import BettingComponent from '@/components/betting-component'
export default {
name: 'game-bapp',
components: {
Wallet,
BettingComponent
},
async mounted () {
await this.connect()
},
computed: {
...mapGetters('wallet', [
'klaytn',
'myaddress'
])
},
methods: {
...mapMutations('wallet', [
'setKlaytn',
'setIsConnectWallet',
'setMyAddress',
'setBalance'
]),
async connect () {
const klaytn = new KlaytnService()
this.setKlaytn(klaytn)
const address = await klaytn.init()
if (address) {
this.setMyAddress(address)
this.getBalance()
this.setIsConnectWallet(true)
} else {
this.setIsConnectWallet(false)
}
},
async getBalance () {
if (this.myaddress) {
const balance = await this.klaytn.getBalance(this.myaddress)
console.log(this.myaddress, balance)
this.setBalance(balance)
}
},
onCompleteChooseNum () {
this.getBalance()
}
}
}
</script>