mirror of
https://github.com/yawaflua/LuckyDiamond.git
synced 2025-12-10 04:09:29 +02:00
PromoCodes
This commit is contained in:
@@ -74,4 +74,31 @@ export async function GetChatHistory() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function ApplyPromoCode(authToken, searchToken, promoCode) {
|
||||||
|
const data = {
|
||||||
|
userCredentials: {
|
||||||
|
searchToken: searchToken,
|
||||||
|
authtoken: authToken
|
||||||
|
},
|
||||||
|
promoCode: promoCode
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${BackendApiUrl}/PromoCode/ApplyPromo`, {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -33,14 +33,14 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="showPromocodeStatus" class="error-promocode">
|
<div v-if="showPromocodeStatus" class="error-promocode">
|
||||||
<h2 v-if="errorPromocode" class="error-text__promocode">Промокод не найден</h2>
|
<h2 v-if="errorPromocode" class="error-text__promocode">{{ promoResponse }}</h2>
|
||||||
<h2 v-else class="correct-text__promocode">Промокод успешно применён</h2>
|
<h2 v-else class="correct-text__promocode">Промокод успешно применён</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="deposit-promocode deposit-promocode__padding--input">
|
<div class="deposit-promocode deposit-promocode__padding--input">
|
||||||
<h3>Промокод</h3>
|
<h3>Промокод</h3>
|
||||||
<div class="promokods">
|
<div class="promokods">
|
||||||
<input @focusout="checkValidationPromocode" v-model="promocode" class="promo-input" type="text" />
|
<input @focusout="checkValidationPromocode" v-model="promocode" class="promo-input" type="text" />
|
||||||
<button class="vvod_promocoda">Ввод</button>
|
<button class="vvod_promocoda" @click="handleApplyPromoCode">Ввод</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="error-checkbox" v-if="errorAgree">
|
<div class="error-checkbox" v-if="errorAgree">
|
||||||
@@ -120,12 +120,14 @@ import PaymentsModalNumbers from "@/mocks/PaymentsModalNumbers";
|
|||||||
import { GettingMoneyOperation, WithdrawMoneyOperation } from "@/assets/js/moneyoperation/Claimmoney";
|
import { GettingMoneyOperation, WithdrawMoneyOperation } from "@/assets/js/moneyoperation/Claimmoney";
|
||||||
import CaptchaComponent from "@/components/CaptchaComponent.vue";
|
import CaptchaComponent from "@/components/CaptchaComponent.vue";
|
||||||
|
|
||||||
|
|
||||||
import {eventBus} from "@/main";
|
import {eventBus} from "@/main";
|
||||||
|
|
||||||
import { useVuelidate } from '@vuelidate/core'
|
import { useVuelidate } from '@vuelidate/core'
|
||||||
import {maxValue, minValue, required, numeric, integer, minLength, maxLength} from "@vuelidate/validators";
|
import {maxValue, minValue, required, numeric, integer, minLength, maxLength} from "@vuelidate/validators";
|
||||||
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 { ApplyPromoCode } from "@/assets/js/rest/RestMethods.js"; // Замените на правильный путь к файлу с функцией ApplyPromoCode
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { CaptchaComponent },
|
components: { CaptchaComponent },
|
||||||
@@ -215,10 +217,10 @@ export default {
|
|||||||
closeModal() {
|
closeModal() {
|
||||||
return this.$emit("closemodal");
|
return this.$emit("closemodal");
|
||||||
},
|
},
|
||||||
checkValidationPromocode() {
|
// checkValidationPromocode() {
|
||||||
this.errorPromocode = !this.promocodeBase.includes(this.promocode);
|
// this.errorPromocode = !this.promocodeBase.includes(this.promocode);
|
||||||
this.showPromocodeStatus = true
|
// this.showPromocodeStatus = true
|
||||||
},
|
// },
|
||||||
completeValidationCheck() {
|
completeValidationCheck() {
|
||||||
this.offBtn = true
|
this.offBtn = true
|
||||||
|
|
||||||
@@ -234,6 +236,46 @@ export default {
|
|||||||
claimCaptchaToken(Token) {
|
claimCaptchaToken(Token) {
|
||||||
this.captchaToken = Token
|
this.captchaToken = Token
|
||||||
this.completeValidtaion.captchatokensaving = true
|
this.completeValidtaion.captchatokensaving = true
|
||||||
|
},
|
||||||
|
async handleApplyPromoCode() {
|
||||||
|
const authToken = GetCookie("AUTHTOKEN");
|
||||||
|
const searchToken = GetCookie("SearchToken");
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await ApplyPromoCode(authToken, searchToken, this.promocode);
|
||||||
|
|
||||||
|
console.log(response);
|
||||||
|
|
||||||
|
if (response === 'Promo dont exist.')
|
||||||
|
{
|
||||||
|
this.showPromocodeStatus = true;
|
||||||
|
this.errorPromocode = true;
|
||||||
|
this.promoResponse = 'Промокод не найден';
|
||||||
|
}
|
||||||
|
else if(response === 'promotional code has expired')
|
||||||
|
{
|
||||||
|
this.showPromocodeStatus = true;
|
||||||
|
this.errorPromocode = true;
|
||||||
|
this.promoResponse = 'Не действителен';
|
||||||
|
}
|
||||||
|
else if(response === 'User is alredy use the promo')
|
||||||
|
{
|
||||||
|
this.showPromocodeStatus = true;
|
||||||
|
this.errorPromocode = true;
|
||||||
|
this.promoResponse = 'Уже использован';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.showPromocodeStatus = true;
|
||||||
|
this.errorPromocode = false;
|
||||||
|
this.promoResponse = response;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
console.error("Ошибка при применении промокода:", error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async RedirectedMethodDep() {
|
async RedirectedMethodDep() {
|
||||||
this.v$.$touch()
|
this.v$.$touch()
|
||||||
|
|||||||
Reference in New Issue
Block a user