fix: solucion integral de activacion de camara QR con deteccion HTTPS, resilencia iOS/Safari y fallback de foto nativa

This commit is contained in:
unknown
2026-10-04 17:33:16 -06:00
parent 02bf67e0ff
commit f9454dbe09
5 changed files with 412 additions and 54 deletions
+24 -7
View File
@@ -29,9 +29,16 @@
.status-listo { background: #dcfce7; color: #166534; }
.status-entregado { background: #f1f5f9; color: #64748b; }
</style>
</head>
<body style="background: #0b1120; color: #f8fafc;">
<!-- 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;">
🔒 Terminal en HTTP. Para activar la cámara en vivo del dispositivo, se requiere conexión HTTPS:
<a id="posLinkHttpsRedirect" href="https://somewhat-ships-looksmart-optical.trycloudflare.com/pos.html" style="margin-left: 8px; color: white; text-decoration: underline; font-weight: 900;">
🚀 Abrir en HTTPS Seguro ↗
</a>
</div>
<div class="pos-layout">
<!-- PANEL IZQUIERDO: CATÁLOGO TÁCTIL Y COLA DE PRE-ÓRDENES -->
<div class="pos-catalog-pane">
@@ -109,17 +116,27 @@
</div>
<div style="position: relative; border-radius: 10px; overflow: hidden; background: #000; min-height: 180px; display: flex; align-items: center; justify-content: center;">
<video id="scannerVideo" class="camera-preview" autoplay playsinline muted></video>
<video id="scannerVideo" class="camera-preview" autoplay playsinline webkit-playsinline muted></video>
<div class="laser-scan-line"></div>
<div id="cameraHelpOverlay" style="display: none; position: absolute; inset: 0; background: rgba(15, 23, 42, 0.9); padding: 14px; text-align: center; flex-direction: column; justify-content: center; align-items: center; gap: 8px; z-index: 10;">
<div id="cameraHelpOverlay" style="display: none; position: absolute; inset: 0; background: rgba(15, 23, 42, 0.92); padding: 14px; text-align: center; flex-direction: column; justify-content: center; align-items: center; gap: 10px; z-index: 10;">
<span style="font-size: 1.8rem;">📷</span>
<p id="cameraHelpText" style="font-size: 0.78rem; color: #f8fafc; line-height: 1.3;">Haz clic en Activar Cámara para escanear</p>
<button onclick="initCamera(true)" style="padding: 6px 14px; background: #0284c7; color: white; border: none; border-radius: 8px; font-weight: 800; font-size: 0.8rem; cursor: pointer;">
Permitir Cámara
</button>
<div id="cameraHelpText" style="font-size: 0.78rem; color: #f8fafc; line-height: 1.35;">Haz clic en Activar Cámara para escanear</div>
<div id="posCameraActionContainer" style="display: flex; flex-direction: column; gap: 8px; width: 100%; align-items: center;">
<button id="btnAllowPosCamera" onclick="initCamera(true)" style="padding: 8px 16px; background: #0284c7; color: white; border: none; border-radius: 8px; font-weight: 800; font-size: 0.82rem; cursor: pointer; box-shadow: 0 4px 10px rgba(2, 132, 199, 0.4);">
Permitir Cámara
</button>
</div>
</div>
</div>
<!-- BOTÓN PARA TOMAR FOTO DEL CARNÉ O QR -->
<div style="display: flex; justify-content: center; margin-top: 8px;">
<label style="cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: #1e293b; border: 1px dashed #475569; border-radius: 8px; font-size: 0.74rem; font-weight: 700; color: #38bdf8;">
<span>📸</span> Tomar foto de carné QR
<input type="file" accept="image/*" capture="environment" style="display: none;" onchange="handlePosQrPhoto(event)">
</label>
</div>
<!-- BOTONES DE PRUEBA RÁPIDA DE QR (SIMULACIÓN DE ESCANEO DE CARNÉ O CELULAR) -->
<div style="margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;">
<span style="font-size: 0.7rem; color: #94a3b8; width: 100%;">Prueba rápida de escaneo de carné:</span>