修复管理师端预约与登录体验
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
const customersApi = require('../../api/customers')
|
||||
|
||||
function canCreateAppointment() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
@@ -9,13 +11,10 @@ Page({
|
||||
id: '',
|
||||
canCreateAppointment: true,
|
||||
avatarText: '客',
|
||||
customer: { name: '王女士', phone: '138****1201' },
|
||||
stats: { orderCount: 12, amount: 2860, lastTime: '06-01' },
|
||||
orders: [
|
||||
{ id: 1, date: '2026-06-01', project: '纯色美甲', amount: 168, artist: '小王' },
|
||||
{ id: 2, date: '2026-05-18', project: '猫眼延长', amount: 268, artist: '小李' },
|
||||
{ id: 3, date: '2026-05-02', project: '手部护理', amount: 98, artist: '小张' }
|
||||
]
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
loadError: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@@ -23,6 +22,48 @@ Page({
|
||||
id: options.id || '',
|
||||
canCreateAppointment: canCreateAppointment()
|
||||
})
|
||||
this.loadCustomer()
|
||||
},
|
||||
|
||||
async loadCustomer() {
|
||||
if (!this.data.id) {
|
||||
this.setData({
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
loadError: '缺少客户 ID'
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
const detail = await customersApi.detail(this.data.id)
|
||||
if (!detail) {
|
||||
throw new Error('客户详情不存在')
|
||||
}
|
||||
const customer = {
|
||||
id: detail.id,
|
||||
name: detail.nickname || detail.name || detail.account || '客户',
|
||||
phone: detail.contactPhone || detail.phone || '未填写'
|
||||
}
|
||||
this.setData({
|
||||
customer,
|
||||
avatarText: String(customer.name || '客').slice(-1),
|
||||
stats: {
|
||||
orderCount: detail.orderCount || detail.totalOrderCount || 0,
|
||||
amount: detail.totalAmount || detail.consumeAmount || 0,
|
||||
lastTime: detail.lastOrderTime || detail.lastConsumeTime || '-'
|
||||
},
|
||||
orders: Array.isArray(detail.orders) ? detail.orders : [],
|
||||
loadError: ''
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
loadError: error.message || '客户详情加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
createAppointment() {
|
||||
@@ -30,7 +71,10 @@ Page({
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.navigateTo({ url: '/pages/appointment-form/index' })
|
||||
const customer = this.data.customer || {}
|
||||
wx.navigateTo({
|
||||
url: `/pages/appointment-form/index?customerName=${encodeURIComponent(customer.name || '')}&phone=${encodeURIComponent(customer.phone || '')}`
|
||||
})
|
||||
},
|
||||
|
||||
back() {
|
||||
|
||||
Reference in New Issue
Block a user