import { projects, technicians } from './mockData' const runtimeProjects = Array.isArray(projects) && projects.length ? projects : [] function normalize(s) { return (s || '').toLowerCase().replace(/\s+/g, '') } function findProjectByText(text) { const t = normalize(text) return runtimeProjects.find((p) => normalize(p.name).includes(t) || t.includes(normalize(p.name))) || null } function pickPopularProject() { return runtimeProjects[0] || null } export function aiReply(userText) { const t = normalize(userText) if (!t) { return { text: '你想预约哪个项目?也可以告诉我“预算/时长/肤质需求”,我给你推荐。', action: null } } if (t.includes('你好') || t.includes('在吗') || t.includes('哈哈') || t.includes('天气') || t.includes('闲聊')) { return { text: '我在的~我可以帮你查项目价格、匹配适合人群/禁忌,并一键发起预约。你想做“补水/清洁/舒缓/肩颈放松”哪一类?', action: null } } if (t.includes('档期') || t.includes('时间') || t.includes('几点') || t.includes('有空')) { return { text: '可选时段(示例):今天 14:30 / 16:00 / 19:00;明天 10:00 / 11:30 / 17:30。你想预约哪个日期和时段?', action: null } } if (t.includes('价格') || t.includes('多少钱') || t.includes('价位')) { const top = runtimeProjects.slice(0, 4).map((p) => `「${p.name}」¥${p.price}(${p.durationMin} 分钟)`).join(';') return { text: `参考价格(示例):${top}。你想预约哪一个?我可以直接帮你打开预约页面。`, action: null } } if (t.includes('禁忌') || t.includes('不能做') || t.includes('适合吗')) { return { text: '可以的。你现在的肤质/是否敏感、近期是否做过医美项目?我会按禁忌与适配人群给你建议。', action: null } } if (t.includes('推荐') || t.includes('爆款') || t.includes('适合')) { const p = pickPopularProject() return { text: p ? `推荐你先做「${p.name}」,${p.durationMin} 分钟,¥${p.price}。要我直接帮你发起预约吗?` : '我可以按需求给你推荐。你更关注补水、清洁还是舒缓?', action: p ? { type: 'suggest_project', projectId: p.id } : null } } if (t.includes('预约') || t.includes('下单') || t.includes('买') || t.includes('购买')) { const p = findProjectByText(userText) || pickPopularProject() if (p) { return { text: `好的,我先为你打开「${p.name}」的预约页面。你可以选择日期、时段和技师。`, action: { type: 'go_booking', projectId: p.id } } } return { text: '好的。你想预约哪个项目?把项目名称发我即可。', action: null } } if (t.includes('技师') || t.includes('老师')) { const names = technicians.map((x) => x.name).join('、') return { text: `我们目前可选技师:${names}。你有偏好哪位?也可以选择系统自动分配。`, action: null } } return { text: '我明白了。你更想做“清洁/补水/舒缓/肩颈放松”哪一类?我可以直接给你项目并发起预约。', action: null } }