优化预约内容填写弹窗
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">选择作品</text>
|
||||
<view class="field-value product-value" bindtap="openProductModal">
|
||||
<text>{{form.manualProductTitle || selectedProduct.title || '请选择作品'}}</text>
|
||||
<view class="field-value product-value {{form.customerName ? '' : 'disabled'}}" bindtap="openProductModal">
|
||||
<text>{{form.customerName ? (form.manualProductTitle || selectedProduct.title || '请选择作品') : '请先填写客户姓名'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{form.productId || form.manualProductTitle}}" class="field">
|
||||
@@ -78,7 +78,7 @@
|
||||
</view>
|
||||
<view class="field textarea-field">
|
||||
<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>
|
||||
|
||||
@@ -100,27 +100,25 @@
|
||||
<view wx:if="{{manualProductPanelVisible}}" class="manual-mask" catchtap="stopTap">
|
||||
<view class="manual-sheet" catchtap="stopTap">
|
||||
<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>
|
||||
<view class="manual-grid">
|
||||
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
|
||||
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
|
||||
</view>
|
||||
<input class="manual-input-full" value="{{form.manualProductDescription}}" data-field="manualProductDescription" bindinput="onInput" placeholder="作品描述(选填)" />
|
||||
<view class="manual-grid single">
|
||||
<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 class="manual-field-row">
|
||||
<view class="manual-field">
|
||||
<text class="manual-field-label required-label">名称</text>
|
||||
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
|
||||
</view>
|
||||
<view class="manual-field manual-price-field">
|
||||
<text class="manual-field-label required-label">价格</text>
|
||||
<view class="manual-price-input">
|
||||
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
|
||||
<text>元</text>
|
||||
</view>
|
||||
</picker>
|
||||
<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-head">
|
||||
<text class="manual-image-title">作品图片</text>
|
||||
<text class="manual-image-title required-label">作品图片</text>
|
||||
</view>
|
||||
<view class="manual-image-list">
|
||||
<view wx:for="{{manualProductImageUrls}}" wx:for-item="imageUrl" wx:key="*this" class="manual-image-item">
|
||||
@@ -132,8 +130,24 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<button class="secondary-btn manual-btn" bindtap="useManualProduct">保存内容</button>
|
||||
<button class="secondary-btn template-entry-btn" bindtap="openProductTemplateSheet">使用已有作品模板</button>
|
||||
<view class="manual-field manual-field-full">
|
||||
<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>
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user