微信小程序页面迁移校验之前 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,92 @@
import { mockTaskDetails } from '../../utils/mock-data'
import type { TaskDetail, Note } from '../../utils/mock-data'
import { sortByTimestamp } from '../../utils/sort'
Page({
data: {
pageState: 'loading' as 'loading' | 'empty' | 'normal',
detail: null as TaskDetail | null,
sortedNotes: [] as Note[],
noteModalVisible: false,
/** 话术列表(竖线样式) */
talkingPoints: [
'王哥您好,上次打球聊得挺开心的,最近有空来玩吗?可以约几个球友一起~',
'王哥,最近店里新到了几副好球杆,知道您是行家,有空来试试手感?',
'王哥好呀,周末有个中式八球友谊赛,奖品挺丰富的,要不要来参加?',
'王哥,上次您推荐的那个朋友来过了,打得不错,下次可以一起约~',
'王哥您好,我们最近推出了老带新活动,您带朋友来都有优惠,了解一下?',
],
/** 近期服务记录 */
serviceRecords: [
{ table: '6号台', type: '基础课', typeClass: 'basic', duration: '1.5h', income: '¥150', drinks: '🍷 可乐x2', date: '2026-02-08 15:00' },
{ table: 'VIP1号房', type: '激励课', typeClass: 'incentive', duration: '2.0h', income: '¥200', drinks: '🍷 红牛x1 花生米x1', date: '2026-02-01 16:00' },
{ table: '3号台', type: '基础课', typeClass: 'basic', duration: '1.5h', income: '¥150', drinks: '🍷 矿泉水x2', date: '2026-01-25 14:30' },
],
},
onLoad(options) {
const id = options?.id || ''
this.loadData(id)
},
loadData(id: string) {
this.setData({ pageState: 'loading' })
setTimeout(() => {
// TODO: 替换为真实 API
const detail = mockTaskDetails.find((t) => t.id === id) || mockTaskDetails[2]
if (!detail) {
this.setData({ pageState: 'empty' })
return
}
const sorted = sortByTimestamp(detail.notes || []) as Note[]
this.setData({ pageState: 'normal', detail, sortedNotes: sorted })
}, 500)
},
onAddNote() {
this.setData({ noteModalVisible: true })
},
onNoteConfirm(e: WechatMiniprogram.CustomEvent) {
const { score, content } = e.detail
wx.showToast({ title: '备注已保存', icon: 'success' })
this.setData({ noteModalVisible: false })
const newNote: Note = {
id: `note-${Date.now()}`,
content,
tagType: 'customer',
tagLabel: `客户:${this.data.detail?.customerName || ''}`,
createdAt: new Date().toLocaleString('zh-CN', { hour12: false }),
}
this.setData({ sortedNotes: [newNote, ...this.data.sortedNotes] })
},
onNoteCancel() {
this.setData({ noteModalVisible: false })
},
onAskAssistant() {
const customerId = this.data.detail?.id || ''
wx.navigateTo({
url: `/pages/chat/chat?customerId=${customerId}`,
fail: () => wx.showToast({ title: '页面跳转失败', icon: 'none' }),
})
},
/** 记录互动 */
onRecordInteraction() {
this.setData({ noteModalVisible: true })
},
onBack() {
wx.navigateBack()
},
onViewAllRecords() {
const customerId = this.data.detail?.id || ''
wx.navigateTo({
url: `/pages/customer-service-records/customer-service-records?customerId=${customerId}`,
fail: () => wx.showToast({ title: '页面跳转失败', icon: 'none' }),
})
},
})