初始化
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
export const demoOrders = [
|
||||
{
|
||||
id: 'ord_demo_booking_001',
|
||||
createdAt: Date.now() - 2 * 24 * 60 * 60 * 1000,
|
||||
status: '待核销',
|
||||
amount: 99,
|
||||
projectId: 'p1',
|
||||
projectName: '水氧净透体验',
|
||||
durationMin: 60,
|
||||
orderType: 'booking',
|
||||
appointmentDate: '2026-06-22',
|
||||
appointmentSlot: '14:30',
|
||||
technicianName: '系统分配',
|
||||
note: '敏感肌,想要补水修护',
|
||||
verifyCode: 'VC20260622001'
|
||||
},
|
||||
{
|
||||
id: 'ord_demo_coupon_001',
|
||||
createdAt: Date.now() - 5 * 24 * 60 * 60 * 1000,
|
||||
status: '待核销',
|
||||
amount: 899,
|
||||
projectId: 'p5',
|
||||
projectName: '皮肤管理次卡 5 次',
|
||||
durationMin: 60,
|
||||
orderType: 'coupon',
|
||||
couponTitle: '皮肤管理次卡 5 次',
|
||||
couponPlanKey: 'times5',
|
||||
couponPlanLabel: '次卡 5 次',
|
||||
validText: '有效期 180 天',
|
||||
remainingTimes: 5,
|
||||
verifyCode: 'VC20260622002'
|
||||
},
|
||||
{
|
||||
id: 'ord_demo_booking_002',
|
||||
createdAt: Date.now() - 12 * 24 * 60 * 60 * 1000,
|
||||
status: '已完成',
|
||||
amount: 188,
|
||||
projectId: 'p4',
|
||||
projectName: '肩颈舒缓筋膜放松',
|
||||
durationMin: 60,
|
||||
orderType: 'booking',
|
||||
appointmentDate: '2026-06-10',
|
||||
appointmentSlot: '19:00',
|
||||
technicianName: '周晴',
|
||||
note: '',
|
||||
verifyCode: 'VC20260622003',
|
||||
verifiedAt: Date.now() - 12 * 24 * 60 * 60 * 1000 + 2 * 60 * 60 * 1000
|
||||
},
|
||||
{
|
||||
id: 'ord_demo_coupon_002',
|
||||
createdAt: Date.now() - 20 * 24 * 60 * 60 * 1000,
|
||||
status: '已完成',
|
||||
amount: 299,
|
||||
projectId: 'p9',
|
||||
projectName: '新客体验套餐 · 3 次',
|
||||
durationMin: 60,
|
||||
orderType: 'coupon',
|
||||
couponTitle: '新客体验套餐 · 3 次',
|
||||
couponPlanKey: 'package',
|
||||
couponPlanLabel: '套餐',
|
||||
validText: '有效期 90 天',
|
||||
remainingTimes: 0,
|
||||
verifyCode: 'VC20260622004'
|
||||
},
|
||||
{
|
||||
id: 'ord_demo_unpaid_001',
|
||||
createdAt: Date.now() - 1 * 60 * 60 * 1000,
|
||||
status: '待付款',
|
||||
amount: 168,
|
||||
projectId: 'p2',
|
||||
projectName: '深层清洁黑头管理',
|
||||
durationMin: 75,
|
||||
orderType: 'coupon',
|
||||
couponTitle: '深层清洁黑头管理',
|
||||
couponPlanKey: 'single',
|
||||
couponPlanLabel: '单次券',
|
||||
validText: '有效期 30 天',
|
||||
remainingTimes: 1,
|
||||
verifyCode: 'VC20260622005'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
export const storeProfile = {
|
||||
tenantId: 'tenant_demo_001',
|
||||
storeId: 'store_demo_001',
|
||||
name: '智约美服 · 旗舰店',
|
||||
logo:
|
||||
'https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=minimal%20luxury%20logo%20mark%2C%20letters%20ZY%2C%20black%20and%20deep%20blue%20gradient%2C%20clean%20vector%20style%2C%20centered%2C%20white%20background%2C%20high%20resolution&image_size=square',
|
||||
latitude: 31.230416,
|
||||
longitude: 121.473701,
|
||||
address: '上海市静安区南京西路 88 号',
|
||||
phone: '021-00000000',
|
||||
openHours: '10:00-22:00',
|
||||
restDay: '每周一'
|
||||
}
|
||||
|
||||
export const technicians = [
|
||||
{ id: 't1', name: '林安', title: '高级美容师', tags: ['敏感肌', '深层清洁'] },
|
||||
{ id: 't2', name: '许言', title: '皮肤管理师', tags: ['补水', '焕肤'] },
|
||||
{ id: 't3', name: '周晴', title: '美体塑形师', tags: ['肩颈', '淋巴'] }
|
||||
]
|
||||
|
||||
export const categories = [
|
||||
{ id: 'c1', name: '体验爆款' },
|
||||
{ id: 'c2', name: '面部护理' },
|
||||
{ id: 'c3', name: '身体养生' },
|
||||
{ id: 'c4', name: '美甲美睫' },
|
||||
{ id: 'c5', name: '特惠套餐' }
|
||||
]
|
||||
|
||||
export const projects = [
|
||||
{
|
||||
id: 'p1',
|
||||
categoryId: 'c1',
|
||||
name: '水氧净透体验',
|
||||
price: 99,
|
||||
originPrice: 199,
|
||||
durationMin: 60,
|
||||
fitFor: '初次体验、暗沉、出油',
|
||||
taboo: '近期激光/微针术后 7 天内不建议',
|
||||
cover:
|
||||
'https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=high-end%20beauty%20spa%20facial%20treatment%2C%20minimal%20modern%20interior%2C%20soft%20blue%20lighting%2C%20photorealistic%2C%2035mm%2C%20shallow%20depth%20of%20field%2C%20ultra%20detail&image_size=landscape_16_9',
|
||||
desc:
|
||||
'轻盈水氧 + 净透护理,适合快速提升肤感与通透度。'
|
||||
},
|
||||
{
|
||||
id: 'p2',
|
||||
categoryId: 'c2',
|
||||
name: '深层清洁黑头管理',
|
||||
price: 168,
|
||||
originPrice: 268,
|
||||
durationMin: 75,
|
||||
fitFor: 'T 区油脂旺盛、黑头粉刺',
|
||||
taboo: '炎症爆痘期需评估后进行',
|
||||
cover:
|
||||
'https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=professional%20esthetician%20performing%20deep%20cleansing%20facial%2C%20clean%20modern%20spa%2C%20soft%20neutral%20lighting%2C%20photorealistic%2C%20high%20detail%2C%2035mm&image_size=landscape_16_9',
|
||||
desc:
|
||||
'清洁、舒缓、收敛三步走,减少反复出油与毛孔困扰。'
|
||||
},
|
||||
{
|
||||
id: 'p3',
|
||||
categoryId: 'c2',
|
||||
name: '补水修护屏障护理',
|
||||
price: 238,
|
||||
originPrice: 368,
|
||||
durationMin: 80,
|
||||
fitFor: '敏感泛红、干燥紧绷',
|
||||
taboo: '过敏急性期请先咨询',
|
||||
cover:
|
||||
'https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=hydrating%20facial%20mask%20treatment%20in%20luxury%20spa%2C%20serene%20atmosphere%2C%20soft%20light%2C%20photorealistic%2C%20ultra%20detail%2C%2035mm&image_size=landscape_16_9',
|
||||
desc:
|
||||
'修护屏障与舒缓敏感,适合换季与长期干燥人群。'
|
||||
},
|
||||
{
|
||||
id: 'p4',
|
||||
categoryId: 'c3',
|
||||
name: '肩颈舒缓筋膜放松',
|
||||
price: 188,
|
||||
originPrice: 288,
|
||||
durationMin: 60,
|
||||
fitFor: '久坐办公、肩颈僵硬',
|
||||
taboo: '急性损伤与发热期不建议',
|
||||
cover:
|
||||
'https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=neck%20and%20shoulder%20massage%20in%20wellness%20spa%2C%20warm%20soft%20lighting%2C%20minimal%20luxury%20interior%2C%20photorealistic%2C%20high%20detail&image_size=landscape_16_9',
|
||||
desc:
|
||||
'深度放松肌群与筋膜,改善紧绷与酸胀。'
|
||||
},
|
||||
{
|
||||
id: 'p5',
|
||||
categoryId: 'c5',
|
||||
name: '皮肤管理次卡 5 次',
|
||||
price: 899,
|
||||
originPrice: 1199,
|
||||
durationMin: 60,
|
||||
fitFor: '长期管理、复购人群',
|
||||
taboo: '具体项目以到店评估为准',
|
||||
cover:
|
||||
'https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=premium%20skincare%20membership%20card%20concept%2C%20minimal%20luxury%2C%20black%20and%20blue%20gradient%2C%20studio%20lighting%2C%20photorealistic%2C%20high%20detail&image_size=landscape_16_9',
|
||||
desc:
|
||||
'灵活使用,随时预约,到店核销自动扣次。'
|
||||
},
|
||||
{
|
||||
id: 'p6',
|
||||
categoryId: 'c4',
|
||||
name: '轻奢美甲 · 单色',
|
||||
price: 168,
|
||||
originPrice: 238,
|
||||
durationMin: 75,
|
||||
fitFor: '通勤、日常、显白',
|
||||
taboo: '甲面破损/感染需先处理',
|
||||
cover:
|
||||
'https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=minimal%20luxury%20nail%20salon%2C%20single%20color%20manicure%2C%20clean%20hands%2C%20modern%20interior%2C%20photorealistic%2C%20high%20detail&image_size=landscape_16_9',
|
||||
desc:
|
||||
'干净利落的通勤单色,显白耐看,可按肤色搭配色卡。'
|
||||
},
|
||||
{
|
||||
id: 'p7',
|
||||
categoryId: 'c4',
|
||||
name: '自然单根美睫 · 清透款',
|
||||
price: 198,
|
||||
originPrice: 298,
|
||||
durationMin: 90,
|
||||
fitFor: '自然放大双眼、日常耐看',
|
||||
taboo: '眼部炎症/过敏期不建议',
|
||||
cover:
|
||||
'https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=natural%20eyelash%20extensions%20beauty%20studio%2C%20minimal%20luxury%2C%20soft%20lighting%2C%20photorealistic%2C%20high%20detail&image_size=landscape_16_9',
|
||||
desc:
|
||||
'清透自然的单根嫁接,整体更轻盈,适合新手与通勤。'
|
||||
},
|
||||
{
|
||||
id: 'p8',
|
||||
categoryId: 'c3',
|
||||
name: '全身精油舒压 · 90 分钟',
|
||||
price: 298,
|
||||
originPrice: 398,
|
||||
durationMin: 90,
|
||||
fitFor: '压力大、睡眠欠佳、疲劳',
|
||||
taboo: '孕期/发热/急性炎症期不建议',
|
||||
cover:
|
||||
'https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=full%20body%20aromatherapy%20massage%20in%20luxury%20spa%2C%20warm%20lighting%2C%20minimal%20interior%2C%20photorealistic%2C%20high%20detail&image_size=landscape_16_9',
|
||||
desc:
|
||||
'精油舒压与深度放松结合,帮助缓解疲劳与紧绷。'
|
||||
},
|
||||
{
|
||||
id: 'p9',
|
||||
categoryId: 'c5',
|
||||
name: '新客体验套餐 · 3 次',
|
||||
price: 299,
|
||||
originPrice: 499,
|
||||
durationMin: 60,
|
||||
fitFor: '初次体验、想要快速改善肤感',
|
||||
taboo: '具体项目以到店评估为准',
|
||||
cover:
|
||||
'https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=premium%20beauty%20spa%20package%20promotion%2C%20minimal%20luxury%2C%20black%20blue%20gradient%2C%20photorealistic%2C%20high%20detail&image_size=landscape_16_9',
|
||||
desc:
|
||||
'高性价比新客套餐,适合建立基础皮肤管理节奏。'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
const STORAGE_KEY = 'zy_orders_v1'
|
||||
|
||||
function readAll() {
|
||||
return uni.getStorageSync(STORAGE_KEY) || []
|
||||
}
|
||||
|
||||
function writeAll(list) {
|
||||
uni.setStorageSync(STORAGE_KEY, list)
|
||||
}
|
||||
|
||||
export function listOrders() {
|
||||
return readAll().sort((a, b) => (b.createdAt || 0) - (a.createdAt || 0))
|
||||
}
|
||||
|
||||
export function getOrderById(id) {
|
||||
return readAll().find((x) => x.id === id) || null
|
||||
}
|
||||
|
||||
export function upsertOrder(order) {
|
||||
const list = readAll()
|
||||
const idx = list.findIndex((x) => x.id === order.id)
|
||||
if (idx >= 0) list[idx] = order
|
||||
else list.unshift(order)
|
||||
writeAll(list)
|
||||
return order
|
||||
}
|
||||
|
||||
export function patchOrder(id, patch) {
|
||||
const list = readAll()
|
||||
const idx = list.findIndex((x) => x.id === id)
|
||||
if (idx < 0) return null
|
||||
list[idx] = { ...list[idx], ...patch }
|
||||
writeAll(list)
|
||||
return list[idx]
|
||||
}
|
||||
|
||||
export function ensureSeedOrders() {
|
||||
const list = readAll()
|
||||
if (list.length) return
|
||||
writeAll([])
|
||||
}
|
||||
|
||||
export function createId(prefix) {
|
||||
const s = `${Date.now()}${Math.floor(Math.random() * 1000)}`
|
||||
return `${prefix}_${s}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user