回溯点:保存注册预约客户流程修复进度

This commit is contained in:
2026-10-30 13:02:38 +08:00
parent 7b40ee1650
commit 53b6fcaa11
45 changed files with 960 additions and 132 deletions
+38
View File
@@ -6,6 +6,8 @@ Page({
customers: [],
loadError: '',
createModalVisible: false,
duplicateModalVisible: false,
duplicateCustomers: [],
creating: false,
createForm: {
nickname: '',
@@ -60,6 +62,17 @@ Page({
this.setData({ createModalVisible: false })
},
closeDuplicateModal() {
this.setData({ duplicateModalVisible: false })
},
selectDuplicateCustomer(event) {
const customerId = event.currentTarget.dataset.id
if (!customerId) return
this.setData({ duplicateModalVisible: false })
this.openDetail({ currentTarget: { dataset: { id: customerId } } })
},
stopTap() {
},
@@ -94,12 +107,37 @@ Page({
}
this.setData({ creating: true })
try {
const matches = await customersApi.matchExactIdentity(nickname, wechatId || undefined, phone || undefined)
if (Array.isArray(matches) && matches.length) {
this.setData({
createModalVisible: false,
duplicateCustomers: matches.map(item => ({
id: item.id,
name: item.name || item.nickname || nickname,
phone: item.phone || '未填写手机号'
})),
duplicateModalVisible: true
})
return
}
await customersApi.create({ nickname, wechatId: wechatId || undefined, phone: phone || undefined })
wx.showToast({ title: '客户已新增', icon: 'success' })
this.resetCreateForm()
this.setData({ createModalVisible: false })
await this.loadCustomers()
} catch (error) {
if (/客户已存在|重复|相同/.test(String(error.message || ''))) {
try {
const matches = await customersApi.matchExactIdentity(nickname, wechatId || undefined, phone || undefined)
if (Array.isArray(matches) && matches.length) {
this.setData({ createModalVisible: false, duplicateCustomers: matches.map(item => ({ id: item.id, name: item.name || item.nickname || nickname, phone: item.phone || '未填写手机号' })), duplicateModalVisible: true })
return
}
} catch (lookupError) {
wx.showToast({ title: lookupError.message || '客户重复,请重新查询已有客户', icon: 'none' })
return
}
}
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
} finally {
this.setData({ creating: false })