211222
This commit is contained in:
parent
00bab18fd4
commit
d45c0ed029
19
recharge.php
19
recharge.php
@ -412,12 +412,18 @@ let remainingSeconds = 1800;
|
|||||||
let modalChatPolling = false;
|
let modalChatPolling = false;
|
||||||
window.lastRechargeStatus = null;
|
window.lastRechargeStatus = null;
|
||||||
|
|
||||||
|
// Helper to get relative API path correctly regardless of subdir
|
||||||
|
const getApiPath = () => {
|
||||||
|
return 'api/';
|
||||||
|
};
|
||||||
|
|
||||||
async function updateRate() {
|
async function updateRate() {
|
||||||
const select = document.getElementById('fiatCurrency');
|
const select = document.getElementById('fiatCurrency');
|
||||||
|
if (!select) return;
|
||||||
const symbol = select.value;
|
const symbol = select.value;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await fetch(apiPath + 'exchange.php?v=' + Date.now());
|
const resp = await fetch(getApiPath() + 'exchange.php?v=' + Date.now());
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
if (data.success && data.rates) {
|
if (data.success && data.rates) {
|
||||||
exchangeRates = data.rates;
|
exchangeRates = data.rates;
|
||||||
@ -486,7 +492,7 @@ function finishTransfer() {
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('action', 'complete_transfer');
|
formData.append('action', 'complete_transfer');
|
||||||
formData.append('order_id', orderId);
|
formData.append('order_id', orderId);
|
||||||
fetch(apiPath + 'finance.php?v=' + Date.now(), { method: 'POST', body: formData })
|
fetch(getApiPath() + 'finance.php?v=' + Date.now(), { method: 'POST', body: formData })
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
@ -549,14 +555,13 @@ function startStatusPolling(order_id) {
|
|||||||
const modalEl = document.getElementById('rechargeModal');
|
const modalEl = document.getElementById('rechargeModal');
|
||||||
if (!modalEl || !modalEl.classList.contains('show')) return;
|
if (!modalEl || !modalEl.classList.contains('show')) return;
|
||||||
try {
|
try {
|
||||||
const r = await fetch(apiPath + `recharge_status.php?id=${order_id}&t=${Date.now()}`);
|
const r = await fetch(getApiPath() + `recharge_status.php?id=${order_id}&t=${Date.now()}`);
|
||||||
if (!r.ok) throw new Error('Network response was not ok');
|
if (!r.ok) throw new Error('Network response was not ok');
|
||||||
const data = await r.json();
|
const data = await r.json();
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
const currentStatus = String(data.status);
|
const currentStatus = String(data.status);
|
||||||
|
|
||||||
const side = document.querySelector('.info-side');
|
if (window.lastRechargeStatus !== currentStatus) {
|
||||||
if (window.lastRechargeStatus !== currentStatus || (side && side.innerHTML.trim() === "")) {
|
|
||||||
window.lastRechargeStatus = currentStatus;
|
window.lastRechargeStatus = currentStatus;
|
||||||
renderRechargeUI(data);
|
renderRechargeUI(data);
|
||||||
}
|
}
|
||||||
@ -580,7 +585,7 @@ function renderRechargeUI(data) {
|
|||||||
const status = String(data.status || '0');
|
const status = String(data.status || '0');
|
||||||
|
|
||||||
if (status === 'completed' || status === '3') {
|
if (status === 'completed' || status === '3') {
|
||||||
finishTransferUI();
|
setTimeout(() => finishTransferUI(), 500);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -753,7 +758,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
if (remainingSeconds > 0 && state.orderId) {
|
if (remainingSeconds > 0 && state.orderId) {
|
||||||
openRechargeModal(state.initialMessage, true, state.orderId);
|
openRechargeModal(state.initialMessage, true, state.orderId);
|
||||||
try {
|
try {
|
||||||
const r = await fetch(apiPath + `recharge_status.php?id=${state.orderId}&_t=${Date.now()}`);
|
const r = await fetch(getApiPath() + `recharge_status.php?id=${state.orderId}&_t=${Date.now()}`);
|
||||||
const data = await r.json();
|
const data = await r.json();
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
window.lastRechargeStatus = String(data.status);
|
window.lastRechargeStatus = String(data.status);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user