优化店务小程序预约作品价格交互
This commit is contained in:
@@ -233,6 +233,17 @@ function splitManualImageValues(value) {
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function formatProductPrice(value) {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
return ''
|
||||
}
|
||||
const price = Number(value)
|
||||
if (!Number.isFinite(price) || price < 0) {
|
||||
return ''
|
||||
}
|
||||
return String(price)
|
||||
}
|
||||
|
||||
function isScheduleCoveringTime(schedule, form, startMinute, endMinute) {
|
||||
if (!schedule || String(schedule.artistId) !== String(form.artistId) || schedule.date !== form.appointmentDate) {
|
||||
return false
|
||||
@@ -270,7 +281,6 @@ Page({
|
||||
manualProductPrice: '',
|
||||
manualProductDescription: '',
|
||||
manualProductTags: '',
|
||||
manualProductTargetAudience: '',
|
||||
manualProductPrecautions: '',
|
||||
manualProductImageFileIds: '',
|
||||
manualProductImageUrl: '',
|
||||
@@ -391,10 +401,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
onToggleChange(event) {
|
||||
toggleFlag(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
[`form.${field}`]: !!event.detail.value
|
||||
[`form.${field}`]: !this.data.form[field]
|
||||
})
|
||||
},
|
||||
|
||||
@@ -523,14 +533,14 @@ Page({
|
||||
|
||||
selectProduct(event) {
|
||||
const selectedProduct = this.data.filteredProducts.find(item => String(item.id) === String(event.currentTarget.dataset.id)) || {}
|
||||
const price = formatProductPrice(selectedProduct.price)
|
||||
this.setData({
|
||||
selectedProduct,
|
||||
'form.productId': selectedProduct.id,
|
||||
'form.manualProductTitle': '',
|
||||
'form.manualProductPrice': '',
|
||||
'form.manualProductPrice': price,
|
||||
'form.manualProductDescription': '',
|
||||
'form.manualProductTags': '',
|
||||
'form.manualProductTargetAudience': '',
|
||||
'form.manualProductPrecautions': '',
|
||||
'form.manualProductImageFileIds': '',
|
||||
'form.manualProductImageUrl': '',
|
||||
@@ -801,6 +811,11 @@ Page({
|
||||
wx.showToast({ title: '请补全预约信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const appointmentPrice = Number(form.manualProductPrice)
|
||||
if (!Number.isFinite(appointmentPrice) || appointmentPrice < 0) {
|
||||
wx.showToast({ title: '请填写本次价格', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!durationMinutes) {
|
||||
wx.showToast({ title: '请填写预约时长', icon: 'none' })
|
||||
return
|
||||
@@ -827,14 +842,13 @@ Page({
|
||||
if (form.productId) {
|
||||
payload.productId = String(form.productId)
|
||||
payload.manualProductTitle = undefined
|
||||
payload.manualProductPrice = undefined
|
||||
payload.manualProductPrice = appointmentPrice
|
||||
} else {
|
||||
payload.productId = undefined
|
||||
payload.manualProductTitle = String(form.manualProductTitle || '').trim()
|
||||
payload.manualProductPrice = Number(form.manualProductPrice)
|
||||
payload.manualProductPrice = appointmentPrice
|
||||
payload.manualProductDescription = String(form.manualProductDescription || '').trim() || undefined
|
||||
payload.manualProductTags = String(form.manualProductTags || '').trim() || undefined
|
||||
payload.manualProductTargetAudience = String(form.manualProductTargetAudience || '').trim() || undefined
|
||||
payload.manualProductPrecautions = String(form.manualProductPrecautions || '').trim() || undefined
|
||||
payload.manualProductImageFileIds = String(form.manualProductImageFileIds || '').trim() || undefined
|
||||
}
|
||||
|
||||
@@ -37,6 +37,11 @@
|
||||
<text wx:if="{{form.manualProductTitle && !form.productId}}" class="manual-badge">手动</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{form.productId || form.manualProductTitle}}" class="field">
|
||||
<text class="field-label required">本次价格</text>
|
||||
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="可按本次预约修改" />
|
||||
<text class="unit">元</text>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">预计时长</text>
|
||||
<input value="{{form.durationMinutes}}" data-field="durationMinutes" bindinput="onInput" type="number" placeholder="请输入预约时长" />
|
||||
@@ -59,23 +64,17 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="appointment-flags">
|
||||
<view class="field toggle-field">
|
||||
<view class="toggle-copy">
|
||||
<text class="field-label">是否交定金</text>
|
||||
</view>
|
||||
<switch checked="{{form.depositPaid}}" color="#6f8f83" data-field="depositPaid" bindchange="onToggleChange" />
|
||||
<view class="flag-card {{form.depositPaid ? 'active' : ''}}" data-field="depositPaid" bindtap="toggleFlag">
|
||||
<view class="flag-check">{{form.depositPaid ? '✓' : ''}}</view>
|
||||
<text>交定金</text>
|
||||
</view>
|
||||
<view class="field toggle-field">
|
||||
<view class="toggle-copy">
|
||||
<text class="field-label">是否需要卸甲</text>
|
||||
</view>
|
||||
<switch checked="{{form.needRemoval}}" color="#6f8f83" data-field="needRemoval" bindchange="onToggleChange" />
|
||||
<view class="flag-card {{form.needRemoval ? 'active' : ''}}" data-field="needRemoval" bindtap="toggleFlag">
|
||||
<view class="flag-check">{{form.needRemoval ? '✓' : ''}}</view>
|
||||
<text>需卸甲</text>
|
||||
</view>
|
||||
<view class="field toggle-field">
|
||||
<view class="toggle-copy">
|
||||
<text class="field-label">是否来自美团</text>
|
||||
</view>
|
||||
<switch checked="{{form.fromMeituan}}" color="#6f8f83" data-field="fromMeituan" bindchange="onToggleChange" />
|
||||
<view class="flag-card {{form.fromMeituan ? 'active' : ''}}" data-field="fromMeituan" bindtap="toggleFlag">
|
||||
<view class="flag-check">{{form.fromMeituan ? '✓' : ''}}</view>
|
||||
<text>美团</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="field textarea-field">
|
||||
@@ -151,7 +150,6 @@
|
||||
<textarea class="manual-textarea" value="{{form.manualProductDescription}}" data-field="manualProductDescription" bindinput="onInput" placeholder="作品描述(选填)" />
|
||||
<view class="manual-grid single">
|
||||
<input value="{{form.manualProductTags}}" data-field="manualProductTags" bindinput="onInput" placeholder="标签,多个用逗号分隔(选填)" />
|
||||
<input value="{{form.manualProductTargetAudience}}" data-field="manualProductTargetAudience" bindinput="onInput" placeholder="适合人群(选填)" />
|
||||
<input value="{{form.manualProductPrecautions}}" data-field="manualProductPrecautions" bindinput="onInput" placeholder="注意事项(选填)" />
|
||||
</view>
|
||||
<view class="manual-image-section">
|
||||
|
||||
@@ -135,22 +135,60 @@
|
||||
}
|
||||
|
||||
.appointment-flags {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14rpx;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 12rpx;
|
||||
margin-top: 4rpx;
|
||||
}
|
||||
|
||||
.toggle-field {
|
||||
.flag-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10rpx;
|
||||
min-width: 0;
|
||||
min-height: 68rpx;
|
||||
padding: 0 12rpx;
|
||||
border: 2rpx solid #eadfd2;
|
||||
border-radius: 16rpx;
|
||||
background: #fffdf8;
|
||||
color: #6d6258;
|
||||
font-size: 24rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.toggle-copy {
|
||||
display: flex;
|
||||
.flag-card.active {
|
||||
border-color: #c9874d;
|
||||
background: #fff2df;
|
||||
color: #9f5f2d;
|
||||
}
|
||||
|
||||
.flag-card text {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
gap: 4rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.flag-check {
|
||||
min-width: 0;
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
border: 2rpx solid #d9cabb;
|
||||
border-radius: 8rpx;
|
||||
color: #fff;
|
||||
font-size: 20rpx;
|
||||
font-weight: 900;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.flag-card.active .flag-check {
|
||||
border-color: #c9874d;
|
||||
background: #c9874d;
|
||||
}
|
||||
|
||||
.capacity-tip {
|
||||
|
||||
Reference in New Issue
Block a user