added request for get percentage-steps in saper-game

This commit is contained in:
Kostya
2024-01-19 21:20:21 +03:00
parent b25141b781
commit e74e51b35e
2 changed files with 50 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
import { BackendApiUrl } from '@/properties/Сonfig.js';
export async function GetPercentageSteps(CrystalsCount) {
const data = {
minesCount: CrystalsCount
}
try {
const response = await fetch(`${BackendApiUrl}/GameMines/GetMultiplierPercentage`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data),
redirect: 'follow'
})
if (!response.ok) {
console.log('Fetch error:', response.status)
}
console.log(response)
return await response.json()
}
catch (error) {
console.log('Fetch Error!')
}
}

View File

@@ -136,6 +136,7 @@
import ChatComponent from "@/components/ChatComponent.vue";
import AsideBarElement from "@/components/AsidebarComponent.vue";
import HeaderElementPage from "@/components/HeaderComponent.vue";
import { GetPercentageSteps } from "@/assets/js/games/saper/SaperAPI";
import { Swiper, SwiperSlide } from 'swiper/vue';
import 'swiper/css';
@@ -153,13 +154,33 @@ export default {
clickedBtn: '',
clickedBtnCrystal : '',
amountCrystals: 5,
amountSaveCrystals: 0,
balance: 1000,
amountDeposit: 5,
flippedCards: [],
PercentageGameSteps: [],
modules: [ Pagination ]
}
},
watch: {
PercentageGameSteps(CrystalsCount) {
if (CrystalsCount >= 1) {
this.amountSaveCrystals = CrystalsCount
setTimeout(() => {
try {
GetPercentageSteps(this.amountSaveCrystals)
.then((response) => {
this.PercentageGameSteps.push(response)
console.log(response)
})
}
catch (e) {
console.error('Error in Percantage', e)
}
}, 1500)
}
}
},
methods: {
flipCard(index) {
if (this.flippedCards.includes(index)) {