微信小程序页面迁移校验之前 P5任务处理之前

This commit is contained in:
Neo
2026-03-09 01:19:21 +08:00
parent 263bf96035
commit 6e20987d2f
1112 changed files with 153824 additions and 219694 deletions

View File

@@ -0,0 +1,161 @@
import { mockCustomers, mockCustomerDetail } from '../../utils/mock-data'
import type { CustomerDetail, ConsumptionRecord } from '../../utils/mock-data'
import { sortByTimestamp } from '../../utils/sort'
Page({
data: {
/** 页面状态 */
pageState: 'loading' as 'loading' | 'empty' | 'normal',
/** 客户 ID */
customerId: '',
/** 客户详情 */
detail: null as CustomerDetail | null,
/** 排序后的消费记录 */
sortedRecords: [] as ConsumptionRecord[],
/** AI 洞察 */
aiInsight: {
summary: '高价值 VIP 客户,月均到店 4-5 次,偏好夜场中式台球,近期对斯诺克产生兴趣。社交属性强,常带固定球搭子,有拉新能力。储值余额充足,对促销活动响应积极。',
strategies: [
{ color: 'green', text: '最后到店距今 12 天,超出理想间隔 7 天,建议尽快安排助教主动联系召回' },
{ color: 'amber', text: '客户提到想练斯诺克走位,可推荐斯诺克专项课程包,结合储值优惠提升客单价' },
{ color: 'pink', text: '社交属性强,可邀请参加门店球友赛事活动,带动球搭子到店消费' },
],
},
/** 维客线索 */
clues: [
{ category: '客户基础', categoryColor: 'primary', text: '🎂 生日 3月15日 · VIP会员 · 注册2年', source: '系统' },
{ category: '消费习惯', categoryColor: 'success', text: '🌙 常来夜场 · 月均4-5次', source: '系统' },
{ category: '消费习惯', categoryColor: 'success', text: '💰 高客单价', source: '系统', detail: '近60天场均消费 ¥420高于门店均值 ¥180偏好夜场时段酒水附加消费占比 35%' },
{ category: '玩法偏好', categoryColor: 'purple', text: '🎱 偏爱中式 · 斯诺克进阶中', source: '系统' },
{ category: '促销接受', categoryColor: 'warning', text: '🍷 爱点酒水套餐 · 对储值活动敏感', source: '系统', detail: '最近3次到店均点了酒水套餐上次 ¥5000 储值活动当天即充值,对满赠类活动响应率高' },
{ category: '社交关系', categoryColor: 'pink', text: '👥 常带朋友 · 固定球搭子2人', source: '系统', detail: '近60天 80% 的到店为多人局常与「李哥」「阿杰」同行曾介绍2位新客办卡' },
{ category: '重要反馈', categoryColor: 'error', text: '⚠️ 上次提到想练斯诺克走位对球桌维护质量比较在意建议优先安排VIP房', source: '小燕' },
],
/** Banner 统计 */
bannerStats: {
balance: '¥8,600',
spend60d: '¥2,800',
idealInterval: '7天',
daysSinceVisit: '12天',
},
/** 助教任务 */
coachTasks: [
{
name: '小燕',
level: '高级助教',
levelColor: 'pink',
taskType: '高优先召回',
taskColor: 'red',
lastService: '02-20 21:30 · 2.5h',
bgClass: 'coach-card-red',
metrics: [
{ label: '近60天次数', value: '18次', color: 'primary' },
{ label: '总时长', value: '17h', color: '' },
{ label: '次均时长', value: '0.9h', color: 'warning' },
],
},
{
name: '泡芙',
level: '中级助教',
levelColor: 'purple',
taskType: '关系构建',
taskColor: 'pink',
lastService: '02-15 14:00 · 1.5h',
bgClass: 'coach-card-pink',
metrics: [
{ label: '近60天次数', value: '12次', color: 'primary' },
{ label: '总时长', value: '11h', color: '' },
{ label: '次均时长', value: '0.9h', color: 'warning' },
],
},
],
/** 最喜欢的助教 */
favoriteCoaches: [
{
name: '小燕',
emoji: '❤️',
relationIndex: '0.92',
indexColor: 'success',
bgClass: 'fav-card-pink',
stats: [
{ label: '基础', value: '12h', color: 'primary' },
{ label: '激励', value: '5h', color: 'warning' },
{ label: '上课', value: '18次', color: '' },
{ label: '充值', value: '¥5,000', color: 'success' },
],
},
{
name: '泡芙',
emoji: '💛',
relationIndex: '0.78',
indexColor: 'warning',
bgClass: 'fav-card-amber',
stats: [
{ label: '基础', value: '8h', color: 'primary' },
{ label: '激励', value: '3h', color: 'warning' },
{ label: '上课', value: '12次', color: '' },
{ label: '充值', value: '¥3,000', color: 'success' },
],
},
],
},
onLoad(options) {
const id = options?.id || ''
this.setData({ customerId: id })
this.loadData(id)
},
loadData(id: string) {
this.setData({ pageState: 'loading' })
setTimeout(() => {
// TODO: 替换为真实 API 调用
// 先从 mockCustomers 查找基本信息,再用 mockCustomerDetail 补充
const customer = mockCustomers.find((c) => c.id === id)
const detail = customer
? { ...mockCustomerDetail, id: customer.id, name: customer.name, heartScore: customer.heartScore, tags: customer.tags }
: mockCustomerDetail
if (!detail) {
this.setData({ pageState: 'empty' })
return
}
const sorted = sortByTimestamp(detail.consumptionRecords || [], 'date') as ConsumptionRecord[]
this.setData({
pageState: 'normal',
detail,
sortedRecords: sorted,
})
}, 500)
},
/** 发起对话 */
onStartChat() {
const id = this.data.customerId || this.data.detail?.id || ''
wx.navigateTo({
url: `/pages/chat/chat?customerId=${id}`,
fail: () => wx.showToast({ title: '页面跳转失败', icon: 'none' }),
})
},
/** 添加备注 */
onAddNote() {
wx.showToast({ title: '备注功能开发中', icon: 'none' })
},
/** 查看服务记录 */
onViewServiceRecords() {
const id = this.data.customerId || this.data.detail?.id || ''
wx.navigateTo({
url: `/pages/customer-service-records/customer-service-records?customerId=${id}`,
fail: () => wx.showToast({ title: '页面跳转失败', icon: 'none' }),
})
},
/** 返回 */
onBack() {
wx.navigateBack()
},
})