feat: portal INCTG, README completo e walled garden do hotspot
- Portal de pagamento redesenhado com identidade INCTG (Manrope/Inter, grafite/azul eletrico) - Logo INCTG servido pelo backend - Walled garden para fontes do portal (Google Fonts) no setup-hotspot.rsc - README passo a passo: Mercado Pago, ZimaOS, MikroTik, producao, CI e troubleshooting - Protege chaves SSH locais no .gitignore
This commit is contained in:
1 parent
e595ab1723
commit
83fba15354
8 files changed
+1713
-173
No files matched your search
+586
-100
@@ -2,97 +2,575 @@
|
||||
<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>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
||||
<meta name="theme-color" content="#101820">
|
||||
<title>INCTG Wi-Fi Convidados</title>
|
||||
<link rel="icon" type="image/png" href="logo.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||
<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; }
|
||||
:root {
|
||||
--graphite: #101820;
|
||||
--graphite-2: #151f2b;
|
||||
--graphite-3: #1c2836;
|
||||
--blue: #246BFD;
|
||||
--blue-hover: #3d7cff;
|
||||
--blue-soft: rgba(36, 107, 253, 0.14);
|
||||
--white: #F4F6F8;
|
||||
--gray: #7C8A9A;
|
||||
--gray-2: #9aa7b5;
|
||||
--line: rgba(124, 138, 154, 0.18);
|
||||
--success: #12B886;
|
||||
--success-soft: rgba(18, 184, 134, 0.12);
|
||||
--danger: #E5484D;
|
||||
--radius-sm: 6px;
|
||||
--radius-md: 10px;
|
||||
--radius-lg: 16px;
|
||||
--font-heading: "Manrope", system-ui, sans-serif;
|
||||
--font-body: "Inter", system-ui, sans-serif;
|
||||
}
|
||||
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
html { -webkit-text-size-adjust: 100%; }
|
||||
|
||||
body {
|
||||
font-family: var(--font-body);
|
||||
background: var(--graphite);
|
||||
color: var(--white);
|
||||
min-height: 100dvh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
|
||||
position: relative;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
body::before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background:
|
||||
radial-gradient(720px 420px at 85% -10%, rgba(36, 107, 253, 0.18), transparent 60%),
|
||||
radial-gradient(520px 320px at -10% 110%, rgba(36, 107, 253, 0.08), transparent 60%);
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.wrap {
|
||||
width: 100%;
|
||||
max-width: 440px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
/* ---------- Header ---------- */
|
||||
.brand {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
text-align: center;
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.brand-logo {
|
||||
width: 108px;
|
||||
height: auto;
|
||||
border-radius: 14px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.brand h1 {
|
||||
font-family: var(--font-heading);
|
||||
font-weight: 700;
|
||||
font-size: 1.45rem;
|
||||
letter-spacing: -0.02em;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.brand .tagline {
|
||||
color: var(--gray);
|
||||
font-size: 0.86rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.brand .tagline strong { color: var(--blue); font-weight: 600; }
|
||||
|
||||
/* ---------- Cards ---------- */
|
||||
.card {
|
||||
background: linear-gradient(180deg, rgba(28, 40, 54, 0.9), rgba(21, 31, 43, 0.9));
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 20px;
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
|
||||
.section-label {
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: var(--gray);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
/* ---------- Planos ---------- */
|
||||
.plan {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
width: 100%;
|
||||
background: var(--graphite-2);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 16px;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
transition: border-color 0.18s, transform 0.18s, background 0.18s;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.plan:last-child { margin-bottom: 0; }
|
||||
|
||||
.plan:hover { border-color: rgba(36, 107, 253, 0.55); transform: translateY(-1px); }
|
||||
.plan:active { transform: translateY(0); }
|
||||
|
||||
.plan:focus-visible,
|
||||
button:focus-visible,
|
||||
a:focus-visible {
|
||||
outline: 2px solid var(--blue);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.plan-info h3 {
|
||||
font-family: var(--font-heading);
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.plan-meta {
|
||||
margin-top: 4px;
|
||||
color: var(--gray);
|
||||
font-size: 0.78rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.plan-price {
|
||||
font-family: var(--font-heading);
|
||||
font-weight: 800;
|
||||
font-size: 1.05rem;
|
||||
color: var(--blue);
|
||||
background: var(--blue-soft);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 8px 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ---------- Checkout ---------- */
|
||||
.pay-head { text-align: center; margin-bottom: 6px; }
|
||||
|
||||
.pay-head h2 {
|
||||
font-family: var(--font-heading);
|
||||
font-size: 1.15rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.pay-head p { color: var(--gray); font-size: 0.84rem; margin-top: 4px; }
|
||||
|
||||
.qr-panel {
|
||||
background: #fff;
|
||||
border-radius: var(--radius-md);
|
||||
padding: 14px;
|
||||
width: 232px;
|
||||
height: 232px;
|
||||
margin: 18px auto 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.qr-panel img { width: 100%; height: 100%; object-fit: contain; }
|
||||
|
||||
.copia {
|
||||
background: var(--graphite);
|
||||
border: 1px dashed rgba(124, 138, 154, 0.35);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 12px;
|
||||
font-size: 0.68rem;
|
||||
line-height: 1.5;
|
||||
word-break: break-all;
|
||||
color: var(--gray-2);
|
||||
font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
|
||||
max-height: 84px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.row { display: flex; gap: 10px; margin-top: 12px; }
|
||||
|
||||
/* ---------- Botões ---------- */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
border-radius: var(--radius-md);
|
||||
padding: 14px 18px;
|
||||
font-family: var(--font-heading);
|
||||
font-size: 0.95rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: background 0.18s, opacity 0.18s, transform 0.15s;
|
||||
text-decoration: none;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn:active { transform: scale(0.985); }
|
||||
.btn:disabled { opacity: 0.55; cursor: wait; }
|
||||
|
||||
.btn-primary { background: var(--blue); }
|
||||
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); }
|
||||
|
||||
.btn-ghost {
|
||||
background: transparent;
|
||||
border: 1px solid var(--line);
|
||||
color: var(--white);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn-ghost:hover { border-color: var(--gray); }
|
||||
|
||||
.btn-success { background: var(--success); }
|
||||
.btn-success:hover:not(:disabled) { background: #16c996; }
|
||||
|
||||
/* ---------- Status pill ---------- */
|
||||
.pill {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
color: var(--gray);
|
||||
font-size: 0.82rem;
|
||||
margin-top: 14px;
|
||||
min-height: 22px;
|
||||
}
|
||||
|
||||
.pill .dot {
|
||||
width: 8px; height: 8px; border-radius: 50%;
|
||||
background: var(--gray);
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.pill.waiting .dot {
|
||||
background: var(--blue);
|
||||
animation: pulse 1.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.pill.ok { color: var(--success); }
|
||||
.pill.ok .dot { background: var(--success); animation: none; }
|
||||
.pill.err { color: var(--danger); }
|
||||
.pill.err .dot { background: var(--danger); animation: none; }
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; transform: scale(1); }
|
||||
50% { opacity: 0.35; transform: scale(0.75); }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
* { animation: none !important; transition: none !important; }
|
||||
}
|
||||
|
||||
/* ---------- Voucher ---------- */
|
||||
.voucher-view { text-align: center; }
|
||||
|
||||
.check {
|
||||
width: 56px; height: 56px;
|
||||
margin: 6px auto 14px;
|
||||
border-radius: 50%;
|
||||
background: var(--success-soft);
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
|
||||
.check svg { width: 28px; height: 28px; }
|
||||
|
||||
.voucher-view h2 {
|
||||
font-family: var(--font-heading);
|
||||
font-size: 1.2rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.voucher-view .hint {
|
||||
color: var(--gray);
|
||||
font-size: 0.85rem;
|
||||
margin: 6px 0 18px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.code-box {
|
||||
background: var(--graphite);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.code-box .lbl {
|
||||
font-size: 0.68rem;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
color: var(--gray);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.code-box .val {
|
||||
font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
|
||||
font-size: 1.45rem;
|
||||
font-weight: 700;
|
||||
color: var(--success);
|
||||
letter-spacing: 0.08em;
|
||||
margin-top: 4px;
|
||||
user-select: all;
|
||||
}
|
||||
|
||||
.steps {
|
||||
margin: 16px 0 4px;
|
||||
text-align: left;
|
||||
color: var(--gray);
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.7;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.steps li { margin-left: 18px; }
|
||||
|
||||
/* ---------- Footer / toast ---------- */
|
||||
footer {
|
||||
margin-top: 8px;
|
||||
text-align: center;
|
||||
color: var(--gray);
|
||||
font-size: 0.72rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
footer strong { color: var(--white); font-weight: 600; }
|
||||
|
||||
.toast {
|
||||
position: fixed;
|
||||
bottom: calc(20px + env(safe-area-inset-bottom));
|
||||
left: 50%;
|
||||
transform: translateX(-50%) translateY(80px);
|
||||
background: var(--graphite-3);
|
||||
border: 1px solid var(--line);
|
||||
color: var(--white);
|
||||
padding: 10px 18px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
opacity: 0;
|
||||
transition: transform 0.25s, opacity 0.25s;
|
||||
z-index: 10;
|
||||
pointer-events: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
|
||||
|
||||
.hidden { display: none !important; }
|
||||
#copied { color: #34d399; font-size: .85rem; margin-top: 6px; display: none; }
|
||||
|
||||
.back {
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin-top: 16px;
|
||||
color: var(--gray);
|
||||
font-size: 0.85rem;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.back:hover { color: var(--white); }
|
||||
|
||||
.empty {
|
||||
text-align: center;
|
||||
color: var(--gray);
|
||||
font-size: 0.88rem;
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.skel {
|
||||
height: 68px;
|
||||
border-radius: var(--radius-md);
|
||||
background: linear-gradient(90deg, var(--graphite-2) 25%, var(--graphite-3) 50%, var(--graphite-2) 75%);
|
||||
background-size: 200% 100%;
|
||||
animation: sk 1.2s infinite linear;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
@keyframes sk { to { background-position: -200% 0; } }
|
||||
</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 class="wrap">
|
||||
<header class="brand">
|
||||
<img class="brand-logo" src="logo.png" alt="INCTG — Incorpore Technology Group" width="108" height="108">
|
||||
<div>
|
||||
<h1>Wi-Fi Convidados</h1>
|
||||
<p class="tagline">Escolha seu plano · <strong>Pague com PIX</strong> · Conecte em segundos</p>
|
||||
</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>
|
||||
</header>
|
||||
|
||||
<!-- ===== PLANOS ===== -->
|
||||
<main id="view-plans">
|
||||
<div class="card">
|
||||
<div class="section-label">Planos disponíveis</div>
|
||||
<div id="plans">
|
||||
<div class="skel"></div><div class="skel"></div><div class="skel"></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- ===== PAGAMENTO ===== -->
|
||||
<section id="view-pay" class="card hidden" aria-labelledby="payTitle">
|
||||
<div class="pay-head">
|
||||
<h2 id="payTitle">PIX</h2>
|
||||
<p>Escaneie o QR Code no app do seu banco</p>
|
||||
</div>
|
||||
|
||||
<div class="qr-panel">
|
||||
<img id="qrImg" alt="QR Code do pagamento PIX">
|
||||
</div>
|
||||
|
||||
<div class="copia" id="copiaCola" title="Código copia e cola"></div>
|
||||
|
||||
<div class="row">
|
||||
<button class="btn btn-ghost" id="copyBtn" type="button">Copiar código</button>
|
||||
<button class="btn btn-primary" id="checkBtn" type="button">Já paguei</button>
|
||||
</div>
|
||||
|
||||
<div class="pill waiting" id="payPill" role="status" aria-live="polite">
|
||||
<span class="dot"></span><span id="payPillText">Aguardando pagamento…</span>
|
||||
</div>
|
||||
|
||||
<a class="back" href="#" id="backBtn">← Voltar aos planos</a>
|
||||
</section>
|
||||
|
||||
<!-- ===== VOUCHER ===== -->
|
||||
<section id="view-voucher" class="card voucher-view hidden" aria-labelledby="vTitle">
|
||||
<div class="check" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="#12B886" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round">
|
||||
<polyline points="20 6 9 17 4 12"></polyline>
|
||||
</svg>
|
||||
</div>
|
||||
<h2 id="vTitle">Pagamento confirmado</h2>
|
||||
<p class="hint">Use os dados abaixo na tela de login do Wi-Fi.</p>
|
||||
|
||||
<div class="code-box">
|
||||
<div class="lbl">Usuário</div>
|
||||
<div class="val" id="vUser">—</div>
|
||||
</div>
|
||||
<div class="code-box">
|
||||
<div class="lbl">Senha</div>
|
||||
<div class="val" id="vPass">—</div>
|
||||
</div>
|
||||
|
||||
<ol class="steps">
|
||||
<li>Volte às configurações de Wi-Fi do celular</li>
|
||||
<li>Conecte em <strong>Convidados-Pix</strong> (se ainda não estiver)</li>
|
||||
<li>Abra qualquer site para exibir o login</li>
|
||||
<li>Digite o usuário e a senha acima</li>
|
||||
</ol>
|
||||
|
||||
<button class="btn btn-success" id="copyVoucher" type="button" style="margin-top:14px">Copiar usuário e senha</button>
|
||||
<a class="back" href="#" id="backBtn2">← Voltar aos planos</a>
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
<strong>INCTG</strong> — Incorpore Technology Group<br>
|
||||
Tecnologia que resolve.
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<div class="toast" id="toast" role="status" aria-live="polite"></div>
|
||||
|
||||
<script>
|
||||
const params = new URLSearchParams(location.search);
|
||||
const mac = params.get('mac') || '';
|
||||
const mac = new URLSearchParams(location.search).get('mac') || '';
|
||||
let currentPaymentId = null;
|
||||
let pollTimer = null;
|
||||
let toastTimer = 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 toast(msg) {
|
||||
const t = $('toast');
|
||||
t.textContent = msg;
|
||||
t.classList.add('show');
|
||||
clearTimeout(toastTimer);
|
||||
toastTimer = setTimeout(() => t.classList.remove('show'), 2200);
|
||||
}
|
||||
|
||||
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 copy(text, msg) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
toast(msg || 'Copiado!');
|
||||
} catch {
|
||||
const ta = document.createElement('textarea');
|
||||
ta.value = text;
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
document.execCommand('copy');
|
||||
ta.remove();
|
||||
toast(msg || 'Copiado!');
|
||||
}
|
||||
}
|
||||
|
||||
function show(view) {
|
||||
$('view-plans').classList.toggle('hidden', view !== 'plans');
|
||||
$('view-pay').classList.toggle('hidden', view !== 'pay');
|
||||
$('view-voucher').classList.toggle('hidden', view !== 'voucher');
|
||||
if (view !== 'pay' && pollTimer) { clearInterval(pollTimer); pollTimer = null; }
|
||||
window.scrollTo({ top: 0, behavior: 'instant' in window ? 'auto' : 'auto' });
|
||||
}
|
||||
|
||||
function money(v) {
|
||||
return 'R$ ' + v.toFixed(2).replace('.', ',');
|
||||
}
|
||||
|
||||
async function loadPlans() {
|
||||
try {
|
||||
const res = await fetch('/api/plans');
|
||||
const plans = await res.json();
|
||||
const box = $('plans');
|
||||
if (!plans.length) {
|
||||
box.innerHTML = '<div class="empty">Nenhum plano disponível no momento.</div>';
|
||||
return;
|
||||
}
|
||||
box.innerHTML = '';
|
||||
for (const p of plans) {
|
||||
const btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
btn.className = 'plan';
|
||||
btn.innerHTML =
|
||||
'<div class="plan-info"><h3></h3><div class="plan-meta"></div></div>' +
|
||||
'<div class="plan-price"></div>';
|
||||
btn.querySelector('h3').textContent = p.name;
|
||||
btn.querySelector('.plan-meta').textContent = p.speed + ' · validade ' + p.uptime;
|
||||
btn.querySelector('.plan-price').textContent = money(p.price);
|
||||
btn.addEventListener('click', () => checkout(p.id));
|
||||
box.appendChild(btn);
|
||||
}
|
||||
} catch {
|
||||
$('plans').innerHTML = '<div class="empty">Não foi possível carregar os planos. Recarregue a página.</div>';
|
||||
}
|
||||
}
|
||||
|
||||
async function checkout(planId) {
|
||||
@@ -104,54 +582,62 @@
|
||||
});
|
||||
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('.', ',')}`;
|
||||
$('payTitle').textContent = data.planName + ' · ' + money(data.price);
|
||||
$('qrImg').src = data.qrCodeBase64 ? 'data:image/png;base64,' + data.qrCodeBase64 : '';
|
||||
$('copiaCola').textContent = data.copiaCola;
|
||||
$('payError').textContent = '';
|
||||
$('copiaCola').textContent = data.copiaCola || '';
|
||||
setPill('waiting', 'Aguardando pagamento…');
|
||||
show('pay');
|
||||
|
||||
clearInterval(pollTimer);
|
||||
pollTimer = setInterval(verify, 6000);
|
||||
} catch (e) {
|
||||
alert('Erro: ' + e.message);
|
||||
toast('Erro: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
$('copyBtn').onclick = async () => {
|
||||
await navigator.clipboard.writeText($('copiaCola').textContent);
|
||||
$('copied').style.display = 'block';
|
||||
setTimeout(() => $('copied').style.display = 'none', 2000);
|
||||
};
|
||||
function setPill(state, text) {
|
||||
const pill = $('payPill');
|
||||
pill.className = 'pill ' + state;
|
||||
$('payPillText').textContent = text;
|
||||
}
|
||||
|
||||
async function verify() {
|
||||
if (!currentPaymentId) return;
|
||||
const btn = $('checkBtn');
|
||||
btn.disabled = true; btn.textContent = 'Verificando...';
|
||||
btn.disabled = true;
|
||||
try {
|
||||
const res = await fetch('/api/status/' + currentPaymentId);
|
||||
const res = await fetch('/api/status/' + encodeURIComponent(currentPaymentId));
|
||||
const data = await res.json();
|
||||
if (data.status === 'paid' && data.voucher) {
|
||||
clearInterval(pollTimer); pollTimer = null;
|
||||
$('vUser').textContent = data.voucher.user;
|
||||
$('vPass').textContent = data.voucher.pass;
|
||||
setPill('ok', 'Pagamento aprovado');
|
||||
show('voucher');
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
if (['rejected', 'cancelled', 'expired'].includes(data.status)) {
|
||||
$('payError').textContent = 'Pagamento não aprovado. Tente novamente.';
|
||||
setPill('err', 'Pagamento não aprovado. Tente novamente.');
|
||||
clearInterval(pollTimer); pollTimer = null;
|
||||
} else {
|
||||
$('payError').textContent = 'Ainda aguardando pagamento...';
|
||||
setPill('waiting', 'Aguardando pagamento…');
|
||||
}
|
||||
} catch (e) {
|
||||
$('payError').textContent = 'Erro ao verificar.';
|
||||
} catch {
|
||||
setPill('err', 'Falha ao verificar. Toque em "Já paguei".');
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
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!');
|
||||
};
|
||||
$('checkBtn').addEventListener('click', verify);
|
||||
$('copyBtn').addEventListener('click', () => copy($('copiaCola').textContent, 'Código PIX copiado'));
|
||||
$('copyVoucher').addEventListener('click', () =>
|
||||
copy('Usuário: ' + $('vUser').textContent + '\nSenha: ' + $('vPass').textContent, 'Credenciais copiadas')
|
||||
);
|
||||
$('backBtn').addEventListener('click', (e) => { e.preventDefault(); show('plans'); });
|
||||
$('backBtn2').addEventListener('click', (e) => { e.preventDefault(); show('plans'); });
|
||||
|
||||
loadPlans();
|
||||
</script>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
Reference in new issue
Block a user