diff --git a/JY-Salon-WeChat/pages/appointment-form/index.js b/JY-Salon-WeChat/pages/appointment-form/index.js
index 663e5bed..6837d94b 100644
--- a/JY-Salon-WeChat/pages/appointment-form/index.js
+++ b/JY-Salon-WeChat/pages/appointment-form/index.js
@@ -327,6 +327,43 @@ function formatProductPrice(value) {
return String(price)
}
+function sanitizePriceInput(value) {
+ const rawValue = String(value || '')
+ let nextValue = ''
+ let hasDot = false
+ for (let index = 0; index < rawValue.length; index += 1) {
+ const char = rawValue[index]
+ if (char >= '0' && char <= '9') {
+ nextValue += char
+ continue
+ }
+ if (char === '.' && !hasDot) {
+ nextValue += char
+ hasDot = true
+ }
+ }
+ if (nextValue.startsWith('.')) {
+ return `0${nextValue}`
+ }
+ return nextValue
+}
+
+function normalizeConfirmedPrice(value) {
+ const priceText = sanitizePriceInput(value).trim()
+ if (!/^\d+(\.\d+)?$/.test(priceText)) {
+ return ''
+ }
+ const price = Number(priceText)
+ if (!Number.isFinite(price) || price < 0) {
+ return ''
+ }
+ return String(price)
+}
+
+function collectManualProductImages(fileIds, imageUrls) {
+ return splitManualImageValues(`${fileIds || ''},${imageUrls || ''}`)
+}
+
function isScheduleCoveringTime(schedule, form, startMinute, endMinute) {
if (!schedule || String(schedule.artistId) !== String(form.artistId) || schedule.date !== form.appointmentDate) {
return false
@@ -491,8 +528,11 @@ Page({
onInput(event) {
const field = event.currentTarget.dataset.field
+ const value = field === 'manualProductPrice'
+ ? sanitizePriceInput(event.detail.value)
+ : event.detail.value
const patch = {
- [`form.${field}`]: event.detail.value
+ [`form.${field}`]: value
}
if (field === 'customerName' || field === 'phone') {
patch['form.customerUserId'] = ''
@@ -506,6 +546,7 @@ Page({
this.refreshAvailableTimes()
this.checkAvailability()
}
+ return value
},
toggleFlag(event) {
@@ -599,6 +640,11 @@ Page({
},
openProductModal() {
+ const customerName = String(this.data.form.customerName || '').trim()
+ if (!customerName) {
+ wx.showToast({ title: '请先填写客户姓名', icon: 'none' })
+ return
+ }
this.openManualProductPanel()
},
@@ -617,14 +663,26 @@ Page({
},
openManualProductPanel() {
+ const customerName = String(this.data.form.customerName || '').trim()
+ if (!customerName) {
+ wx.showToast({ title: '请先填写客户姓名', icon: 'none' })
+ return
+ }
const imageUrls = this.data.manualProductImageUrls.length > 0
? this.data.manualProductImageUrls
: splitManualImageValues(this.data.form.manualProductImageUrl)
- this.setData({
+ const productTitle = String(this.data.form.manualProductTitle || '').trim()
+ const patch = {
manualProductPanelVisible: true,
productModalVisible: false,
manualProductImageUrls: imageUrls,
tagPickerIndex: resolveTagPickerIndex(this.data.tagOptions, this.data.form.manualProductTags)
+ }
+ if (!productTitle) {
+ patch['form.manualProductTitle'] = customerName
+ }
+ this.setData({
+ ...patch
})
},
@@ -683,16 +741,25 @@ Page({
useManualProduct() {
const title = String(this.data.form.manualProductTitle || '').trim()
- const price = Number(this.data.form.manualProductPrice)
- if (!title || Number.isNaN(price) || price < 0) {
- wx.showToast({ title: '请填写作品名称和价格', icon: 'none' })
+ const priceText = normalizeConfirmedPrice(this.data.form.manualProductPrice)
+ const imageValues = collectManualProductImages(this.data.form.manualProductImageFileIds, this.data.form.manualProductImageUrl)
+ if (!title) {
+ wx.showToast({ title: '请填写作品名称', icon: 'none' })
+ return
+ }
+ if (!priceText) {
+ wx.showToast({ title: '请填写正确的作品价格', icon: 'none' })
+ return
+ }
+ if (imageValues.length === 0) {
+ wx.showToast({ title: '请上传作品图片', icon: 'none' })
return
}
this.setData({
selectedProduct: {},
'form.productId': '',
'form.manualProductTitle': title,
- 'form.manualProductPrice': String(price),
+ 'form.manualProductPrice': priceText,
manualProductPanelVisible: false
})
this.closeProductModal()
@@ -944,11 +1011,17 @@ Page({
wx.showToast({ title: '请补全预约信息', icon: 'none' })
return
}
- const appointmentPrice = Number(form.manualProductPrice)
- if (!Number.isFinite(appointmentPrice) || appointmentPrice < 0) {
+ const appointmentPriceText = normalizeConfirmedPrice(form.manualProductPrice)
+ if (!appointmentPriceText) {
wx.showToast({ title: '请填写本次价格', icon: 'none' })
return
}
+ const appointmentPrice = Number(appointmentPriceText)
+ const manualProductImages = collectManualProductImages(form.manualProductImageFileIds, form.manualProductImageUrl)
+ if (!form.productId && manualProductImages.length === 0) {
+ wx.showToast({ title: '请上传作品图片', icon: 'none' })
+ return
+ }
if (!durationMinutes) {
wx.showToast({ title: '请填写预约时长', icon: 'none' })
return
diff --git a/JY-Salon-WeChat/pages/appointment-form/index.wxml b/JY-Salon-WeChat/pages/appointment-form/index.wxml
index f6d75966..c30a16b6 100644
--- a/JY-Salon-WeChat/pages/appointment-form/index.wxml
+++ b/JY-Salon-WeChat/pages/appointment-form/index.wxml
@@ -32,8 +32,8 @@
选择作品
-
- {{form.manualProductTitle || selectedProduct.title || '请选择作品'}}
+
+ {{form.customerName ? (form.manualProductTitle || selectedProduct.title || '请选择作品') : '请先填写客户姓名'}}
@@ -78,7 +78,7 @@
备注
-
+
@@ -100,27 +100,25 @@
- 选择作品
+ 预约内容填写
×
-
-
-
-
-
-
-
-
- {{form.manualProductTags || (tagOptions.length ? '请选择标签' : '暂无标签')}}
- ›
+
+
+ 名称
+
+
+
+ 价格
+
+
+ 元
-
-
+
- {{tagError}}
- 作品图片
+ 作品图片
@@ -132,8 +130,24 @@
-
-
+
+ 标签
+
+
+ {{form.manualProductTags || (tagOptions.length ? '请选择标签' : '暂无标签')}}
+ ›
+
+
+
+ {{tagError}}
+
+
+
+
+
diff --git a/JY-Salon-WeChat/pages/appointment-form/index.wxss b/JY-Salon-WeChat/pages/appointment-form/index.wxss
index 3a7254fe..1c381ebf 100644
--- a/JY-Salon-WeChat/pages/appointment-form/index.wxss
+++ b/JY-Salon-WeChat/pages/appointment-form/index.wxss
@@ -7,6 +7,10 @@
position: relative;
}
+.customer-select .field {
+ border-bottom: 1rpx solid #eee8df;
+}
+
.customer-dropdown {
position: absolute;
top: 214rpx;
@@ -81,6 +85,11 @@
gap: 12rpx;
}
+.product-value.disabled {
+ color: #aaa096;
+ opacity: 0.72;
+}
+
.time-value {
display: flex;
align-items: center;
@@ -134,6 +143,12 @@
align-self: center;
}
+.textarea-field textarea {
+ min-height: 44rpx;
+ padding: 32rpx 0;
+ line-height: 44rpx;
+}
+
.appointment-flags {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
@@ -592,10 +607,10 @@
}
.template-entry-btn {
- width: 100%;
+ width: auto;
min-width: 0;
- max-width: 100%;
- margin-top: 16rpx;
+ max-width: none;
+ margin-top: 0;
}
.manual-mask {
@@ -620,17 +635,24 @@
}
.manual-sheet-head {
+ position: relative;
display: flex;
align-items: center;
- justify-content: space-between;
+ justify-content: center;
gap: 18rpx;
margin-bottom: 20rpx;
}
+.manual-sheet-head .modal-close {
+ position: absolute;
+ right: 0;
+}
+
.manual-sheet-title {
color: #27211d;
font-size: 34rpx;
font-weight: 900;
+ text-align: center;
}
.manual-sheet-subtitle {
@@ -667,6 +689,74 @@
font-size: 26rpx;
}
+.manual-field-row {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) 200rpx;
+ gap: 14rpx;
+}
+
+.manual-field {
+ min-width: 0;
+}
+
+.manual-field-full {
+ margin-top: 14rpx;
+}
+
+.manual-field-label {
+ display: block;
+ margin-bottom: 10rpx;
+ color: #4e4740;
+ font-size: 24rpx;
+ font-weight: 900;
+}
+
+.manual-field input,
+.manual-remark-field textarea {
+ width: 100%;
+ min-height: 70rpx;
+ padding: 0 18rpx;
+ border-radius: 14rpx;
+ background: #fffaf4;
+ color: #302923;
+ font-size: 26rpx;
+}
+
+.manual-price-input {
+ display: flex;
+ align-items: center;
+ height: 70rpx;
+ padding-right: 16rpx;
+ border-radius: 14rpx;
+ background: #fffaf4;
+}
+
+.manual-price-input input {
+ flex: 1;
+ width: auto;
+ min-width: 0;
+ padding-right: 8rpx;
+ background: transparent;
+}
+
+.manual-price-input text {
+ flex: 0 0 auto;
+ color: #9a9288;
+ font-size: 22rpx;
+}
+
+.manual-field picker {
+ display: block;
+ width: 100%;
+}
+
+.manual-remark-field textarea {
+ min-height: 70rpx;
+ padding-top: 16rpx;
+ padding-bottom: 16rpx;
+ line-height: 38rpx;
+}
+
.manual-input-full {
width: 100%;
height: 70rpx;
@@ -826,7 +916,20 @@
}
.manual-btn {
- margin-top: 16rpx;
+ margin-top: 0;
+}
+
+.manual-action-row {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
+ gap: 14rpx;
+ margin-top: 18rpx;
+}
+
+.manual-action-row .secondary-btn,
+.manual-action-row .primary-btn {
+ min-width: 0;
+ max-width: none;
}
.action-row {