mirror of
https://github.com/yawaflua/LuckyDiamond.git
synced 2025-12-10 12:19:31 +02:00
61
luckydiamond/src/assets/js/Profile/Referrals.js
Normal file
61
luckydiamond/src/assets/js/Profile/Referrals.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import { BackendApiUrl } from '@/properties/Сonfig.js';
|
||||
import { GetCookie } from "@/assets/js/storage/CookieStorage";
|
||||
export async function GetReferralData () {
|
||||
|
||||
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 response = await fetch(`${BackendApiUrl}/PromoCode/GetReferralInfo`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: raw,
|
||||
redirect: "follow"
|
||||
});
|
||||
|
||||
return await response.json();
|
||||
|
||||
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
@@ -14,20 +14,29 @@
|
||||
<br>
|
||||
<h3>Ваш реферальный код</h3>
|
||||
<input
|
||||
:class="{ 'animate-start-btn': errorDeposit }" readonly
|
||||
:class="{ 'animate-start-btn': errorDeposit }"
|
||||
readonly
|
||||
class="deposit-amount__input"
|
||||
v-model="amount"
|
||||
type="number"
|
||||
/>
|
||||
v-if="referralData.referralCode"
|
||||
:value="referralData.referralCode"
|
||||
/>
|
||||
<br>
|
||||
<br>
|
||||
<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-model="amount"
|
||||
type="number"
|
||||
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">
|
||||
@@ -48,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-model="amount"
|
||||
type="number"
|
||||
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>
|
||||
@@ -72,7 +89,7 @@
|
||||
<p>
|
||||
Вы подтверждаете правильность введенных данных при создании вывода.
|
||||
</p>
|
||||
<button type="submit" @click="RedirectedMethodDep">Вывести</button>
|
||||
<button type="submit" @click="handleWithdraw">Вывести</button>
|
||||
<p>
|
||||
Перед пополнение прочитайте политику конфиденциальности и
|
||||
пользовательское соглашение.
|
||||
@@ -81,16 +98,70 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import "@/assets/css/ComponentsStyles/payments-modal.css";
|
||||
export default {
|
||||
props: ["payments"],
|
||||
methods: {
|
||||
closeModal() {
|
||||
return this.$emit("closemodal");
|
||||
},
|
||||
},
|
||||
<script>
|
||||
import "@/assets/css/ComponentsStyles/payments-modal.css";
|
||||
import { GetReferralData } from "@/assets/js/Profile/Referrals";
|
||||
import { WithdrawReferralMoney } from "@/assets/js/Profile/Referrals";
|
||||
import { eventBus } from "@/main";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
referralData: {},
|
||||
errorDeposit: false,
|
||||
errorAgree: false,
|
||||
agreeUser: false,
|
||||
amount: 0,
|
||||
PaymentsModalNumbers: [],
|
||||
};
|
||||
</script>
|
||||
},
|
||||
props: ["payments"],
|
||||
async created() {
|
||||
this.referralData = await GetReferralData();
|
||||
},
|
||||
computed: {
|
||||
avalibleAmountValue() {
|
||||
return this.referralData.avalibleAmount !== 0 ? this.referralData.avalibleAmount : '0';
|
||||
},
|
||||
activationsAmountValue() {
|
||||
return this.referralData.activationsAmount !== 0 ? this.referralData.activationsAmount : '0';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async handleWithdraw() {
|
||||
try {
|
||||
if (!this.agreeUser) {
|
||||
this.errorAgree = true;
|
||||
setTimeout(() => {
|
||||
this.errorAgree = false;
|
||||
}, 1500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.referralData.avalibleAmount == 0) {
|
||||
window.alert("У вас нет денег на вывод :(");
|
||||
return;
|
||||
}
|
||||
|
||||
await WithdrawReferralMoney().then(async (response) => {
|
||||
try {
|
||||
console.log("work", response);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
await this.$emit("notifacetionmoney");
|
||||
eventBus.emit("Updatebalance");
|
||||
this.$emit("closemodal");
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error withdrawing referral money:", error);
|
||||
}
|
||||
},
|
||||
closeModal() {
|
||||
this.$emit("closemodal");
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -100,6 +100,57 @@ export default {
|
||||
this.RemoveWindowListener()
|
||||
},
|
||||
created() {
|
||||
|
||||
const myHeaders = new Headers();
|
||||
myHeaders.append("Content-Type", "application/json");
|
||||
myHeaders.append("Cookie", "ARRAffinity=a6e48b9e9d2653435be7b61998d8624b44115214104213d6c8b8c526cc56dc70; ARRAffinitySameSite=a6e48b9e9d2653435be7b61998d8624b44115214104213d6c8b8c526cc56dc70");
|
||||
|
||||
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/GetReferralInfo", requestOptions)
|
||||
.then((response) => response.text())
|
||||
.then((result) => {
|
||||
console.log(result);
|
||||
if (result == "\"The Referral is not created\"") {
|
||||
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/CreateReferal", requestOptions)
|
||||
.then((response) => response.text())
|
||||
.then((result) => console.log(result))
|
||||
.catch((error) => console.error(error));
|
||||
}
|
||||
})
|
||||
.catch((error) => console.error(error));
|
||||
|
||||
axios.post('https://spsystemcore20231122004605.azurewebsites.net/api/Payment/GetPaymentHistory', {
|
||||
searchToken: GetCookie('SearchToken'),
|
||||
authtoken: GetCookie('AUTHTOKEN')
|
||||
|
||||
Reference in New Issue
Block a user