diff --git a/miniapp/assets/app.js b/miniapp/assets/app.js index 128e06c..7400c1c 100644 --- a/miniapp/assets/app.js +++ b/miniapp/assets/app.js @@ -1625,9 +1625,13 @@ function hideSplash() { }, wait); } +let _hashListenerAdded = false; async function init() { setupTelegram(); - window.addEventListener("hashchange", routeByHash); + if (!_hashListenerAdded) { + window.addEventListener("hashchange", routeByHash); + _hashListenerAdded = true; + } const qp = new URLSearchParams(window.location.search); // Telegram ставит #tgWebAppData=... в hash при открытии — это НЕ наш роут. @@ -1658,75 +1662,8 @@ async function init() { try { const me = await fetchMe(); window.__zovMe = me; // кешируем профиль для подэкранов - if (location.hash.startsWith("#/podbor")) { - Podbor.mount(app); - hideSplash(); - return; - } - if (location.hash.startsWith("#/clients")) { - Clients.mount(app); - hideSplash(); - return; - } - if (location.hash.startsWith("#/measure")) { - Measurements.mount(app); - hideSplash(); - return; - } - if (location.hash.startsWith("#/request")) { - MeasurementRequest.mount(app); - hideSplash(); - return; - } - if (location.hash.startsWith("#/inbox/")) { - const id = location.hash.replace("#/inbox/", ""); - renderInboxDetail(id); - hideSplash(); - return; - } - if (location.hash === "#/inbox") { - if (typeof InboxScreen !== "undefined") InboxScreen.mount(app); - hideSplash(); - return; - } - if (location.hash.startsWith("#/assembly")) { - Assembly.mount(app); - hideSplash(); - return; - } - if (location.hash.startsWith("#/c/proposal")) { - app.innerHTML = ""; - document.body.classList.remove("has-bottom-nav"); - const oldNav = document.getElementById("bottom-nav"); - if (oldNav) oldNav.remove(); - if (typeof Proposals !== "undefined") { - Proposals.mountClient(app); - } else { - app.innerHTML = `
Модуль подбора не загружен
`; - } - hideSplash(); - return; - } - if (location.hash.startsWith("#/c/contract")) { - app.innerHTML = ""; - document.body.classList.remove("has-bottom-nav"); - const oldNavC = document.getElementById("bottom-nav"); - if (oldNavC) oldNavC.remove(); - if (typeof Proposals !== "undefined") { - Proposals.mountContractReview(app); - } else { - app.innerHTML = `
Модуль не загружен
`; - } - hideSplash(); - return; - } - if (me.role === "staff") { - renderStaff(me); - } else if (me.role === "manager") { - renderManager(me); - } else { - renderClient(me); - } + // Единая точка роутинга — routeByHash покрывает все маршруты + routeByHash(); hideSplash(); } catch (e) { console.error(e); diff --git a/miniapp/assets/cabinet.js b/miniapp/assets/cabinet.js index 625b78b..9a69d2b 100644 --- a/miniapp/assets/cabinet.js +++ b/miniapp/assets/cabinet.js @@ -76,7 +76,7 @@ const CabinetScreen = (function () {
Мои подборы
Подборов пока нет
- +
`; } const items = proposals.slice(0, 3).map(p => ` @@ -96,7 +96,7 @@ const CabinetScreen = (function () { ${proposals.length > 3 ? `Все ${proposals.length}` : ""}
${items}
- + `; } diff --git a/miniapp/assets/me.js b/miniapp/assets/me.js index a010e17..aae3549 100644 --- a/miniapp/assets/me.js +++ b/miniapp/assets/me.js @@ -158,7 +158,7 @@ const MeScreen = (function () {
- +
`;