Fix so it is not collapsing when value is 0, added withdraw

This commit is contained in:
Swino4ka
2024-04-07 18:28:43 +02:00
parent 82b32794b8
commit d342617a13
2 changed files with 85 additions and 13 deletions

View File

@@ -4,7 +4,6 @@ export async function GetReferralData () {
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "ARRAffinity=a6e48b9e9d2653435be7b61998d8624b44115214104213d6c8b8c526cc56dc70; ARRAffinitySameSite=a6e48b9e9d2653435be7b61998d8624b44115214104213d6c8b8c526cc56dc70");
const userData = {
searchToken: GetCookie("SearchToken"),
@@ -31,3 +30,32 @@ export async function GetReferralData () {
}
export async function WithdrawReferralMoney () {
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
const userData = {
searchToken: GetCookie("SearchToken"),
authtoken: GetCookie("AUTHTOKEN"),
};
const raw = JSON.stringify({
"userCredentials": {
"searchToken": userData.searchToken,
"authtoken": userData.authtoken
}
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://spsystemcore20231122004605.azurewebsites.net/api/PromoCode/TakeMoneyReferral", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
}

View File

@@ -25,10 +25,18 @@
<h3>Доступно к выводу</h3>
<img src="@/assets/icons-games/saper-game/icon-diamond-ore-saper.png" />
<input
:class="{ 'animate-start-btn': errorDeposit }" readonly
:class="{ 'animate-start-btn': errorDeposit }"
readonly
class="deposit-amount__input"
v-if="referralData.avalibleAmount"
v-if="referralData.avalibleAmount !== 0"
:value="referralData.avalibleAmount"
/>
<input
:class="{ 'animate-start-btn': errorDeposit }"
readonly
class="deposit-amount__input"
v-else
:value="'0'"
/>
<div class="deposit-btns">
<ul class="display-btns btns-style-diamonds">
@@ -49,10 +57,18 @@
<h3>Всего привели рефералов</h3>
<div class="promokods">
<input
:class="{ 'animate-start-btn': errorDeposit }" readonly
:class="{ 'animate-start-btn': errorDeposit }"
readonly
class="deposit-amount__input"
v-if="referralData.activationsAmount"
v-if="referralData.activationsAmount !== 0"
:value="referralData.activationsAmount"
/>
<input
:class="{ 'animate-start-btn': errorDeposit }"
readonly
class="deposit-amount__input"
v-else
:value="'0'"
/>
</div>
</div>
@@ -73,7 +89,7 @@
<p>
Вы подтверждаете правильность введенных данных при создании вывода.
</p>
<button type="submit" @click="RedirectedMethodDep">Вывести</button>
<button type="submit" @click="handleWithdraw">Вывести</button>
<p>
Перед пополнение прочитайте политику конфиденциальности и
пользовательское соглашение.
@@ -87,6 +103,7 @@
<script>
import "@/assets/css/ComponentsStyles/payments-modal.css";
import { GetReferralData } from "@/assets/js/Profile/Referrals";
import { WithdrawReferralMoney } from "@/assets/js/Profile/Referrals";
export default {
data() {
@@ -104,7 +121,34 @@ export default {
// При создании компонента загружаем данные о реферале
this.referralData = await GetReferralData();
},
computed: {
avalibleAmountValue() {
if (this.referralData.avalibleAmount !== 0) {
return this.referralData.avalibleAmount;
} else {
return '0';
}
},
activationsAmountValue() {
if (this.referralData.activationsAmount !== 0) {
return this.referralData.activationsAmount;
} else {
return '0';
}
}
},
methods: {
async handleWithdraw() {
try {
// Call the WithdrawReferralMoney function
await WithdrawReferralMoney();
// Handle success, e.g., show a success message or perform other actions
console.log("Withdrawal successful!");
} catch (error) {
// Handle errors, e.g., show an error message or perform other actions
console.error("Error withdrawing referral money:", error);
}
},
closeModal() {
return this.$emit("closemodal");
},