优化预约客户输入与唯一性校验

This commit is contained in:
2026-10-16 17:33:58 +08:00
parent 3d18a1972b
commit 4a7bd90088
12 changed files with 318 additions and 164 deletions
@@ -7,13 +7,17 @@ global.wx = {
setStorageSync: () => {},
removeStorageSync: () => {},
showToast: () => {},
showModal: options => options.success({ confirm: modalConfirm }),
navigateTo: () => {}
}
global.getApp = () => ({ globalData: { userInfo: { type: 2, id: 1, shopId: 2 } } })
let modalConfirm = true
let definition
global.Page = value => { definition = value }
require('./index')
const customersApi = require('../../api/customers')
function createPage() {
return {
@@ -39,11 +43,30 @@ async function run() {
assert.strictEqual(page.data.customerSheetVisible, false)
page.data.form.customerUserId = 18
page.data.manualCustomerForm = { name: '新客户', phone: '13900139000' }
page.useManualCustomer()
page.onCustomerInput({ currentTarget: { dataset: { field: 'customerName' } }, detail: { value: '新客户' } })
assert.strictEqual(page.data.form.customerUserId, '')
assert.strictEqual(page.data.form.customerName, '新客户')
assert.strictEqual(page.data.form.phone, '13900139000')
assert.strictEqual(page.data.form.phone, '')
customersApi.matchIdentity = async () => []
customersApi.create = async payload => {
assert.strictEqual(payload.nickname, '新客户')
assert.strictEqual(payload.phone, undefined)
return '42'
}
assert.strictEqual(await page.ensureCustomerBeforeSubmit(), true)
assert.strictEqual(page.data.form.customerUserId, '42')
page.data.form.customerUserId = ''
page.data.form.customerName = '小周'
page.data.form.phone = '13800138000'
customersApi.matchIdentity = async (name, phone) => {
assert.strictEqual(name, '小周')
assert.strictEqual(phone, '13800138000')
return [{ id: '18', nickname: '小周', phone: '13800138000' }]
}
assert.strictEqual(await page.ensureCustomerBeforeSubmit(), true)
assert.strictEqual(page.data.form.customerUserId, '18')
page.data.artists = [{ id: 1, name: '小周' }, { id: 2, name: '小李' }]
page.onArtistSearch({ detail: { value: '李' } })