added upd-balance func

This commit is contained in:
Kostya
2024-02-04 23:00:31 +03:00
parent 8478e23be4
commit 910ac16ea9

View File

@@ -116,6 +116,7 @@ export default {
if (this.crashObject.Status === 'GameEnd' && this.startGame === true && this.crashObject.Players.some(player => player.UserName === GetCookie('SpUserName'))) { if (this.crashObject.Status === 'GameEnd' && this.startGame === true && this.crashObject.Players.some(player => player.UserName === GetCookie('SpUserName'))) {
this.startGame = false this.startGame = false
this.updateUserMoney()
} }
if ( if (
this.crashObject.Players.some(player => player.UserName === GetCookie('SpUserName')) && this.crashObject.Players.some(player => player.UserName === GetCookie('SpUserName')) &&
@@ -205,6 +206,15 @@ export default {
} }
}, },
methods: { methods: {
async updateUserMoney() {
if (GetCookie('AUTHTOKEN') && GetCookie('SearchToken')) {
await GetCurrentMoney(GetCookie('AUTHTOKEN'), GetCookie('SearchToken'))
.then((response) => {
this.balance = response.currentMoney
return eventBus.emit('Updatebalance')
})
}
},
async clickPlayBtn() { async clickPlayBtn() {
this.v$.$touch() this.v$.$touch()
@@ -221,6 +231,7 @@ export default {
await JoinCrashGame(userData, this.amountDeposit) await JoinCrashGame(userData, this.amountDeposit)
.then((response) => { .then((response) => {
console.log(this.balance)
console.log(response) console.log(response)
if (response === `You can't join to started or ended game` || response === 'Player alredy in the game.') { if (response === `You can't join to started or ended game` || response === 'Player alredy in the game.') {
@@ -257,8 +268,13 @@ export default {
.then((response) => { .then((response) => {
console.log(response) console.log(response)
this.startGame = false this.startGame = false
return eventBus.emit('Updatebalance') this.updateUserMoney()
}) })
// await GetCurrentMoney(GetCookie('AUTHTOKEN'), GetCookie('SearchToken'))
// .then((response) => {
// this.balance = response.currentMoney
// return eventBus.emit('Updatebalance')
// })
} }
}, },
async clickedBtnChoice(index, content) { async clickedBtnChoice(index, content) {