优化预约表单并支持散客预约
This commit is contained in:
@@ -46,16 +46,13 @@ async function run() {
|
||||
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, '')
|
||||
assert.strictEqual(page.data.form.phone, '13800138000')
|
||||
|
||||
customersApi.matchIdentity = async () => []
|
||||
customersApi.create = async payload => {
|
||||
assert.strictEqual(payload.nickname, '新客户')
|
||||
assert.strictEqual(payload.phone, undefined)
|
||||
return '42'
|
||||
}
|
||||
customersApi.create = async () => { throw new Error('预约客户建档应随预约请求提交') }
|
||||
assert.strictEqual(await page.ensureCustomerBeforeSubmit(), true)
|
||||
assert.strictEqual(page.data.form.customerUserId, '42')
|
||||
assert.strictEqual(page.data.form.customerUserId, '')
|
||||
assert.strictEqual(page.data.form.createCustomerRecord, true)
|
||||
|
||||
page.data.form.customerUserId = ''
|
||||
page.data.form.customerName = '小周'
|
||||
|
||||
@@ -192,6 +192,113 @@ function flattenTimeGroups(groups) {
|
||||
return (groups || []).reduce((list, group) => list.concat(group.times || []), [])
|
||||
}
|
||||
|
||||
function buildTimeValues(durationMinutes) {
|
||||
const values = []
|
||||
const open = dateUtil.minutesOfDay('10:00')
|
||||
const close = dateUtil.minutesOfDay('22:00')
|
||||
for (let minute = open; minute + durationMinutes <= close; minute += TIME_SLOT_MINUTES) {
|
||||
values.push(dateUtil.timeFromMinutes(minute))
|
||||
}
|
||||
return values
|
||||
}
|
||||
|
||||
function buildTimePickerSlots(calendar, form, durationMinutes) {
|
||||
const schedules = calendar.schedules || []
|
||||
const busyRanges = form.artistId ? buildBusyRanges(calendar.appointments || [], form) : []
|
||||
return buildTimeValues(durationMinutes).map(value => {
|
||||
const startMinute = dateUtil.minutesOfDay(value)
|
||||
const endMinute = startMinute + durationMinutes
|
||||
const occupied = hasBusyConflict(startMinute, endMinute, busyRanges)
|
||||
const scheduled = !form.artistId || schedules.some(schedule =>
|
||||
isScheduleCoveringTime(schedule, form, startMinute, endMinute)
|
||||
)
|
||||
const status = occupied ? 'occupied' : scheduled ? 'available' : 'off-shift'
|
||||
return {
|
||||
value,
|
||||
hour: Number(value.slice(0, 2)),
|
||||
minute: Number(value.slice(3, 5)),
|
||||
rangeText: buildTimeRangeLabel(startMinute, durationMinutes),
|
||||
status,
|
||||
statusText: status === 'occupied' ? '已占用' : status === 'off-shift' ? '无排班' : ''
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function buildTimePickerGroups(slots) {
|
||||
const groupMap = {
|
||||
morning: { key: 'morning', title: '上午', times: [] },
|
||||
afternoon: { key: 'afternoon', title: '下午', times: [] },
|
||||
evening: { key: 'evening', title: '晚上', times: [] }
|
||||
}
|
||||
;(slots || []).forEach(slot => groupMap[getTimePeriod(dateUtil.minutesOfDay(slot.value)).key].times.push(slot))
|
||||
return Object.keys(groupMap).map(key => groupMap[key]).filter(group => group.times.length > 0)
|
||||
}
|
||||
|
||||
function buildTimeWheelState(slots, preferredTime) {
|
||||
if (!slots || slots.length === 0) {
|
||||
return {
|
||||
timePickerHours: [],
|
||||
timePickerMinutes: [],
|
||||
timePickerValue: [0, 0],
|
||||
selectedTimeCandidate: '',
|
||||
timePickerCandidateStatus: 'off-shift'
|
||||
}
|
||||
}
|
||||
const preferredSlot = slots.find(slot => slot.value === preferredTime) || slots.find(slot => slot.value === '14:00')
|
||||
const firstAvailableSlot = slots.find(slot => slot.status === 'available')
|
||||
const selectedSlot = preferredSlot && preferredSlot.status === 'available'
|
||||
? preferredSlot
|
||||
: firstAvailableSlot || preferredSlot || slots[0]
|
||||
const hours = Array.from(new Set(slots.map(slot => slot.hour)))
|
||||
const selectedHourIndex = Math.max(0, hours.indexOf(selectedSlot.hour))
|
||||
const minuteValues = [0, 15, 30, 45]
|
||||
const minutes = minuteValues.map(minute => {
|
||||
const slot = slots.find(item => item.hour === selectedSlot.hour && item.minute === minute)
|
||||
return {
|
||||
value: minute,
|
||||
label: String(minute).padStart(2, '0'),
|
||||
status: slot ? slot.status : 'off-shift',
|
||||
disabled: !slot || slot.status !== 'available'
|
||||
}
|
||||
})
|
||||
const selectedMinuteIndex = Math.max(0, minuteValues.indexOf(selectedSlot.minute))
|
||||
return {
|
||||
timePickerHours: hours.map(hour => ({
|
||||
value: hour,
|
||||
label: String(hour).padStart(2, '0'),
|
||||
disabled: !slots.some(slot => slot.hour === hour && slot.status === 'available')
|
||||
})),
|
||||
timePickerMinutes: minutes,
|
||||
timePickerValue: [selectedHourIndex, selectedMinuteIndex],
|
||||
selectedTimeCandidate: selectedSlot.value,
|
||||
timePickerCandidateStatus: selectedSlot.status
|
||||
}
|
||||
}
|
||||
|
||||
function timeWheelStateForHour(slots, hour, selectedMinute) {
|
||||
const minuteValues = [0, 15, 30, 45]
|
||||
const minutes = minuteValues.map(minute => {
|
||||
const slot = slots.find(item => item.hour === hour && item.minute === minute)
|
||||
return {
|
||||
value: minute,
|
||||
label: String(minute).padStart(2, '0'),
|
||||
status: slot ? slot.status : 'off-shift',
|
||||
disabled: !slot || slot.status !== 'available'
|
||||
}
|
||||
})
|
||||
const selectedMinuteIndex = Math.max(0, minuteValues.indexOf(selectedMinute))
|
||||
return { timePickerMinutes: minutes, selectedMinuteIndex }
|
||||
}
|
||||
|
||||
function customerCreatedAt(customer) {
|
||||
return customer.createTime || customer.createdAt || customer.addedAt || ''
|
||||
}
|
||||
|
||||
function formatCustomerCreatedAt(value) {
|
||||
if (!value) return '添加时间未知'
|
||||
return `添加于 ${String(value).replace('T', ' ').slice(0, 16)}`
|
||||
}
|
||||
|
||||
function parseProductTags(product) {
|
||||
if (Array.isArray(product.tagList) && product.tagList.length > 0) {
|
||||
return product.tagList
|
||||
@@ -245,7 +352,8 @@ function normalizeCustomer(customer) {
|
||||
name,
|
||||
phone,
|
||||
displayName: name || phone || '客户',
|
||||
displayPhone: phone || '未填写手机号'
|
||||
displayPhone: phone || '未填写手机号',
|
||||
createdAt: customerCreatedAt(customer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,8 +361,8 @@ function buildCustomerSelectorItem(customer) {
|
||||
return {
|
||||
...customer,
|
||||
title: customer.displayName,
|
||||
subtitle: customer.displayPhone,
|
||||
badge: '已有客户'
|
||||
subtitle: formatCustomerCreatedAt(customer.createdAt),
|
||||
rightText: customer.displayPhone
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,6 +384,7 @@ Page({
|
||||
phone: '',
|
||||
appointmentDate: dateUtil.formatDate(new Date()),
|
||||
appointmentTime: '',
|
||||
amount: '',
|
||||
productId: '',
|
||||
manualProductTitle: '',
|
||||
manualProductPrice: '',
|
||||
@@ -285,14 +394,18 @@ Page({
|
||||
manualProductPrecautions: '',
|
||||
manualProductImageFileIds: '',
|
||||
manualProductImageUrl: '',
|
||||
durationMinutes: '',
|
||||
durationMinutes: '60',
|
||||
artistId: '',
|
||||
createCustomerRecord: false,
|
||||
remark: ''
|
||||
},
|
||||
manualProductDraft: { title: '', price: '', description: '', tags: '', targetAudience: '', precautions: '', imageFileIds: '', imageUrl: '' },
|
||||
customerOptions: [],
|
||||
customerDirectory: [],
|
||||
customerSheetVisible: false,
|
||||
customerKeyword: '',
|
||||
customerViewMode: 'list',
|
||||
customerNewestFirst: true,
|
||||
customerSuggestions: [],
|
||||
customerLoading: false,
|
||||
customerError: '',
|
||||
products: [],
|
||||
@@ -306,8 +419,6 @@ Page({
|
||||
selectedProductPriceText: '',
|
||||
selectedArtist: {},
|
||||
productModalVisible: false,
|
||||
productSelectorMode: 'list',
|
||||
manualProductMoreExpanded: false,
|
||||
productKeyword: '',
|
||||
productError: '',
|
||||
loadingProducts: false,
|
||||
@@ -317,6 +428,14 @@ Page({
|
||||
draftSavedAtText: '',
|
||||
manualImageUploading: false,
|
||||
timeSheetVisible: false,
|
||||
timePickerMode: 'wheel',
|
||||
timePickerValue: [0, 0],
|
||||
timePickerHours: [],
|
||||
timePickerMinutes: [],
|
||||
timePickerSlots: [],
|
||||
timePickerGroups: [],
|
||||
timePickerCandidateStatus: 'off-shift',
|
||||
selectedTimeCandidate: '',
|
||||
timeLoading: false,
|
||||
timeError: '',
|
||||
timeSelectTip: '请先选择美甲师并填写时长',
|
||||
@@ -330,16 +449,6 @@ Page({
|
||||
const baseForm = draftForm || {}
|
||||
this.setData({
|
||||
canCreateAppointment: creatable,
|
||||
manualProductDraft: {
|
||||
title: baseForm.manualProductTitle || '',
|
||||
price: baseForm.manualProductPrice || '',
|
||||
description: baseForm.manualProductDescription || '',
|
||||
tags: baseForm.manualProductTags || '',
|
||||
targetAudience: baseForm.manualProductTargetAudience || '',
|
||||
precautions: baseForm.manualProductPrecautions || '',
|
||||
imageFileIds: baseForm.manualProductImageFileIds || '',
|
||||
imageUrl: baseForm.manualProductImageUrl || ''
|
||||
},
|
||||
form: {
|
||||
...this.data.form,
|
||||
...baseForm,
|
||||
@@ -375,10 +484,14 @@ Page({
|
||||
await this.loadArtists()
|
||||
this.refreshProductCards()
|
||||
const selectedProduct = this.data.filteredProducts.find(item => String(item.id) === String(this.data.form.productId)) || {}
|
||||
this.setData({
|
||||
const selectedProductPatch = {
|
||||
selectedProduct,
|
||||
selectedProductPriceText: selectedProduct.priceText || ''
|
||||
})
|
||||
}
|
||||
if (selectedProduct.id && (this.data.form.amount === '' || this.data.form.amount === undefined)) {
|
||||
selectedProductPatch['form.amount'] = selectedProduct.price === undefined || selectedProduct.price === null ? '' : String(selectedProduct.price)
|
||||
}
|
||||
this.setData(selectedProductPatch)
|
||||
await this.refreshAvailableTimes()
|
||||
this.checkAvailability()
|
||||
},
|
||||
@@ -420,6 +533,47 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
async loadCustomerDirectory() {
|
||||
this.setData({ customerLoading: true })
|
||||
try {
|
||||
const size = 100
|
||||
const rows = []
|
||||
let page = 1
|
||||
let total = Number.POSITIVE_INFINITY
|
||||
while (rows.length < total) {
|
||||
const result = await customersApi.list({ page, size })
|
||||
const currentRows = Array.isArray(result) ? result : (result.list || [])
|
||||
rows.push(...currentRows)
|
||||
if (!Array.isArray(result) && Number.isFinite(Number(result.total))) {
|
||||
total = Number(result.total)
|
||||
} else if (currentRows.length < size) {
|
||||
total = rows.length
|
||||
}
|
||||
if (currentRows.length === 0) break
|
||||
page += 1
|
||||
}
|
||||
const directory = rows.map(normalizeCustomer)
|
||||
this.setData({
|
||||
customerDirectory: directory,
|
||||
customerOptions: this.sortCustomerOptions(directory),
|
||||
customerError: ''
|
||||
})
|
||||
this.refreshCustomerSuggestions(this.data.form.customerName, this.data.form.phone)
|
||||
} catch (error) {
|
||||
this.setData({ customerDirectory: [], customerOptions: [], customerError: error.message || '客户列表加载失败' })
|
||||
} finally {
|
||||
this.setData({ customerLoading: false })
|
||||
}
|
||||
},
|
||||
|
||||
sortCustomerOptions(customers, newestFirst = this.data.customerNewestFirst) {
|
||||
return (customers || []).slice().sort((left, right) => {
|
||||
const leftDate = String(left.createdAt || '')
|
||||
const rightDate = String(right.createdAt || '')
|
||||
return newestFirst ? rightDate.localeCompare(leftDate) : leftDate.localeCompare(rightDate)
|
||||
}).map(buildCustomerSelectorItem)
|
||||
},
|
||||
|
||||
onInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
const patch = {
|
||||
@@ -432,18 +586,81 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
onStyleTitleInput(event) {
|
||||
const patch = { 'form.manualProductTitle': event.detail.value }
|
||||
if (this.data.form.productId) {
|
||||
patch['form.productId'] = ''
|
||||
patch.selectedProduct = {}
|
||||
patch.selectedProductPriceText = ''
|
||||
patch['form.manualProductImageFileIds'] = ''
|
||||
patch['form.manualProductImageUrl'] = ''
|
||||
}
|
||||
this.setData(patch)
|
||||
},
|
||||
|
||||
onCustomerInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
const patch = {
|
||||
[`form.${field}`]: event.detail.value,
|
||||
'form.customerUserId': ''
|
||||
}
|
||||
if (field === 'customerName' && this.data.form.customerUserId) {
|
||||
patch['form.phone'] = ''
|
||||
'form.customerUserId': '',
|
||||
'form.createCustomerRecord': false
|
||||
}
|
||||
this.setData({
|
||||
...patch
|
||||
})
|
||||
const customerName = field === 'customerName' ? event.detail.value : this.data.form.customerName
|
||||
const phone = field === 'phone' ? event.detail.value : this.data.form.phone
|
||||
this.refreshCustomerSuggestions(customerName, phone)
|
||||
},
|
||||
|
||||
refreshCustomerSuggestions(nameValue, phoneValue) {
|
||||
const name = String(nameValue || '').trim().toLowerCase()
|
||||
const phone = String(phoneValue || '').trim().toLowerCase()
|
||||
if (!name && !phone) {
|
||||
this._customerSuggestionSeq = (this._customerSuggestionSeq || 0) + 1
|
||||
clearTimeout(this._suggestionTimer)
|
||||
this.setData({ customerSuggestions: [] })
|
||||
return
|
||||
}
|
||||
const suggestions = this.data.customerDirectory
|
||||
.filter(customer => (!name || customer.name.toLowerCase().includes(name)) && (!phone || customer.phone.toLowerCase().includes(phone)))
|
||||
.slice(0, 3)
|
||||
.map(buildCustomerSelectorItem)
|
||||
this.setData({ customerSuggestions: suggestions })
|
||||
const requestSeq = (this._customerSuggestionSeq || 0) + 1
|
||||
this._customerSuggestionSeq = requestSeq
|
||||
clearTimeout(this._suggestionTimer)
|
||||
this._suggestionTimer = setTimeout(async () => {
|
||||
try {
|
||||
const result = await customersApi.list({ page: 1, size: 50, keyword: name || phone })
|
||||
if (requestSeq !== this._customerSuggestionSeq) return
|
||||
const rows = Array.isArray(result) ? result : (result.list || [])
|
||||
const remoteSuggestions = rows.map(normalizeCustomer)
|
||||
.filter(customer => (!name || customer.name.toLowerCase().includes(name)) && (!phone || customer.phone.toLowerCase().includes(phone)))
|
||||
.slice(0, 3)
|
||||
.map(buildCustomerSelectorItem)
|
||||
this.setData({ customerSuggestions: remoteSuggestions })
|
||||
} catch (error) {
|
||||
if (requestSeq === this._customerSuggestionSeq && suggestions.length === 0) {
|
||||
this.setData({ customerSuggestions: [] })
|
||||
}
|
||||
}
|
||||
}, 240)
|
||||
},
|
||||
|
||||
selectCustomerSuggestion(event) {
|
||||
const index = Number(event.currentTarget.dataset.index)
|
||||
const customer = this.data.customerSuggestions[index]
|
||||
if (!customer) return
|
||||
this.setData({
|
||||
'form.customerUserId': customer.id,
|
||||
'form.customerName': customer.name,
|
||||
'form.phone': customer.phone,
|
||||
'form.createCustomerRecord': false,
|
||||
customerSuggestions: [],
|
||||
customerSheetVisible: false,
|
||||
customerKeyword: ''
|
||||
})
|
||||
},
|
||||
|
||||
openCustomerSheet() {
|
||||
@@ -467,22 +684,24 @@ Page({
|
||||
return
|
||||
}
|
||||
const keyword = String(keywordValue === undefined ? this.data.customerKeyword : keywordValue || '').trim()
|
||||
this.setData({ customerLoading: true })
|
||||
try {
|
||||
const data = await customersApi.list({ keyword, page: 1, size: 20 })
|
||||
const list = data.list || data || []
|
||||
this.setData({
|
||||
customerOptions: list.map(normalizeCustomer).map(buildCustomerSelectorItem),
|
||||
customerError: ''
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
customerOptions: [],
|
||||
customerError: error.message || '客户列表加载失败'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ customerLoading: false })
|
||||
}
|
||||
if (this.data.customerDirectory.length === 0) await this.loadCustomerDirectory()
|
||||
const matches = this.data.customerDirectory.filter(customer =>
|
||||
!keyword || `${customer.name} ${customer.phone}`.toLowerCase().includes(keyword.toLowerCase())
|
||||
)
|
||||
this.setData({ customerOptions: this.sortCustomerOptions(matches), customerError: '' })
|
||||
},
|
||||
|
||||
changeCustomerView(event) {
|
||||
this.setData({ customerViewMode: event.detail.mode || 'list' })
|
||||
},
|
||||
|
||||
toggleCustomerSort() {
|
||||
const customerNewestFirst = !this.data.customerNewestFirst
|
||||
const keyword = String(this.data.customerKeyword || '').trim().toLowerCase()
|
||||
const matches = this.data.customerDirectory.filter(customer =>
|
||||
!keyword || `${customer.name} ${customer.phone}`.toLowerCase().includes(keyword)
|
||||
)
|
||||
this.setData({ customerNewestFirst, customerOptions: this.sortCustomerOptions(matches, customerNewestFirst) })
|
||||
},
|
||||
|
||||
retryCustomerSearch() {
|
||||
@@ -498,8 +717,10 @@ Page({
|
||||
'form.customerUserId': customer.id,
|
||||
'form.customerName': customer.name,
|
||||
'form.phone': customer.phone,
|
||||
'form.createCustomerRecord': false,
|
||||
customerSheetVisible: false,
|
||||
customerKeyword: ''
|
||||
customerKeyword: '',
|
||||
customerSuggestions: []
|
||||
})
|
||||
},
|
||||
|
||||
@@ -507,6 +728,9 @@ Page({
|
||||
if (this._customerTimer) {
|
||||
clearTimeout(this._customerTimer)
|
||||
}
|
||||
if (this._suggestionTimer) {
|
||||
clearTimeout(this._suggestionTimer)
|
||||
}
|
||||
},
|
||||
|
||||
async onDateChange(event) {
|
||||
@@ -555,29 +779,20 @@ Page({
|
||||
|
||||
openProductModal() {
|
||||
this.refreshProductCards()
|
||||
this.setData({ productModalVisible: true, productSelectorMode: 'list' })
|
||||
this.setData({ productModalVisible: true })
|
||||
},
|
||||
|
||||
closeProductModal() {
|
||||
this.setData({ productModalVisible: false, productSelectorMode: 'list' })
|
||||
this.setData({ productModalVisible: false })
|
||||
},
|
||||
|
||||
openManualProduct() {
|
||||
this.setData({ productSelectorMode: 'manual', manualProductMoreExpanded: false })
|
||||
},
|
||||
|
||||
backToProductList() {
|
||||
this.setData({ productSelectorMode: 'list' })
|
||||
this.refreshProductCards()
|
||||
},
|
||||
|
||||
onManualProductInput(event) {
|
||||
const field = event.detail.field
|
||||
this.setData({ [`manualProductDraft.${field}`]: event.detail.value })
|
||||
},
|
||||
|
||||
toggleManualProductMore() {
|
||||
this.setData({ manualProductMoreExpanded: !this.data.manualProductMoreExpanded })
|
||||
this.setData({
|
||||
productModalVisible: false,
|
||||
selectedProduct: {},
|
||||
selectedProductPriceText: '',
|
||||
'form.productId': ''
|
||||
})
|
||||
},
|
||||
|
||||
stopTap() {
|
||||
@@ -597,16 +812,8 @@ Page({
|
||||
this.setData({
|
||||
selectedProduct,
|
||||
selectedProductPriceText: selectedProduct.priceText || '',
|
||||
manualProductDraft: { title: '', price: '', description: '', tags: '', targetAudience: '', precautions: '', imageFileIds: '', imageUrl: '' },
|
||||
'form.productId': selectedProduct.id,
|
||||
'form.manualProductTitle': '',
|
||||
'form.manualProductPrice': '',
|
||||
'form.manualProductDescription': '',
|
||||
'form.manualProductTags': '',
|
||||
'form.manualProductTargetAudience': '',
|
||||
'form.manualProductPrecautions': '',
|
||||
'form.manualProductImageFileIds': '',
|
||||
'form.manualProductImageUrl': '',
|
||||
'form.amount': selectedProduct.price === undefined || selectedProduct.price === null ? '' : String(selectedProduct.price),
|
||||
'form.durationMinutes': String(selectedDuration || this.data.form.durationMinutes || '')
|
||||
})
|
||||
this.closeProductModal()
|
||||
@@ -614,33 +821,6 @@ Page({
|
||||
this.checkAvailability()
|
||||
},
|
||||
|
||||
useManualProduct() {
|
||||
const draft = this.data.manualProductDraft
|
||||
const title = String(draft.title || '').trim()
|
||||
const priceText = String(draft.price === undefined ? '' : draft.price).trim()
|
||||
const price = Number(priceText)
|
||||
if (!title || !priceText || !Number.isFinite(price) || price < 0) {
|
||||
wx.showToast({ title: '请填写手动预约作品名称和价格', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
selectedProduct: {},
|
||||
selectedProductPriceText: `¥${price}`,
|
||||
'form.productId': '',
|
||||
'form.manualProductTitle': title,
|
||||
'form.manualProductPrice': String(price),
|
||||
'form.manualProductDescription': String(draft.description || '').trim(),
|
||||
'form.manualProductTags': String(draft.tags || '').trim(),
|
||||
'form.manualProductTargetAudience': String(draft.targetAudience || '').trim(),
|
||||
'form.manualProductPrecautions': String(draft.precautions || '').trim(),
|
||||
'form.manualProductImageFileIds': String(draft.imageFileIds || ''),
|
||||
'form.manualProductImageUrl': String(draft.imageUrl || '')
|
||||
})
|
||||
this.closeProductModal()
|
||||
this.refreshAvailableTimes()
|
||||
this.checkAvailability()
|
||||
},
|
||||
|
||||
async chooseManualProductImage() {
|
||||
if (this.data.manualImageUploading) {
|
||||
return
|
||||
@@ -658,8 +838,11 @@ Page({
|
||||
throw new Error('作品图片上传成功但未返回文件ID')
|
||||
}
|
||||
this.setData({
|
||||
'manualProductDraft.imageFileIds': String(fileId),
|
||||
'manualProductDraft.imageUrl': fileUrl
|
||||
'form.productId': '',
|
||||
selectedProduct: {},
|
||||
selectedProductPriceText: '',
|
||||
'form.manualProductImageFileIds': String(fileId),
|
||||
'form.manualProductImageUrl': fileUrl
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '图片上传失败', icon: 'none' })
|
||||
@@ -670,8 +853,8 @@ Page({
|
||||
|
||||
removeManualProductImage() {
|
||||
this.setData({
|
||||
'manualProductDraft.imageFileIds': '',
|
||||
'manualProductDraft.imageUrl': ''
|
||||
'form.manualProductImageFileIds': '',
|
||||
'form.manualProductImageUrl': ''
|
||||
})
|
||||
},
|
||||
|
||||
@@ -781,6 +964,13 @@ Page({
|
||||
if (!form.appointmentDate || !durationMinutes) {
|
||||
const patch = {
|
||||
availableTimeGroups: [],
|
||||
timePickerGroups: [],
|
||||
timePickerSlots: [],
|
||||
timePickerHours: [],
|
||||
timePickerMinutes: [],
|
||||
timePickerValue: [0, 0],
|
||||
selectedTimeCandidate: '',
|
||||
timePickerCandidateStatus: 'off-shift',
|
||||
timeError: '',
|
||||
timeSelectTip: '请先填写预约日期和时长'
|
||||
}
|
||||
@@ -792,8 +982,12 @@ Page({
|
||||
}
|
||||
if (!form.artistId) {
|
||||
const availableTimeGroups = buildUnassignedTimeGroups(durationMinutes)
|
||||
const timePickerSlots = buildTimePickerSlots({ schedules: [], appointments: [] }, form, durationMinutes)
|
||||
this.setData({
|
||||
availableTimeGroups,
|
||||
timePickerSlots,
|
||||
timePickerGroups: buildTimePickerGroups(timePickerSlots),
|
||||
...buildTimeWheelState(timePickerSlots, form.appointmentTime),
|
||||
timeError: '',
|
||||
timeLoading: false,
|
||||
timeSelectTip: '请选择预约时间,员工可稍后分配'
|
||||
@@ -816,8 +1010,12 @@ Page({
|
||||
}
|
||||
const availableTimeGroups = buildAvailableTimeGroups(calendar, form, durationMinutes)
|
||||
const availableTimes = flattenTimeGroups(availableTimeGroups).map(item => item.value)
|
||||
const timePickerSlots = buildTimePickerSlots(calendar, form, durationMinutes)
|
||||
const patch = {
|
||||
availableTimeGroups,
|
||||
timePickerSlots,
|
||||
timePickerGroups: buildTimePickerGroups(timePickerSlots),
|
||||
...buildTimeWheelState(timePickerSlots, form.appointmentTime),
|
||||
timeSelectTip: availableTimes.length > 0 ? '请选择预约时间' : '当前美甲师当天暂无可约时间'
|
||||
}
|
||||
if (form.appointmentTime && !availableTimes.includes(form.appointmentTime)) {
|
||||
@@ -845,7 +1043,7 @@ Page({
|
||||
wx.showToast({ title: '请先填写预约日期和时长', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ timeSheetVisible: true })
|
||||
this.setData({ timeSheetVisible: true, timePickerMode: 'wheel' })
|
||||
await this.refreshAvailableTimes()
|
||||
},
|
||||
|
||||
@@ -855,16 +1053,61 @@ Page({
|
||||
|
||||
selectAvailableTime(event) {
|
||||
const value = event.currentTarget.dataset.value
|
||||
this.setData({
|
||||
'form.appointmentTime': value,
|
||||
timeSheetVisible: false
|
||||
})
|
||||
this.checkAvailability()
|
||||
const slot = this.data.timePickerSlots.find(item => item.value === value)
|
||||
if (!slot || slot.status !== 'available') {
|
||||
wx.showToast({ title: slot && slot.status === 'occupied' ? '该时间已被占用' : '该时间不可预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ selectedTimeCandidate: value, timePickerCandidateStatus: slot.status })
|
||||
},
|
||||
|
||||
async checkAvailability() {
|
||||
onTimePickerModeChange(event) {
|
||||
this.setData({ timePickerMode: event.currentTarget.dataset.mode || 'wheel' })
|
||||
},
|
||||
|
||||
onTimePickerChange(event) {
|
||||
const values = event.detail.value || [0, 0]
|
||||
const hourItem = this.data.timePickerHours[values[0]]
|
||||
if (!hourItem) return
|
||||
const hour = Number(hourItem.value)
|
||||
const minuteIndex = Number(values[1] || 0)
|
||||
const minuteItem = this.data.timePickerMinutes[minuteIndex]
|
||||
const minute = minuteItem ? Number(minuteItem.value) : 0
|
||||
const candidate = `${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}`
|
||||
const slot = this.data.timePickerSlots.find(item => item.value === candidate)
|
||||
const nextMinutes = timeWheelStateForHour(this.data.timePickerSlots, hour, minute)
|
||||
this.setData({
|
||||
timePickerValue: [Number(values[0]), nextMinutes.selectedMinuteIndex],
|
||||
timePickerMinutes: nextMinutes.timePickerMinutes,
|
||||
selectedTimeCandidate: candidate,
|
||||
timePickerCandidateStatus: slot ? slot.status : 'off-shift'
|
||||
})
|
||||
},
|
||||
|
||||
confirmTimeSelection() {
|
||||
const candidate = this.data.selectedTimeCandidate
|
||||
const slot = this.data.timePickerSlots.find(item => item.value === candidate)
|
||||
if (!slot || slot.status !== 'available') {
|
||||
wx.showToast({ title: slot && slot.status === 'occupied' ? '该时间已被占用' : '该时间不可预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.checkAvailability(candidate).then(availability => {
|
||||
if (!availability.ok) {
|
||||
wx.showToast({
|
||||
title: availability.tip && availability.tip.includes('已有预约') ? '该时间已被占用' : availability.tip || '该时间不可预约',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
this.setData({ 'form.appointmentTime': candidate, timeSheetVisible: false })
|
||||
this.checkAvailability()
|
||||
})
|
||||
},
|
||||
|
||||
async checkAvailability(candidateTime) {
|
||||
const form = this.data.form
|
||||
if (!form.appointmentDate || !form.appointmentTime) {
|
||||
const appointmentTime = candidateTime || form.appointmentTime
|
||||
if (!form.appointmentDate || !appointmentTime) {
|
||||
this.setData({ conflictTip: '', conflictLevel: 'free' })
|
||||
return { ok: true }
|
||||
}
|
||||
@@ -873,7 +1116,7 @@ Page({
|
||||
this.setData({ conflictTip: '', conflictLevel: 'free' })
|
||||
return { ok: true }
|
||||
}
|
||||
const startMinute = dateUtil.minutesOfDay(form.appointmentTime)
|
||||
const startMinute = dateUtil.minutesOfDay(appointmentTime)
|
||||
const endMinute = startMinute + durationMinutes
|
||||
if (startMinute < dateUtil.minutesOfDay('10:00') || endMinute > dateUtil.minutesOfDay('22:00')) {
|
||||
const tip = '该时间超出营业时间 10:00-22:00'
|
||||
@@ -912,7 +1155,7 @@ Page({
|
||||
this.setData({ conflictTip: tip, conflictLevel: 'danger' })
|
||||
return { ok: false, tip }
|
||||
}
|
||||
const tip = `${this.data.selectedArtist.name || '该美甲师'} ${form.appointmentTime}-${dateUtil.timeFromMinutes(endMinute)} 可预约`
|
||||
const tip = `${this.data.selectedArtist.name || '该美甲师'} ${appointmentTime}-${dateUtil.timeFromMinutes(endMinute)} 可预约`
|
||||
this.setData({ conflictTip: tip, conflictLevel: 'free' })
|
||||
return { ok: true, tip }
|
||||
} catch (error) {
|
||||
@@ -925,8 +1168,12 @@ Page({
|
||||
async ensureCustomerBeforeSubmit() {
|
||||
const name = String(this.data.form.customerName || '').trim()
|
||||
const phone = String(this.data.form.phone || '').trim()
|
||||
if (!name && !phone) {
|
||||
this.setData({ 'form.createCustomerRecord': false })
|
||||
return true
|
||||
}
|
||||
if (!name) {
|
||||
wx.showToast({ title: '请输入客户姓名', icon: 'none' })
|
||||
wx.showToast({ title: '填写手机号时请同时填写客户姓名', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
if (phone && !/^1[3-9]\d{9}$/.test(phone)) {
|
||||
@@ -934,6 +1181,7 @@ Page({
|
||||
return false
|
||||
}
|
||||
if (this.data.form.customerUserId) {
|
||||
this.setData({ 'form.createCustomerRecord': false })
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -941,6 +1189,20 @@ Page({
|
||||
try {
|
||||
const matches = await customersApi.matchIdentity(name, phone || undefined)
|
||||
if (matches.length > 1) {
|
||||
const choice = await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '找到多个同名客户',
|
||||
content: phone ? '无法确定唯一客户,请选择已有客户或按散客继续。' : '请先补充手机号或选择一个已有客户,也可以按散客继续。',
|
||||
cancelText: '不关联提交',
|
||||
confirmText: '选择客户',
|
||||
success: resolve,
|
||||
fail: () => resolve({ confirm: false })
|
||||
})
|
||||
})
|
||||
if (!choice.confirm) {
|
||||
this.setData({ 'form.createCustomerRecord': false })
|
||||
return true
|
||||
}
|
||||
this.setData({
|
||||
customerOptions: matches.map(normalizeCustomer).map(buildCustomerSelectorItem),
|
||||
customerKeyword: name,
|
||||
@@ -954,20 +1216,22 @@ Page({
|
||||
wx.showModal({
|
||||
title: '客户已存在',
|
||||
content: `系统中已有“${name}”${phone ? `(${phone})` : ''},是否使用该客户?`,
|
||||
cancelText: '取消',
|
||||
cancelText: '不关联提交',
|
||||
confirmText: '使用已有',
|
||||
success: resolve,
|
||||
fail: () => resolve({ confirm: false })
|
||||
})
|
||||
})
|
||||
if (!choice.confirm) {
|
||||
return false
|
||||
if (choice.confirm) {
|
||||
this.setData({
|
||||
'form.customerUserId': customer.id,
|
||||
'form.customerName': customer.name,
|
||||
'form.phone': customer.phone,
|
||||
'form.createCustomerRecord': false
|
||||
})
|
||||
} else {
|
||||
this.setData({ 'form.createCustomerRecord': false })
|
||||
}
|
||||
this.setData({
|
||||
'form.customerUserId': customer.id,
|
||||
'form.customerName': customer.name,
|
||||
'form.phone': customer.phone
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -981,11 +1245,7 @@ Page({
|
||||
fail: () => resolve({ confirm: false })
|
||||
})
|
||||
})
|
||||
if (!createChoice.confirm) {
|
||||
return false
|
||||
}
|
||||
const customerId = await customersApi.create({ nickname: name, phone: phone || undefined })
|
||||
this.setData({ 'form.customerUserId': customerId })
|
||||
this.setData({ 'form.createCustomerRecord': Boolean(createChoice.confirm) })
|
||||
return true
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '客户校验失败,请稍后重试', icon: 'none' })
|
||||
@@ -1003,13 +1263,25 @@ Page({
|
||||
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const form = this.data.form
|
||||
const hasManualProduct = String(form.manualProductTitle || '').trim() && String(form.manualProductPrice || '').trim()
|
||||
let form = this.data.form
|
||||
const manualProductTitle = String(form.manualProductTitle || '').trim()
|
||||
const manualProductImageFileIds = String(form.manualProductImageFileIds || '').trim()
|
||||
const hasManualProduct = Boolean(manualProductTitle || manualProductImageFileIds || String(form.customerName || '').trim())
|
||||
const amountText = String(form.amount === undefined || form.amount === null ? '' : form.amount).trim()
|
||||
const amount = Number(amountText)
|
||||
const durationMinutes = normalizeDuration(form.durationMinutes)
|
||||
if (!form.customerName || (!form.productId && !hasManualProduct) || !form.appointmentDate || !form.appointmentTime) {
|
||||
if ((!form.productId && !hasManualProduct) || !form.appointmentDate || !form.appointmentTime || !amountText) {
|
||||
wx.showToast({ title: '请补全预约信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!Number.isFinite(amount) || amount < 0) {
|
||||
wx.showToast({ title: '请输入不小于0的成交金额', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (form.phone && !String(form.customerName || '').trim()) {
|
||||
wx.showToast({ title: '填写手机号时请同时填写客户姓名', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (form.phone && !/^1[3-9]\d{9}$/.test(String(form.phone).trim())) {
|
||||
wx.showToast({ title: '请输入正确手机号', icon: 'none' })
|
||||
return
|
||||
@@ -1039,12 +1311,17 @@ Page({
|
||||
if (!(await this.ensureCustomerBeforeSubmit())) {
|
||||
return
|
||||
}
|
||||
form = this.data.form
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const payload = {
|
||||
...form,
|
||||
customerUserId: form.customerUserId ? String(form.customerUserId) : undefined,
|
||||
artistId: form.artistId ? String(form.artistId) : undefined,
|
||||
customerName: String(form.customerName || '').trim() || undefined,
|
||||
phone: String(form.phone || '').trim() || undefined,
|
||||
amount,
|
||||
createCustomerRecord: Boolean(form.createCustomerRecord),
|
||||
durationMinutes,
|
||||
clientRequestId: buildClientRequestId('manager-appointment')
|
||||
}
|
||||
@@ -1054,8 +1331,8 @@ Page({
|
||||
payload.manualProductPrice = undefined
|
||||
} else {
|
||||
payload.productId = undefined
|
||||
payload.manualProductTitle = String(form.manualProductTitle || '').trim()
|
||||
payload.manualProductPrice = Number(form.manualProductPrice)
|
||||
payload.manualProductTitle = manualProductTitle || undefined
|
||||
payload.manualProductPrice = amount
|
||||
payload.manualProductDescription = String(form.manualProductDescription || '').trim() || undefined
|
||||
payload.manualProductTags = String(form.manualProductTags || '').trim() || undefined
|
||||
payload.manualProductTargetAudience = String(form.manualProductTargetAudience || '').trim() || undefined
|
||||
|
||||
@@ -1,136 +1,67 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card form-card">
|
||||
<view class="field customer-field">
|
||||
<text class="field-label required">客户姓名</text>
|
||||
<view class="customer-entry">
|
||||
<input class="customer-name-input" value="{{form.customerName}}" data-field="customerName" bindinput="onCustomerInput" placeholder="请输入客户姓名" />
|
||||
<button class="customer-select-btn" catchtap="openCustomerSheet">选择已有客户</button>
|
||||
</view>
|
||||
<input class="customer-phone-input" value="{{form.phone}}" data-field="phone" bindinput="onCustomerInput" type="number" maxlength="11" placeholder="手机号(可选)" />
|
||||
<text wx:if="{{form.customerUserId}}" class="customer-selected-tip">已关联系统客户</text>
|
||||
<view class="page no-tab appointment-page">
|
||||
<view class="card form-card style-section">
|
||||
<view class="section-heading">
|
||||
<view><text class="section-title-main">美甲款式</text><text class="section-caption">手动输入为主,也可快速选择已有款式</text></view>
|
||||
<button class="link-action" bindtap="openProductModal">{{form.productId ? '更换款式' : '选择已有款式'}}</button>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">预约日期</text>
|
||||
<picker mode="date" value="{{form.appointmentDate}}" bindchange="onDateChange">
|
||||
<view class="field-value">{{form.appointmentDate}}</view>
|
||||
</picker>
|
||||
<view wx:if="{{form.productId}}" class="selected-style-card">
|
||||
<image wx:if="{{selectedProduct.coverImage}}" class="selected-style-image" src="{{selectedProduct.coverImage}}" mode="aspectFill"></image>
|
||||
<view class="selected-style-copy"><text class="selected-style-title">{{selectedProduct.title}}</text><text class="selected-style-meta">参考价 {{selectedProductPriceText || '待定'}} · {{selectedProduct.durationText || '时长待定'}}</text></view>
|
||||
<button class="switch-manual-action" bindtap="openManualProduct">手动录入</button>
|
||||
</view>
|
||||
<view class="field product-field" bindtap="openProductModal">
|
||||
<text class="field-label required" bindtap="openProductModal">预约作品</text>
|
||||
<button class="field-value product-value product-picker-button" bindtap="openProductModal">
|
||||
<view><text>{{selectedProduct.title || form.manualProductTitle || '请选择预约作品'}}</text><text wx:if="{{selectedProductPriceText || form.manualProductPrice}}" class="product-selected-price">{{selectedProductPriceText || ('¥' + form.manualProductPrice)}}</text></view>
|
||||
<text wx:if="{{form.manualProductTitle && !form.productId}}" class="manual-badge">手动</text>
|
||||
</button>
|
||||
<view wx:else class="style-name-row">
|
||||
<input class="style-name-input" value="{{form.manualProductTitle}}" bindinput="onStyleTitleInput" placeholder="款式名称(选填)" />
|
||||
<button class="image-action" bindtap="chooseManualProductImage" loading="{{manualImageUploading}}">{{form.manualProductImageUrl ? '更换图片' : '添加图片'}}</button>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">预计时长</text>
|
||||
<input value="{{form.durationMinutes}}" data-field="durationMinutes" bindinput="onInput" type="number" placeholder="请输入预约时长" />
|
||||
<text class="unit">分钟</text>
|
||||
<view wx:if="{{!form.productId && form.manualProductImageUrl}}" class="style-image-preview-row">
|
||||
<image class="style-image-preview" src="{{form.manualProductImageUrl}}" mode="aspectFill"></image>
|
||||
<button class="remove-image-action" bindtap="removeManualProductImage">移除图片</button>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">员工(可稍后分配)</text>
|
||||
<view class="field-value reference-value" bindtap="openArtistSheet">
|
||||
<text>{{selectedArtist.name || '暂不分配'}}</text>
|
||||
<text class="reference-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">预约时间</text>
|
||||
<view class="field-value time-value {{form.appointmentTime ? '' : 'placeholder'}}" bindtap="openTimeSheet">
|
||||
<view>
|
||||
<text>{{form.appointmentTime || timeSelectTip}}</text>
|
||||
<text wx:if="{{form.appointmentTime}}" class="time-range">{{form.appointmentDate}} · {{selectedArtist.name || '待分配'}} · {{form.durationMinutes}}分钟</text>
|
||||
</view>
|
||||
<text class="time-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="field textarea-field">
|
||||
<text class="field-label">备注</text>
|
||||
<textarea value="{{form.remark}}" data-field="remark" bindinput="onInput" placeholder="客户偏好、款式说明" />
|
||||
<view class="style-number-row">
|
||||
<view class="number-field"><text class="field-label required">成交金额</text><input type="digit" value="{{form.amount}}" data-field="amount" bindinput="onInput" placeholder="请输入实际金额" /><text class="number-unit">元</text></view>
|
||||
<view class="number-field"><text class="field-label required">预计时长</text><input type="number" value="{{form.durationMinutes}}" data-field="durationMinutes" bindinput="onInput" placeholder="60" /><text class="number-unit">分钟</text></view>
|
||||
</view>
|
||||
<view class="style-remark-field"><text class="field-label">款式备注</text><textarea value="{{form.remark}}" data-field="remark" bindinput="onInput" placeholder="客户偏好、款式说明(选填)" /></view>
|
||||
<text class="style-hint">名称和图片至少填写一项;名称为空时会使用客户姓名或“散客款式”。</text>
|
||||
</view>
|
||||
|
||||
<view class="capacity-tip card">
|
||||
<text class="tip-title">容量校验</text>
|
||||
<text class="tip-text">已指定员工时会校验排班和冲突;暂不分配时只校验营业时间,后续分配时再完整校验。</text>
|
||||
<view class="card form-card appointment-info-section">
|
||||
<view class="section-heading"><view><text class="section-title-main">预约信息</text><text class="section-caption">时间默认使用滚轮选择</text></view></view>
|
||||
<view class="field"><text class="field-label required">预约日期</text><picker mode="date" value="{{form.appointmentDate}}" bindchange="onDateChange"><view class="field-value">{{form.appointmentDate}}</view></picker></view>
|
||||
<view class="field"><text class="field-label required">预约时间</text><view class="field-value time-value {{form.appointmentTime ? '' : 'placeholder'}}" bindtap="openTimeSheet"><view><text>{{form.appointmentTime || timeSelectTip}}</text><text wx:if="{{form.appointmentTime}}" class="time-range">{{form.appointmentDate}} · {{selectedArtist.name || '待分配'}} · {{form.durationMinutes}}分钟</text></view><text class="time-arrow">›</text></view></view>
|
||||
<view class="field"><text class="field-label">员工(可稍后分配)</text><view class="field-value reference-value" bindtap="openArtistSheet"><text>{{selectedArtist.name || '暂不分配'}}</text><text class="reference-arrow">›</text></view></view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{draftSavedAtText}}" class="draft-tip card">
|
||||
<text>{{draftSavedAtText}}</text>
|
||||
<button class="text-btn draft-clear" bindtap="clearDraft">清空</button>
|
||||
<view class="card form-card customer-section">
|
||||
<view class="section-heading"><view><text class="section-title-main">客户</text><text class="section-caption">可留空,按散客保存</text></view></view>
|
||||
<view class="customer-entry"><input class="customer-name-input" value="{{form.customerName}}" data-field="customerName" bindinput="onCustomerInput" placeholder="客户姓名(选填)" /><button class="customer-select-btn" catchtap="openCustomerSheet">选择已有客户</button></view>
|
||||
<input class="customer-phone-input" value="{{form.phone}}" data-field="phone" bindinput="onCustomerInput" type="number" maxlength="11" placeholder="手机号(选填,填写时需同时填写姓名)" />
|
||||
<view wx:if="{{customerSuggestions.length}}" class="customer-suggestion-list"><view wx:for="{{customerSuggestions}}" wx:key="id" class="customer-suggestion" data-index="{{index}}" bindtap="selectCustomerSuggestion"><text>{{item.name}}</text><text>{{item.phone || '未填写手机号'}}</text></view></view>
|
||||
<text wx:if="{{form.customerUserId}}" class="customer-selected-tip">已关联系统客户</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{conflictTip}}" class="availability-tip card {{conflictLevel}}">
|
||||
<text class="tip-title">时段检查</text>
|
||||
<text class="tip-text">{{conflictTip}}</text>
|
||||
</view>
|
||||
<view class="capacity-tip card"><text class="tip-title">容量校验</text><text class="tip-text">已指定员工时会校验排班和冲突;暂不分配时不校验员工占用,后续分配时再完整校验。</text></view>
|
||||
<view wx:if="{{draftSavedAtText}}" class="draft-tip card"><text>{{draftSavedAtText}}</text><button class="text-btn draft-clear" bindtap="clearDraft">清空</button></view>
|
||||
<view wx:if="{{conflictTip}}" class="availability-tip card {{conflictLevel}}"><text class="tip-title">时段检查</text><text class="tip-text">{{conflictTip}}</text></view>
|
||||
|
||||
<entity-selector-sheet
|
||||
visible="{{customerSheetVisible}}"
|
||||
title="选择客户"
|
||||
keyword="{{customerKeyword}}"
|
||||
placeholder="搜索客户姓名或手机号"
|
||||
items="{{customerOptions}}"
|
||||
selected-id="{{form.customerUserId}}"
|
||||
loading="{{customerLoading}}"
|
||||
error-text="{{customerError}}"
|
||||
empty-text="暂无匹配客户"
|
||||
bind:search="onCustomerSearch"
|
||||
bind:select="selectCustomer"
|
||||
bind:retry="retryCustomerSearch"
|
||||
bind:close="closeCustomerSheet"
|
||||
/>
|
||||
<entity-selector-sheet visible="{{customerSheetVisible}}" title="选择客户" keyword="{{customerKeyword}}" placeholder="搜索客户姓名或手机号" items="{{customerOptions}}" selected-id="{{form.customerUserId}}" loading="{{customerLoading}}" error-text="{{customerError}}" empty-text="暂无匹配客户" show-view-switch="{{true}}" view-mode="{{customerViewMode}}" sort-label="{{customerNewestFirst ? '最新添加' : '最早添加'}}" bind:search="onCustomerSearch" bind:select="selectCustomer" bind:retry="retryCustomerSearch" bind:changeview="changeCustomerView" bind:sort="toggleCustomerSort" bind:close="closeCustomerSheet" />
|
||||
<entity-selector-sheet visible="{{artistSheetVisible}}" title="选择员工" keyword="{{artistKeyword}}" placeholder="搜索员工姓名" items="{{artistSelectorItems}}" selected-id="{{form.artistId}}" loading="{{false}}" error-text="{{artistError}}" empty-text="暂无匹配员工" action-text="快速新增员工" bind:search="onArtistSearch" bind:select="selectArtist" bind:retry="retryArtists" bind:action="addEmployeeFromSelector" bind:close="closeArtistSheet" />
|
||||
<product-selector-sheet visible="{{productModalVisible}}" mode="list" title="选择已有款式" keyword="{{productKeyword}}" placeholder="搜索款式、标签、美甲师" items="{{filteredProducts}}" selected-id="{{form.productId}}" loading="{{loadingProducts}}" error-text="{{productError}}" empty-text="暂无匹配款式" show-manual-action="{{false}}" bind:search="onProductSearch" bind:select="selectProduct" bind:retry="loadOptions" bind:close="closeProductModal" />
|
||||
|
||||
<entity-selector-sheet
|
||||
visible="{{artistSheetVisible}}"
|
||||
title="选择员工"
|
||||
keyword="{{artistKeyword}}"
|
||||
placeholder="搜索员工姓名"
|
||||
items="{{artistSelectorItems}}"
|
||||
selected-id="{{form.artistId}}"
|
||||
loading="{{false}}"
|
||||
error-text="{{artistError}}"
|
||||
empty-text="暂无匹配员工"
|
||||
action-text="快速新增员工"
|
||||
bind:search="onArtistSearch"
|
||||
bind:select="selectArtist"
|
||||
bind:retry="retryArtists"
|
||||
bind:action="addEmployeeFromSelector"
|
||||
bind:close="closeArtistSheet"
|
||||
/>
|
||||
|
||||
<product-selector-sheet visible="{{productModalVisible}}" mode="{{productSelectorMode}}" title="选择预约作品" keyword="{{productKeyword}}" placeholder="搜索作品、标签、美甲师" items="{{filteredProducts}}" selected-id="{{form.productId}}" loading="{{loadingProducts}}" error-text="{{productError}}" empty-text="暂无匹配作品" manual-form="{{manualProductDraft}}" manual-more-expanded="{{manualProductMoreExpanded}}" manual-image-url="{{manualProductDraft.imageUrl}}" manual-image-uploading="{{manualImageUploading}}" bind:search="onProductSearch" bind:select="selectProduct" bind:openmanual="openManualProduct" bind:backtolist="backToProductList" bind:manualinput="onManualProductInput" bind:togglemore="toggleManualProductMore" bind:chooseimage="chooseManualProductImage" bind:removeimage="removeManualProductImage" bind:confirmmanual="useManualProduct" bind:retry="loadOptions" bind:close="closeProductModal" />
|
||||
|
||||
<view wx:if="{{timeSheetVisible}}" class="modal-mask" bindtap="closeTimeSheet">
|
||||
<view class="time-modal" catchtap="stopTap">
|
||||
<view class="modal-head">
|
||||
<view>
|
||||
<text class="modal-title">选择预约时间</text>
|
||||
<text class="modal-subtitle">{{form.appointmentDate}} · {{selectedArtist.name || '待分配'}} · {{form.durationMinutes}}分钟</text>
|
||||
</view>
|
||||
<view class="modal-close" bindtap="closeTimeSheet">×</view>
|
||||
</view>
|
||||
<view wx:if="{{timeSheetVisible}}" class="modal-mask" bindtap="closeTimeSheet" catchtouchmove="stopTouchMove">
|
||||
<view class="time-modal" catchtap="stopTap" catchtouchmove="stopTouchMove">
|
||||
<view class="modal-head"><view><text class="modal-title">选择预约时间</text><text class="modal-subtitle">{{form.appointmentDate}} · {{selectedArtist.name || '待分配'}} · {{form.durationMinutes}}分钟</text></view><view class="modal-close" bindtap="closeTimeSheet" aria-label="关闭时间选择"></view></view>
|
||||
<view class="time-mode-switch"><button class="{{timePickerMode === 'wheel' ? 'active' : ''}}" data-mode="wheel" bindtap="onTimePickerModeChange">滚轮选择</button><button class="{{timePickerMode === 'grid' ? 'active' : ''}}" data-mode="grid" bindtap="onTimePickerModeChange">15分钟时段</button></view>
|
||||
<view wx:if="{{timeLoading}}" class="time-empty">正在计算可约时间...</view>
|
||||
<view wx:elif="{{timeError}}" class="time-empty">{{timeError}}</view>
|
||||
<view wx:elif="{{availableTimeGroups.length === 0}}" class="time-empty">当前没有可选时间</view>
|
||||
<scroll-view wx:else class="time-list" scroll-y>
|
||||
<view wx:for="{{availableTimeGroups}}" wx:key="key" class="time-group">
|
||||
<text class="time-group-title">{{item.title}}</text>
|
||||
<view class="time-grid">
|
||||
<view wx:for="{{item.times}}" wx:for-item="time" wx:key="value" class="time-chip {{form.appointmentTime === time.value ? 'active' : ''}}" data-value="{{time.value}}" bindtap="selectAvailableTime">
|
||||
<text>{{time.value}}</text>
|
||||
<text>{{time.rangeText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<block wx:elif="{{timePickerMode === 'wheel'}}">
|
||||
<picker-view class="time-wheel" indicator-style="height: 76rpx;" value="{{timePickerValue}}" bindchange="onTimePickerChange"><picker-view-column><view wx:for="{{timePickerHours}}" wx:key="value" class="wheel-item {{item.disabled ? 'disabled' : ''}}">{{item.label}}</view></picker-view-column><picker-view-column><view wx:for="{{timePickerMinutes}}" wx:key="value" class="wheel-item {{item.disabled ? 'disabled' : ''}}">{{item.label}}</view></picker-view-column></picker-view>
|
||||
<view class="time-wheel-caption">{{selectedTimeCandidate || '请选择时间'}}<text wx:if="{{timePickerCandidateStatus === 'occupied'}}"> · 已被占用</text><text wx:elif="{{timePickerCandidateStatus === 'off-shift'}}"> · 当前无排班</text></view>
|
||||
<button class="time-confirm-btn" bindtap="confirmTimeSelection">确认时间</button>
|
||||
</block>
|
||||
<block wx:else><scroll-view class="time-list" scroll-y><view wx:for="{{timePickerGroups}}" wx:key="key" class="time-group"><text class="time-group-title">{{item.title}}</text><view class="time-grid"><view wx:for="{{item.times}}" wx:for-item="time" wx:key="value" class="time-chip {{selectedTimeCandidate === time.value ? 'active' : ''}} {{time.status !== 'available' ? 'disabled' : ''}}" data-value="{{time.value}}" bindtap="selectAvailableTime"><text>{{time.value}}</text><text>{{time.statusText || time.rangeText}}</text></view></view></view></scroll-view><button class="time-confirm-btn" bindtap="confirmTimeSelection">确认当前时间</button></block>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="fixed-bottom">
|
||||
<view wx:if="{{canCreateAppointment}}" class="action-row">
|
||||
<button class="secondary-btn draft-btn" bindtap="saveDraft">保存草稿</button>
|
||||
<button class="primary-btn submit-btn" loading="{{loading}}" bindtap="submit">提交预约</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="fixed-bottom"><view wx:if="{{canCreateAppointment}}" class="action-row"><button class="secondary-btn draft-btn" bindtap="saveDraft">保存草稿</button><button class="primary-btn submit-btn" loading="{{loading}}" bindtap="submit">提交预约</button></view></view>
|
||||
</view>
|
||||
|
||||
@@ -269,8 +269,12 @@
|
||||
}
|
||||
|
||||
.time-modal {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 76vh;
|
||||
max-height: 82vh;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
|
||||
border-radius: 28rpx 28rpx 0 0;
|
||||
background: #fffaf4;
|
||||
@@ -337,10 +341,17 @@
|
||||
}
|
||||
|
||||
.time-list {
|
||||
max-height: 620rpx;
|
||||
height: 0;
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
padding-right: 2rpx;
|
||||
}
|
||||
|
||||
.time-wheel {
|
||||
min-height: 260rpx;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.time-group {
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
@@ -427,3 +438,358 @@
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.appointment-page .form-card {
|
||||
margin-bottom: 18rpx;
|
||||
padding: 20rpx 24rpx 10rpx;
|
||||
}
|
||||
|
||||
.section-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
margin: 0 0 18rpx;
|
||||
}
|
||||
|
||||
.section-title-main,
|
||||
.section-caption {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.section-title-main {
|
||||
color: #302a24;
|
||||
font-size: 30rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.section-caption {
|
||||
margin-top: 5rpx;
|
||||
color: #9a9288;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
|
||||
.link-action {
|
||||
flex: 0 0 auto;
|
||||
height: 60rpx;
|
||||
padding: 0 17rpx;
|
||||
border: 1rpx solid #d7b38e;
|
||||
border-radius: 14rpx;
|
||||
background: #fff7ed;
|
||||
color: #9f5f2d;
|
||||
font-size: 22rpx;
|
||||
line-height: 60rpx;
|
||||
}
|
||||
|
||||
.style-name-row,
|
||||
.style-image-preview-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
.style-name-input {
|
||||
min-width: 0;
|
||||
height: 78rpx;
|
||||
flex: 1;
|
||||
padding: 0 18rpx;
|
||||
border: 1rpx solid #e7e0d7;
|
||||
border-radius: 15rpx;
|
||||
background: #fff;
|
||||
color: #29241f;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.image-action,
|
||||
.remove-image-action {
|
||||
flex: 0 0 auto;
|
||||
height: 72rpx;
|
||||
padding: 0 18rpx;
|
||||
border-radius: 14rpx;
|
||||
background: #edf4f1;
|
||||
color: #2f6f62;
|
||||
font-size: 23rpx;
|
||||
line-height: 72rpx;
|
||||
}
|
||||
|
||||
.style-image-preview-row {
|
||||
justify-content: flex-start;
|
||||
margin-top: 14rpx;
|
||||
}
|
||||
|
||||
.style-image-preview {
|
||||
width: 112rpx;
|
||||
height: 112rpx;
|
||||
border-radius: 14rpx;
|
||||
background: #eee9e2;
|
||||
}
|
||||
|
||||
.remove-image-action {
|
||||
height: 58rpx;
|
||||
background: #f5f0e9;
|
||||
color: #756e66;
|
||||
font-size: 21rpx;
|
||||
line-height: 58rpx;
|
||||
}
|
||||
|
||||
.selected-style-note {
|
||||
margin-top: 12rpx;
|
||||
color: #4f766d;
|
||||
font-size: 23rpx;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.style-number-row {
|
||||
display: flex;
|
||||
gap: 18rpx;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.number-field {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
height: 88rpx;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
border-bottom: 1rpx solid #eee8df;
|
||||
}
|
||||
|
||||
.number-field .field-label {
|
||||
width: auto;
|
||||
flex: 0 0 auto;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.number-field input {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
color: #302923;
|
||||
font-size: 27rpx;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.number-unit {
|
||||
flex: 0 0 auto;
|
||||
color: #9a9288;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.style-remark-field {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 14rpx;
|
||||
padding: 18rpx 0 8rpx;
|
||||
border-bottom: 1rpx solid #eee8df;
|
||||
}
|
||||
|
||||
.style-remark-field .field-label {
|
||||
width: 124rpx;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.style-remark-field textarea {
|
||||
min-height: 86rpx;
|
||||
flex: 1;
|
||||
padding: 0;
|
||||
color: #302923;
|
||||
font-size: 25rpx;
|
||||
}
|
||||
|
||||
.style-hint {
|
||||
display: block;
|
||||
padding: 12rpx 0 16rpx;
|
||||
color: #a1978c;
|
||||
font-size: 20rpx;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.appointment-info-section .section-heading,
|
||||
.customer-section .section-heading {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.appointment-info-section .field:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.customer-section {
|
||||
padding-bottom: 22rpx !important;
|
||||
}
|
||||
|
||||
.customer-section .customer-entry {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.customer-entry .customer-name-input {
|
||||
height: 76rpx;
|
||||
}
|
||||
|
||||
.customer-entry .customer-select-btn {
|
||||
min-width: 170rpx;
|
||||
height: 76rpx;
|
||||
line-height: 76rpx;
|
||||
}
|
||||
|
||||
.customer-phone-input {
|
||||
height: 70rpx;
|
||||
}
|
||||
|
||||
.customer-suggestion-list {
|
||||
margin-top: 10rpx;
|
||||
overflow: hidden;
|
||||
border: 1rpx solid #e8e0d7;
|
||||
border-radius: 14rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.customer-suggestion {
|
||||
display: flex;
|
||||
min-height: 68rpx;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 18rpx;
|
||||
padding: 0 16rpx;
|
||||
border-bottom: 1rpx solid #f0ebe4;
|
||||
color: #39332d;
|
||||
font-size: 23rpx;
|
||||
}
|
||||
|
||||
.customer-suggestion:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.customer-suggestion text:last-child {
|
||||
color: #82796f;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
|
||||
.time-mode-switch {
|
||||
display: flex;
|
||||
gap: 8rpx;
|
||||
margin-bottom: 18rpx;
|
||||
padding: 6rpx;
|
||||
border-radius: 15rpx;
|
||||
background: #f2eee8;
|
||||
}
|
||||
|
||||
.time-mode-switch button {
|
||||
height: 58rpx;
|
||||
flex: 1;
|
||||
border-radius: 11rpx;
|
||||
color: #81786e;
|
||||
font-size: 23rpx;
|
||||
line-height: 58rpx;
|
||||
}
|
||||
|
||||
.time-mode-switch button.active {
|
||||
background: #fffdf8;
|
||||
color: #4f766d;
|
||||
font-weight: 800;
|
||||
box-shadow: 0 3rpx 8rpx rgba(58, 48, 34, 0.08);
|
||||
}
|
||||
|
||||
.time-wheel {
|
||||
width: 100%;
|
||||
height: 320rpx;
|
||||
border-top: 1rpx solid #eee7de;
|
||||
border-bottom: 1rpx solid #eee7de;
|
||||
}
|
||||
|
||||
.wheel-item {
|
||||
height: 76rpx;
|
||||
color: #302923;
|
||||
font-size: 34rpx;
|
||||
line-height: 76rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wheel-item.disabled {
|
||||
color: #c8c1b8;
|
||||
}
|
||||
|
||||
.time-wheel-caption {
|
||||
padding: 18rpx 0 8rpx;
|
||||
color: #736a60;
|
||||
font-size: 23rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.time-confirm-btn {
|
||||
width: 100%;
|
||||
height: 76rpx;
|
||||
margin-top: 12rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #4f766d;
|
||||
color: #fff;
|
||||
font-size: 26rpx;
|
||||
font-weight: 800;
|
||||
line-height: 76rpx;
|
||||
}
|
||||
|
||||
.time-chip.disabled {
|
||||
border-color: #e8e4df;
|
||||
background: #f3f1ee;
|
||||
color: #bcb5ad;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.time-chip.disabled text:last-child {
|
||||
color: #c1bab2;
|
||||
}
|
||||
|
||||
.selected-style-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14rpx;
|
||||
min-height: 104rpx;
|
||||
padding: 12rpx;
|
||||
border: 1rpx solid #d9e5df;
|
||||
border-radius: 15rpx;
|
||||
background: #f4f8f5;
|
||||
}
|
||||
|
||||
.selected-style-image {
|
||||
width: 82rpx;
|
||||
height: 82rpx;
|
||||
flex: 0 0 auto;
|
||||
border-radius: 12rpx;
|
||||
background: #e9e5df;
|
||||
}
|
||||
|
||||
.selected-style-copy {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
gap: 6rpx;
|
||||
}
|
||||
|
||||
.selected-style-title,
|
||||
.selected-style-meta {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.selected-style-title {
|
||||
color: #302923;
|
||||
font-size: 26rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.selected-style-meta {
|
||||
color: #81796f;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
|
||||
.switch-manual-action {
|
||||
height: 58rpx;
|
||||
flex: 0 0 auto;
|
||||
padding: 0 14rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #e7f0ec;
|
||||
color: #4f766d;
|
||||
font-size: 21rpx;
|
||||
line-height: 58rpx;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ const wxss = fs.readFileSync(path.join(__dirname, 'index.wxss'), 'utf8')
|
||||
const pageScript = fs.readFileSync(path.join(__dirname, 'index.js'), 'utf8')
|
||||
|
||||
assert.match(wxml, /<product-selector-sheet[^>]*bind:close="closeProductModal"/)
|
||||
assert.match(wxml, /manual-form="\{\{manualProductDraft\}\}"/)
|
||||
assert.match(wxml, /show-manual-action="\{\{false\}\}"/)
|
||||
assert.match(wxml, /bind:select="selectProduct"/)
|
||||
const componentWxml = fs.readFileSync(path.join(__dirname, '../../components/product-selector-sheet/index.wxml'), 'utf8')
|
||||
const componentWxss = fs.readFileSync(path.join(__dirname, '../../components/product-selector-sheet/index.wxss'), 'utf8')
|
||||
@@ -15,6 +15,8 @@ assert.match(componentWxml, /catchtouchmove="stopEvent"/)
|
||||
assert.match(componentWxml, /bindtap="openManual"/)
|
||||
assert.match(componentWxml, /bindtap="selectItem"/)
|
||||
assert.match(componentWxml, /bindtap="confirmManual"/)
|
||||
assert.match(wxml, /picker-view class="time-wheel"/)
|
||||
assert.match(wxml, /data-mode="grid" bindtap="onTimePickerModeChange"/)
|
||||
assert.match(componentWxss, /\.product-selector-sheet\{[^}]*height:88vh;[^}]*max-height:88vh;/s)
|
||||
assert.match(componentWxss, /.product-selector-scroll{height:0;min-height:0;flex:1}/)
|
||||
assert.match(pageScript, /openManualProduct\(\)\s*\{/)
|
||||
|
||||
@@ -24,20 +24,25 @@ function createPage() {
|
||||
const page = createPage()
|
||||
page.openProductModal()
|
||||
assert.strictEqual(page.data.productModalVisible, true)
|
||||
assert.strictEqual(page.data.productSelectorMode, 'list')
|
||||
page.refreshAvailableTimes = () => {}
|
||||
page.checkAvailability = () => {}
|
||||
page.selectProduct({ detail: { item: { id: 8, title: '法式', price: 238, priceText: '¥238', approximateDuration: '90' } } })
|
||||
assert.strictEqual(page.data.form.productId, 8)
|
||||
assert.strictEqual(page.data.selectedProduct.title, '法式')
|
||||
assert.strictEqual(page.data.selectedProductPriceText, '¥238')
|
||||
assert.strictEqual(page.data.form.amount, '238')
|
||||
assert.strictEqual(page.data.form.manualProductTitle, '')
|
||||
assert.strictEqual(page.data.form.durationMinutes, '90')
|
||||
|
||||
page.data.manualProductDraft = { title: '手绘款', price: '299', description: '', tags: '', targetAudience: '', precautions: '', imageFileIds: '', imageUrl: '' }
|
||||
page.useManualProduct()
|
||||
page.onStyleTitleInput({ detail: { value: '手绘款' } })
|
||||
assert.strictEqual(page.data.form.productId, '')
|
||||
assert.strictEqual(page.data.form.manualProductTitle, '手绘款')
|
||||
assert.strictEqual(page.data.form.manualProductPrice, '299')
|
||||
assert.strictEqual(page.data.selectedProductPriceText, '¥299')
|
||||
assert.strictEqual(page.data.form.amount, '238')
|
||||
assert.strictEqual(page.data.selectedProductPriceText, '')
|
||||
|
||||
const wxml = require('fs').readFileSync(require('path').join(__dirname, 'index.wxml'), 'utf8')
|
||||
assert.ok(wxml.indexOf('美甲款式') < wxml.indexOf('预约信息'))
|
||||
assert.ok(wxml.indexOf('预约信息') < wxml.indexOf('>客户</text>'))
|
||||
assert.match(wxml, /placeholder="款式名称(选填)"/)
|
||||
assert.match(wxml, /成交金额/)
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ async function run() {
|
||||
productId: '41',
|
||||
appointmentDate: '2026-10-13',
|
||||
appointmentTime: '14:00',
|
||||
amount: '120',
|
||||
durationMinutes: '60',
|
||||
artistId: ''
|
||||
})
|
||||
@@ -62,7 +63,32 @@ async function run() {
|
||||
|
||||
assert.strictEqual(submittedPayload.artistId, undefined)
|
||||
assert.strictEqual(submittedPayload.appointmentTime, '14:00')
|
||||
assert.strictEqual(submittedPayload.amount, 120)
|
||||
assert.strictEqual(submittedPayload.createCustomerRecord, false)
|
||||
assert.strictEqual(redirectedTo, '/pages/appointment-detail/index?id=61')
|
||||
|
||||
const walkInPage = createPage()
|
||||
Object.assign(walkInPage.data.form, {
|
||||
productId: '41',
|
||||
appointmentDate: '2026-10-13',
|
||||
appointmentTime: '15:00',
|
||||
amount: '88',
|
||||
durationMinutes: '45',
|
||||
artistId: ''
|
||||
})
|
||||
let walkInPayload
|
||||
planningApi.createAppointment = async payload => {
|
||||
walkInPayload = payload
|
||||
return { orderItemId: 62 }
|
||||
}
|
||||
await walkInPage.submit()
|
||||
|
||||
assert.strictEqual(walkInPayload.customerUserId, undefined)
|
||||
assert.strictEqual(walkInPayload.customerName, undefined)
|
||||
assert.strictEqual(walkInPayload.phone, undefined)
|
||||
assert.strictEqual(walkInPayload.createCustomerRecord, false)
|
||||
assert.strictEqual(walkInPayload.artistId, undefined)
|
||||
assert.strictEqual(walkInPayload.appointmentTime, '15:00')
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user