Умный генератор карточек товара
+
+
+
+
+
+ + Введите название товара, и ИИ подготовит описание, характеристики и промпты для генерации изображений. +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Продающее описание
+ +SEO Теги
+ +
+
+
+
+
+
+ Технические характеристики
+Промпты для ИИ-фото (DALL-E/Midjourney)
+ +Доступные маркетплейсы
diff --git a/frontend/js/app.js b/frontend/js/app.js index c75308c..76aef3d 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -272,10 +272,86 @@ function initTabs() { if(target === 'seo-section') loadSEO(); if(target === 'content-section') loadReferences(); if(target === 'finance-section') { /* No initial load */ } + if(target === 'generator-section') { /* No initial load */ } }); }); } +document.getElementById('ai-gen-card-btn').addEventListener('click', async () => { + const title = document.getElementById('gen-title-input').value; + if (!title) { + alert('Введите название товара'); + return; + } + + const btn = document.getElementById('ai-gen-card-btn'); + const originalText = btn.innerHTML; + btn.disabled = true; + btn.innerHTML = ' Магия ИИ в процессе...'; + if (window.lucide) lucide.createIcons(); + + try { + const token = localStorage.getItem('token'); + const res = await fetch('http://localhost:5000/api/ai/generate-card', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` + }, + body: JSON.stringify({ title }) + }); + const data = await res.json(); + + if (data.error) throw new Error(data.error); + + document.getElementById('gen-result-container').classList.remove('hidden'); + document.getElementById('gen-description').innerText = data.description; + + // Tags + const tagsDiv = document.getElementById('gen-tags'); + tagsDiv.innerHTML = ''; + data.seo_tags.forEach(tag => { + const span = document.createElement('span'); + span.className = 'status-pill'; + span.style.background = 'rgba(255,255,255,0.1)'; + span.innerText = `#${tag}`; + tagsDiv.appendChild(span); + }); + + // Features + const featuresTbody = document.querySelector('#gen-features-table tbody'); + featuresTbody.innerHTML = ''; + for (const [key, val] of Object.entries(data.features)) { + const tr = document.createElement('tr'); + tr.innerHTML = `${p}`; + promptsDiv.appendChild(pBox); + }); + + showToast('Карточка успешно сгенерирована!', 'success'); + + } catch (err) { + alert(err.message); + } finally { + btn.disabled = false; + btn.innerHTML = originalText; + if (window.lucide) lucide.createIcons(); + } +}); + document.getElementById('pnl-form').addEventListener('submit', async (e) => { e.preventDefault(); const fd = new FormData(e.target);