优化店务小程序预约作品交互

This commit is contained in:
2026-07-21 12:09:28 +08:00
parent 75d38dc352
commit 7f9f9e74a6
11 changed files with 627 additions and 88 deletions
+85 -16
View File
@@ -3,7 +3,7 @@ const productsApi = require('../../api/products')
const customersApi = require('../../api/customers')
const dateUtil = require('../../utils/date')
const { markPlanningRefresh } = require('../../utils/planning-refresh')
const { chooseImageFilePath, uploadObjectFile } = require('../../utils/upload')
const { chooseImageFilePaths, uploadObjectFile } = require('../../utils/upload')
const DRAFT_STORAGE_PREFIX = 'managerAppointmentDraft'
const TIME_SLOT_MINUTES = 15
@@ -226,6 +226,13 @@ function normalizeProduct(product, artists) {
}
}
function splitManualImageValues(value) {
return String(value || '')
.split(',')
.map(item => item.trim())
.filter(Boolean)
}
function isScheduleCoveringTime(schedule, form, startMinute, endMinute) {
if (!schedule || String(schedule.artistId) !== String(form.artistId) || schedule.date !== form.appointmentDate) {
return false
@@ -284,6 +291,8 @@ Page({
selectedProduct: {},
selectedArtist: {},
productModalVisible: false,
manualProductPanelVisible: false,
manualProductImageUrls: [],
productKeyword: '',
productError: '',
conflictTip: '',
@@ -313,6 +322,7 @@ Page({
appointmentDate: options.date || baseForm.appointmentDate || dateUtil.formatDate(new Date()),
artistId: options.artistId || baseForm.artistId || ''
},
manualProductImageUrls: splitManualImageValues(baseForm.manualProductImageUrl || ''),
draftSavedAtText: draftForm ? '已恢复本机草稿' : ''
})
if (!creatable) {
@@ -473,11 +483,34 @@ Page({
openProductModal() {
this.refreshProductCards()
this.setData({ productModalVisible: true })
this.setData({
productModalVisible: true,
manualProductPanelVisible: false
})
},
closeProductModal() {
this.setData({ productModalVisible: false })
this.setData({
productModalVisible: false,
manualProductPanelVisible: false
})
},
openManualProductPanel() {
const imageUrls = this.data.manualProductImageUrls.length > 0
? this.data.manualProductImageUrls
: splitManualImageValues(this.data.form.manualProductImageUrl)
this.setData({
manualProductPanelVisible: true,
manualProductImageUrls: imageUrls
})
},
closeManualProductPanel() {
if (this.data.manualImageUploading) {
return
}
this.setData({ manualProductPanelVisible: false })
},
stopTap() {
@@ -501,6 +534,8 @@ Page({
'form.manualProductPrecautions': '',
'form.manualProductImageFileIds': '',
'form.manualProductImageUrl': '',
manualProductImageUrls: [],
manualProductPanelVisible: false,
'form.durationMinutes': String(parseInt(selectedProduct.approximateDuration, 10) || this.data.form.durationMinutes || '')
})
this.closeProductModal()
@@ -519,7 +554,8 @@ Page({
selectedProduct: {},
'form.productId': '',
'form.manualProductTitle': title,
'form.manualProductPrice': String(price)
'form.manualProductPrice': String(price),
manualProductPanelVisible: false
})
this.closeProductModal()
this.refreshAvailableTimes()
@@ -530,21 +566,38 @@ Page({
if (this.data.manualImageUploading) {
return
}
const currentFileIds = splitManualImageValues(this.data.form.manualProductImageFileIds)
const currentImageUrls = this.data.manualProductImageUrls.length > 0
? this.data.manualProductImageUrls
: splitManualImageValues(this.data.form.manualProductImageUrl)
const remainingCount = 9 - currentFileIds.length
if (remainingCount <= 0) {
wx.showToast({ title: '最多上传 9 张作品图片', icon: 'none' })
return
}
try {
const filePath = await chooseImageFilePath()
if (!filePath) {
const filePaths = await chooseImageFilePaths(remainingCount)
if (filePaths.length === 0) {
return
}
this.setData({ manualImageUploading: true })
const uploadResult = await uploadObjectFile(filePath)
const fileId = uploadResult.id || uploadResult.fileId
const fileUrl = uploadResult.fileUrl || uploadResult.primaryUrl || filePath
if (!fileId) {
throw new Error('作品图片上传成功但未返回文件ID')
const nextFileIds = currentFileIds.slice()
const nextImageUrls = currentImageUrls.slice()
for (let index = 0; index < filePaths.length; index += 1) {
const filePath = filePaths[index]
const uploadResult = await uploadObjectFile(filePath)
const fileId = uploadResult.id || uploadResult.fileId
const fileUrl = uploadResult.fileUrl || uploadResult.primaryUrl || filePath
if (!fileId) {
throw new Error('作品图片上传成功但未返回文件ID')
}
nextFileIds.push(String(fileId))
nextImageUrls.push(fileUrl)
}
this.setData({
'form.manualProductImageFileIds': String(fileId),
'form.manualProductImageUrl': fileUrl
'form.manualProductImageFileIds': nextFileIds.join(','),
'form.manualProductImageUrl': nextImageUrls.join(','),
manualProductImageUrls: nextImageUrls
})
} catch (error) {
wx.showToast({ title: error.message || '图片上传失败', icon: 'none' })
@@ -553,10 +606,26 @@ Page({
}
},
removeManualProductImage() {
removeManualProductImage(event) {
const currentFileIds = splitManualImageValues(this.data.form.manualProductImageFileIds)
const currentImageUrls = this.data.manualProductImageUrls.length > 0
? this.data.manualProductImageUrls
: splitManualImageValues(this.data.form.manualProductImageUrl)
const index = Number(event.currentTarget.dataset.index)
if (!Number.isInteger(index) || index < 0) {
this.setData({
'form.manualProductImageFileIds': '',
'form.manualProductImageUrl': '',
manualProductImageUrls: []
})
return
}
const nextFileIds = currentFileIds.filter((item, itemIndex) => itemIndex !== index)
const nextImageUrls = currentImageUrls.filter((item, itemIndex) => itemIndex !== index)
this.setData({
'form.manualProductImageFileIds': '',
'form.manualProductImageUrl': ''
'form.manualProductImageFileIds': nextFileIds.join(','),
'form.manualProductImageUrl': nextImageUrls.join(','),
manualProductImageUrls: nextImageUrls
})
},
@@ -126,7 +126,23 @@
</view>
<view wx:if="{{!productError && filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
</scroll-view>
<view class="manual-panel">
<view class="manual-entry-card">
<view>
<text class="manual-entry-title">没有合适作品?</text>
<text class="manual-entry-desc">临时新增一个预约作品,提交时会一并保存到预约信息。</text>
</view>
<button class="secondary-btn manual-entry-btn" bindtap="openManualProductPanel">新增作品</button>
</view>
</view>
<view wx:if="{{manualProductPanelVisible}}" class="manual-mask" catchtap="stopTap">
<view class="manual-sheet" catchtap="stopTap">
<view class="manual-sheet-head">
<view>
<text class="manual-sheet-title">新增预约作品</text>
<text class="manual-sheet-subtitle">填写本次预约使用的作品信息</text>
</view>
<view class="modal-close" bindtap="closeManualProductPanel">×</view>
</view>
<text class="manual-title required-label">手动新增预约作品</text>
<view class="manual-grid">
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
@@ -138,13 +154,21 @@
<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-row">
<image wx:if="{{form.manualProductImageUrl}}" class="manual-image" src="{{form.manualProductImageUrl}}" mode="aspectFill"></image>
<view wx:else class="manual-image placeholder">图</view>
<button class="secondary-btn image-btn" loading="{{manualImageUploading}}" bindtap="chooseManualProductImage">上传图片</button>
<button wx:if="{{form.manualProductImageUrl}}" class="text-btn image-remove" bindtap="removeManualProductImage">移除</button>
<view class="manual-image-section">
<view class="manual-image-head">
<text class="manual-image-title">作品图片</text>
<text class="manual-image-desc">支持上传多张图片</text>
</view>
<view class="manual-image-list">
<view wx:for="{{manualProductImageUrls}}" wx:for-item="imageUrl" wx:key="*this" class="manual-image-item">
<image class="manual-image" src="{{imageUrl}}" mode="aspectFill"></image>
<view class="manual-image-remove" data-index="{{index}}" catchtap="removeManualProductImage">×</view>
</view>
<view wx:if="{{manualProductImageUrls.length === 0}}" class="manual-image-empty">图</view>
</view>
<button class="secondary-btn image-btn" loading="{{manualImageUploading}}" disabled="{{manualImageUploading}}" bindtap="chooseManualProductImage">上传图片</button>
</view>
<button class="secondary-btn manual-btn" bindtap="useManualProduct">使用手动预约作品</button>
<button class="secondary-btn manual-btn" bindtap="useManualProduct">确认新增</button>
</view>
</view>
</view>
+151 -15
View File
@@ -127,7 +127,11 @@
}
.textarea-field {
align-items: flex-start;
align-items: center;
}
.textarea-field .field-label {
align-self: center;
}
.appointment-flags {
@@ -500,11 +504,86 @@
text-align: center;
}
.manual-panel {
margin-top: 12rpx;
padding: 20rpx;
.manual-entry-card {
display: flex;
align-items: center;
justify-content: space-between;
gap: 18rpx;
margin-top: 18rpx;
padding: 18rpx;
border: 1rpx solid #eadfd2;
border-radius: 18rpx;
background: #fffdf8;
}
.manual-entry-title,
.manual-entry-desc,
.manual-sheet-title,
.manual-sheet-subtitle,
.manual-image-title,
.manual-image-desc {
display: block;
}
.manual-entry-title {
color: #302923;
font-size: 26rpx;
font-weight: 900;
}
.manual-entry-desc {
margin-top: 8rpx;
color: #8c8177;
font-size: 22rpx;
line-height: 1.45;
}
.manual-entry-btn {
flex: 0 0 auto;
width: 196rpx;
min-width: 196rpx;
max-width: 196rpx;
}
.manual-mask {
position: fixed;
inset: 0;
z-index: 90;
display: flex;
align-items: center;
justify-content: center;
padding: 38rpx 28rpx;
background: rgba(18, 15, 12, 0.48);
}
.manual-sheet {
width: 100%;
max-height: 86vh;
overflow-y: auto;
padding: 26rpx 24rpx calc(26rpx + env(safe-area-inset-bottom));
border-radius: 28rpx;
background: #f7efe7;
box-shadow: 0 24rpx 54rpx rgba(41, 31, 23, 0.22);
}
.manual-sheet-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 18rpx;
margin-bottom: 20rpx;
}
.manual-sheet-title {
color: #27211d;
font-size: 34rpx;
font-weight: 900;
}
.manual-sheet-subtitle {
margin-top: 8rpx;
color: #8d8278;
font-size: 23rpx;
}
.manual-title {
@@ -547,37 +626,94 @@
}
.manual-image-row {
display: none;
}
.manual-image-section {
margin-top: 14rpx;
padding: 16rpx;
border-radius: 16rpx;
background: #fffaf4;
}
.manual-image-head {
display: flex;
align-items: center;
gap: 14rpx;
margin-top: 14rpx;
justify-content: space-between;
gap: 12rpx;
margin-bottom: 14rpx;
}
.manual-image-title {
color: #4e4740;
font-size: 24rpx;
font-weight: 900;
}
.manual-image-desc {
color: #958a7f;
font-size: 22rpx;
}
.manual-image-list {
display: flex;
flex-wrap: wrap;
gap: 12rpx;
}
.manual-image {
flex: 0 0 auto;
width: 92rpx;
height: 92rpx;
border-radius: 14rpx;
display: block;
width: 104rpx;
height: 104rpx;
border-radius: 16rpx;
background: #efe5da;
}
.manual-image.placeholder {
.manual-image-item {
position: relative;
width: 104rpx;
height: 104rpx;
}
.manual-image-empty {
display: flex;
align-items: center;
justify-content: center;
width: 104rpx;
height: 104rpx;
border-radius: 16rpx;
background: #efe5da;
color: #b79b82;
font-size: 26rpx;
font-weight: 900;
}
.manual-image-remove {
position: absolute;
top: -10rpx;
right: -10rpx;
display: flex;
align-items: center;
justify-content: center;
width: 34rpx;
height: 34rpx;
border-radius: 50%;
background: #bf4949;
color: #fff;
font-size: 24rpx;
font-weight: 900;
line-height: 34rpx;
}
.image-btn {
flex: 1;
min-width: 0;
max-width: none;
width: 100%;
min-width: 100%;
max-width: 100%;
margin-top: 14rpx;
}
.image-remove {
flex: 0 0 auto;
display: none;
}
.manual-btn {
+17 -11
View File
@@ -7,6 +7,7 @@ Page({
id: '',
employee: {},
loadError: '',
deleteConfirmVisible: false,
deletingEmployee: false
},
@@ -54,21 +55,25 @@ Page({
if (this.data.deletingEmployee) {
return
}
wx.showModal({
title: '删除员工',
content: '确定要删除该员工吗?该操作只移除当前店铺员工关系,不会删除登录账号。',
confirmText: '删除',
confirmColor: '#BF4949',
success: (result) => {
if (result.confirm) {
this.confirmDeleteEmployee()
}
}
})
this.setData({ deleteConfirmVisible: true })
},
closeDeleteConfirm() {
if (this.data.deletingEmployee) {
return
}
this.setData({ deleteConfirmVisible: false })
},
stopTap() {
},
async confirmDeleteEmployee() {
if (this.data.deletingEmployee) {
return
}
if (!this.data.id) {
wx.showToast({ title: '缺少员工 ID,无法删除', icon: 'none' })
return
}
this.setData({ deletingEmployee: true })
@@ -77,6 +82,7 @@ Page({
if (!success) {
throw new Error('员工不存在或已被删除')
}
this.setData({ deleteConfirmVisible: false })
wx.showToast({ title: '员工已删除', icon: 'success' })
setTimeout(() => {
wx.navigateBack()
@@ -40,10 +40,48 @@
</view>
<view wx:if="{{!loadError}}" class="card delete-card">
<view>
<text class="delete-title">删除员工</text>
<text class="delete-desc">删除后该员工会从当前店铺员工列表移除,登录账号仍会保留。</text>
<view class="delete-shell">
<view class="delete-icon">!</view>
<view class="delete-copy">
<view class="delete-title-row">
<text class="delete-title">删除员工</text>
<text class="delete-badge">危险操作</text>
</view>
<text class="delete-desc">只会解除该员工与当前店铺的关系,登录账号和历史订单会继续保留。</text>
</view>
</view>
<view class="delete-facts">
<view class="delete-fact">
<text class="delete-fact-label">员工列表</text>
<text class="delete-fact-value">移除</text>
</view>
<view class="delete-fact">
<text class="delete-fact-label">登录账号</text>
<text class="delete-fact-value">保留</text>
</view>
</view>
<button class="delete-btn" loading="{{deletingEmployee}}" disabled="{{deletingEmployee}}" bindtap="requestDeleteEmployee">删除员工</button>
</view>
<view wx:if="{{deleteConfirmVisible}}" class="delete-confirm-mask" bindtap="closeDeleteConfirm">
<view class="delete-confirm-panel" catchtap="stopTap">
<view class="delete-confirm-icon">!</view>
<text class="delete-confirm-title">确认删除员工</text>
<text class="delete-confirm-desc">删除后该员工会从当前店铺员工列表移除,但登录账号不会被删除。</text>
<view class="delete-confirm-facts">
<view class="delete-confirm-fact">
<text>员工列表</text>
<text>移除</text>
</view>
<view class="delete-confirm-fact">
<text>登录账号</text>
<text>保留</text>
</view>
</view>
<view class="delete-confirm-actions">
<button class="delete-confirm-cancel" disabled="{{deletingEmployee}}" bindtap="closeDeleteConfirm">取消</button>
<button class="delete-confirm-submit" loading="{{deletingEmployee}}" disabled="{{deletingEmployee}}" bindtap="confirmDeleteEmployee">确认删除</button>
</view>
</view>
<button class="delete-btn" loading="{{deletingEmployee}}" bindtap="requestDeleteEmployee">删除员工</button>
</view>
</view>
+242 -13
View File
@@ -85,16 +85,54 @@
}
.delete-card {
margin-top: 24rpx;
padding: 28rpx;
border-color: rgba(191, 73, 73, 0.18);
background: linear-gradient(180deg, #fffdf8 0%, #fff5f2 100%);
}
.delete-shell {
display: flex;
align-items: flex-start;
gap: 18rpx;
}
.delete-icon,
.delete-confirm-icon {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20rpx;
margin-top: 24rpx;
padding: 24rpx;
justify-content: center;
flex: 0 0 auto;
width: 54rpx;
height: 54rpx;
border: 1rpx solid rgba(191, 73, 73, 0.2);
border-radius: 50%;
background: #fff0f0;
color: #bf4949;
font-size: 32rpx;
font-weight: 900;
line-height: 1;
}
.delete-copy {
flex: 1;
min-width: 0;
}
.delete-title-row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12rpx;
}
.delete-title,
.delete-desc {
.delete-desc,
.delete-fact-label,
.delete-fact-value,
.delete-confirm-title,
.delete-confirm-desc,
.delete-confirm-fact text {
display: block;
}
@@ -105,20 +143,211 @@
}
.delete-desc {
margin-top: 10rpx;
color: #7b6f66;
font-size: 24rpx;
line-height: 1.55;
}
.delete-badge {
display: inline-flex;
align-items: center;
min-height: 36rpx;
padding: 0 14rpx;
border-radius: 999rpx;
background: rgba(191, 73, 73, 0.1);
color: #bf4949;
font-size: 20rpx;
font-weight: 900;
}
.delete-facts {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 12rpx;
margin: 22rpx 0;
}
.delete-fact {
min-width: 0;
padding: 16rpx;
border: 1rpx solid rgba(191, 73, 73, 0.1);
border-radius: 16rpx;
background: rgba(255, 253, 248, 0.78);
}
.delete-fact-label {
color: #8e8077;
font-size: 21rpx;
font-weight: 700;
}
.delete-fact-value {
margin-top: 8rpx;
color: #91897f;
font-size: 22rpx;
line-height: 1.5;
color: #bf4949;
font-size: 26rpx;
font-weight: 900;
}
.delete-btn {
flex: 0 0 auto;
min-width: 172rpx;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
width: 100%;
min-width: 0;
max-width: 100%;
min-height: 78rpx;
margin: 0;
border: 0;
border-radius: 999rpx;
border-radius: 14px;
background: #BF4949;
color: #fff;
font-size: 26rpx;
font-weight: 900;
box-shadow: 0 12rpx 24rpx rgba(191, 73, 73, 0.22);
}
.delete-btn[disabled],
.delete-confirm-submit[disabled],
.delete-confirm-cancel[disabled] {
opacity: 0.72;
}
.delete-btn::after {
border: 0;
}
.delete-confirm-mask {
position: fixed;
inset: 0;
z-index: 90;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
background: rgba(18, 15, 12, 0.48);
animation: deleteMaskIn 180ms ease both;
}
.delete-confirm-panel {
box-sizing: border-box;
width: 100%;
max-width: 632rpx;
padding: 36rpx 30rpx 30rpx;
border: 1rpx solid rgba(191, 73, 73, 0.14);
border-radius: 28rpx;
background: #fffdf8;
box-shadow: 0 24rpx 56rpx rgba(41, 31, 23, 0.2);
animation: deleteConfirmIn 200ms ease both;
}
.delete-confirm-icon {
width: 66rpx;
height: 66rpx;
margin: 0 auto 20rpx;
font-size: 38rpx;
}
.delete-confirm-title {
color: #302c27;
text-align: center;
font-size: 34rpx;
font-weight: 900;
}
.delete-confirm-desc {
margin-top: 14rpx;
color: #756a62;
text-align: center;
font-size: 24rpx;
font-weight: 800;
line-height: 1.6;
}
.delete-confirm-facts {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 12rpx;
margin-top: 26rpx;
}
.delete-confirm-fact {
padding: 16rpx;
border-radius: 16rpx;
background: #f8f1ea;
}
.delete-confirm-fact text:first-child {
color: #8f8278;
font-size: 21rpx;
font-weight: 700;
}
.delete-confirm-fact text:last-child {
margin-top: 8rpx;
color: #bf4949;
font-size: 26rpx;
font-weight: 900;
}
.delete-confirm-actions {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap: 14rpx;
margin-top: 28rpx;
min-width: 0;
overflow: hidden;
}
.delete-confirm-cancel,
.delete-confirm-submit {
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
width: 100%;
min-width: 0;
max-width: 100%;
min-height: 76rpx;
margin: 0;
padding: 0 12rpx;
border-radius: 14px;
font-size: 26rpx;
font-weight: 900;
}
.delete-confirm-cancel::after,
.delete-confirm-submit::after {
border: 0;
}
.delete-confirm-cancel {
border: 1rpx solid #e1d8ce;
background: #fffdf8;
color: #514b44;
}
.delete-confirm-submit {
background: #BF4949;
color: #fff;
box-shadow: 0 12rpx 24rpx rgba(191, 73, 73, 0.2);
}
@keyframes deleteMaskIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes deleteConfirmIn {
from {
opacity: 0;
transform: translateY(20rpx) scale(0.98);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
+2 -2
View File
@@ -394,8 +394,8 @@ Page({
hours,
timelineHeight: timelineHeight + laneHeaderHeight,
laneHeaderHeight,
laneItemWidth: 248,
laneWidth: Math.max(720, lanes.length * 248),
laneItemWidth: 268,
laneWidth: Math.max(760, lanes.length * 268),
dayTotal: dayAppointments.length,
freeArtistCount: lanes.filter(item => item.blocks.length === 0).length,
pendingCount
+17 -7
View File
@@ -288,9 +288,9 @@
left: 12rpx;
display: flex;
flex-direction: column;
gap: 4rpx;
gap: 3rpx;
overflow: hidden;
padding: 12rpx 12rpx;
padding: 11rpx 12rpx;
border-left: 8rpx solid #7ba7c7;
border-radius: 10px;
background: #fff7ee;
@@ -343,33 +343,43 @@
}
.block-title {
overflow: hidden;
color: #2c2823;
font-size: 24rpx;
font-weight: 800;
line-height: 1.2;
text-overflow: ellipsis;
white-space: nowrap;
}
.block-meta,
.block-status {
overflow: hidden;
color: #7e756b;
font-size: 20rpx;
line-height: 1.25;
text-overflow: ellipsis;
white-space: nowrap;
}
.block-badges {
display: flex;
flex-wrap: wrap;
gap: 6rpx;
flex-wrap: nowrap;
gap: 5rpx;
max-width: 100%;
overflow: hidden;
}
.block-badge {
display: inline-flex;
align-items: center;
height: 24rpx;
padding: 0 8rpx;
flex: 0 0 auto;
height: 25rpx;
padding: 0 7rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.82);
color: #7b5b46;
font-size: 18rpx;
font-size: 17rpx;
font-weight: 800;
line-height: 1;
}