微信小程序页面迁移校验之前 P5任务处理之前
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
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: [
|
||||
'赵姐您好!上次打球感觉怎么样?新到的球杆手感还习惯吗?这周末您有空的话,可以提前帮您预留老位置~',
|
||||
'赵姐,最近店里新进了一批斯诺克专用巧克粉,手感特别好,下次来的时候可以试试~',
|
||||
'赵姐好呀,上次您说想学几个高级杆法,我最近整理了一些教学视频,要不要发给您先看看?',
|
||||
'赵姐,这周六下午VIP包厢有空位,要不要帮您提前预留?可以叫上朋友一起来打球~',
|
||||
'赵姐您好,我们下个月有个会员积分兑换活动,您的积分可以换不少好东西,到时候提醒您哦~',
|
||||
],
|
||||
/** 近期服务记录 */
|
||||
serviceRecords: [
|
||||
{ table: 'VIP2号房', type: '基础课', typeClass: 'basic', duration: '2.0h', income: '¥190', drinks: '🍷 红牛x2 花生米x1', date: '2026-02-04 15:00' },
|
||||
{ table: '8号台', type: '激励课', typeClass: 'incentive', duration: '1.5h', income: '¥120', drinks: '🍷 可乐x2', date: '2026-01-30 16:30' },
|
||||
{ table: 'VIP2号房', type: '基础课', typeClass: 'basic', duration: '2.5h', income: '¥200', drinks: '🍷 百威x3 薯条x1', date: '2026-01-25 14: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[0]
|
||||
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' }),
|
||||
})
|
||||
},
|
||||
|
||||
/** 记录回访 */
|
||||
onRecordCallback() {
|
||||
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' }),
|
||||
})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user