added logic to added money on balance

This commit is contained in:
Kostya
2024-01-23 23:24:53 +03:00
parent d463ef75a1
commit 6166260f63
2 changed files with 45 additions and 3 deletions

View File

@@ -88,4 +88,31 @@ export async function ClickCirclePlay(InfoUser, ClickedCell) {
catch (error) { catch (error) {
console.error('Fetch error') console.error('Fetch error')
} }
}
export async function GetWinningAmount(UserInfo) {
const data = {
SearchToken: UserInfo.SearchToken,
AuthToken: UserInfo.AuthToken
}
try {
const response = await fetch(`${BackendApiUrl}/GameMines/TransferMoneyFromGameToWallet`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data),
redirect: 'follow'
})
if (!response.ok) {
console.log('Fetch error:', response.status)
}
return await response.json()
}
catch (error) {
console.log('Fetch error', error)
}
} }

View File

@@ -44,8 +44,8 @@
<h2>Ошибка при заполнении</h2> <h2>Ошибка при заполнении</h2>
</div> </div>
<button class="btn-start" :class="{ 'animate-start-btn' : ErrorClick }" @click="clickPlayButton">Начать игру</button> <button class="btn-start" :class="{ 'animate-start-btn' : ErrorClick }" @click="clickPlayButton">Начать игру</button>
<button class="btn-claim" v-if="winningAmount === 0">Забрать {{ winningAmount }} АР</button> <button class="btn-claim" @click="claimWinningAmount()" v-if="winningAmount === 0">Забрать {{ winningAmount }} АР</button>
<button class="btn-claim" v-else>Забрать {{ winningAmount.toFixed(2) }} АР</button> <button class="btn-claim" @click="claimWinningAmount()" v-else>Забрать {{ winningAmount.toFixed(2) }} АР</button>
</div> </div>
<div class="saper-start__steps btns-style__steps"> <div class="saper-start__steps btns-style__steps">
<swiper v-if="PercentageGameSteps.length" :key="PercentageGameSteps[0]" :spaceBetween="30" :slides-per-view="4" :centeredSlides="false" :navigation="true" :modules="modules"> <swiper v-if="PercentageGameSteps.length" :key="PercentageGameSteps[0]" :spaceBetween="30" :slides-per-view="4" :centeredSlides="false" :navigation="true" :modules="modules">
@@ -140,7 +140,7 @@
import ChatComponent from "@/components/ChatComponent.vue"; import ChatComponent from "@/components/ChatComponent.vue";
import AsideBarElement from "@/components/AsidebarComponent.vue"; import AsideBarElement from "@/components/AsidebarComponent.vue";
import HeaderElementPage from "@/components/HeaderComponent.vue"; import HeaderElementPage from "@/components/HeaderComponent.vue";
import { GetPercentageSteps, GetUserData, ClickCirclePlay } from "@/assets/js/games/saper/SaperAPI"; import { GetPercentageSteps, GetUserData, ClickCirclePlay, GetWinningAmount } from "@/assets/js/games/saper/SaperAPI";
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";
@@ -326,11 +326,26 @@ export default {
this.playNotification() this.playNotification()
this.gameStart = true this.gameStart = true
this.offEventPointers = true this.offEventPointers = true
this.amountCrystals = this.amountSaveCrystals
this.amountDeposit = this.amountSaveDeposit
} }
}, },
updatePage() { updatePage() {
window.location.reload() window.location.reload()
}, },
async claimWinningAmount() {
if (this.winningAmount >= 1) {
try {
await GetWinningAmount({ SearchToken: GetCookie('SearchToken'), AuthToken: GetCookie('AUTHTOKEN') })
setTimeout(() => {
window.location.reload()
}, 1000)
}
catch (e) {
console.error(e)
}
}
},
validationCheck() { validationCheck() {
if (this.ValidationPlay.CrystalValidate === true && this.ValidationPlay.DiamondValidate === true) { if (this.ValidationPlay.CrystalValidate === true && this.ValidationPlay.DiamondValidate === true) {
return true return true