325345634
This commit is contained in:
parent
f242953d94
commit
b738662b4f
@ -237,37 +237,37 @@ $requests = $stmt->fetchAll();
|
||||
<td>
|
||||
<?php if ($r['status'] === '0' || $r['status'] === 'pending'): ?>
|
||||
<span class="badge bg-secondary">待匹配</span>
|
||||
<?php elseif ($r['status'] === 'matched' || $r['status'] === '1'): ?>
|
||||
<?php elseif ($r['status'] === '1' || $r['status'] === 'matched'): ?>
|
||||
<span class="badge bg-info">匹配成功/待发账号</span>
|
||||
<?php elseif ($r['status'] === 'account_sent' || $r['status'] === '2'): ?>
|
||||
<?php elseif ($r['status'] === '2' || $r['status'] === 'account_sent'): ?>
|
||||
<span class="badge bg-warning text-dark">已发账号/待转账</span>
|
||||
<?php elseif ($r['status'] === 'finished'): ?>
|
||||
<span class="badge bg-primary">用户已转账/待审核</span>
|
||||
<?php elseif ($r['status'] === '3'): ?>
|
||||
<?php elseif ($r['status'] === '3' || $r['status'] === 'completed'): ?>
|
||||
<span class="badge bg-success">已通过</span>
|
||||
<?php elseif ($r['status'] === '4'): ?>
|
||||
<?php elseif ($r['status'] === '4' || $r['status'] === 'rejected'): ?>
|
||||
<span class="badge bg-danger">已拒绝</span>
|
||||
<?php else: ?>
|
||||
<span class="badge bg-dark"><?= htmlspecialchars($r['status']) ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if (in_array($r['status'], ['3', '4'])): ?>
|
||||
<span class="badge bg-light text-muted border"><?= $r['status'] == '4' ? '已拒绝' : '已通过' ?></span>
|
||||
<?php if ($r['status'] === '3' || $r['status'] === '4' || $r['status'] === 'completed' || $r['status'] === 'rejected'): ?>
|
||||
<span class="badge bg-light text-muted border"><?= in_array($r['status'], ['4', 'rejected']) ? '已拒绝' : '已通过' ?></span>
|
||||
<?php else: ?>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<?php if ($r['type'] === 'recharge'): ?>
|
||||
<?php if ($r['status'] == '0' || $r['status'] == 'pending'): ?>
|
||||
<?php if ($r['status'] === '0' || $r['status'] === 'pending'): ?>
|
||||
<button type="button" class="btn btn-primary" onclick="submitMatchOnly(<?= $r['id'] ?>)">
|
||||
匹配成功
|
||||
</button>
|
||||
<?php elseif ($r['status'] == '1' || $r['status'] == 'matched'): ?>
|
||||
<?php elseif ($r['status'] === '1' || $r['status'] === 'matched'): ?>
|
||||
<button type="button" class="btn btn-info text-white" onclick="showSendModal(<?= $r['id'] ?>, '<?= htmlspecialchars($r['account_bank'] ?? '') ?>', '<?= htmlspecialchars($r['account_name'] ?? '') ?>', '<?= htmlspecialchars($r['account_number'] ?? '') ?>')">
|
||||
发送账户
|
||||
</button>
|
||||
<?php elseif ($r['status'] == '2' || $r['status'] == 'account_sent'): ?>
|
||||
<?php elseif ($r['status'] === '2' || $r['status'] === 'account_sent'): ?>
|
||||
<span class="badge bg-light text-muted border d-flex align-items-center px-2">等待用户转账...</span>
|
||||
<?php elseif ($r['status'] == 'finished'): ?>
|
||||
<?php elseif ($r['status'] === 'finished'): ?>
|
||||
<button type="button" class="btn btn-outline-success fw-bold"
|
||||
onclick="showApproveModal(<?= $r['id'] ?>, <?= $r['fiat_amount'] ?: 0 ?>, '<?= $r['fiat_currency'] ?: 'USDT' ?>', <?= $display_amount ?>)">
|
||||
通过
|
||||
@ -277,7 +277,7 @@ $requests = $stmt->fetchAll();
|
||||
<span class="badge bg-light text-muted border"><?= htmlspecialchars($r['status']) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php else: /* Withdrawal */ ?>
|
||||
<?php if ($r['status'] == '0' || $r['status'] == 'pending' || $r['status'] == 'finished'): ?>
|
||||
<?php if ($r['status'] === '0' || $r['status'] === 'pending' || $r['status'] === 'finished'): ?>
|
||||
<form method="POST" class="d-inline">
|
||||
<input type="hidden" name="request_id" value="<?= $r['id'] ?>">
|
||||
<input type="hidden" name="action" value="approve">
|
||||
|
||||
79
recharge.php
79
recharge.php
@ -405,14 +405,12 @@ $bep20_addr = $settings['usdt_bep20_address'] ?? '0x742d35Cc6634C0532925a3b844Bc
|
||||
let currentNetwork = 'TRC20';
|
||||
let currentAddress = '<?= $trc20_addr ?>';
|
||||
const userId = '<?= $user['uid'] ?? $user['id'] ?>';
|
||||
const apiPath = 'api/';
|
||||
let rechargeCountdownInterval;
|
||||
let modalChatLastIds = new Set();
|
||||
let remainingSeconds = 1800;
|
||||
let modalChatPolling = false;
|
||||
window.lastRechargeStatus = null;
|
||||
|
||||
// Helper to get relative API path correctly regardless of subdir
|
||||
const getApiPath = () => {
|
||||
// Determine the path to the api directory relative to current location
|
||||
const loc = window.location.pathname;
|
||||
@ -426,7 +424,9 @@ async function updateRate() {
|
||||
const symbol = select.value;
|
||||
|
||||
try {
|
||||
const resp = await fetch(getApiPath() + 'exchange.php?v=' + Date.now());
|
||||
const resp = await fetch(getApiPath() + 'exchange.php?v=' + Date.now(), {
|
||||
headers: { 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' }
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (data.success && data.rates) {
|
||||
exchangeRates = data.rates;
|
||||
@ -787,7 +787,7 @@ function initModalChat() {
|
||||
scrollModalToBottom();
|
||||
const formData = new FormData(); formData.append('file', file); formData.append('action', 'upload_image');
|
||||
try {
|
||||
const resp = await fetch(apiPath + 'chat.php?v=' + Date.now(), { method: 'POST', body: formData }), data = await resp.json();
|
||||
const resp = await fetch(getApiPath() + 'chat.php?v=' + Date.now(), { method: 'POST', body: formData }), data = await resp.json();
|
||||
document.querySelector(`[data-modal-id="${tempId}"]`)?.remove();
|
||||
if (data.success) { appendModalMessage(data.message); scrollModalToBottom(); }
|
||||
} catch (err) { console.error(err); }
|
||||
@ -799,7 +799,7 @@ function initModalChat() {
|
||||
appendModalMessage({ id: tempId, sender: 'user', message: msg, created_at: new Date().toISOString() });
|
||||
scrollModalToBottom();
|
||||
try {
|
||||
const resp = await fetch(apiPath + 'chat.php?action=send_message&v=' + Date.now(), { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: `message=${encodeURIComponent(msg)}` });
|
||||
const resp = await fetch(getApiPath() + 'chat.php?action=send_message&v=' + Date.now(), { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: `message=${encodeURIComponent(msg)}` });
|
||||
const data = await resp.json();
|
||||
document.querySelector(`[data-modal-id="${tempId}"]`)?.remove();
|
||||
if (data.success) { appendModalMessage(data.message); scrollModalToBottom(); }
|
||||
@ -811,8 +811,8 @@ function initModalChat() {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
fetch(apiPath + `chat.php?action=ping&user_time=${encodeURIComponent(new Date().toLocaleString())}&v=` + Date.now());
|
||||
const resp = await fetch(apiPath + 'chat.php?action=get_messages&v=' + Date.now()), data = await resp.json();
|
||||
fetch(getApiPath() + `chat.php?action=ping&user_time=${encodeURIComponent(new Date().toLocaleString())}&v=` + Date.now());
|
||||
const resp = await fetch(getApiPath() + 'chat.php?action=get_messages&v=' + Date.now()), data = await resp.json();
|
||||
if (Array.isArray(data)) { data.forEach(m => { if (!modalChatLastIds.has(m.id)) { appendModalMessage(m); modalChatLastIds.add(m.id); scrollModalToBottom(); } }); }
|
||||
} catch (err) {}
|
||||
setTimeout(modalPoll, 2000);
|
||||
@ -821,9 +821,72 @@ function initModalChat() {
|
||||
}
|
||||
|
||||
async function sendModalMessage(msg) {
|
||||
try { await fetch(apiPath + 'chat.php?action=send_message&v=' + Date.now(), { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: `message=${encodeURIComponent(msg)}` }); } catch (err) {}
|
||||
try { await fetch(getApiPath() + 'chat.php?action=send_message&v=' + Date.now(), { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: `message=${encodeURIComponent(msg)}` }); } catch (err) {}
|
||||
}
|
||||
|
||||
function appendModalMessage(m) {
|
||||
const container = document.getElementById('modal-chat-messages');
|
||||
if (!container || document.querySelector(`[data-modal-id="${m.id}"]`)) return;
|
||||
const sender = m.sender; let text = (m.message || '').toString(), displayMsg = text;
|
||||
const isImage = text.includes('<img') || text.includes('/assets/images/chat/') || text.includes('data:image');
|
||||
if (isImage && !displayMsg.includes('<img')) displayMsg = `<img src="${displayMsg.includes('assets/') ? '/'+displayMsg : displayMsg}" class="img-fluid rounded" style="max-height: 250px; cursor: zoom-in;" onclick="window.open(this.src)">`;
|
||||
let timeStr = ''; try { const d = m.created_at ? (m.created_at.includes('-') ? new Date(m.created_at.replace(/-/g, "/")) : new Date(m.created_at)) : new Date(); timeStr = d.toLocaleTimeString('zh-CN', {hour:'2-digit', minute:'2-digit'}); } catch(e) { timeStr = '--:--'; }
|
||||
const html = `
|
||||
<div class="mb-3 d-flex flex-column ${sender === 'user' ? 'align-items-end' : 'align-items-start'} modal-msg" data-modal-id="${m.id}">
|
||||
<div class="msg-bubble p-2 px-3 rounded-4 small ${sender === 'user' ? 'bg-primary text-white' : 'bg-dark text-white border border-secondary border-opacity-30'}" style="max-width: 85%; position: relative; padding-bottom: 22px !important;">
|
||||
<div class="message-content">${displayMsg}</div>
|
||||
<div style="font-size: 9px; opacity: 0.6; position: absolute; bottom: 4px; ${sender === 'user' ? 'right: 12px;' : 'left: 12px;'}">${timeStr}</div>
|
||||
</div>
|
||||
</div>`;
|
||||
container.insertAdjacentHTML('beforeend', html); modalChatLastIds.add(m.id);
|
||||
}
|
||||
|
||||
function copyText(text) {
|
||||
const el = document.createElement('textarea'); el.value = text; document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el);
|
||||
Swal.fire({ icon: 'success', title: '<?= __("copy_success") ?>', toast: true, position: 'top-end', showConfirmButton: false, timer: 2000 });
|
||||
}
|
||||
|
||||
function scrollModalToBottom() { const c = document.getElementById('modal-chat-messages'); if (c) c.scrollTop = c.scrollHeight; }
|
||||
|
||||
function confirmFiatOrder(btn, event) {
|
||||
if (event) event.preventDefault();
|
||||
const amount = parseFloat(document.getElementById('fiatAmount').value), select = document.getElementById('fiatCurrency'), currency = select.value, rate = parseFloat(select.options[select.selectedIndex].getAttribute('data-rate'));
|
||||
if (isNaN(amount) || amount <= 0) { notify('warning', '<?= __("enter_amount") ?>'); return; }
|
||||
const originalText = btn.innerHTML; btn.disabled = true; btn.innerHTML = `<span class="spinner-border spinner-border-sm me-2"></span>${originalText}`;
|
||||
const formData = new FormData(); formData.append('action', 'recharge'); formData.append('amount', amount / rate); formData.append('symbol', 'USDT'); formData.append('fiat_amount', amount); formData.append('fiat_currency', currency); formData.append('method', '<?= __("fiat_recharge") ?> (' + currency + ')');
|
||||
fetch(getApiPath() + 'finance.php?v=' + Date.now(), { method: 'POST', body: formData }).then(r => r.json()).then(data => {
|
||||
btn.disabled = false; btn.innerHTML = originalText;
|
||||
if (data.success) {
|
||||
let msg = `<?= __("recharge_msg_fiat") ?>`;
|
||||
const resAmount = (amount / rate).toFixed(2);
|
||||
msg = msg.replace('%uid%', userId).replace('%amount%', amount).replace('%currency%', currency).replace('%res%', resAmount);
|
||||
openRechargeModal(msg, false, data.id);
|
||||
document.getElementById('fiatAmount').value = '';
|
||||
}
|
||||
else notify('error', data.error || '<?= __("request_failed") ?>');
|
||||
}).catch(err => { btn.disabled = false; btn.innerHTML = originalText; notify('error', err.message); });
|
||||
}
|
||||
|
||||
function confirmCryptoOrder(btn, event) {
|
||||
if (event) event.preventDefault();
|
||||
const amountInput = document.getElementById('cryptoAmount');
|
||||
const amount = parseFloat(amountInput.value);
|
||||
if (isNaN(amount) || amount <= 0) { notify('warning', '<?= __("enter_amount") ?>'); return; }
|
||||
const originalText = btn.innerHTML; btn.disabled = true; btn.innerHTML = `<span class="spinner-border spinner-border-sm me-2"></span>${originalText}`;
|
||||
const formData = new FormData(); formData.append('action', 'recharge'); formData.append('amount', amount); formData.append('symbol', 'USDT'); formData.append('method', 'Crypto (USDT-' + currentNetwork + ')');
|
||||
fetch(getApiPath() + 'finance.php?v=' + Date.now(), { method: 'POST', body: formData }).then(r => r.json()).then(data => {
|
||||
btn.disabled = false; btn.innerHTML = originalText;
|
||||
if (data.success) {
|
||||
let msg = `<?= __("recharge_msg_crypto") ?>`;
|
||||
msg = msg.replace('%uid%', userId).replace('%amount%', amount).replace('%network%', currentNetwork).replace('%addr%', currentAddress);
|
||||
openRechargeModal(msg, false, data.id);
|
||||
amountInput.value = '';
|
||||
}
|
||||
else notify('error', data.error || '<?= __("request_failed") ?>');
|
||||
}).catch(err => { btn.disabled = false; btn.innerHTML = originalText; notify('error', err.message); });
|
||||
}
|
||||
|
||||
|
||||
function appendModalMessage(m) {
|
||||
const container = document.getElementById('modal-chat-messages');
|
||||
if (!container || document.querySelector(`[data-modal-id="${m.id}"]`)) return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user