added func to join in game crash

This commit is contained in:
Kostya
2024-02-04 16:25:21 +03:00
parent 4aabb78367
commit 886a62e208

View File

@@ -38,6 +38,9 @@
<div class="error-block" v-if="ErrorClick"> <div class="error-block" v-if="ErrorClick">
<h2>Ошибка при заполнении</h2> <h2>Ошибка при заполнении</h2>
</div> </div>
<div class="error-block" v-if="ErrorJoin">
<h2>Игра уже начата или только закончилась</h2>
</div>
<div class="crash-game-window__btn-start"> <div class="crash-game-window__btn-start">
<button @click="clickPlayBtn" :class="{ 'animate-start-btn': ErrorClick }">Начать игру</button> <button @click="clickPlayBtn" :class="{ 'animate-start-btn': ErrorClick }">Начать игру</button>
<button>Забрать</button> <button>Забрать</button>
@@ -79,6 +82,7 @@ import SaperNumbers from "@/mocks/SaperNumbers";
import {GetCurrentMoney} from "@/assets/js/rest/RestMethods"; import {GetCurrentMoney} from "@/assets/js/rest/RestMethods";
import {GetCookie} from "@/assets/js/storage/CookieStorage"; import {GetCookie} from "@/assets/js/storage/CookieStorage";
import {eventBus} from "@/main"; import {eventBus} from "@/main";
import {JoinCrashGame} from "@/assets/js/games/crash/CrashAPI";
export default { export default {
components: { HeaderComponent, AsideBarComponent, ChatComponent, CrashGraphComponent }, components: { HeaderComponent, AsideBarComponent, ChatComponent, CrashGraphComponent },
@@ -87,10 +91,12 @@ export default {
SaperNumbers, SaperNumbers,
clickedBtn: null, clickedBtn: null,
ErrorClick: false, ErrorClick: false,
ErrorJoin: false,
balance: 0, balance: 0,
amountDeposit: 0, amountDeposit: 0,
autoRatio: '', autoRatio: '',
crashObject: '' crashObject: '',
startGame: false
} }
}, },
setup() { setup() {
@@ -102,7 +108,6 @@ export default {
const dataCrashParse = JSON.parse(dataCrash) const dataCrashParse = JSON.parse(dataCrash)
this.crashObject = dataCrashParse this.crashObject = dataCrashParse
console.log(dataCrashParse)
} }
catch (e) { catch (e) {
console.error(e) console.error(e)
@@ -181,17 +186,34 @@ export default {
} }
}, },
methods: { methods: {
clickPlayBtn() { async clickPlayBtn() {
this.v$.$touch() this.v$.$touch()
if (this.v$.amountDeposit.$error) { if (this.v$.amountDeposit.$error) {
this.errorPlayButton() this.errorPlayButton()
} }
if (this.v$.autoRatio.$error) { // if (this.v$.autoRatio.$error) {
this.errorPlayButton() // this.errorPlayButton()
} // }
if (!this.v$.amountDeposit.$error && this.v$.autoRatio.$error) { // && this.v$.autoRatio.$error
// if (!this.v$.amountDeposit.$error) {
const userData = {
searchToken: GetCookie('SearchToken'),
authtoken: GetCookie('AUTHTOKEN')
}
await JoinCrashGame(userData, this.amountDeposit)
.then((response) => {
console.log(response)
if (response === `You can't join to started or ended game`) {
this.ErrorJoin = true
setTimeout(() => {
this.ErrorJoin = false
}, 2000)
}
this.startGame = true
})
} }
}, },
errorPlayButton() { errorPlayButton() {