diff --git a/JC-Salon-WeChat/pages/appointment-form/history-date.test.js b/JC-Salon-WeChat/pages/appointment-form/history-date.test.js index 0162c849..e489b5e4 100644 --- a/JC-Salon-WeChat/pages/appointment-form/history-date.test.js +++ b/JC-Salon-WeChat/pages/appointment-form/history-date.test.js @@ -64,6 +64,8 @@ async function run() { await page.onDateChange({ detail: { value: '2099-10-11' } }) assert.strictEqual(page.data.form.appointmentDate, '2099-10-11') assert.strictEqual(page.data.form.appointmentTime, '') + assert.strictEqual(page.data.appointmentDateBadge.includes('10月11日'), true) + assert.strictEqual(page.data.appointmentDateLong.includes('2099年10月11日'), true) assert.strictEqual(refreshes, 3) } diff --git a/JC-Salon-WeChat/pages/appointment-form/index.js b/JC-Salon-WeChat/pages/appointment-form/index.js index a53209fc..37f8f6e5 100644 --- a/JC-Salon-WeChat/pages/appointment-form/index.js +++ b/JC-Salon-WeChat/pages/appointment-form/index.js @@ -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 || '') }) diff --git a/JC-Salon-WeChat/pages/appointment-form/index.json b/JC-Salon-WeChat/pages/appointment-form/index.json index 263a301f..28a971f8 100644 --- a/JC-Salon-WeChat/pages/appointment-form/index.json +++ b/JC-Salon-WeChat/pages/appointment-form/index.json @@ -1,5 +1,5 @@ { - "navigationBarTitleText": "新建预约", + "navigationBarTitleText": "新增预约", "usingComponents": { "entity-selector-sheet": "/components/entity-selector-sheet/index", "product-selector-sheet": "/components/product-selector-sheet/index" diff --git a/JC-Salon-WeChat/pages/appointment-form/index.wxml b/JC-Salon-WeChat/pages/appointment-form/index.wxml index 4420cff7..2a7226b1 100644 --- a/JC-Salon-WeChat/pages/appointment-form/index.wxml +++ b/JC-Salon-WeChat/pages/appointment-form/index.wxml @@ -1,52 +1,104 @@ + + + NEW APPOINTMENT + 安排一场美甲 + + ◷{{appointmentDateBadge}} + + - 美甲款式手动输入为主,也可快速选择已有款式 - + 美甲款式* + - + + + ✦ {{selectedProduct.title}}参考价 {{selectedProductPriceText || '待定'}} · {{selectedProduct.durationText || '时长待定'}} - - - - - - - - - + - 成交金额元 - 预计时长分钟 + + - 款式备注