对齐新增预约页面演示稿设计

This commit is contained in:
2026-10-20 15:50:29 +08:00
parent c952a913e8
commit 274c6af30b
9 changed files with 723 additions and 34 deletions
@@ -376,6 +376,26 @@ function buildArtistSelectorItem(artist) {
}
}
function buildAppointmentDateLabels(value) {
const dateValue = String(value || dateUtil.formatDate(new Date()))
const date = new Date(dateValue.replace(/-/g, '/'))
if (Number.isNaN(date.getTime())) {
return { day: '', badge: dateValue, long: dateValue }
}
const today = dateUtil.formatDate(new Date())
const tomorrow = dateUtil.formatDate(dateUtil.addDays(new Date(), 1))
const dayLabel = dateValue === today
? '今天'
: dateValue === tomorrow
? '明天'
: `周${'日一二三四五六'[date.getDay()]}`
return {
day: dayLabel,
badge: `${dayLabel} · ${dateUtil.formatCnDate(dateValue)}`,
long: `${dayLabel} · ${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`
}
}
Page({
data: {
form: {
@@ -419,6 +439,7 @@ Page({
selectedProductPriceText: '',
selectedArtist: {},
productModalVisible: false,
manualProductSheetVisible: false,
productKeyword: '',
productError: '',
loadingProducts: false,
@@ -439,6 +460,9 @@ Page({
timeLoading: false,
timeError: '',
timeSelectTip: '请先选择美甲师并填写时长',
appointmentDayLabel: '',
appointmentDateBadge: '',
appointmentDateLong: '',
availableTimeGroups: [],
loading: false
},
@@ -447,6 +471,8 @@ Page({
const creatable = canCreateAppointment()
const draftForm = creatable && !hasPresetOptions(options) ? readDraftForm() : null
const baseForm = draftForm || {}
const appointmentDate = options.date || baseForm.appointmentDate || dateUtil.formatDate(new Date())
const dateLabels = buildAppointmentDateLabels(appointmentDate)
this.setData({
canCreateAppointment: creatable,
form: {
@@ -454,10 +480,13 @@ Page({
...baseForm,
customerName: options.customerName ? decodeURIComponent(options.customerName) : (baseForm.customerName || ''),
phone: options.phone ? decodeURIComponent(options.phone) : (baseForm.phone || ''),
appointmentDate: options.date || baseForm.appointmentDate || dateUtil.formatDate(new Date()),
appointmentDate,
artistId: options.artistId || baseForm.artistId || ''
},
draftSavedAtText: draftForm ? '已恢复本机草稿' : ''
draftSavedAtText: draftForm ? '已恢复本机草稿' : '',
appointmentDayLabel: dateLabels.day,
appointmentDateBadge: dateLabels.badge,
appointmentDateLong: dateLabels.long
})
if (!creatable) {
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
@@ -756,9 +785,13 @@ Page({
}
return
}
const dateLabels = buildAppointmentDateLabels(nextDate)
this.setData({
'form.appointmentDate': nextDate,
'form.appointmentTime': ''
'form.appointmentTime': '',
appointmentDayLabel: dateLabels.day,
appointmentDateBadge: dateLabels.badge,
appointmentDateLong: dateLabels.long
})
await this.loadArtists()
await this.refreshAvailableTimes()
@@ -779,7 +812,7 @@ Page({
openProductModal() {
this.refreshProductCards()
this.setData({ productModalVisible: true })
this.setData({ productModalVisible: true, manualProductSheetVisible: false })
},
closeProductModal() {
@@ -789,9 +822,31 @@ Page({
openManualProduct() {
this.setData({
productModalVisible: false,
manualProductSheetVisible: true
})
},
closeManualProduct() {
this.setData({ manualProductSheetVisible: false })
},
confirmManualProduct() {
const hasTitle = Boolean(String(this.data.form.manualProductTitle || '').trim())
const hasImage = Boolean(String(this.data.form.manualProductImageFileIds || '').trim())
const hasFallbackName = Boolean(String(this.data.form.customerName || '').trim())
if (this.data.form.productId && !hasTitle && !hasImage) {
this.closeManualProduct()
return
}
if (!hasTitle && !hasImage && !hasFallbackName) {
wx.showToast({ title: '请填写款式名称或添加图片', icon: 'none' })
return
}
this.setData({
'form.productId': '',
selectedProduct: {},
selectedProductPriceText: '',
'form.productId': ''
manualProductSheetVisible: false
})
},
@@ -813,6 +868,14 @@ Page({
selectedProduct,
selectedProductPriceText: selectedProduct.priceText || '',
'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 || '')
})