修复管理师端预约与登录体验
This commit is contained in:
@@ -3,7 +3,14 @@ const customersApi = require('../../api/customers')
|
||||
Page({
|
||||
data: {
|
||||
keyword: '',
|
||||
customers: []
|
||||
customers: [],
|
||||
loadError: '',
|
||||
createModalVisible: false,
|
||||
creating: false,
|
||||
createForm: {
|
||||
nickname: '',
|
||||
phone: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -17,15 +24,11 @@ Page({
|
||||
},
|
||||
|
||||
async loadCustomers() {
|
||||
const fallback = [
|
||||
{ id: 1, name: '王女士', phone: '138****1201', lastTime: '2026-06-01' },
|
||||
{ id: 2, name: '陈女士', phone: '136****8842', lastTime: '2026-05-29' },
|
||||
{ id: 3, name: '林女士', phone: '159****6671', lastTime: '2026-05-27' }
|
||||
]
|
||||
try {
|
||||
const data = await customersApi.list({ keyword: this.data.keyword, page: 1, size: 30 })
|
||||
const list = data.list || data || []
|
||||
this.setData({
|
||||
loadError: '',
|
||||
customers: list.map(item => ({
|
||||
id: item.id,
|
||||
name: item.nickname || item.name || item.account || '客户',
|
||||
@@ -34,11 +37,65 @@ Page({
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ customers: fallback })
|
||||
this.setData({
|
||||
customers: [],
|
||||
loadError: error.message || '客户列表加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
openDetail(event) {
|
||||
wx.navigateTo({ url: `/pages/customer-detail/index?id=${event.currentTarget.dataset.id}` })
|
||||
},
|
||||
|
||||
addCustomer() {
|
||||
this.setData({ createModalVisible: true })
|
||||
},
|
||||
|
||||
closeCreateModal() {
|
||||
if (this.data.creating) {
|
||||
return
|
||||
}
|
||||
this.setData({ createModalVisible: false })
|
||||
},
|
||||
|
||||
stopTap() {
|
||||
},
|
||||
|
||||
onCreateInput(event) {
|
||||
this.setData({
|
||||
[`createForm.${event.currentTarget.dataset.field}`]: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
resetCreateForm() {
|
||||
this.setData({
|
||||
createForm: {
|
||||
nickname: '',
|
||||
phone: ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async submitCustomer() {
|
||||
const form = this.data.createForm
|
||||
const nickname = String(form.nickname || '').trim()
|
||||
const phone = String(form.phone || '').trim()
|
||||
if (!nickname || !phone) {
|
||||
wx.showToast({ title: '请填写客户姓名和手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ creating: true })
|
||||
try {
|
||||
await customersApi.create({ nickname, phone })
|
||||
wx.showToast({ title: '客户已新增', icon: 'success' })
|
||||
this.resetCreateForm()
|
||||
this.setData({ createModalVisible: false })
|
||||
await this.loadCustomers()
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ creating: false })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user