fix(pos): responsive layout for mobile cashier terminal with tab navigation, floating checkout bar, and preventing pane overlap

This commit is contained in:
unknown
2026-10-04 20:05:33 -06:00
parent b32ffdbb61
commit cfa8efbc0a
3 changed files with 333 additions and 29 deletions
+196
View File
@@ -534,6 +534,8 @@ body.dark-mode .floating-cart-bar {
display: flex;
flex-direction: column;
gap: 16px;
min-width: 0;
box-sizing: border-box;
}
.pos-tabs {
@@ -580,6 +582,7 @@ body.dark-mode .floating-cart-bar {
justify-content: space-between;
min-height: 140px;
transition: all 0.15s;
box-sizing: border-box;
}
.pos-prod-card:hover {
@@ -594,6 +597,10 @@ body.dark-mode .floating-cart-bar {
flex-direction: column;
justify-content: space-between;
padding: 20px;
min-width: 0;
box-sizing: border-box;
overflow-y: auto;
overflow-x: hidden;
}
.scanner-feed-card {
@@ -604,6 +611,9 @@ body.dark-mode .floating-cart-bar {
text-align: center;
position: relative;
overflow: hidden;
box-sizing: border-box;
width: 100%;
max-width: 100%;
}
.camera-preview {
@@ -639,6 +649,8 @@ body.dark-mode .floating-cart-bar {
display: flex;
flex-direction: column;
gap: 8px;
box-sizing: border-box;
width: 100%;
}
.pos-cart-item {
@@ -649,6 +661,190 @@ body.dark-mode .floating-cart-bar {
padding: 10px 14px;
border-radius: 10px;
border: 1px solid #334155;
gap: 10px;
box-sizing: border-box;
width: 100%;
}
/* Elementos móviles ocultos por defecto en pantallas grandes */
.pos-mobile-nav {
display: none;
}
.pos-mobile-back-bar {
display: none;
}
.pos-floating-checkout-bar {
display: none;
}
/* ==========================================================================
ADAPTACIÓN RESPONSIVE POS PARA MÓVILES Y PANTALLAS ANGOSTAS (<= 900px)
========================================================================== */
@media (max-width: 900px) {
html, body {
overflow-x: hidden !important;
width: 100% !important;
position: relative;
}
.pos-layout {
display: flex;
flex-direction: column;
height: auto;
min-height: 100vh;
overflow-x: hidden;
width: 100%;
box-sizing: border-box;
}
/* BARRA DE PESTAÑAS MÓVIL EN LA CABECERA */
.pos-mobile-nav {
display: flex;
background: #0b1120;
border-bottom: 2px solid #334155;
position: sticky;
top: 0;
z-index: 100;
padding: 8px 10px;
gap: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
box-sizing: border-box;
width: 100%;
}
.pos-mobile-nav-btn {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
padding: 10px 12px;
background: #1e293b;
border: 1.5px solid #334155;
border-radius: 12px;
color: #94a3b8;
font-size: 0.88rem;
font-weight: 800;
cursor: pointer;
transition: all 0.15s ease;
}
.pos-mobile-nav-btn.active {
background: #0284c7;
color: #ffffff;
border-color: #38bdf8;
box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}
.pos-mobile-nav-badge {
background: #ef4444;
color: white;
font-size: 0.72rem;
font-weight: 900;
padding: 2px 7px;
border-radius: 10px;
line-height: 1;
}
/* CONTROL DE VISIBILIDAD ENTRE CATÁLOGO Y CAJA EN MÓVIL */
body.pos-mobile-view-catalog .pos-catalog-pane {
display: flex !important;
width: 100% !important;
max-width: 100% !important;
padding: 14px;
padding-bottom: 95px; /* Espacio para barra flotante */
box-sizing: border-box;
}
body.pos-mobile-view-catalog .pos-checkout-pane {
display: none !important;
}
body.pos-mobile-view-checkout .pos-catalog-pane {
display: none !important;
}
body.pos-mobile-view-checkout .pos-checkout-pane {
display: flex !important;
width: 100% !important;
max-width: 100% !important;
border-left: none;
border-top: none;
padding: 14px;
box-sizing: border-box;
min-height: calc(100vh - 65px);
}
/* BOTÓN REGRESAR AL CATÁLOGO */
.pos-mobile-back-bar {
display: block;
margin-bottom: 12px;
width: 100%;
}
.pos-mobile-back-btn {
width: 100%;
padding: 11px 14px;
background: #0f172a;
color: #38bdf8;
border: 1.5px solid #334155;
border-radius: 12px;
font-size: 0.88rem;
font-weight: 800;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
box-sizing: border-box;
}
.pos-mobile-back-btn:active {
background: #1e293b;
}
/* BARRA FLOTANTE INFERIOR DE ACCESO RÁPIDO */
.pos-floating-checkout-bar {
position: fixed;
bottom: 14px;
left: 12px;
right: 12px;
background: #0f172a;
border: 2px solid #0284c7;
border-radius: 16px;
padding: 10px 16px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.75), 0 0 18px rgba(2, 132, 199, 0.45);
z-index: 99;
cursor: pointer;
box-sizing: border-box;
animation: popUpFloat 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popUpFloat {
from { transform: translateY(50px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
/* AJUSTE DE CUADRÍCULA DE PRODUCTOS EN PANTALLAS PEQUEÑAS */
.pos-products-grid {
grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
gap: 10px !important;
}
.pos-prod-card {
padding: 12px !important;
min-height: 115px !important;
}
.pos-cart-item {
padding: 8px 10px !important;
gap: 8px !important;
}
}
/* ==========================================================================
+80 -8
View File
@@ -8,8 +8,42 @@ let currentTab = 'mostrador';
let sseSource = null;
let videoStream = null;
let isScanningActive = true;
let posMobileActiveView = 'catalog';
let CLOUDFLARE_TUNNEL_URL = 'https://somewhat-ships-looksmart-optical.trycloudflare.com';
function switchPosMobileView(view) {
posMobileActiveView = view;
const body = document.body;
const tabCat = document.getElementById('btnMobileNavCatalog');
const tabCheck = document.getElementById('btnMobileNavCheckout');
const floatBar = document.getElementById('posFloatingCheckoutBar');
if (view === 'checkout') {
body.classList.remove('pos-mobile-view-catalog');
body.classList.add('pos-mobile-view-checkout');
if (tabCat) tabCat.classList.remove('active');
if (tabCheck) tabCheck.classList.add('active');
if (floatBar) floatBar.style.display = 'none';
window.scrollTo({ top: 0, behavior: 'smooth' });
} else {
body.classList.remove('pos-mobile-view-checkout');
body.classList.add('pos-mobile-view-catalog');
if (tabCat) tabCat.classList.add('active');
if (tabCheck) tabCheck.classList.remove('active');
updatePosCartUI();
window.scrollTo({ top: 0, behavior: 'smooth' });
}
}
window.addEventListener('resize', () => {
if (window.innerWidth > 900) {
const floatBar = document.getElementById('posFloatingCheckoutBar');
if (floatBar) floatBar.style.display = 'none';
} else {
updatePosCartUI();
}
});
function checkPosHttpsEnvironment() {
const isHttp = window.location.protocol !== 'https:' &&
window.location.hostname !== 'localhost' &&
@@ -121,10 +155,27 @@ function addToPosCart(prodId) {
function updatePosCartUI() {
const list = document.getElementById('posCartList');
const totalEl = document.getElementById('posCartTotal');
const totalItems = posCart.reduce((sum, item) => sum + item.cantidad, 0);
// Actualizar badge móvil
const mobileBadge = document.getElementById('mobileCartBadge');
if (mobileBadge) {
if (totalItems > 0) {
mobileBadge.textContent = totalItems;
mobileBadge.style.display = 'inline-block';
} else {
mobileBadge.style.display = 'none';
}
}
const floatBar = document.getElementById('posFloatingCheckoutBar');
const floatText = document.getElementById('posFloatingCartText');
const floatTotal = document.getElementById('posFloatingCartTotal');
if (posCart.length === 0) {
list.innerHTML = '<p style="text-align: center; color: #64748b; padding: 20px; font-size: 0.85rem;">Toca productos del menú para cobrar</p>';
totalEl.textContent = '₡0';
if (floatBar) floatBar.style.display = 'none';
return;
}
@@ -134,21 +185,32 @@ function updatePosCartUI() {
total += subtotal;
return `
<div class="pos-cart-item">
<div style="flex: 1;">
<strong style="color: #f8fafc; font-size: 0.85rem;">${item.product.icono} ${item.product.nombre}</strong>
<div style="font-size: 0.75rem; color: #94a3b8;">₡${item.product.precio_colones.toLocaleString('es-CR')} c/u</div>
<div style="flex: 1; min-width: 0; word-break: break-word;">
<strong style="color: #f8fafc; font-size: 0.85rem; display: block; line-height: 1.2;">${item.product.icono} ${item.product.nombre}</strong>
<div style="font-size: 0.74rem; color: #94a3b8; margin-top: 2px;">₡${item.product.precio_colones.toLocaleString('es-CR')} c/u</div>
</div>
<div style="display: flex; align-items: center; gap: 8px;">
<button onclick="changePosQty(${idx}, -1)" style="width: 24px; height: 24px; background: #334155; color: white; border: none; border-radius: 4px; font-weight: 800; cursor: pointer;">-</button>
<span style="font-weight: 800; min-width: 14px; text-align: center; color: #ffffff;">${item.cantidad}</span>
<button onclick="changePosQty(${idx}, 1)" style="width: 24px; height: 24px; background: #334155; color: white; border: none; border-radius: 4px; font-weight: 800; cursor: pointer;">+</button>
<span style="font-weight: 900; color: #38bdf8; min-width: 55px; text-align: right;">₡${subtotal.toLocaleString('es-CR')}</span>
<div style="display: flex; align-items: center; gap: 6px; flex-shrink: 0;">
<button onclick="changePosQty(${idx}, -1)" style="width: 26px; height: 26px; background: #334155; color: white; border: none; border-radius: 6px; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center;">-</button>
<span style="font-weight: 800; min-width: 16px; text-align: center; color: #ffffff; font-size: 0.88rem;">${item.cantidad}</span>
<button onclick="changePosQty(${idx}, 1)" style="width: 26px; height: 26px; background: #334155; color: white; border: none; border-radius: 6px; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center;">+</button>
<span style="font-weight: 900; color: #38bdf8; min-width: 58px; text-align: right; font-size: 0.88rem;">₡${subtotal.toLocaleString('es-CR')}</span>
</div>
</div>
`;
}).join('');
totalEl.textContent = `₡${total.toLocaleString('es-CR')}`;
// Controlar barra flotante en móvil
if (floatBar && window.innerWidth <= 900) {
if (totalItems > 0 && posMobileActiveView === 'catalog') {
floatBar.style.display = 'flex';
if (floatText) floatText.textContent = `${totalItems} ${totalItems === 1 ? 'ítem' : 'ítems'} en mostrador`;
if (floatTotal) floatTotal.textContent = `₡${total.toLocaleString('es-CR')}`;
} else {
floatBar.style.display = 'none';
}
}
}
function changePosQty(idx, delta) {
@@ -469,6 +531,11 @@ function renderScannedStudent() {
} else {
alertBox.style.display = 'none';
}
// En pantallas móviles, mostrar la vista de caja automáticamente
if (window.innerWidth <= 900) {
switchPosMobileView('checkout');
}
}
function clearScannedStudent() {
@@ -527,6 +594,11 @@ async function executePosDebit() {
// Limpiar caja y refrescar
clearPosCart();
clearScannedStudent();
// En móviles, volver a la vista del catálogo para la siguiente venta
if (window.innerWidth <= 900) {
switchPosMobileView('catalog');
}
} catch (err) {
alert(`❌ Fallo en la transacción: ${err.message}`);
} finally {
+57 -21
View File
@@ -29,7 +29,7 @@
.status-listo { background: #dcfce7; color: #166534; }
.status-entregado { background: #f1f5f9; color: #64748b; }
</style>
<body style="background: #0b1120; color: #f8fafc;">
<body style="background: #0b1120; color: #f8fafc;" class="pos-mobile-view-catalog">
<!-- BANNER DE ADVERTENCIA HTTPS PARA TERMINALES REMOTAS -->
<div id="posBannerHttpsWarning" style="display: none; background: linear-gradient(135deg, #b45309, #d97706); color: white; padding: 10px 14px; font-size: 0.8rem; font-weight: 700; text-align: center;">
@@ -39,25 +39,39 @@
</a>
</div>
<!-- BARRA DE PESTAÑAS MÓVIL (PANTALLAS <= 900px) -->
<div class="pos-mobile-nav" id="posMobileNav">
<button class="pos-mobile-nav-btn active" id="btnMobileNavCatalog" onclick="switchPosMobileView('catalog')">
<span>🥪</span> Catálogo
</button>
<button class="pos-mobile-nav-btn" id="btnMobileNavCheckout" onclick="switchPosMobileView('checkout')">
<span>💳</span> Caja / Cobro QR
<span class="pos-mobile-nav-badge" id="mobileCartBadge" style="display: none;">0</span>
</button>
</div>
<div class="pos-layout">
<!-- PANEL IZQUIERDO: CATÁLOGO TÁCTIL Y COLA DE PRE-ÓRDENES -->
<div class="pos-catalog-pane">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #334155; padding-bottom: 12px;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #334155; padding-bottom: 12px; flex-wrap: wrap; gap: 10px;">
<div style="display: flex; align-items: center; gap: 10px;">
<span style="font-size: 1.8rem;">🥪</span>
<div>
<h1 style="font-size: 1.25rem; font-weight: 900; color: #ffffff;">RecreoPay <span style="color: #38bdf8;">Terminal Soda</span></h1>
<h1 style="font-size: 1.25rem; font-weight: 900; color: #ffffff; margin: 0;">RecreoPay <span style="color: #38bdf8;">Terminal Soda</span></h1>
<span style="font-size: 0.78rem; color: #94a3b8;">Soda Escolar • Ventana de Atención Rápida</span>
</div>
</div>
<div style="display: flex; align-items: center; gap: 12px;">
<span style="display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; background: #064e3b; color: #34d399; padding: 4px 10px; border-radius: 20px; font-weight: 700;">
<div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
<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 Activo)
En Línea (SSE)
</span>
<a href="/index.html" target="_blank" style="color: #38bdf8; font-size: 0.8rem; font-weight: 700; text-decoration: none; border: 1px solid #38bdf8; padding: 4px 10px; border-radius: 8px;">
Ver PWA Estudiante ↗
<a href="/index.html" style="color: #cbd5e1; font-size: 0.75rem; font-weight: 700; text-decoration: none; border: 1px solid #475569; padding: 4px 8px; border-radius: 8px; background: #1e293b;">
👨‍🍳 Admin
</a>
<a href="/index.html" target="_blank" style="color: #38bdf8; font-size: 0.75rem; font-weight: 700; text-decoration: none; border: 1px solid #38bdf8; padding: 4px 8px; border-radius: 8px;">
PWA Estudiante ↗
</a>
</div>
</div>
@@ -99,11 +113,33 @@
<!-- Lista de pre-órdenes -->
</div>
</div>
<!-- BARRA FLOTANTE DE ACCESO RÁPIDO A CAJA EN MÓVIL -->
<div id="posFloatingCheckoutBar" class="pos-floating-checkout-bar" onclick="switchPosMobileView('checkout')" style="display: none;">
<div style="display: flex; align-items: center; gap: 10px;">
<span style="font-size: 1.3rem;">🛒</span>
<div>
<div style="font-weight: 800; font-size: 0.88rem; color: #ffffff;" id="posFloatingCartText">0 ítems</div>
<div style="font-size: 0.72rem; color: #94a3b8;">Toca para cobrar o escanear QR</div>
</div>
</div>
<div style="display: flex; align-items: center; gap: 8px;">
<span style="font-size: 1.15rem; font-weight: 900; color: #38bdf8;" id="posFloatingCartTotal">₡0</span>
<span style="background: #0284c7; color: white; padding: 6px 12px; border-radius: 8px; font-weight: 800; font-size: 0.8rem;">Cobrar ➔</span>
</div>
</div>
</div>
<!-- PANEL DERECHO: SCANNER QR, IDENTIFICACIÓN Y COBRO -->
<div class="pos-checkout-pane">
<div>
<!-- BOTÓN VOLVER EN MÓVIL DENTRO DE CHECKOUT -->
<div class="pos-mobile-back-bar">
<button onclick="switchPosMobileView('catalog')" class="pos-mobile-back-btn">
<span>⬅</span> Volver al Catálogo de Alimentos
</button>
</div>
<!-- CÁMARA / ESCÁNER DE CÓDIGO QR -->
<div class="scanner-feed-card">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
@@ -148,16 +184,16 @@
<!-- TARJETA DEL ESTUDIANTE IDENTIFICADO POR QR -->
<div id="studentScannedCard" style="display: none; margin-top: 14px;" class="student-badge-scanned">
<img id="scannedAvatar" src="" style="width: 46px; height: 46px; border-radius: 50%; border: 2px solid #38bdf8; background: white;">
<div style="flex: 1;">
<h4 id="scannedName" style="font-size: 0.95rem; font-weight: 800; color: #ffffff;">Nombre del Alumno</h4>
<div id="scannedGrade" style="font-size: 0.75rem; color: #94a3b8;">2° Grado • Sección 2-A</div>
<div style="display: flex; gap: 10px; margin-top: 4px; font-size: 0.76rem;">
<img id="scannedAvatar" src="" style="width: 44px; height: 44px; border-radius: 50%; border: 2px solid #38bdf8; background: white; flex-shrink: 0;">
<div style="flex: 1; min-width: 0; word-break: break-word;">
<h4 id="scannedName" style="font-size: 0.92rem; font-weight: 800; color: #ffffff; margin: 0; line-height: 1.2;">Nombre del Alumno</h4>
<div id="scannedGrade" style="font-size: 0.74rem; color: #94a3b8; margin-top: 2px;">2° Grado • Sección 2-A</div>
<div style="display: flex; gap: 8px; margin-top: 4px; font-size: 0.74rem; flex-wrap: wrap;">
<span>Saldo: <strong id="scannedBalance" style="color: #34d399;">₡0</strong></span>
<span>Disp. hoy: <strong id="scannedAvailable" style="color: #38bdf8;">₡0</strong></span>
</div>
</div>
<button onclick="clearScannedStudent()" style="background: none; border: none; color: #ef4444; font-size: 1.1rem; cursor: pointer;" title="Desconectar alumno">✕</button>
<button onclick="clearScannedStudent()" style="background: none; border: none; color: #ef4444; font-size: 1.2rem; cursor: pointer; padding: 4px 8px; flex-shrink: 0;" title="Desconectar alumno">✕</button>
</div>
<!-- ALERTA DE ALERGIAS AL CAJERO -->
@@ -167,9 +203,9 @@
<!-- LISTA DE PRODUCTOS SELECCIONADOS EN CAJA -->
<div style="margin-top: 14px;">
<div style="display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 700; color: #94a3b8; border-bottom: 1px solid #334155; padding-bottom: 6px;">
<div style="display: flex; justify-content: space-between; align-items: center; font-size: 0.82rem; font-weight: 700; color: #94a3b8; border-bottom: 1px solid #334155; padding-bottom: 6px;">
<span>Ítems en Mostrador</span>
<button onclick="clearPosCart()" style="background: none; border: none; color: #ef4444; font-size: 0.75rem; cursor: pointer;">Limpiar</button>
<button onclick="clearPosCart()" style="background: none; border: none; color: #ef4444; font-size: 0.75rem; font-weight: 700; cursor: pointer; padding: 2px 6px;">Limpiar</button>
</div>
<div class="pos-cart-list" id="posCartList">
<p style="text-align: center; color: #64748b; padding: 20px; font-size: 0.85rem;">Toca productos del menú para cobrar</p>
@@ -178,13 +214,13 @@
</div>
<!-- BOTÓN DE COBRO Y TOTAL -->
<div style="border-top: 2px solid #334155; padding-top: 14px;">
<div style="display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px;">
<span style="font-size: 0.9rem; font-weight: 700; color: #94a3b8;">TOTAL A DEBITAR:</span>
<span id="posCartTotal" style="font-size: 1.8rem; font-weight: 900; color: #38bdf8;">₡0</span>
<div style="border-top: 2px solid #334155; padding-top: 14px; margin-top: auto;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px;">
<span style="font-size: 0.88rem; font-weight: 800; color: #94a3b8; letter-spacing: 0.5px;">TOTAL A DEBITAR:</span>
<span id="posCartTotal" style="font-size: 1.7rem; font-weight: 900; color: #38bdf8;">₡0</span>
</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: 1.05rem; 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);">
<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
</button>
</div>