From 2a3ae88dc5eb238c6134e21f6f53048916f6d7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?UI=20=E8=AE=BE=E8=AE=A1?= Date: Thu, 21 May 2026 17:23:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(products):=20=E5=88=9B=E5=BB=BA=E5=95=86?= =?UTF-8?q?=E5=93=81=20=C2=B7=20=E4=BF=AE=E5=A4=8D=E5=8D=96=E7=82=B9?= =?UTF-8?q?=E6=94=B6=E9=9B=86(=E8=AF=BB=20.bl-text=20+=20=E5=85=9C?= =?UTF-8?q?=E5=BA=95=E6=9C=AA=E5=9B=9E=E8=BD=A6)=C2=B7=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BF=85=E5=A1=AB=E6=8F=90=E7=A4=BA=20=C2=B7=20?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E5=BB=B6=E6=97=B6=20400=E2=86=921200ms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 电商AI平台/products.html | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/电商AI平台/products.html b/电商AI平台/products.html index f45b15f..459abfe 100644 --- a/电商AI平台/products.html +++ b/电商AI平台/products.html @@ -1677,20 +1677,30 @@ blInput.addEventListener('keydown', e => { // 创建商品 (真正插入 grid) saveBtn.addEventListener('click', () => { + // 防呆:每一步明确反馈,清晰看出在哪一步出问题 const name = document.getElementById('pf-name').value.trim(); const cat = document.getElementById('pf-cat').value; if (!name) { - Shell.toast('请填写商品名称'); + Shell.toast('请填写商品名称', '必填项'); document.getElementById('pf-name').focus(); return; } if (pfFiles.length === 0) { - Shell.toast('请上传商品主图', '至少 1 张'); + Shell.toast('请上传商品主图', '至少 1 张 · 必填'); return; } - // 计数器收集卖点 bullets - const bullets = [...document.querySelectorAll('#pf-bullets .bl-item input')] - .map(i => i.value.trim()).filter(Boolean); + // 收集核心卖点:存在 .bl-item .bl-text 里(已确认的)+ .bl-add input(用户打了字但未回车) + const confirmedBullets = [...document.querySelectorAll('#pf-bullets .bl-item .bl-text')] + .map(el => el.textContent.trim()).filter(Boolean); + const pendingInput = document.querySelector('#pf-bullets .bl-add .bl-input'); + const pendingText = (pendingInput?.value || '').trim(); + if (pendingText) confirmedBullets.push(pendingText); // 包容用户没按回车的情况 + if (confirmedBullets.length === 0) { + Shell.toast('请填写核心卖点', '至少 1 条 · 回车确认'); + pendingInput?.focus(); + return; + } + const bullets = confirmedBullets; // 创建 card 并插入 grid 最前 const today = new Date().toISOString().slice(0, 10); const card = document.createElement('div'); @@ -1767,7 +1777,7 @@ saveBtn.addEventListener('click', () => { const sidebar = document.querySelector('aside.sidebar a[href="products.html"] .pill-mini'); if (sidebar) sidebar.textContent = remaining; - Shell.toast('商品已创建', `+ ${name} · 跳转至详情页`); + Shell.toast('商品已创建 · 即将跳转详情', `+ ${name} · ${bullets.length} 条卖点`); closeNewProductDrawer(); // 重置表单(为下次新建准备) document.getElementById('pf-name').value = ''; @@ -1777,10 +1787,12 @@ saveBtn.addEventListener('click', () => { if (pfGrid) pfGrid.innerHTML = ''; const blList = document.getElementById('pf-bullets'); if (blList) blList.querySelectorAll('.bl-item').forEach(li => li.remove()); - // 商品库新建商品后跳转到该商品的详情页(其他页保持原行为) + const pendingI = document.querySelector('#pf-bullets .bl-add .bl-input'); + if (pendingI) pendingI.value = ''; + // 1200ms 后跳转(让 toast 看清),商品库新建商品后跳转到该商品的详情页 setTimeout(() => { location.href = 'product-detail.html?t=' + Date.now() + '&product=' + encodeURIComponent(name); - }, 400); + }, 1200); });