Files
Neo-ZQYY/apps/miniprogram - 副本/miniprogram/pages/task-detail-callback/task-detail-callback.ts

95 lines
3.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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' }),
})
},
})