mirror of
https://github.com/yawaflua/LuckyDiamond.git
synced 2025-12-10 12:19:31 +02:00
Referral creation on page load, api things
This commit is contained in:
33
luckydiamond/src/assets/js/Profile/Referrals.js
Normal file
33
luckydiamond/src/assets/js/Profile/Referrals.js
Normal file
@@ -0,0 +1,33 @@
|
||||
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");
|
||||
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 response = await fetch(`${BackendApiUrl}/PromoCode/GetReferralInfo`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: raw,
|
||||
redirect: "follow"
|
||||
});
|
||||
|
||||
return await response.json();
|
||||
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
class="deposit-input deposit-text referal-icon-diamond deposit-icon__input"
|
||||
>
|
||||
<br>
|
||||
<h3>Ваш реферальный код</h3>
|
||||
<h3 v-if="data in ReferralData">{{ referralCode }}</h3>
|
||||
<input
|
||||
:class="{ 'animate-start-btn': errorDeposit }" readonly
|
||||
class="deposit-amount__input"
|
||||
@@ -85,7 +85,13 @@
|
||||
|
||||
<script>
|
||||
import "@/assets/css/ComponentsStyles/payments-modal.css";
|
||||
import {GetReferralData} from "@/assets/js/Profile/Referrals";
|
||||
export default {
|
||||
data () {
|
||||
return{
|
||||
ReferralData: GetReferralData
|
||||
}
|
||||
},
|
||||
props: ["payments"],
|
||||
methods: {
|
||||
closeModal() {
|
||||
|
||||
@@ -90,7 +90,7 @@ export default {
|
||||
arrayHistory: [],
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
emits: ['notificationremove'],
|
||||
mounted() {
|
||||
this.checkWindowSize()
|
||||
@@ -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')
|
||||
@@ -140,7 +191,7 @@ export default {
|
||||
this.payments = false
|
||||
this.openRef = false
|
||||
},
|
||||
referalClick() {
|
||||
referalClick() {
|
||||
this.openModal = false
|
||||
this.openRef = true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user