微信小程序页面迁移校验之前 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: '5号台', type: '基础课', typeClass: 'basic', duration: '2.0h', income: '¥160', drinks: '🍷 雪花x2 矿泉水x1', date: '2026-02-06 19:00' },
{ table: 'A08号台', type: '激励课', typeClass: 'incentive', duration: '1.5h', income: '¥150', drinks: '🍷 百威x1', date: '2026-01-20 20:30' },
{ table: '3号台', type: '基础课', typeClass: 'basic', duration: '2.0h', income: '¥160', drinks: '🍷 可乐x2 红牛x1', date: '2026-01-05 21:00' },
],
},
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[1]
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' }),
})
},
/** 记录联系 */
onRecordContact() {
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' }),
})
},
})