update numbergame bapp
This commit is contained in:
66
numbergame/src/components/game-bapp.vue
Normal file
66
numbergame/src/components/game-bapp.vue
Normal 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>
|
||||
Reference in New Issue
Block a user