mirror of
https://github.com/yawaflua/LuckyDiamond.git
synced 2025-12-10 04:09:29 +02:00
add get money funcs
This commit is contained in:
@@ -22,25 +22,26 @@ export async function Post(url = "", data = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function GetCurrentMoney(authToken) {
|
export async function GetCurrentMoney(authToken, searchToken) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${BackendApiUrl}/Payment/GetCurrentMoney`, {
|
const response = await fetch(`${BackendApiUrl}/Payment/GetCurrentMoney`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'AuthToken': authToken,
|
'AUTHTOKEN': authToken,
|
||||||
}
|
'SearchToken': searchToken
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const data = await response.json();
|
if (!response.ok) {
|
||||||
console.log(data); // Здесь вы можете обработать полученные данные
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
return data;
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
console.log(data); // Здесь вы можете обработать полученные данные
|
||||||
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('There was a problem with the fetch operation:', error);
|
console.error('There was a problem with the fetch operation:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,13 +41,21 @@ export default {
|
|||||||
this.imageUrl = this.imageUrl + `${response.spUserName}.png`;
|
this.imageUrl = this.imageUrl + `${response.spUserName}.png`;
|
||||||
this.userName = response.spUserName;
|
this.userName = response.spUserName;
|
||||||
this.auth = true;
|
this.auth = true;
|
||||||
|
let currentMoney = GetCurrentMoney(
|
||||||
|
GetCookie("AuthToken"),
|
||||||
|
GetCookie("SearchToken")
|
||||||
|
);
|
||||||
|
this.balance = currentMoney;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Auth Code error:", error);
|
console.error("Auth Code error:", error);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let currentUserName = GetCookie("SpUserName");
|
let currentUserName = GetCookie("SpUserName");
|
||||||
|
let currentMoney = GetCurrentMoney(
|
||||||
|
GetCookie("AuthToken"),
|
||||||
|
GetCookie("SearchToken")
|
||||||
|
);
|
||||||
// let currentMoney = GetCurrentMoney(
|
// let currentMoney = GetCurrentMoney(
|
||||||
// "2405bf72008f835c9f5b336a84d3efbd7a742b828ca41fcaab1c40ca842e6425"
|
// "2405bf72008f835c9f5b336a84d3efbd7a742b828ca41fcaab1c40ca842e6425"
|
||||||
// );
|
// );
|
||||||
@@ -56,7 +64,7 @@ export default {
|
|||||||
if (currentUserName) {
|
if (currentUserName) {
|
||||||
this.imageUrl = this.imageUrl + `${currentUserName}.png`;
|
this.imageUrl = this.imageUrl + `${currentUserName}.png`;
|
||||||
this.auth = true;
|
this.auth = true;
|
||||||
// this.balance = currentMoney;
|
this.balance = currentMoney;
|
||||||
} else {
|
} else {
|
||||||
this.auth = false;
|
this.auth = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user