优化预约内容填写弹窗
This commit is contained in:
@@ -327,6 +327,43 @@ function formatProductPrice(value) {
|
|||||||
return String(price)
|
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) {
|
function isScheduleCoveringTime(schedule, form, startMinute, endMinute) {
|
||||||
if (!schedule || String(schedule.artistId) !== String(form.artistId) || schedule.date !== form.appointmentDate) {
|
if (!schedule || String(schedule.artistId) !== String(form.artistId) || schedule.date !== form.appointmentDate) {
|
||||||
return false
|
return false
|
||||||
@@ -491,8 +528,11 @@ Page({
|
|||||||
|
|
||||||
onInput(event) {
|
onInput(event) {
|
||||||
const field = event.currentTarget.dataset.field
|
const field = event.currentTarget.dataset.field
|
||||||
|
const value = field === 'manualProductPrice'
|
||||||
|
? sanitizePriceInput(event.detail.value)
|
||||||
|
: event.detail.value
|
||||||
const patch = {
|
const patch = {
|
||||||
[`form.${field}`]: event.detail.value
|
[`form.${field}`]: value
|
||||||
}
|
}
|
||||||
if (field === 'customerName' || field === 'phone') {
|
if (field === 'customerName' || field === 'phone') {
|
||||||
patch['form.customerUserId'] = ''
|
patch['form.customerUserId'] = ''
|
||||||
@@ -506,6 +546,7 @@ Page({
|
|||||||
this.refreshAvailableTimes()
|
this.refreshAvailableTimes()
|
||||||
this.checkAvailability()
|
this.checkAvailability()
|
||||||
}
|
}
|
||||||
|
return value
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleFlag(event) {
|
toggleFlag(event) {
|
||||||
@@ -599,6 +640,11 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
openProductModal() {
|
openProductModal() {
|
||||||
|
const customerName = String(this.data.form.customerName || '').trim()
|
||||||
|
if (!customerName) {
|
||||||
|
wx.showToast({ title: '请先填写客户姓名', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
this.openManualProductPanel()
|
this.openManualProductPanel()
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -617,14 +663,26 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
openManualProductPanel() {
|
openManualProductPanel() {
|
||||||
|
const customerName = String(this.data.form.customerName || '').trim()
|
||||||
|
if (!customerName) {
|
||||||
|
wx.showToast({ title: '请先填写客户姓名', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
const imageUrls = this.data.manualProductImageUrls.length > 0
|
const imageUrls = this.data.manualProductImageUrls.length > 0
|
||||||
? this.data.manualProductImageUrls
|
? this.data.manualProductImageUrls
|
||||||
: splitManualImageValues(this.data.form.manualProductImageUrl)
|
: splitManualImageValues(this.data.form.manualProductImageUrl)
|
||||||
this.setData({
|
const productTitle = String(this.data.form.manualProductTitle || '').trim()
|
||||||
|
const patch = {
|
||||||
manualProductPanelVisible: true,
|
manualProductPanelVisible: true,
|
||||||
productModalVisible: false,
|
productModalVisible: false,
|
||||||
manualProductImageUrls: imageUrls,
|
manualProductImageUrls: imageUrls,
|
||||||
tagPickerIndex: resolveTagPickerIndex(this.data.tagOptions, this.data.form.manualProductTags)
|
tagPickerIndex: resolveTagPickerIndex(this.data.tagOptions, this.data.form.manualProductTags)
|
||||||
|
}
|
||||||
|
if (!productTitle) {
|
||||||
|
patch['form.manualProductTitle'] = customerName
|
||||||
|
}
|
||||||
|
this.setData({
|
||||||
|
...patch
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -683,16 +741,25 @@ Page({
|
|||||||
|
|
||||||
useManualProduct() {
|
useManualProduct() {
|
||||||
const title = String(this.data.form.manualProductTitle || '').trim()
|
const title = String(this.data.form.manualProductTitle || '').trim()
|
||||||
const price = Number(this.data.form.manualProductPrice)
|
const priceText = normalizeConfirmedPrice(this.data.form.manualProductPrice)
|
||||||
if (!title || Number.isNaN(price) || price < 0) {
|
const imageValues = collectManualProductImages(this.data.form.manualProductImageFileIds, this.data.form.manualProductImageUrl)
|
||||||
wx.showToast({ title: '请填写作品名称和价格', icon: 'none' })
|
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
|
return
|
||||||
}
|
}
|
||||||
this.setData({
|
this.setData({
|
||||||
selectedProduct: {},
|
selectedProduct: {},
|
||||||
'form.productId': '',
|
'form.productId': '',
|
||||||
'form.manualProductTitle': title,
|
'form.manualProductTitle': title,
|
||||||
'form.manualProductPrice': String(price),
|
'form.manualProductPrice': priceText,
|
||||||
manualProductPanelVisible: false
|
manualProductPanelVisible: false
|
||||||
})
|
})
|
||||||
this.closeProductModal()
|
this.closeProductModal()
|
||||||
@@ -944,11 +1011,17 @@ Page({
|
|||||||
wx.showToast({ title: '请补全预约信息', icon: 'none' })
|
wx.showToast({ title: '请补全预约信息', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const appointmentPrice = Number(form.manualProductPrice)
|
const appointmentPriceText = normalizeConfirmedPrice(form.manualProductPrice)
|
||||||
if (!Number.isFinite(appointmentPrice) || appointmentPrice < 0) {
|
if (!appointmentPriceText) {
|
||||||
wx.showToast({ title: '请填写本次价格', icon: 'none' })
|
wx.showToast({ title: '请填写本次价格', icon: 'none' })
|
||||||
return
|
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) {
|
if (!durationMinutes) {
|
||||||
wx.showToast({ title: '请填写预约时长', icon: 'none' })
|
wx.showToast({ title: '请填写预约时长', icon: 'none' })
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -32,8 +32,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="field">
|
<view class="field">
|
||||||
<text class="field-label required">选择作品</text>
|
<text class="field-label required">选择作品</text>
|
||||||
<view class="field-value product-value" bindtap="openProductModal">
|
<view class="field-value product-value {{form.customerName ? '' : 'disabled'}}" bindtap="openProductModal">
|
||||||
<text>{{form.manualProductTitle || selectedProduct.title || '请选择作品'}}</text>
|
<text>{{form.customerName ? (form.manualProductTitle || selectedProduct.title || '请选择作品') : '请先填写客户姓名'}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view wx:if="{{form.productId || form.manualProductTitle}}" class="field">
|
<view wx:if="{{form.productId || form.manualProductTitle}}" class="field">
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="field textarea-field">
|
<view class="field textarea-field">
|
||||||
<text class="field-label">备注</text>
|
<text class="field-label">备注</text>
|
||||||
<textarea value="{{form.remark}}" data-field="remark" bindinput="onInput" placeholder="客户偏好、款式说明" />
|
<textarea value="{{form.remark}}" data-field="remark" bindinput="onInput" auto-height placeholder="客户偏好、款式说明" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -100,27 +100,25 @@
|
|||||||
<view wx:if="{{manualProductPanelVisible}}" class="manual-mask" catchtap="stopTap">
|
<view wx:if="{{manualProductPanelVisible}}" class="manual-mask" catchtap="stopTap">
|
||||||
<view class="manual-sheet" catchtap="stopTap">
|
<view class="manual-sheet" catchtap="stopTap">
|
||||||
<view class="manual-sheet-head">
|
<view class="manual-sheet-head">
|
||||||
<text class="manual-sheet-title">选择作品</text>
|
<text class="manual-sheet-title">预约内容填写</text>
|
||||||
<view class="modal-close" bindtap="closeManualProductPanel">×</view>
|
<view class="modal-close" bindtap="closeManualProductPanel">×</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="manual-grid">
|
<view class="manual-field-row">
|
||||||
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
|
<view class="manual-field">
|
||||||
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
|
<text class="manual-field-label required-label">名称</text>
|
||||||
</view>
|
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
|
||||||
<input class="manual-input-full" value="{{form.manualProductDescription}}" data-field="manualProductDescription" bindinput="onInput" placeholder="作品描述(选填)" />
|
</view>
|
||||||
<view class="manual-grid single">
|
<view class="manual-field manual-price-field">
|
||||||
<picker range="{{tagOptions}}" range-key="name" value="{{tagPickerIndex}}" bindchange="onManualTagChange" disabled="{{tagOptions.length === 0}}">
|
<text class="manual-field-label required-label">价格</text>
|
||||||
<view class="manual-picker {{form.manualProductTags ? '' : 'placeholder'}}">
|
<view class="manual-price-input">
|
||||||
<text>{{form.manualProductTags || (tagOptions.length ? '请选择标签' : '暂无标签')}}</text>
|
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
|
||||||
<text class="manual-picker-arrow">›</text>
|
<text>元</text>
|
||||||
</view>
|
</view>
|
||||||
</picker>
|
</view>
|
||||||
<input value="{{form.manualProductPrecautions}}" data-field="manualProductPrecautions" bindinput="onInput" placeholder="注意事项(选填)" />
|
|
||||||
</view>
|
</view>
|
||||||
<view wx:if="{{tagError}}" class="manual-tag-error">{{tagError}}</view>
|
|
||||||
<view class="manual-image-section">
|
<view class="manual-image-section">
|
||||||
<view class="manual-image-head">
|
<view class="manual-image-head">
|
||||||
<text class="manual-image-title">作品图片</text>
|
<text class="manual-image-title required-label">作品图片</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="manual-image-list">
|
<view class="manual-image-list">
|
||||||
<view wx:for="{{manualProductImageUrls}}" wx:for-item="imageUrl" wx:key="*this" class="manual-image-item">
|
<view wx:for="{{manualProductImageUrls}}" wx:for-item="imageUrl" wx:key="*this" class="manual-image-item">
|
||||||
@@ -132,8 +130,24 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<button class="secondary-btn manual-btn" bindtap="useManualProduct">保存内容</button>
|
<view class="manual-field manual-field-full">
|
||||||
<button class="secondary-btn template-entry-btn" bindtap="openProductTemplateSheet">使用已有作品模板</button>
|
<text class="manual-field-label">标签</text>
|
||||||
|
<picker range="{{tagOptions}}" range-key="name" value="{{tagPickerIndex}}" bindchange="onManualTagChange" disabled="{{tagOptions.length === 0}}">
|
||||||
|
<view class="manual-picker {{form.manualProductTags ? '' : 'placeholder'}}">
|
||||||
|
<text>{{form.manualProductTags || (tagOptions.length ? '请选择标签' : '暂无标签')}}</text>
|
||||||
|
<text class="manual-picker-arrow">›</text>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
<view wx:if="{{tagError}}" class="manual-tag-error">{{tagError}}</view>
|
||||||
|
<view class="manual-field manual-field-full manual-remark-field">
|
||||||
|
<text class="manual-field-label">备注</text>
|
||||||
|
<textarea value="{{form.manualProductPrecautions}}" data-field="manualProductPrecautions" bindinput="onInput" auto-height placeholder="备注(选填)" />
|
||||||
|
</view>
|
||||||
|
<view class="manual-action-row">
|
||||||
|
<button class="secondary-btn template-entry-btn" bindtap="openProductTemplateSheet">作品库</button>
|
||||||
|
<button class="primary-btn manual-btn" bindtap="useManualProduct">确认</button>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.customer-select .field {
|
||||||
|
border-bottom: 1rpx solid #eee8df;
|
||||||
|
}
|
||||||
|
|
||||||
.customer-dropdown {
|
.customer-dropdown {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 214rpx;
|
top: 214rpx;
|
||||||
@@ -81,6 +85,11 @@
|
|||||||
gap: 12rpx;
|
gap: 12rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.product-value.disabled {
|
||||||
|
color: #aaa096;
|
||||||
|
opacity: 0.72;
|
||||||
|
}
|
||||||
|
|
||||||
.time-value {
|
.time-value {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -134,6 +143,12 @@
|
|||||||
align-self: center;
|
align-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.textarea-field textarea {
|
||||||
|
min-height: 44rpx;
|
||||||
|
padding: 32rpx 0;
|
||||||
|
line-height: 44rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.appointment-flags {
|
.appointment-flags {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
@@ -592,10 +607,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.template-entry-btn {
|
.template-entry-btn {
|
||||||
width: 100%;
|
width: auto;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
max-width: 100%;
|
max-width: none;
|
||||||
margin-top: 16rpx;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.manual-mask {
|
.manual-mask {
|
||||||
@@ -620,17 +635,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.manual-sheet-head {
|
.manual-sheet-head {
|
||||||
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: center;
|
||||||
gap: 18rpx;
|
gap: 18rpx;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.manual-sheet-head .modal-close {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.manual-sheet-title {
|
.manual-sheet-title {
|
||||||
color: #27211d;
|
color: #27211d;
|
||||||
font-size: 34rpx;
|
font-size: 34rpx;
|
||||||
font-weight: 900;
|
font-weight: 900;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.manual-sheet-subtitle {
|
.manual-sheet-subtitle {
|
||||||
@@ -667,6 +689,74 @@
|
|||||||
font-size: 26rpx;
|
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 {
|
.manual-input-full {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 70rpx;
|
height: 70rpx;
|
||||||
@@ -826,7 +916,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.manual-btn {
|
.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 {
|
.action-row {
|
||||||
|
|||||||
Reference in New Issue
Block a user