Copy PIX successfully before granting internet and closing captive portal
build-image / build-push (push) Successful in 2m47s
build-image / build-push (push) Successful in 2m47s
This commit is contained in:
1 parent
8d38a9136b
commit
b69b3afa5d
3 files changed
+76
-20
No files matched your search
+30
-11
@@ -533,7 +533,7 @@
|
||||
<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>
|
||||
<p>Copie o PIX antes de abrir o banco. Ao liberar a internet, esta janela pode fechar automaticamente.</p>
|
||||
</div>
|
||||
|
||||
<div class="qr-panel">
|
||||
@@ -543,7 +543,7 @@
|
||||
<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-ghost" id="copyBtn" type="button">Copiar PIX e liberar internet</button>
|
||||
<button class="btn btn-primary" id="checkBtn" type="button">Já paguei</button>
|
||||
</div>
|
||||
|
||||
@@ -641,16 +641,20 @@
|
||||
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!');
|
||||
try {
|
||||
if (!document.execCommand('copy')) throw new Error('Clipboard unavailable');
|
||||
} catch {
|
||||
toast('Não foi possível copiar. Selecione e copie o código manualmente.');
|
||||
return false;
|
||||
} finally { ta.remove(); }
|
||||
}
|
||||
toast(msg || 'Copiado!');
|
||||
return true;
|
||||
}
|
||||
|
||||
function show(view) {
|
||||
@@ -724,7 +728,9 @@
|
||||
|
||||
clearInterval(pollTimer);
|
||||
pollTimer = setInterval(verify, 6000);
|
||||
startFreeAccess();
|
||||
$('freeAccessMessage').textContent = 'PIX pronto. Toque em “Copiar PIX e liberar internet”; depois abra o banco e cole o código.';
|
||||
$('retryFreeAccess').textContent = 'Já copiei: liberar internet';
|
||||
$('retryFreeAccess').hidden = false;
|
||||
} catch (e) {
|
||||
toast('Erro: ' + e.message);
|
||||
} finally {
|
||||
@@ -773,7 +779,16 @@
|
||||
}
|
||||
|
||||
$('checkBtn').addEventListener('click', verify);
|
||||
$('copyBtn').addEventListener('click', () => copy($('copiaCola').textContent, 'Código PIX copiado'));
|
||||
$('copyBtn').addEventListener('click', async () => {
|
||||
const button = $('copyBtn');
|
||||
if (button.disabled) return;
|
||||
const code = $('copiaCola').textContent.trim();
|
||||
if (!code) { toast('O código PIX ainda não está disponível.'); return; }
|
||||
button.disabled = true;
|
||||
try {
|
||||
if (await copy(code, 'PIX copiado. Abra o banco e cole o código.')) await startFreeAccess();
|
||||
} finally { button.disabled = false; }
|
||||
});
|
||||
$('copyVoucher').addEventListener('click', () =>
|
||||
copy('Usuário: ' + $('vUser').textContent + '\nSenha: ' + $('vPass').textContent, 'Credenciais copiadas')
|
||||
);
|
||||
@@ -916,10 +931,14 @@
|
||||
}
|
||||
|
||||
loadSiteConfig().then(() => {
|
||||
if (!/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i.test(mac) || new URLSearchParams(location.search).get('free') === '1' || sessionStorage.getItem('pendingPix')) startFreeAccess();
|
||||
const pendingPix = sessionStorage.getItem('pendingPix');
|
||||
const returningFromAccess = new URLSearchParams(location.search).get('free') === '1' &&
|
||||
(!pendingPix || Number(sessionStorage.getItem('freeAccessConfirmedUntil') || 0) > Date.now() ||
|
||||
Number(sessionStorage.getItem('freeLoginAttemptUntil') || 0) > Date.now());
|
||||
if (!/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i.test(mac) || returningFromAccess) startFreeAccess();
|
||||
else {
|
||||
$('freeAccessMessage').textContent = 'O acesso temporário para abrir o aplicativo do banco começa após gerar o PIX. Se precisar antes, toque em liberar acesso.';
|
||||
$('retryFreeAccess').textContent = 'Liberar acesso para pagamento';
|
||||
$('freeAccessMessage').textContent = pendingPix ? 'PIX pronto. Copie o código antes de liberar a internet e abrir o banco.' : 'Gere o PIX e copie o código para liberar a internet e abrir o banco. Se precisar antes, toque em liberar acesso.';
|
||||
$('retryFreeAccess').textContent = pendingPix ? 'Já copiei: liberar internet' : 'Liberar acesso para pagamento';
|
||||
$('retryFreeAccess').hidden = false;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user