From 9e828e1c5479264e0f01258ba8233bb25b59b254 Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 13 Nov 2026 23:04:21 +0800 Subject: [PATCH] Update App.jsx via upload script - 2026-11-13 23:03:59 --- App.jsx | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 134 insertions(+), 2 deletions(-) diff --git a/App.jsx b/App.jsx index a85fdcf..46a550a 100644 --- a/App.jsx +++ b/App.jsx @@ -5,7 +5,7 @@ import { Building2, Globe, Phone, Save, RefreshCw, LayoutDashboard, Users, Package, Layers, Zap, Tag, Inbox, Paperclip, Menu, LogOut, GripVertical, BookOpen, FileText, FolderTree, Lock, Sparkles, Printer, Image as ImageIcon, - ShieldCheck, Settings2, Boxes, Download, Wifi, Radio, QrCode, Folder, FolderPlus, Factory, UploadCloud, ClipboardList, MessageCircle + ShieldCheck, Settings2, Boxes, Download, Wifi, Radio, QrCode, Folder, FolderPlus, Factory, UploadCloud, ClipboardList, MessageCircle, CalendarDays, MapPin } from 'lucide-react'; import { MicUploadPage } from './mic-upload/MicUploadPage'; import { ImageToolPage } from './mic-upload/ImageToolPage'; @@ -2184,6 +2184,29 @@ const Styles = () => ( .web-thumb.tall img { object-fit: cover; object-position: top; } .web-thumb-add { width: 88px; height: 88px; border: 1px dashed var(--line); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; color: var(--ink-soft); cursor: pointer; } .web-badge { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; font-size: 11px; font-weight: 500; color: #1d7a3e; background: #dcf1e2; padding: 2px 8px; border-radius: 99px; } + .visit-card { display: grid; grid-template-columns: 120px 1fr 150px; gap: 16px; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--panel); } + .visit-card.focus { box-shadow: 0 0 0 2px #2563eb; } + .visit-card.st-done, .visit-card.st-cancelled { opacity: .7; } + .visit-when { text-align: center; border-right: 1px dashed var(--line); padding-right: 14px; display: flex; flex-direction: column; align-items: center; gap: 2px; } + .visit-date { font-size: 26px; font-weight: 700; line-height: 1.1; } + .visit-hour { font-size: 20px; font-weight: 700; margin-top: 6px; font-family: 'IBM Plex Mono', monospace; } + .visit-wk { font-size: 11.5px; color: var(--ink-soft); } + .visit-st { margin-top: 8px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #eef2f7; color: #475467; } + .visit-st.st-new { background: #fef3c7; color: #92400e; } + .visit-st.st-confirmed { background: #dcfce7; color: #166534; } + .visit-co { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; } + .visit-cc { font-size: 12px; font-weight: 500; color: var(--ink-soft); } + .visit-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; margin-top: 6px; } + .visit-line svg { color: var(--ink-soft); flex: none; } + .visit-notes { margin-top: 8px; font-size: 13px; background: var(--bg); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; } + .visit-meta { margin-top: 8px; font-size: 11.5px; color: var(--ink-soft); } + .visit-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; } + .visit-lic { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; } + .visit-lic-h { font-size: 12px; color: var(--ink-soft); font-weight: 600; } + .visit-lic img { width: 150px; max-height: 190px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; } + .visit-pdf { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 150px; height: 120px; border: 1px solid #f5b5ac; border-radius: 8px; background: #fef1ef; color: #b42318; text-decoration: none; font-weight: 700; } + .visit-pdf small { font-weight: 500; color: #b42318; } + @media (max-width: 760px) { .visit-card { grid-template-columns: 1fr; } .visit-when { border-right: 0; border-bottom: 1px dashed var(--line); padding: 0 0 10px; } } .brand-vis { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; font-weight: 500; } .brand-vis button { display: inline-flex; align-items: center; gap: 3px; border: 0; background: transparent; font-size: 11px; padding: 1px 8px; cursor: pointer; color: var(--ink-soft); } .brand-vis button.on { background: var(--ink); color: #fff; } @@ -2454,6 +2477,7 @@ const NAV_GROUPS = [ ] }, { id: 'website', label: '网站管理', icon: Globe, children: [ { id: 'webnews', label: '新闻 / 动态', icon: FileText }, + { id: 'webvisits', label: '预约拜访', icon: CalendarDays }, ] }, { id: 'backpanel', label: '后板图模板', icon: Settings2 }, { id: 'mic-upload', label: 'MIC产品上传', icon: UploadCloud }, @@ -2578,7 +2602,9 @@ function MainApp({ username, onLogout }) { const [products, setProducts] = useState([]); // 推送消息里的链接 /?chat=对话id → 直接打开在线客服的这个对话 const chatLinkSid = useMemo(() => { try { return new URLSearchParams(window.location.search).get('chat') || null; } catch (e) { return null; } }, []); - const [view, setView] = useState(chatLinkSid ? 'chat' : 'monitor'); + // 推送消息里的链接 /?visit=预约id → 打开"网站管理 → 预约拜访"并定位到这条 + const visitLinkId = useMemo(() => { try { return new URLSearchParams(window.location.search).get('visit') || null; } catch (e) { return null; } }, []); + const [view, setView] = useState(chatLinkSid ? 'chat' : visitLinkId ? 'webvisits' : 'monitor'); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const [selectedId, setSelectedId] = useState(null); @@ -4335,6 +4361,18 @@ function MainApp({ username, onLogout }) { }} /> )} + {view === 'webvisits' && ( + { + const c = { ...blankCustomer(), company: v.company || '', contact: [v.name, v.title && `(${v.title})`].filter(Boolean).join(' '), country: v.country || '', email: v.email || '', phone: v.phone || '', + website: v.website || '', intendedModel: [...(v.products || []), v.productsOther].filter(Boolean).join(', '), source: '网站预约拜访', + notes: [`预约拜访:${v.date} ${String(v.hour).padStart(2, '0')}:00(北京时间),${v.people} 人`, v.notes].filter(Boolean).join('\n') }; + setCustomers(prev => [...prev, c]); + setView('manage'); setDraft(null); setSelectedId(c.id); + notify('已存为客户档案,可以继续补充'); + }} /> + )} + {(view === 'website' || view === 'webnews') && ( { try { const j = await chApi('GET', '/api/chat/admin/visits'); setList(j.list || []); } catch (e) { setList([]); onNotify('读取预约失败:' + e.message); } }; + useEffect(() => { load(); const t = setInterval(load, 60000); return () => clearInterval(t); }, []); + useEffect(() => { if (focusId && list) { const el = document.getElementById('visit-' + focusId); if (el) el.scrollIntoView({ block: 'center' }); } }, [focusId, list && list.length]); + const patch = async (v, body, msg) => { + try { const j = await chApi('POST', `/api/chat/admin/visits/${v.id}`, body); setList(l => l.map(x => (x.id === v.id ? j.visit : x))); if (msg) onNotify(msg); } + catch (e) { onNotify('保存失败:' + e.message); } + }; + const del = async (v) => { + if (!window.confirm(`删除 ${v.company} 的预约?营业执照文件也会一起删除。`)) return; + try { await chApi('POST', `/api/chat/admin/visits/${v.id}/delete`); setList(l => l.filter(x => x.id !== v.id)); onNotify('已删除'); } + catch (e) { onNotify('删除失败:' + e.message); } + }; + if (!list) return
加载中…
; + const todayBj = new Date(Date.now() + 8 * 3600e3).toISOString().slice(0, 10); + const shown = list + .filter(v => (filter === 'open' ? v.status === 'new' || v.status === 'confirmed' : filter === 'all' ? true : v.status === filter)) + .sort((a, b) => (filter === 'open' ? `${a.date}${String(a.hour).padStart(2, '0')}`.localeCompare(`${b.date}${String(b.hour).padStart(2, '0')}`) : b.at - a.at)); + const count = (k) => list.filter(v => (k === 'open' ? v.status === 'new' || v.status === 'confirmed' : k === 'all' || v.status === k)).length; + const waOf = (ph) => String(ph || '').replace(/[^\d]/g, ''); + return ( +
+
+
预约拜访
+ 客户在网站"预约拜访"页面提交;时间都是北京时间 +
+ {[['open', '待处理'], ['new', '待确认'], ['confirmed', '已确认'], ['done', '已完成'], ['cancelled', '已取消'], ['all', '全部']].map(([k, l]) => ( + + ))} + +
+
+
+ {shown.length === 0 &&
没有{filter === 'all' ? '' : '这类'}预约
} + {shown.map(v => { + const d = new Date(v.date + 'T00:00:00+08:00'); + const past = v.date < todayBj; + const isImg = v.license && /^image\//.test(v.license.mime); + const licUrl = `/api/chat/admin/visits/${v.id}/license`; + return ( +
+
+
{v.date.slice(5).replace('-', '/')}
+
{WEEK_ZH[d.getUTCDay()]} · {v.date.slice(0, 4)}
+
{String(v.hour).padStart(2, '0')}:00
+
北京时间
+ {VISIT_STATUS_ZH[v.status] || v.status}{past && (v.status === 'new' || v.status === 'confirmed') ? ' · 已过期' : ''} +
+
+
{v.company}{v.country && {chFlag(v.country)} {v.country}}
+
{v.name}{v.title ? `(${v.title})` : ''} · 共 {v.people} 人
+
{(v.places || []).map(k => VISIT_PLACE_SHORT[k] || k).join(' + ')}{(v.places || []).includes('shenzhen') && (v.places || []).includes('dongguan') ? '(深圳总部 ↔ 东莞工厂约 36 km,车程约 1 小时)' : ''}
+
{v.phone}{waOf(v.phone).length >= 7 && WhatsApp} + {v.email} + {v.website && <>{v.website}} +
+ {((v.products || []).length > 0 || v.productsOther) &&
{[...(v.products || []), v.productsOther].filter(Boolean).join('、')}
} + {v.notes &&
{v.notes}
} +
提交于 {new Date(v.at).toLocaleString('zh-CN', { hour12: false })}{v.lang ? ` · 网站语言 ${v.lang}` : ''}
+
+ + + +
+