feat: soporte nativo para pistola lectora QR y modal de cobro rapido en terminal POS
This commit is contained in:
+232
-35
@@ -80,6 +80,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
await loadPreOrders();
|
await loadPreOrders();
|
||||||
initCamera();
|
initCamera();
|
||||||
initSSE();
|
initSSE();
|
||||||
|
initPistolScanner();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cargar catálogo de productos
|
// Cargar catálogo de productos
|
||||||
@@ -471,7 +472,13 @@ async function onQrCodeDetected(token) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si estamos en mostrador, identificamos al estudiante
|
// Si ya hay productos en el carrito, procesar cobro inmediato con este QR
|
||||||
|
if (posCart.length > 0) {
|
||||||
|
await handlePistolBarcodeScan(token);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si estamos en mostrador sin productos, identificamos al estudiante
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`/api/estudiantes/qr/${encodeURIComponent(token)}`);
|
const res = await fetch(`/api/estudiantes/qr/${encodeURIComponent(token)}`);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
@@ -513,7 +520,7 @@ function renderScannedStudent() {
|
|||||||
document.getElementById('scannedName').textContent = scannedStudent.nombre_completo;
|
document.getElementById('scannedName').textContent = scannedStudent.nombre_completo;
|
||||||
if (btnCobrar) {
|
if (btnCobrar) {
|
||||||
btnCobrar.disabled = false;
|
btnCobrar.disabled = false;
|
||||||
btnCobrar.textContent = 'Cobrar y Despachar ⚡';
|
btnCobrar.innerHTML = `<span>🔫</span> COBRAR A ${scannedStudent.nombre_completo.split(' ')[0].toUpperCase()} ➔`;
|
||||||
btnCobrar.style.background = 'linear-gradient(135deg, #10b981, #059669)';
|
btnCobrar.style.background = 'linear-gradient(135deg, #10b981, #059669)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -541,72 +548,262 @@ function renderScannedStudent() {
|
|||||||
function clearScannedStudent() {
|
function clearScannedStudent() {
|
||||||
scannedStudent = null;
|
scannedStudent = null;
|
||||||
renderScannedStudent();
|
renderScannedStudent();
|
||||||
|
const btnCobrar = document.getElementById('btnCobrarPos');
|
||||||
|
if (btnCobrar) {
|
||||||
|
btnCobrar.disabled = false;
|
||||||
|
btnCobrar.innerHTML = '<span>🔫</span> COBRAR CON PISTOLA QR';
|
||||||
|
btnCobrar.style.background = 'linear-gradient(135deg, #0284c7, #0369a1)';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecutar cobro en mostrador
|
// ==========================================
|
||||||
async function executePosDebit() {
|
// PISTOLA LECTORA DE QR (USB/BLUETOOTH) Y COBRO RÁPIDO
|
||||||
if (!scannedStudent) {
|
// ==========================================
|
||||||
if (window.sounds) window.sounds.playError();
|
|
||||||
return alert('⚠️ Primero escanea el carné o celular del estudiante (puedes usar los botones de prueba rápida en la cámara).');
|
let barcodeBuffer = '';
|
||||||
|
let barcodeLastTime = 0;
|
||||||
|
let pistolaAutoCloseTimer = null;
|
||||||
|
|
||||||
|
function initPistolScanner() {
|
||||||
|
// Listener global para capturar ráfagas rápidas de pistola USB/Bluetooth
|
||||||
|
window.addEventListener('keydown', (e) => {
|
||||||
|
// Si presiona Escape, cerrar modal de cobro si está abierto
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
closePistolaModal();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scannedStudent.tarjeta_bloqueada) {
|
// Si presiona Enter y el modal está en pantalla de éxito, cerrarlo para el siguiente
|
||||||
if (window.sounds) window.sounds.playError();
|
const modalSuccess = document.getElementById('pistolaStateSuccess');
|
||||||
return alert(`⛔ ¡TARJETA SUSPENDIDA!\nLa tarjeta de ${scannedStudent.nombre_completo} ha sido bloqueada por la administración de la soda. No se pueden procesar cobros.`);
|
if (e.key === 'Enter' && modalSuccess && modalSuccess.style.display !== 'none') {
|
||||||
|
e.preventDefault();
|
||||||
|
closePistolaModal();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
|
// Si pasaron más de 80ms entre teclas, no es pistola, es un humano escribiendo
|
||||||
|
if (now - barcodeLastTime > 80 && barcodeBuffer.length > 0) {
|
||||||
|
barcodeBuffer = '';
|
||||||
|
}
|
||||||
|
barcodeLastTime = now;
|
||||||
|
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
if (barcodeBuffer.trim().length >= 3) {
|
||||||
|
e.preventDefault();
|
||||||
|
const code = barcodeBuffer.trim();
|
||||||
|
barcodeBuffer = '';
|
||||||
|
handlePistolBarcodeScan(code);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (e.key.length === 1) {
|
||||||
|
barcodeBuffer += e.key;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Listener para el input de texto del modal
|
||||||
|
const inputScan = document.getElementById('inputPistolaDirectScan');
|
||||||
|
if (inputScan) {
|
||||||
|
inputScan.addEventListener('keydown', (e) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
e.preventDefault();
|
||||||
|
const val = inputScan.value.trim();
|
||||||
|
if (val.length >= 3) {
|
||||||
|
inputScan.value = '';
|
||||||
|
handlePistolBarcodeScan(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openPistolaModal() {
|
||||||
if (posCart.length === 0) {
|
if (posCart.length === 0) {
|
||||||
if (window.sounds) window.sounds.playError();
|
if (window.sounds) window.sounds.playError();
|
||||||
return alert('⚠️ Selecciona al menos un producto en el mostrador para cobrar.');
|
alert('⚠️ Selecciona al menos un producto en el mostrador para cobrar.');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const modal = document.getElementById('modalPistolaCobro');
|
||||||
|
if (!modal) return;
|
||||||
|
|
||||||
|
const total = posCart.reduce((sum, item) => sum + (item.product.precio_colones * item.cantidad), 0);
|
||||||
|
const totalItems = posCart.reduce((sum, item) => sum + item.cantidad, 0);
|
||||||
|
|
||||||
|
document.getElementById('pistolaModalTotal').textContent = `₡${total.toLocaleString('es-CR')}`;
|
||||||
|
document.getElementById('pistolaModalItemCount').textContent = `${totalItems} ${totalItems === 1 ? 'producto' : 'productos'} en mostrador`;
|
||||||
|
|
||||||
|
resetPistolaModalWaiting();
|
||||||
|
modal.style.display = 'flex';
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const input = document.getElementById('inputPistolaDirectScan');
|
||||||
|
if (input) input.focus();
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
if (window.sounds) window.sounds.playTap();
|
||||||
|
}
|
||||||
|
|
||||||
|
function closePistolaModal(e) {
|
||||||
|
if (e && e.target && e.target.id !== 'modalPistolaCobro') return;
|
||||||
|
if (pistolaAutoCloseTimer) {
|
||||||
|
clearTimeout(pistolaAutoCloseTimer);
|
||||||
|
pistolaAutoCloseTimer = null;
|
||||||
|
}
|
||||||
|
const modal = document.getElementById('modalPistolaCobro');
|
||||||
|
if (modal) modal.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetPistolaModalWaiting() {
|
||||||
|
if (pistolaAutoCloseTimer) {
|
||||||
|
clearTimeout(pistolaAutoCloseTimer);
|
||||||
|
pistolaAutoCloseTimer = null;
|
||||||
|
}
|
||||||
|
document.getElementById('pistolaStateWaiting').style.display = 'block';
|
||||||
|
document.getElementById('pistolaStateProcessing').style.display = 'none';
|
||||||
|
document.getElementById('pistolaStateSuccess').style.display = 'none';
|
||||||
|
document.getElementById('pistolaStateError').style.display = 'none';
|
||||||
|
|
||||||
|
const input = document.getElementById('inputPistolaDirectScan');
|
||||||
|
if (input) {
|
||||||
|
input.value = '';
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handlePistolBarcodeScan(rawToken) {
|
||||||
|
const token = String(rawToken).trim();
|
||||||
|
if (!token) return;
|
||||||
|
|
||||||
|
if (window.sounds) window.sounds.playScanChirp();
|
||||||
|
|
||||||
|
// Si no hay productos en el carrito, identificar al alumno para mostrador
|
||||||
|
if (posCart.length === 0) {
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/estudiantes/qr/${encodeURIComponent(token)}`);
|
||||||
|
const data = await res.json();
|
||||||
|
if (!res.ok) throw new Error(data.error);
|
||||||
|
|
||||||
|
scannedStudent = data;
|
||||||
|
renderScannedStudent();
|
||||||
|
if (window.sounds) window.sounds.playSuccess();
|
||||||
|
} catch (err) {
|
||||||
|
if (window.sounds) window.sounds.playError();
|
||||||
|
alert(`⚠️ Estudiante no reconocido: ${err.message}`);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SI HAY PRODUCTOS EN EL CARRITO: EJECUTAR COBRO INMEDIATO CON PISTOLA
|
||||||
|
const modal = document.getElementById('modalPistolaCobro');
|
||||||
|
if (modal && modal.style.display === 'none') {
|
||||||
|
openPistolaModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mostrar estado de procesamiento
|
||||||
|
document.getElementById('pistolaStateWaiting').style.display = 'none';
|
||||||
|
document.getElementById('pistolaStateError').style.display = 'none';
|
||||||
|
document.getElementById('pistolaStateSuccess').style.display = 'none';
|
||||||
|
document.getElementById('pistolaStateProcessing').style.display = 'block';
|
||||||
|
document.getElementById('pistolaProcessingName').textContent = 'Identificando estudiante y validando monedero...';
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. Buscar estudiante por token o código
|
||||||
|
const resEst = await fetch(`/api/estudiantes/qr/${encodeURIComponent(token)}`);
|
||||||
|
const student = await resEst.json();
|
||||||
|
if (!resEst.ok) throw new Error(student.error || 'Carné escolar no encontrado');
|
||||||
|
|
||||||
|
document.getElementById('pistolaProcessingName').textContent = `Verificando saldo para ${student.nombre_completo}...`;
|
||||||
|
|
||||||
|
// 2. Validar si la tarjeta está suspendida
|
||||||
|
if (student.tarjeta_bloqueada) {
|
||||||
|
throw new Error(`⛔ TARJETA SUSPENDIDA: La tarjeta de ${student.nombre_completo} ha sido bloqueada por la administración de la soda.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Validar saldo disponible y límite diario
|
||||||
|
const totalCompra = posCart.reduce((sum, item) => sum + (item.product.precio_colones * item.cantidad), 0);
|
||||||
|
|
||||||
|
if (student.saldo_colones < totalCompra) {
|
||||||
|
throw new Error(`⚠️ SALDO INSUFICIENTE: ${student.nombre_completo} tiene ₡${student.saldo_colones.toLocaleString('es-CR')} de saldo y la compra es de ₡${totalCompra.toLocaleString('es-CR')}.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (student.disponible_hoy < totalCompra) {
|
||||||
|
throw new Error(`⚠️ SUPERA LÍMITE DIARIO: Le quedan ₡${student.disponible_hoy.toLocaleString('es-CR')} disponibles hoy de su límite diario asignado.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Procesar cobro en servidor
|
||||||
const items = posCart.map(item => ({
|
const items = posCart.map(item => ({
|
||||||
producto_id: item.product.id,
|
producto_id: item.product.id,
|
||||||
cantidad: item.cantidad
|
cantidad: item.cantidad
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const btn = document.getElementById('btnCobrarPos');
|
const resCobro = await fetch('/api/ordenes', {
|
||||||
btn.disabled = true;
|
|
||||||
btn.textContent = 'Procesando débito...';
|
|
||||||
|
|
||||||
try {
|
|
||||||
const res = await fetch('/api/ordenes', {
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
estudiante_id: scannedStudent.id,
|
estudiante_id: student.id,
|
||||||
tipo_orden: 'mostrador',
|
tipo_orden: 'mostrador',
|
||||||
momento_entrega: 'inmediato',
|
momento_entrega: 'inmediato',
|
||||||
items
|
items
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await res.json();
|
const dataCobro = await resCobro.json();
|
||||||
if (!res.ok) {
|
if (!resCobro.ok) throw new Error(dataCobro.error || 'Error al procesar el débito');
|
||||||
if (window.sounds) window.sounds.playError();
|
|
||||||
throw new Error(data.error);
|
// 5. Éxito: Mostrar pantalla de confirmación
|
||||||
|
document.getElementById('pistolaStateProcessing').style.display = 'none';
|
||||||
|
document.getElementById('pistolaStateSuccess').style.display = 'block';
|
||||||
|
|
||||||
|
document.getElementById('pistolaSuccessStudent').textContent = student.nombre_completo;
|
||||||
|
document.getElementById('pistolaSuccessTicket').textContent = dataCobro.codigo_orden;
|
||||||
|
document.getElementById('pistolaSuccessAmount').textContent = `₡${totalCompra.toLocaleString('es-CR')}`;
|
||||||
|
const nuevoSaldo = (dataCobro.financiero && dataCobro.financiero.estudiante)
|
||||||
|
? dataCobro.financiero.estudiante.saldo_nuevo
|
||||||
|
: (student.saldo_colones - totalCompra);
|
||||||
|
document.getElementById('pistolaSuccessBalance').textContent = `₡${nuevoSaldo.toLocaleString('es-CR')}`;
|
||||||
|
|
||||||
|
if (window.sounds) {
|
||||||
|
window.sounds.playSuccess();
|
||||||
|
window.sounds.playCoin();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.sounds) window.sounds.playSuccess();
|
// Limpiar carrito de mostrador
|
||||||
|
|
||||||
alert(`✅ ¡COBRO EXITOSO!\nTicket: ${data.codigo_orden}\nEstudiante: ${scannedStudent.nombre_completo}\nMonto: ₡${data.total_colones.toLocaleString('es-CR')}\nNuevo Saldo: ₡${data.financiero.estudiante.saldo_nuevo.toLocaleString('es-CR')}`);
|
|
||||||
|
|
||||||
// Limpiar caja y refrescar
|
|
||||||
clearPosCart();
|
clearPosCart();
|
||||||
clearScannedStudent();
|
clearScannedStudent();
|
||||||
|
|
||||||
// En móviles, volver a la vista del catálogo para la siguiente venta
|
// Auto-cerrar el modal en 2.5 segundos para quedar listo para el siguiente alumno
|
||||||
if (window.innerWidth <= 900) {
|
pistolaAutoCloseTimer = setTimeout(() => {
|
||||||
switchPosMobileView('catalog');
|
closePistolaModal();
|
||||||
}
|
}, 2500);
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert(`❌ Fallo en la transacción: ${err.message}`);
|
if (window.sounds) window.sounds.playError();
|
||||||
} finally {
|
document.getElementById('pistolaStateProcessing').style.display = 'none';
|
||||||
btn.disabled = false;
|
document.getElementById('pistolaStateError').style.display = 'block';
|
||||||
btn.innerHTML = '<span>📱</span> COBRAR CON QR DE ALUMNO';
|
document.getElementById('pistolaErrorTitle').textContent = 'No se pudo realizar el cobro';
|
||||||
|
document.getElementById('pistolaErrorDesc').textContent = err.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ejecutar cobro en mostrador (desde botón principal)
|
||||||
|
async function executePosDebit() {
|
||||||
|
if (posCart.length === 0) {
|
||||||
|
if (window.sounds) window.sounds.playError();
|
||||||
|
alert('⚠️ Selecciona al menos un producto en el mostrador para cobrar.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si ya tenemos un estudiante identificado previamente, cobramos directamente
|
||||||
|
if (scannedStudent) {
|
||||||
|
await handlePistolBarcodeScan(scannedStudent.qr_token || scannedStudent.codigo_estudiante);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si no hay estudiante previo, abrir modal esperando el disparo de la pistola QR
|
||||||
|
openPistolaModal();
|
||||||
|
}
|
||||||
|
|
||||||
// ==========================================
|
// ==========================================
|
||||||
// FILA RÁPIDA DE PRE-ÓRDENES
|
// FILA RÁPIDA DE PRE-ÓRDENES
|
||||||
// ==========================================
|
// ==========================================
|
||||||
|
|||||||
+107
-3
@@ -28,6 +28,15 @@
|
|||||||
.status-en_preparacion { background: #e0e7ff; color: #3730a3; }
|
.status-en_preparacion { background: #e0e7ff; color: #3730a3; }
|
||||||
.status-listo { background: #dcfce7; color: #166534; }
|
.status-listo { background: #dcfce7; color: #166534; }
|
||||||
.status-entregado { background: #f1f5f9; color: #64748b; }
|
.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>
|
</style>
|
||||||
<body style="background: #0b1120; color: #f8fafc;" class="pos-mobile-view-catalog">
|
<body style="background: #0b1120; color: #f8fafc;" class="pos-mobile-view-catalog">
|
||||||
|
|
||||||
@@ -63,6 +72,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
|
<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="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>
|
<span style="width: 8px; height: 8px; background: #34d399; border-radius: 50%; display: inline-block;"></span>
|
||||||
En Línea (SSE)
|
En Línea (SSE)
|
||||||
@@ -221,14 +233,106 @@
|
|||||||
</div>
|
</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;">
|
<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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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/jsQR.js"></script>
|
||||||
<script src="/js/pos.js"></script>
|
<script src="/js/pos.js?v=8.1"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
// RecreoPay PWA Service Worker v8.1
|
// RecreoPay PWA Service Worker v8.2 - Pistola QR POS & Cobro Rápido
|
||||||
const CACHE_NAME = 'recreopay-v8.1';
|
const CACHE_NAME = 'recreopay-v8.2';
|
||||||
const STATIC_ASSETS = [
|
const STATIC_ASSETS = [
|
||||||
'/',
|
'/',
|
||||||
'/index.html',
|
'/index.html',
|
||||||
|
|||||||
Reference in New Issue
Block a user