added styles and logic for checkvalidation, erorbtn and clickplaybtn

This commit is contained in:
Kostya
2024-01-21 00:31:32 +03:00
parent 0f02a92b23
commit 041f0c19e4
2 changed files with 55 additions and 8 deletions

View File

@@ -255,6 +255,23 @@ input[type="number"]::-webkit-outer-spin-button {
height: 40px; height: 40px;
} }
.error-block {
position: absolute;
top: 440px;
}
.error-block h2 {
color: #982f2f;
font-weight: 700;
font-family: Montserrat Alternates;
font-size: 10px;
}
.animate-start-btn {
animation: shake 0.6s cubic-bezier(.36, .07, .19, .97);
opacity: 50%;
}
/* Saper Game */ /* Saper Game */
.saper-game { .saper-game {

View File

@@ -40,7 +40,10 @@
</div> </div>
</div> </div>
<div class="saper-start__btns"> <div class="saper-start__btns">
<button class="btn-start">Начать игру</button> <div class="error-block" v-if="ErrorClick === true">
<h2>Ошибка при заполнении</h2>
</div>
<button class="btn-start" :class="{ 'animate-start-btn' : ErrorClick }" @click="clickPlayButton">Начать игру</button>
<button class="btn-claim">Забрать 15 АР</button> <button class="btn-claim">Забрать 15 АР</button>
</div> </div>
<div class="saper-start__steps btns-style__steps"> <div class="saper-start__steps btns-style__steps">
@@ -53,11 +56,6 @@
</swiper-slide> </swiper-slide>
</template> </template>
</swiper> </swiper>
<!-- <ul class="steps-btns__display">-->
<!-- <li v-for="(item, index) in SaperNumbers" :key="index">-->
<!-- <button v-if="item.steps !== undefined">{{ item.steps }}</button>-->
<!-- </li>-->
<!-- </ul>-->
</div> </div>
</div> </div>
</div> </div>
@@ -158,17 +156,30 @@ export default {
amountCrystals: 0, amountCrystals: 0,
amountSaveCrystals: 0, amountSaveCrystals: 0,
balance: 1000, balance: 1000,
amountDeposit: 5, ErrorClick: '',
amountDeposit: 0,
amountSaveDeposit: 0,
flippedCards: [], flippedCards: [],
PercentageGameSteps: [], PercentageGameSteps: [],
ValidationPlay: {
CrystalValidate: false,
DiamondValidate: false
},
modules: [ Navigation ] modules: [ Navigation ]
} }
}, },
watch: { watch: {
amountDeposit(DiamondCount) {
if (DiamondCount >= 1) {
this.amountSaveDeposit = DiamondCount
this.ValidationPlay.DiamondValidate = true
}
},
async amountCrystals(CrystalsCount) { async amountCrystals(CrystalsCount) {
this.PercentageGameSteps = [] this.PercentageGameSteps = []
if (CrystalsCount >= 1 && CrystalsCount <= 24) { if (CrystalsCount >= 1 && CrystalsCount <= 24) {
this.amountSaveCrystals = CrystalsCount this.amountSaveCrystals = CrystalsCount
this.ValidationPlay.CrystalValidate = true
try { try {
await GetPercentageSteps(this.amountSaveCrystals) await GetPercentageSteps(this.amountSaveCrystals)
.then((response) => { .then((response) => {
@@ -184,7 +195,7 @@ export default {
console.error('Error in Percantage', e) console.error('Error in Percantage', e)
} }
} }
} },
}, },
async created() { async created() {
const AUTHTOKEN = GetCookie('AUTHTOKEN') const AUTHTOKEN = GetCookie('AUTHTOKEN')
@@ -203,6 +214,25 @@ export default {
} }
}, },
methods: { methods: {
clickPlayButton() {
if(!this.validationCheck()) {
this.errorPlayButton()
}
else {
console.log('yes')
}
},
validationCheck() {
if (this.ValidationPlay.CrystalValidate === true && this.ValidationPlay.DiamondValidate === true) {
return true
}
},
errorPlayButton() {
this.ErrorClick = true
setTimeout(() => {
this.ErrorClick = false
}, 2000)
},
flipCard(index) { flipCard(index) {
if (this.flippedCards.includes(index)) { if (this.flippedCards.includes(index)) {
this.flippedCards.splice(this.flippedCards.indexOf(index), 1); this.flippedCards.splice(this.flippedCards.indexOf(index), 1);