feat: hotspot PIX MikroTik + backend Docker + CI Gitea Actions
build-image / build-push (push) Failing after 4m36s
build-image / build-push (push) Failing after 4m36s
This commit is contained in:
commit
de9bd4ae0b
15 files changed
+1720
No files matched your search
@@ -0,0 +1,159 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pt-BR">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>WiFi Convidados - Pagar com PIX</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; font-family: system-ui, sans-serif; }
|
||||
body { background: linear-gradient(135deg, #0f172a, #1e3a5f); min-height: 100vh; color: #e2e8f0; padding: 20px; }
|
||||
.container { max-width: 480px; margin: 0 auto; }
|
||||
h1 { text-align: center; font-size: 1.5rem; margin-bottom: 6px; }
|
||||
.sub { text-align: center; color: #94a3b8; margin-bottom: 24px; font-size: .9rem; }
|
||||
.plan { background: #1e293b; border: 1px solid #334155; border-radius: 14px; padding: 18px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: .15s; }
|
||||
.plan:hover { border: 1px solid #38bdf8; transform: translateY(-2px); }
|
||||
.plan h3 { font-size: 1.05rem; }
|
||||
.plan .speed { color: #94a3b8; font-size: .8rem; margin-top: 3px; }
|
||||
.price { background: #059669; color: #fff; font-weight: 700; padding: 8px 14px; border-radius: 10px; font-size: 1rem; white-space: nowrap; }
|
||||
#pay, #voucher { display: none; background: #1e293b; border: 1px solid #334155; border-radius: 14px; padding: 24px; text-align: center; }
|
||||
#pay img, #voucher img { width: 220px; height: 220px; background: #fff; border-radius: 10px; padding: 8px; margin: 16px 0; }
|
||||
.colacode { background: #0f172a; border: 1px dashed #475569; border-radius: 10px; padding: 12px; font-size: .75rem; word-break: break-all; color: #7dd3fc; margin-bottom: 14px; }
|
||||
button { background: #0ea5e9; color: #fff; border: 0; border-radius: 10px; padding: 14px 22px; font-size: 1rem; font-weight: 600; cursor: pointer; width: 100%; margin-top: 8px; }
|
||||
button.secondary { background: #334155; }
|
||||
button:disabled { opacity: .5; cursor: wait; }
|
||||
.voucher-box { background: #0f172a; border: 2px solid #10b981; border-radius: 12px; padding: 18px; margin: 16px 0; }
|
||||
.voucher-box .code { font-size: 1.6rem; font-weight: 800; color: #34d399; letter-spacing: 2px; }
|
||||
.voucher-box .lbl { color: #94a3b8; font-size: .8rem; margin-top: 10px; }
|
||||
.error { color: #f87171; margin-top: 12px; font-size: .9rem; }
|
||||
.back { text-align: center; margin-top: 16px; }
|
||||
.back a { color: #7dd3fc; font-size: .9rem; }
|
||||
.hidden { display: none !important; }
|
||||
#copied { color: #34d399; font-size: .85rem; margin-top: 6px; display: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>📶 WiFi Convidados</h1>
|
||||
<p class="sub">Escolha seu plano e pague com PIX — liberação automática</p>
|
||||
|
||||
<div id="plans"></div>
|
||||
|
||||
<div id="pay">
|
||||
<h2 id="payTitle"></h2>
|
||||
<p style="color:#94a3b8;margin-top:6px">Escaneie o QR Code no app do seu banco</p>
|
||||
<img id="qrImg" alt="QR Code PIX">
|
||||
<div class="colacode" id="copiaCola"></div>
|
||||
<button class="secondary" id="copyBtn">Copiar código PIX</button>
|
||||
<div id="copied">Copiado!</div>
|
||||
<button id="checkBtn">Já paguei — verificar</button>
|
||||
<div class="error" id="payError"></div>
|
||||
<div class="back"><a href="#" id="backBtn">← Voltar aos planos</a></div>
|
||||
</div>
|
||||
|
||||
<div id="voucher">
|
||||
<h2 style="color:#34d399">✅ Pagamento confirmado!</h2>
|
||||
<div class="voucher-box">
|
||||
<div class="lbl">Usuário</div>
|
||||
<div class="code" id="vUser"></div>
|
||||
<div class="lbl">Senha</div>
|
||||
<div class="code" id="vPass"></div>
|
||||
</div>
|
||||
<p style="color:#94a3b8;font-size:.9rem">Use esses dados na tela de login do WiFi.<br>Válido conforme o plano escolhido.</p>
|
||||
<button class="secondary" id="copyVoucher">Copiar usuário e senha</button>
|
||||
<div class="back"><a href="#" id="backBtn2">← Voltar aos planos</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const params = new URLSearchParams(location.search);
|
||||
const mac = params.get('mac') || '';
|
||||
let currentPaymentId = null;
|
||||
let pollTimer = null;
|
||||
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
async function loadPlans() {
|
||||
const res = await fetch('/api/plans');
|
||||
const plans = await res.json();
|
||||
$('plans').innerHTML = plans.map(p => `
|
||||
<div class="plan" data-id="${p.id}">
|
||||
<div>
|
||||
<h3>${p.name}</h3>
|
||||
<div class="speed">${p.speed} · validade ${p.uptime}</div>
|
||||
</div>
|
||||
<div class="price">R$ ${p.price.toFixed(2).replace('.', ',')}</div>
|
||||
</div>`).join('');
|
||||
document.querySelectorAll('.plan').forEach(el => {
|
||||
el.onclick = () => checkout(el.dataset.id);
|
||||
});
|
||||
}
|
||||
|
||||
function show(which) {
|
||||
$('plans').style.display = which === 'plans' ? '' : 'none';
|
||||
$('pay').style.display = which === 'pay' ? 'block' : 'none';
|
||||
$('voucher').style.display = which === 'voucher' ? 'block' : 'none';
|
||||
if (which === 'plans' && pollTimer) { clearInterval(pollTimer); pollTimer = null; }
|
||||
}
|
||||
|
||||
async function checkout(planId) {
|
||||
try {
|
||||
const res = await fetch('/api/checkout', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ planId, mac }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.error) throw new Error(data.error);
|
||||
currentPaymentId = data.paymentId;
|
||||
$('payTitle').textContent = `${data.planName} — R$ ${data.price.toFixed(2).replace('.', ',')}`;
|
||||
$('qrImg').src = data.qrCodeBase64 ? 'data:image/png;base64,' + data.qrCodeBase64 : '';
|
||||
$('copiaCola').textContent = data.copiaCola;
|
||||
$('payError').textContent = '';
|
||||
show('pay');
|
||||
} catch (e) {
|
||||
alert('Erro: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
$('copyBtn').onclick = async () => {
|
||||
await navigator.clipboard.writeText($('copiaCola').textContent);
|
||||
$('copied').style.display = 'block';
|
||||
setTimeout(() => $('copied').style.display = 'none', 2000);
|
||||
};
|
||||
|
||||
async function verify() {
|
||||
const btn = $('checkBtn');
|
||||
btn.disabled = true; btn.textContent = 'Verificando...';
|
||||
try {
|
||||
const res = await fetch('/api/status/' + currentPaymentId);
|
||||
const data = await res.json();
|
||||
if (data.status === 'paid' && data.voucher) {
|
||||
$('vUser').textContent = data.voucher.user;
|
||||
$('vPass').textContent = data.voucher.pass;
|
||||
show('voucher');
|
||||
return true;
|
||||
}
|
||||
if (['rejected', 'cancelled', 'expired'].includes(data.status)) {
|
||||
$('payError').textContent = 'Pagamento não aprovado. Tente novamente.';
|
||||
} else {
|
||||
$('payError').textContent = 'Ainda aguardando pagamento...';
|
||||
}
|
||||
} catch (e) {
|
||||
$('payError').textContent = 'Erro ao verificar.';
|
||||
}
|
||||
btn.disabled = false; btn.textContent = 'Já paguei — verificar';
|
||||
return false;
|
||||
}
|
||||
|
||||
$('checkBtn').onclick = verify;
|
||||
$('backBtn').onclick = (e) => { e.preventDefault(); show('plans'); };
|
||||
$('backBtn2').onclick = (e) => { e.preventDefault(); show('plans'); };
|
||||
$('copyVoucher').onclick = async () => {
|
||||
await navigator.clipboard.writeText(`User: ${$('vUser').textContent}\nPass: ${$('vPass').textContent}`);
|
||||
alert('Copiado!');
|
||||
};
|
||||
|
||||
loadPlans();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user