322 lines
20 KiB
PHP
322 lines
20 KiB
PHP
<?php
|
||
require_once __DIR__ . '/includes/header.php';
|
||
|
||
if (!$user) {
|
||
header('Location: /auth/login.php');
|
||
exit;
|
||
}
|
||
|
||
$stmt = db()->prepare("SELECT available FROM user_balances WHERE user_id = ? AND symbol = 'USDT'");
|
||
$stmt->execute([$user['id']]);
|
||
$bal = $stmt->fetch();
|
||
$available = $bal['available'] ?? 0;
|
||
?>
|
||
|
||
<div class="container py-4">
|
||
<div class="row justify-content-center">
|
||
<div class="col-lg-8">
|
||
<!-- Back Button -->
|
||
<div class="mb-4">
|
||
<a href="javascript:history.back()" class="text-white-50 text-decoration-none d-inline-flex align-items-center gap-2">
|
||
<i class="bi bi-arrow-left fs-4"></i>
|
||
<span><?= __('back') ?></span>
|
||
</a>
|
||
</div>
|
||
|
||
<div class="card bg-surface border-secondary rounded-4 shadow-lg overflow-hidden mb-4">
|
||
<div class="card-header border-secondary bg-black bg-opacity-30 p-4">
|
||
<h4 class="mb-0 fw-bold d-flex align-items-center gap-3 text-white">
|
||
<i class="bi bi-cash-stack text-warning"></i>
|
||
<?= __('withdraw') ?>
|
||
</h4>
|
||
</div>
|
||
|
||
<div class="card-body p-4">
|
||
<!-- Tabs -->
|
||
<ul class="nav nav-pills nav-fill mb-4 bg-black p-1 rounded-pill" id="withdrawTabs" role="tablist">
|
||
<li class="nav-item" role="presentation">
|
||
<button class="nav-link active rounded-pill px-4" id="crypto-withdraw-tab" data-bs-toggle="pill" data-bs-target="#crypto-withdraw" type="button" role="tab"><?= __('crypto_withdraw') ?? 'USDT Withdrawal' ?></button>
|
||
</li>
|
||
<li class="nav-item" role="presentation">
|
||
<button class="nav-link rounded-pill px-4" id="fiat-withdraw-tab" data-bs-toggle="pill" data-bs-target="#fiat-withdraw" type="button" role="tab"><?= __('fiat_withdraw') ?? 'Fiat Withdrawal' ?></button>
|
||
</li>
|
||
</ul>
|
||
|
||
<div class="tab-content" id="withdrawTabsContent">
|
||
<!-- USDT Withdrawal -->
|
||
<div class="tab-pane fade show active" id="crypto-withdraw" role="tabpanel">
|
||
<form id="cryptoWithdrawForm">
|
||
<div class="mb-4">
|
||
<label class="form-label text-white-50 small fw-bold mb-2"><?= __('coin') ?></label>
|
||
<div class="d-flex align-items-center gap-3 p-3 bg-dark border border-secondary rounded-4">
|
||
<img src="<?= getCoinIcon('USDT') ?>" width="32" height="32" alt="USDT">
|
||
<div>
|
||
<div class="fw-bold text-white">USDT</div>
|
||
<div class="text-white-50 small">Tether USD</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mb-4">
|
||
<label class="form-label text-white-50 small fw-bold mb-2"><?= __('network') ?></label>
|
||
<div class="d-flex gap-2" id="withdrawNetworkSelectors">
|
||
<button type="button" class="btn btn-outline-warning btn-sm px-4 rounded-pill active" onclick="selectWithdrawNetwork('TRC20')">TRC20</button>
|
||
<button type="button" class="btn btn-outline-secondary btn-sm px-4 rounded-pill" onclick="selectWithdrawNetwork('ERC20')">ERC20</button>
|
||
<button type="button" class="btn btn-outline-secondary btn-sm px-4 rounded-pill" onclick="selectWithdrawNetwork('BEP20')">BEP20</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mb-4">
|
||
<label class="form-label text-white-50 small fw-bold mb-2"><?= __('withdraw_address') ?></label>
|
||
<input type="text" class="form-control bg-dark border-secondary text-white py-3" id="withdrawAddress" placeholder="请输入您的 USDT 地址">
|
||
</div>
|
||
|
||
<div class="mb-4">
|
||
<div class="d-flex justify-content-between mb-2">
|
||
<label class="form-label text-white-50 small fw-bold"><?= __('withdraw_amount') ?> (USDT)</label>
|
||
<span class="small text-white-50"><?= __('balance') ?>: <span class="text-white"><?= number_format($available, 2) ?> USDT</span></span>
|
||
</div>
|
||
<div class="input-group">
|
||
<input type="number" class="form-control bg-dark border-secondary text-white py-3" id="withdrawAmount" placeholder="最小提现 10.00" oninput="calculateCryptoWithdraw()">
|
||
<button type="button" class="input-group-text bg-dark border-secondary text-primary fw-bold" onclick="setMax('withdrawAmount', 'cryptoReceiveAmount')">ALL</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mb-4">
|
||
<label class="form-label text-white-50 small fw-bold mb-2"><?= __('withdraw_password') ?? '提现密码' ?></label>
|
||
<input type="password" class="form-control bg-dark border-secondary text-white py-3" id="withdrawPassword" placeholder="默认密码 123456">
|
||
</div>
|
||
|
||
<div class="mb-5 p-4 bg-warning bg-opacity-10 border border-warning border-opacity-20 rounded-4">
|
||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||
<span class="text-white-50 small">手续费 (Fee)</span>
|
||
<span class="text-white small">1.00 USDT</span>
|
||
</div>
|
||
<div class="d-flex justify-content-between align-items-center">
|
||
<span class="text-white-50"><?= __('to_receive') ?? '预计到账' ?></span>
|
||
<span class="h4 mb-0 fw-bold text-warning" id="cryptoReceiveAmount">0.00 USDT</span>
|
||
</div>
|
||
</div>
|
||
|
||
<button type="button" class="btn btn-warning w-100 py-3 rounded-pill fw-bold shadow-lg" onclick="confirmCryptoWithdraw()">
|
||
<?= __('confirm_order') ?>
|
||
</button>
|
||
</form>
|
||
</div>
|
||
|
||
<!-- Fiat Withdrawal -->
|
||
<div class="tab-pane fade" id="fiat-withdraw" role="tabpanel">
|
||
<form id="fiatWithdrawForm">
|
||
<div class="mb-4">
|
||
<label class="form-label text-white-50 small fw-bold mb-2"><?= __('select_currency') ?></label>
|
||
<select class="form-select bg-dark border-secondary text-white py-3" id="fiatWithdrawCurrency" onchange="updateFiatWithdrawRate()">
|
||
<option value="USD" data-rate="1">🇺🇸 USD - US Dollar</option>
|
||
<option value="EUR" data-rate="0.92">🇪🇺 EUR - Euro</option>
|
||
<option value="GBP" data-rate="0.79">🇬🇧 GBP - British Pound</option>
|
||
<option value="CNY" data-rate="7.19">🇨🇳 CNY - Chinese Yuan</option>
|
||
<option value="JPY" data-rate="150.2">🇯🇵 JPY - Japanese Yen</option>
|
||
<option value="KRW" data-rate="1330.5">🇰🇷 KRW - Korean Won</option>
|
||
<option value="HKD" data-rate="7.82">🇭🇰 HKD - Hong Kong Dollar</option>
|
||
<option value="TWD" data-rate="31.5">🇹🇼 TWD - Taiwan Dollar</option>
|
||
<option value="SGD" data-rate="1.34">🇸🇬 SGD - Singapore Dollar</option>
|
||
<option value="MYR" data-rate="4.77">🇲🇾 MYR - Malaysian Ringgit</option>
|
||
<option value="THB" data-rate="35.8">🇹🇭 THB - Thai Baht</option>
|
||
<option value="VND" data-rate="24500">🇻🇳 VND - Vietnamese Dong</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="mb-4">
|
||
<div class="d-flex justify-content-between mb-2">
|
||
<label class="form-label text-white-50 small fw-bold"><?= __('withdraw_amount') ?> (USDT)</label>
|
||
<span class="small text-white-50"><?= __('balance') ?>: <span class="text-white"><?= number_format($available, 2) ?> USDT</span></span>
|
||
</div>
|
||
<div class="input-group">
|
||
<input type="number" class="form-control bg-dark border-secondary text-white py-3" id="fiatWithdrawAmount" placeholder="最小提现 10.00" oninput="calculateFiatWithdraw()">
|
||
<button type="button" class="input-group-text bg-dark border-secondary text-primary fw-bold" onclick="setMax('fiatWithdrawAmount', 'fiatReceiveAmount')">ALL</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mb-4">
|
||
<label class="form-label text-white-50 small fw-bold mb-2"><?= __('withdraw_password') ?? '提现密码' ?></label>
|
||
<input type="password" class="form-control bg-dark border-secondary text-white py-3" id="fiatWithdrawPassword" placeholder="默认密码 123456">
|
||
</div>
|
||
|
||
<div class="mb-5 p-4 bg-primary bg-opacity-10 border border-primary border-opacity-20 rounded-4">
|
||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||
<span class="text-white-50 small"><?= __('rate') ?>: 1 USDT ≈ </span>
|
||
<span class="text-white small" id="fiatWithdrawRateText">1.00 USD</span>
|
||
</div>
|
||
<div class="d-flex justify-content-between align-items-center">
|
||
<span class="text-white-50"><?= __('est_receive_fiat') ?? '预计收到法币' ?></span>
|
||
<span class="h4 mb-0 fw-bold text-primary" id="fiatReceiveAmount">0.00 USD</span>
|
||
</div>
|
||
</div>
|
||
|
||
<button type="button" class="btn btn-primary w-100 py-3 rounded-pill fw-bold shadow-lg" onclick="confirmFiatWithdraw()">
|
||
<?= __('confirm_order') ?>
|
||
</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Rich Content Sections -->
|
||
<div class="row g-4 mb-5">
|
||
<div class="col-md-6">
|
||
<div class="card bg-surface border-secondary rounded-4 h-100">
|
||
<div class="card-body p-4">
|
||
<h5 class="text-white fw-bold mb-3"><i class="bi bi-journal-text text-warning me-2"></i> <?= __('withdraw_steps') ?? '提现步骤' ?></h5>
|
||
<div class="text-white-50 small lh-lg">
|
||
<div class="d-flex gap-3 mb-2">
|
||
<span class="badge bg-warning text-dark rounded-circle p-2" style="width:24px; height:24px; display:flex; align-items:center; justify-content:center;">1</span>
|
||
<span>选择提现方式(加密货币或法币)</span>
|
||
</div>
|
||
<div class="d-flex gap-3 mb-2">
|
||
<span class="badge bg-warning text-dark rounded-circle p-2" style="width:24px; height:24px; display:flex; align-items:center; justify-content:center;">2</span>
|
||
<span>填写提现地址/选择币种并输入金额</span>
|
||
</div>
|
||
<div class="d-flex gap-3 mb-2">
|
||
<span class="badge bg-warning text-dark rounded-circle p-2" style="width:24px; height:24px; display:flex; align-items:center; justify-content:center;">3</span>
|
||
<span>输入提现密码(默认123456)</span>
|
||
</div>
|
||
<div class="d-flex gap-3">
|
||
<span class="badge bg-warning text-dark rounded-circle p-2" style="width:24px; height:24px; display:flex; align-items:center; justify-content:center;">4</span>
|
||
<span>确认后提交审核,预计10-30分钟内处理</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<div class="card bg-surface border-secondary rounded-4 h-100">
|
||
<div class="card-body p-4">
|
||
<h5 class="text-white fw-bold mb-3"><i class="bi bi-shield-lock text-danger me-2"></i> <?= __('security_tips') ?? '安全提示' ?></h5>
|
||
<div class="text-white-50 small lh-lg">
|
||
<ul class="ps-3 mb-0">
|
||
<li>提现前请务必确认地址正确,转错将无法找回</li>
|
||
<li>为了您的资金安全,大额提现可能需要人工电话核实</li>
|
||
<li>请确保提现主网与接收端主网一致(如均为 TRC20)</li>
|
||
<li>严禁参与任何非法洗钱活动,平台将配合监管部门调查</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="text-center text-white-50 small mb-5">
|
||
<div class="d-flex justify-content-center gap-4">
|
||
<span><i class="bi bi-shield-check text-success me-1"></i> <?= __('secure') ?></span>
|
||
<span><i class="bi bi-lightning-fill text-warning me-1"></i> <?= __('fast') ?></span>
|
||
<span><i class="bi bi-headset text-primary me-1"></i> <?= __('support_247') ?></span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<style>
|
||
.nav-pills .nav-link { color: #9ba3af; font-weight: 500; }
|
||
.nav-pills .nav-link.active { background-color: #ffc107; color: #000; }
|
||
.btn-outline-warning:hover { background-color: #ffc107; color: #000; }
|
||
</style>
|
||
|
||
<script>
|
||
let currentWithdrawNetwork = 'TRC20';
|
||
|
||
function setMax(inputId, displayId) {
|
||
document.getElementById(inputId).value = <?= $available ?>;
|
||
if (inputId === 'withdrawAmount') calculateCryptoWithdraw();
|
||
else calculateFiatWithdraw();
|
||
}
|
||
|
||
function selectWithdrawNetwork(net) {
|
||
currentWithdrawNetwork = net;
|
||
const btns = document.querySelectorAll('#withdrawNetworkSelectors button');
|
||
btns.forEach(btn => {
|
||
if (btn.innerText === net) {
|
||
btn.classList.add('active', 'btn-outline-warning');
|
||
btn.classList.remove('btn-outline-secondary');
|
||
} else {
|
||
btn.classList.remove('active', 'btn-outline-warning');
|
||
btn.classList.add('btn-outline-secondary');
|
||
}
|
||
});
|
||
}
|
||
|
||
function calculateCryptoWithdraw() {
|
||
const amount = parseFloat(document.getElementById('withdrawAmount').value) || 0;
|
||
const fee = amount > 0 ? 1 : 0;
|
||
const receive = Math.max(0, amount - fee);
|
||
document.getElementById('cryptoReceiveAmount').innerText = receive.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + ' USDT';
|
||
}
|
||
|
||
function updateFiatWithdrawRate() {
|
||
const select = document.getElementById('fiatWithdrawCurrency');
|
||
const symbol = select.value;
|
||
const rate = select.options[select.selectedIndex].getAttribute('data-rate');
|
||
document.getElementById('fiatWithdrawRateText').innerText = `${rate} ${symbol}`;
|
||
calculateFiatWithdraw();
|
||
}
|
||
|
||
function calculateFiatWithdraw() {
|
||
const amount = parseFloat(document.getElementById('fiatWithdrawAmount').value) || 0;
|
||
const select = document.getElementById('fiatWithdrawCurrency');
|
||
const rate = parseFloat(select.options[select.selectedIndex].getAttribute('data-rate'));
|
||
const est = amount * rate;
|
||
document.getElementById('fiatReceiveAmount').innerText = est.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + ' ' + select.value;
|
||
}
|
||
|
||
function confirmCryptoWithdraw() {
|
||
const addr = document.getElementById('withdrawAddress').value.trim();
|
||
const amount = parseFloat(document.getElementById('withdrawAmount').value);
|
||
const password = document.getElementById('withdrawPassword').value;
|
||
|
||
if (!addr) { alert('<?= __("enter_address") ?>'); return; }
|
||
if (!amount || amount < 10) { alert('<?= __("min_withdraw_hint") ?>'); return; }
|
||
if (amount > <?= $available ?>) { alert('<?= __("insufficient_balance") ?>'); return; }
|
||
if (!password) { alert('<?= __("enter_password") ?>'); return; }
|
||
|
||
const message = `【<?= __("withdraw") ?>】\n<?= __("type") ?>:USDT\n<?= __("network") ?>:${currentWithdrawNetwork}\n<?= __("address") ?>:${addr}\n<?= __("amount") ?>:${amount} USDT\n<?= __("to_receive") ?>:${document.getElementById('cryptoReceiveAmount').innerText}\n<?= __("password") ?>:${password}`;
|
||
|
||
sendWithdrawToCS(message);
|
||
}
|
||
|
||
function confirmFiatWithdraw() {
|
||
const amount = parseFloat(document.getElementById('fiatWithdrawAmount').value);
|
||
const currency = document.getElementById('fiatWithdrawCurrency').value;
|
||
const estFiat = document.getElementById('fiatReceiveAmount').innerText;
|
||
const password = document.getElementById('fiatWithdrawPassword').value;
|
||
|
||
if (!amount || amount < 10) { alert('<?= __("min_withdraw_hint") ?>'); return; }
|
||
if (amount > <?= $available ?>) { alert('<?= __("insufficient_balance") ?>'); return; }
|
||
if (!password) { alert('<?= __("enter_password") ?>'); return; }
|
||
|
||
const message = `【<?= __("withdraw") ?>】\n<?= __("type") ?>:<?= __("fiat_withdraw") ?>\n<?= __("amount") ?>:${amount} USDT\n<?= __("est_receive_fiat") ?>:${estFiat}\n<?= __("password") ?>:${password}`;
|
||
|
||
sendWithdrawToCS(message);
|
||
}
|
||
|
||
function sendWithdrawToCS(message) {
|
||
// Open chat box
|
||
const csBox = document.getElementById('cs-box');
|
||
if (csBox.classList.contains('d-none')) {
|
||
const toggle = document.getElementById('cs-toggle');
|
||
if (toggle) toggle.click();
|
||
}
|
||
|
||
// Auto-fill and send message
|
||
const csInput = document.getElementById('cs-input');
|
||
if (csInput) {
|
||
csInput.value = message;
|
||
document.getElementById('cs-form').dispatchEvent(new Event('submit'));
|
||
alert('<?= __("request_sent") ?>');
|
||
} else {
|
||
alert('<?= __("cs_connect_fail") ?>');
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|