📎
@@ -343,13 +331,13 @@ body{font-family:'Inter',sans-serif;background:var(--bg);color:var(--text);displ
-
🧠
Этап 4 из 5
Анализ бизнеса
Елена строит модель вашего бизнеса
+
🧠
Этап 3 из 4
Анализ бизнеса
Елена строит модель вашего бизнеса
-
🚀
Этап 5 из 5
План — ТЗ на программу
Проект системы для вашего бизнеса
+
🚀
Этап 4 из 4
План — ТЗ на программу
Проект системы для вашего бизнеса
@@ -389,7 +377,7 @@ const urlToken=new URLSearchParams(location.search).get("t");
if(urlToken)localStorage.setItem("cab_token",urlToken);
let token=urlToken||localStorage.getItem("cab_token"), state=null, cur=1;
const chat=document.getElementById("chat"), inp=document.getElementById("inp");
-const PCTS={1:20,2:40,3:60,4:80,5:100};
+const PCTS={1:25,3:50,4:75,5:100}; // 4 шага для клиента (Этап 1 объединён)
function esc(s){return (s||"").replace(/&/g,"&").replace(//g,">")}
function fmt(s){return esc(s).replace(/\*\*(.+?)\*\*/g,"
$1")}
@@ -411,7 +399,6 @@ function go(n){
document.getElementById('si'+n).classList.add('active');
if(PCTS[n]!=null){document.getElementById('pbPct').textContent=PCTS[n]+'%';document.getElementById('pbFill').style.width=PCTS[n]+'%';}
if(n===1){renderChat1();requestAnimationFrame(scrollChatBottom);} // ре-рендер из общей беседы
- if(n===2)renderChat2(); // продолжение того же диалога
if(n===6){renderOpChat();startOpPoll();}else{stopOpPoll();}
if(n===3)renderDocs();
if(n===4)renderAnalysis();
@@ -593,15 +580,6 @@ function renderAll(){
checkPayment();
}
function renderChat1(){const c=document.getElementById("chat");if(!c)return;c.innerHTML="";(state.messages||[]).forEach(m=>addMsg(m.role==="user"?"user":"elena",m.content));}
-/* ── Этап 2 — продолжение диалога (тот же state.messages) ── */
-function addMsg2(role,text){const c=document.getElementById("chat2");if(!c)return;const m=document.createElement("div");m.className="msg "+(role==="user"?"user":"");m.innerHTML=`
${role==='user'?'Я':'Е'}
${fmt(text)}
`;c.appendChild(m);const sc=c.parentElement;if(sc)sc.scrollTop=sc.scrollHeight;}
-function renderChat2(){const c=document.getElementById("chat2");if(!c)return;c.innerHTML="";const m=state.messages||[];if(!m.length){c.innerHTML='
Начните разговор на Этапе 1 — здесь Елена продолжит уточнять детали.
';return;}m.forEach(x=>addMsg2(x.role==="user"?"user":"elena",x.content));requestAnimationFrame(()=>{const sc=c.parentElement;if(sc)sc.scrollTop=sc.scrollHeight;});}
-async function sendMsg2(){const i=document.getElementById("inp2");const t=i.value.trim();if(!t)return;if(recording)stopMic();i.value="";i.style.height="auto";addMsg2("user",t);state.messages.push({role:"user",content:t});
- const btn=document.getElementById("send2");btn.disabled=true;
- const tp=document.createElement("div");tp.className="msg";tp.id="typing2";tp.innerHTML='
Е
';document.getElementById("chat2").appendChild(tp);const sc=document.getElementById("chat2").parentElement;if(sc)sc.scrollTop=sc.scrollHeight;
- try{const r=await fetch(`${API}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token,message:t})});const d=await r.json();const x=document.getElementById("typing2");if(x)x.remove();addMsg2("elena",d.reply||("Ошибка: "+(d.error||"?")));state.messages.push({role:"assistant",content:d.reply||""});unlockStages();}catch(e){const x=document.getElementById("typing2");if(x)x.remove();addMsg2("elena","Ошибка связи: "+e.message);}
- btn.disabled=false;
-}
function money(n){return (n||0).toLocaleString("ru-RU")+" ₽"}
function checkPayment(){
const crm=state.crm||{};const deal=crm.deal_amount||0;
@@ -668,7 +646,7 @@ async function payVia(method){
function unlockStages(){
// Этап 4 доступен если есть достаточно сообщений
const enough=state.messages.length>=3;
- [2,3,4,5].forEach(n=>{const si=document.getElementById('si'+n);if(enough||n<=3)si.classList.remove('locked');});
+ [3,4,5].forEach(n=>{const si=document.getElementById('si'+n);if(si&&(enough||n===3))si.classList.remove('locked');});
}
async function sendMsg(){