From 64c7d18e2c20777751f7f980de7724d8b9aa6dab Mon Sep 17 00:00:00 2001 From: wasrusgen Date: Thu, 28 May 2026 17:45:45 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20GPS=20=D0=BF=D1=80=D0=B8=D0=B1=D1=8B?= =?UTF-8?q?=D1=82=D0=B8=D0=B5=20=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=8A=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=20=D1=83=20=D1=81=D0=B1=D0=BE=D1=80=D1=89=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0=20(=D0=BC=D0=B0=D1=82=D1=87=20=D0=BF=D0=BE=20?= =?UTF-8?q?=D0=B0=D0=B4=D1=80=D0=B5=D1=81=D1=83=20=D0=BA=D0=BB=D0=B8=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/mockup_assembler.html | 90 +++++++++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 7 deletions(-) diff --git a/docs/mockup_assembler.html b/docs/mockup_assembler.html index 65de1d9..50af554 100644 --- a/docs/mockup_assembler.html +++ b/docs/mockup_assembler.html @@ -447,6 +447,52 @@ function render(id) { } } +// ── GPS: прибытие на объект сборки ──────────────────────────────────────────── +var _ASM_GPS_RADIUS = 300; // метров — у клиента адрес уличный, допуск больше чем у салона +var _ASM_JOBS = { + 'А-2847': {addr:'ул. Ленина, 45', lat:59.9548, lng:30.3158}, + 'А-2851': {addr:'пр. Победы, 88', lat:59.8695, lng:30.2867} +}; +window._ASM_GPS = {}; // jobId → null | 'loading' | {ok,dist,forced} +window._ASM_GPS_DEMO = 'near'; // 'near' | 'far' + +function _asmGpsDist(la1,lo1,la2,lo2){ + var R=6371000,dL=(la2-la1)*Math.PI/180,dG=(lo2-lo1)*Math.PI/180; + var a=Math.sin(dL/2)*Math.sin(dL/2)+Math.cos(la1*Math.PI/180)*Math.cos(la2*Math.PI/180)*Math.sin(dG/2)*Math.sin(dG/2); + return Math.round(R*2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))); +} +function _asmFmt(m){ return m<1000?(m+' м'):(m/1000).toFixed(1)+' км'; } +function _asmGpsResult(jobId,dist){ + var ok=dist<=_ASM_GPS_RADIUS; + window._ASM_GPS[jobId]={ok:ok,dist:dist}; + document.getElementById('screen').innerHTML=render('asm_detail'); +} +function _asmGpsRequest(jobId){ + window._ASM_GPS[jobId]='loading'; + document.getElementById('screen').innerHTML=render('asm_detail'); + var job=_ASM_JOBS[jobId]; + function onGot(lat,lng){ _asmGpsResult(jobId,_asmGpsDist(lat,lng,job.lat,job.lng)); } + function onFail(){ _asmGpsResult(jobId, window._ASM_GPS_DEMO==='near'?62:1380); } + var tg=window.Telegram&&Telegram.WebApp; + if(tg&&tg.LocationManager&&tg.LocationManager.isInited){ + tg.LocationManager.getLocation(function(r){ r&&r.latitude?onGot(r.latitude,r.longitude):onFail(); }); + } else if(navigator.geolocation){ + navigator.geolocation.getCurrentPosition( + function(p){ onGot(p.coords.latitude,p.coords.longitude); }, + onFail,{timeout:8000,maximumAge:15000} + ); + } else { onFail(); } +} +function _asmGpsForce(jobId){ + var prev=window._ASM_GPS[jobId]; + window._ASM_GPS[jobId]={ok:false,dist:prev&&prev.dist||0,forced:true}; + document.getElementById('screen').innerHTML=render('asm_detail'); +} +function _asmGpsCancelCheck(jobId){ + window._ASM_GPS[jobId]=null; + document.getElementById('screen').innerHTML=render('asm_detail'); +} + /* ─── BOTTOM SHEET ─── */ function showSheet(d) { const existing = document.getElementById('bottomSheet'); @@ -650,13 +696,43 @@ function screenAsmDetail() {
-
- -
-
В процессе · 4 из 7 позиций
-
Начато в 10:15 · прошло 1ч 43мин
-
-
+ ${(function(){ + var jobId='А-2847'; + var gst=window._ASM_GPS[jobId]; + if(!gst){ + // Ещё не прибыл + return '
' + +'
📍 Подтвердите прибытие на объект
' + +'
ул. Ленина, 45, кв. 12 · Иванов Дмитрий
' + +'
' + +'' + +'
' + +'
Демо: ' + +'Рядом · ' + +'Далеко
' + +'
'; + } else if(gst==='loading'){ + return '
' + +'Определяем местоположение…
'; + } else if(gst&&!gst.ok&&!gst.forced){ + return '
' + +'
⚠️ Вы в '+_asmFmt(gst.dist)+' от объекта
' + +'
ул. Ленина, 45 · Допустимый радиус: 300 м
' + +'
' + +'' + +'' + +'
'; + } else { + // Прибыл (ok или forced) + var chip = gst.forced + ? '⚡ вручную' + : 'GPS ✓'; + return '
' + +'' + +'
В процессе · 4 из 7 позиций'+chip+'
' + +'
Начато в 10:15 · прошло 1ч 43мин
'; + } + })()}