feat: soporte nativo para pistola lectora QR y modal de cobro rapido en terminal POS

This commit is contained in:
unknown
2026-10-04 21:17:56 -06:00
parent 661987bf41
commit 104ee5c223
3 changed files with 345 additions and 44 deletions
+107 -3
View File
@@ -28,6 +28,15 @@
.status-en_preparacion { background: #e0e7ff; color: #3730a3; }
.status-listo { background: #dcfce7; color: #166534; }
.status-entregado { background: #f1f5f9; color: #64748b; }
@keyframes pulse {
0%, 100% { transform: scale(1); opacity: 1; }
50% { transform: scale(1.08); opacity: 0.85; }
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
</style>
<body style="background: #0b1120; color: #f8fafc;" class="pos-mobile-view-catalog">
@@ -63,6 +72,9 @@
</div>
<div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
<span id="pistolaStatusBadge" style="display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; background: #0c4a6e; color: #38bdf8; padding: 4px 10px; border-radius: 20px; font-weight: 800; border: 1px solid #0284c7;" title="Pistola lectora USB/Bluetooth lista para escanear en cualquier momento">
<span>🔫</span> Pistola QR Conectada
</span>
<span style="display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; background: #064e3b; color: #34d399; padding: 4px 8px; border-radius: 20px; font-weight: 700;">
<span style="width: 8px; height: 8px; background: #34d399; border-radius: 50%; display: inline-block;"></span>
En Línea (SSE)
@@ -221,14 +233,106 @@
</div>
<button id="btnCobrarPos" onclick="executePosDebit()" style="width: 100%; padding: 14px; background: linear-gradient(135deg, #0284c7, #0369a1); border: none; border-radius: 14px; color: white; font-size: 1rem; font-weight: 900; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4); box-sizing: border-box;">
<span>📱</span> COBRAR CON QR DE ALUMNO
<span>🔫</span> COBRAR CON PISTOLA QR
</button>
</div>
</div>
</div>
<script src="/js/sounds.js"></script>
<!-- MODAL DE COBRO RÁPIDO CON PISTOLA QR -->
<div class="modal-qr-backdrop" id="modalPistolaCobro" style="display: none;" onclick="closePistolaModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; background: #0f172a; border: 2px solid #38bdf8; border-radius: 20px; box-shadow: 0 20px 50px rgba(0,0,0,0.8); padding: 22px; color: #f8fafc; text-align: center;">
<!-- CABECERA -->
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #334155; padding-bottom: 12px; margin-bottom: 16px;">
<div style="display: flex; align-items: center; gap: 8px;">
<span style="font-size: 1.5rem;">🔫</span>
<strong style="font-size: 1.1rem; color: #38bdf8; letter-spacing: 0.5px;">Cobro con Pistola QR</strong>
</div>
<button type="button" onclick="closePistolaModal()" style="background: none; border: none; font-size: 1.3rem; color: #94a3b8; cursor: pointer;">✕</button>
</div>
<!-- ESTADO 1: ESPERANDO ESCANEO (DEFAULT) -->
<div id="pistolaStateWaiting">
<!-- TOTAL A COBRAR GIGANTE -->
<div style="background: #1e293b; border: 1.5px solid #0284c7; border-radius: 14px; padding: 12px; margin-bottom: 16px;">
<div style="font-size: 0.78rem; font-weight: 800; color: #94a3b8; text-transform: uppercase;">Monto Total a Cobrar</div>
<div id="pistolaModalTotal" style="font-size: 2.3rem; font-weight: 900; color: #38bdf8; margin: 4px 0;">₡0</div>
<div id="pistolaModalItemCount" style="font-size: 0.75rem; color: #cbd5e1;">0 productos en mostrador</div>
</div>
<!-- INDICADOR VISUAL ANIMADO DE PISTOLA LÁSER -->
<div style="background: #022c22; border: 2px dashed #10b981; border-radius: 14px; padding: 16px; margin-bottom: 14px; position: relative;">
<div style="font-size: 2.5rem; animation: pulse 1.5s infinite;">🎯</div>
<strong style="font-size: 1rem; color: #34d399; display: block; margin-top: 6px;">¡LISTO PARA DISPARAR LA PISTOLA!</strong>
<p style="font-size: 0.78rem; color: #a7f3d0; margin: 4px 0 0 0;">
Apunta la pistola al carné del niño o acerca el código QR.
</p>
</div>
<!-- CAMPO DE ENTRADA ENFOCADO PARA PISTOLA USB -->
<div style="margin-bottom: 12px;">
<input type="text" id="inputPistolaDirectScan" placeholder="Esperando lectura de pistola..." autocomplete="off" style="width: 100%; padding: 10px; border-radius: 10px; border: 1.5px solid #334155; background: #1e293b; color: #f8fafc; font-size: 0.9rem; font-weight: 800; text-align: center; box-sizing: border-box;">
</div>
<!-- ACCESOS RÁPIDOS DE PRUEBA -->
<div style="border-top: 1px dashed #334155; padding-top: 10px; margin-top: 10px;">
<span style="font-size: 0.72rem; color: #94a3b8; display: block; margin-bottom: 6px;">Simulación rápida sin pistola física:</span>
<div style="display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;">
<button type="button" onclick="handlePistolBarcodeScan('QR-MATEO-2026-A891')" style="padding: 5px 10px; background: #334155; color: white; border: none; border-radius: 6px; font-size: 0.72rem; font-weight: 700; cursor: pointer;">🧒 Mateo (8a)</button>
<button type="button" onclick="handlePistolBarcodeScan('QR-SOFIA-2026-B442')" style="padding: 5px 10px; background: #334155; color: white; border: none; border-radius: 6px; font-size: 0.72rem; font-weight: 700; cursor: pointer;">👧 Sofía (9a)</button>
<button type="button" onclick="handlePistolBarcodeScan('QR-NACHO-2026-D902')" style="padding: 5px 10px; background: #334155; color: white; border: none; border-radius: 6px; font-size: 0.72rem; font-weight: 700; cursor: pointer;">🧑 Ignacio (14a)</button>
</div>
</div>
</div>
<!-- ESTADO 2: PROCESANDO COBRO -->
<div id="pistolaStateProcessing" style="display: none; padding: 20px 0;">
<div style="font-size: 2.8rem; animation: spin 1s infinite linear;">⚡</div>
<h3 style="font-size: 1.15rem; color: #38bdf8; margin: 10px 0 4px 0;">Procesando Débito...</h3>
<p style="font-size: 0.8rem; color: #94a3b8;" id="pistolaProcessingName">Verificando carné y saldo del alumno...</p>
</div>
<!-- ESTADO 3: ÉXITO -->
<div id="pistolaStateSuccess" style="display: none; padding: 10px 0;">
<div style="font-size: 3rem;">✅</div>
<h3 style="font-size: 1.3rem; color: #34d399; margin: 6px 0;">¡COBRO EXITOSO!</h3>
<div style="background: #1e293b; border-radius: 12px; padding: 12px; margin: 12px 0; text-align: left; font-size: 0.82rem;">
<div style="display: flex; justify-content: space-between; margin-bottom: 4px;">
<span style="color: #94a3b8;">Estudiante:</span>
<strong id="pistolaSuccessStudent" style="color: #f8fafc;">-</strong>
</div>
<div style="display: flex; justify-content: space-between; margin-bottom: 4px;">
<span style="color: #94a3b8;">Ticket:</span>
<strong id="pistolaSuccessTicket" style="color: #38bdf8;">-</strong>
</div>
<div style="display: flex; justify-content: space-between; margin-bottom: 4px;">
<span style="color: #94a3b8;">Monto Cobrado:</span>
<strong id="pistolaSuccessAmount" style="color: #f8fafc;">-</strong>
</div>
<div style="display: flex; justify-content: space-between; border-top: 1px dashed #334155; padding-top: 6px; margin-top: 6px;">
<span style="color: #94a3b8;">Nuevo Saldo Disponible:</span>
<strong id="pistolaSuccessBalance" style="color: #34d399; font-size: 0.95rem;">-</strong>
</div>
</div>
<button type="button" onclick="closePistolaModal()" style="width: 100%; padding: 12px; background: #10b981; color: white; border: none; border-radius: 10px; font-weight: 800; font-size: 0.9rem; cursor: pointer;">
Listo / Siguiente Alumno (Enter) ➔
</button>
</div>
<!-- ESTADO 4: ERROR / ALERTA -->
<div id="pistolaStateError" style="display: none; padding: 10px 0;">
<div style="font-size: 3rem;">⛔</div>
<h3 style="font-size: 1.2rem; color: #ef4444; margin: 6px 0;" id="pistolaErrorTitle">No se pudo cobrar</h3>
<p style="font-size: 0.85rem; color: #fca5a5; line-height: 1.4; margin-bottom: 16px;" id="pistolaErrorDesc">Detalle del error</p>
<button type="button" onclick="resetPistolaModalWaiting()" style="padding: 10px 20px; background: #334155; color: white; border: none; border-radius: 10px; font-weight: 800; font-size: 0.85rem; cursor: pointer;">
🔄 Intentar con otro carné
</button>
</div>
</div>
</div>
<script src="/js/sounds.js?v=8.1"></script>
<script src="/js/jsQR.js"></script>
<script src="/js/pos.js"></script>
<script src="/js/pos.js?v=8.1"></script>
</body>
</html>