Update App.jsx via upload script - 2026-11-13 23:03:59
This commit is contained in:
parent
1a120bdb03
commit
9e828e1c54
136
App.jsx
136
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' && (
|
||||
<VisitManager onNotify={notify} focusId={visitLinkId}
|
||||
onSaveCustomer={(v) => {
|
||||
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') && (
|
||||
<WebsiteManager
|
||||
section={view === 'webnews' ? 'news' : 'assets'}
|
||||
|
|
@ -10511,6 +10549,100 @@ function Info({ icon, label, value }) {
|
|||
// 网站聊天窗口的后台:实时看 AI 和客户的对话、接管 / 交还 AI、悄悄话、中文自动翻译、客户分级;
|
||||
// 知识库、待解答问题、规则、范例;设置(企业微信推送等)。数据在服务器 chat-data.json(public-api.js 里的 mountChat)。
|
||||
const CH_TIER = { project: ['工程项目', '#7c3aed'], importer: ['进口商/批发商', '#2F8F5B'], reseller: ['小经销商', '#3D6E99'], personal: ['个人买家', '#C9842E'], unknown: ['待判断', '#8a96a8'], spam: ['垃圾消息', '#b9c0cc'] };
|
||||
/* ------------------------------ 预约拜访(网站 /visit/ 页面提交) ------------------------------ */
|
||||
const VISIT_STATUS_ZH = { new: '待确认', confirmed: '已确认', done: '已完成', cancelled: '已取消' };
|
||||
const VISIT_PLACE_SHORT = { beijing: '北京办公室', shenzhen: '深圳总部', dongguan: '东莞工厂' };
|
||||
const WEEK_ZH = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
||||
function VisitManager({ onNotify, onSaveCustomer, focusId }) {
|
||||
const [list, setList] = useState(null);
|
||||
const [filter, setFilter] = useState('open');
|
||||
const [memo, setMemo] = useState({});
|
||||
const load = async () => { 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 <div className="panel" style={{ padding: 24 }}>加载中…</div>;
|
||||
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 (
|
||||
<div className="panel" style={{ padding: 0 }}>
|
||||
<div className="panel-header" style={{ display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' }}>
|
||||
<div style={{ fontWeight: 600 }}>预约拜访</div>
|
||||
<span style={{ fontSize: 12.5, color: 'var(--ink-soft)' }}>客户在网站"预约拜访"页面提交;时间都是北京时间</span>
|
||||
<div style={{ marginLeft: 'auto', display: 'flex', gap: 6, flexWrap: 'wrap' }}>
|
||||
{[['open', '待处理'], ['new', '待确认'], ['confirmed', '已确认'], ['done', '已完成'], ['cancelled', '已取消'], ['all', '全部']].map(([k, l]) => (
|
||||
<button key={k} className={`btn btn-sm${filter === k ? ' btn-primary' : ''}`} onClick={() => setFilter(k)}>{l} {count(k)}</button>
|
||||
))}
|
||||
<button className="btn btn-sm btn-ghost" onClick={load} title="刷新"><RefreshCw size={13} /></button>
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ padding: 16, display: 'grid', gap: 12 }}>
|
||||
{shown.length === 0 && <div style={{ color: 'var(--ink-soft)', padding: 20, textAlign: 'center' }}>没有{filter === 'all' ? '' : '这类'}预约</div>}
|
||||
{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 (
|
||||
<div key={v.id} id={'visit-' + v.id} className={`visit-card st-${v.status}${focusId === v.id ? ' focus' : ''}`}>
|
||||
<div className="visit-when">
|
||||
<div className="visit-date">{v.date.slice(5).replace('-', '/')}</div>
|
||||
<div className="visit-wk">{WEEK_ZH[d.getUTCDay()]} · {v.date.slice(0, 4)}</div>
|
||||
<div className="visit-hour">{String(v.hour).padStart(2, '0')}:00</div>
|
||||
<div className="visit-wk">北京时间</div>
|
||||
<span className={`visit-st st-${v.status}`}>{VISIT_STATUS_ZH[v.status] || v.status}{past && (v.status === 'new' || v.status === 'confirmed') ? ' · 已过期' : ''}</span>
|
||||
</div>
|
||||
<div className="visit-body">
|
||||
<div className="visit-co">{v.company}{v.country && <span className="visit-cc">{chFlag(v.country)} {v.country}</span>}</div>
|
||||
<div className="visit-line"><Users size={13} />{v.name}{v.title ? `(${v.title})` : ''} · 共 {v.people} 人</div>
|
||||
<div className="visit-line"><MapPin size={13} />{(v.places || []).map(k => VISIT_PLACE_SHORT[k] || k).join(' + ')}{(v.places || []).includes('shenzhen') && (v.places || []).includes('dongguan') ? '(深圳总部 ↔ 东莞工厂约 36 km,车程约 1 小时)' : ''}</div>
|
||||
<div className="visit-line"><Phone size={13} />{v.phone}{waOf(v.phone).length >= 7 && <a href={`https://wa.me/${waOf(v.phone)}`} target="_blank" rel="noreferrer" style={{ marginLeft: 8 }}>WhatsApp</a>}
|
||||
<Mail size={13} style={{ marginLeft: 14 }} /><a href={`mailto:${v.email}`}>{v.email}</a>
|
||||
{v.website && <><Globe size={13} style={{ marginLeft: 14 }} /><a href={/^https?:\/\//i.test(v.website) ? v.website : `https://${v.website}`} target="_blank" rel="noreferrer">{v.website}</a></>}
|
||||
</div>
|
||||
{((v.products || []).length > 0 || v.productsOther) && <div className="visit-line"><Package size={13} />{[...(v.products || []), v.productsOther].filter(Boolean).join('、')}</div>}
|
||||
{v.notes && <div className="visit-notes">{v.notes}</div>}
|
||||
<div className="visit-meta">提交于 {new Date(v.at).toLocaleString('zh-CN', { hour12: false })}{v.lang ? ` · 网站语言 ${v.lang}` : ''}</div>
|
||||
<div className="visit-actions">
|
||||
<select className="input" style={{ width: 'auto' }} value={v.status} onChange={e => patch(v, { status: e.target.value }, `已改为"${VISIT_STATUS_ZH[e.target.value]}"`)}>
|
||||
{Object.entries(VISIT_STATUS_ZH).map(([k, l]) => <option key={k} value={k}>{l}</option>)}
|
||||
</select>
|
||||
<button className="btn btn-sm" onClick={() => onSaveCustomer(v)}><Plus size={13} />存为客户档案</button>
|
||||
<button className="btn btn-sm btn-ghost btn-danger" onClick={() => del(v)}><Trash2 size={13} />删除</button>
|
||||
</div>
|
||||
<textarea className="textarea" rows={2} style={{ marginTop: 8, fontSize: 13 }} placeholder="内部备注(接待人、接车安排等,客户看不到)"
|
||||
value={memo[v.id] !== undefined ? memo[v.id] : (v.memo || '')}
|
||||
onChange={e => setMemo(m => ({ ...m, [v.id]: e.target.value }))}
|
||||
onBlur={() => { if (memo[v.id] !== undefined && memo[v.id] !== (v.memo || '')) patch(v, { memo: memo[v.id] }, '备注已保存'); }} />
|
||||
</div>
|
||||
<div className="visit-lic">
|
||||
<div className="visit-lic-h">营业执照</div>
|
||||
{v.license ? (isImg
|
||||
? <a href={licUrl} target="_blank" rel="noreferrer"><img src={licUrl} alt="营业执照" /></a>
|
||||
: <a className="visit-pdf" href={licUrl} target="_blank" rel="noreferrer"><FileText size={28} /><span>PDF</span><small>点击查看</small></a>)
|
||||
: <span style={{ color: 'var(--ink-soft)', fontSize: 12 }}>未上传</span>}
|
||||
{v.license && <small style={{ color: 'var(--ink-soft)', wordBreak: 'break-all' }}>{v.license.name}</small>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const chApi = async (method, url, body) => {
|
||||
const r = await fetch(url, { method, headers: body ? { 'Content-Type': 'application/json' } : undefined, body: body ? JSON.stringify(body) : undefined, credentials: 'same-origin' });
|
||||
const j = await r.json().catch(() => ({}));
|
||||
|
|
|
|||
Loading…
Reference in New Issue