完善店务预约状态与详情流程

This commit is contained in:
2026-07-23 01:34:35 +08:00
parent c347e59b50
commit aeaead1648
18 changed files with 1360 additions and 139 deletions
+350 -42
View File
@@ -2,6 +2,12 @@ const planningApi = require('../../api/planning')
const { markPlanningRefresh } = require('../../utils/planning-refresh')
const { chooseImageFilePaths, uploadObjectFile, resolveUploadedImagePreviewUrl } = require('../../utils/upload')
const MAX_APPOINTMENT_IMAGE_COUNT = 9
const SIGNED_IMAGE_EXPIRE_MINUTES = 60
const STATUS_PENDING_SERVICE = 1
const STATUS_COMPLETED = 2
const STATUS_CANCELLED = 3
function canTransferAppointment() {
const app = getApp()
const userInfo = app.globalData.userInfo || {}
@@ -15,11 +21,68 @@ function splitImageValues(value) {
.filter(Boolean)
}
function resolveProductImageUrls(appointment) {
if (appointment && Array.isArray(appointment.productImageUrls)) {
return appointment.productImageUrls.filter(Boolean)
function splitTagValues(value) {
return String(value || '')
.split(/[;,,、]/)
.map(item => item.trim())
.filter(Boolean)
}
function normalizeImageUrlArray(value) {
if (Array.isArray(value)) {
return value
.map(item => String(item || '').trim())
.filter(Boolean)
}
return []
return splitImageValues(value)
}
function resolveProductImageFileIds(appointment) {
if (!appointment || typeof appointment !== 'object') {
return []
}
return splitImageValues(appointment.productImageFileIds || appointment.imageFileIds)
}
function resolveProductImageUrls(appointment) {
if (!appointment || typeof appointment !== 'object') {
return []
}
const productImageUrls = normalizeImageUrlArray(appointment.productImageUrls)
if (productImageUrls.length > 0) {
return productImageUrls
}
const imageUrls = normalizeImageUrlArray(appointment.imageUrls)
if (imageUrls.length > 0) {
return imageUrls
}
return normalizeImageUrlArray(appointment.productImageUrl || appointment.imageUrl)
}
async function resolveSignedImageUrls(fileIds) {
const imageUrls = []
for (let index = 0; index < fileIds.length; index += 1) {
const fileId = fileIds[index]
const signedUrl = await planningApi.signedImageUrl(fileId, SIGNED_IMAGE_EXPIRE_MINUTES)
const imageUrl = String(signedUrl || '').trim()
if (!imageUrl) {
throw new Error(`文件 ${fileId} 未返回可访问图片链接`)
}
imageUrls.push(imageUrl)
}
return imageUrls
}
async function resolveDisplayImageUrls(appointment) {
const imageUrls = resolveProductImageUrls(appointment)
if (imageUrls.length > 0) {
return imageUrls
}
const fileIds = resolveProductImageFileIds(appointment)
if (fileIds.length === 0) {
return []
}
return resolveSignedImageUrls(fileIds)
}
async function uploadAppointmentImageFiles(limit) {
@@ -40,16 +103,133 @@ async function uploadAppointmentImageFiles(limit) {
return { fileIds, imageUrls }
}
function isPriceUndetermined(value) {
const amount = Number(value)
return Number.isFinite(amount) && amount === 0
}
function formatMoneyValue(value) {
const amount = Number(value)
if (!Number.isFinite(amount) || amount <= 0) {
return ''
}
return amount.toFixed(2).replace(/\.00$/, '')
}
function formatAppointmentPrice(value) {
if (value === undefined || value === null || value === '' || isPriceUndetermined(value)) {
return '未定'
}
const moneyText = formatMoneyValue(value)
return moneyText ? `¥${moneyText}` : '未定'
}
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 buildPriceForm(amount) {
const pricePending = isPriceUndetermined(amount)
return {
pricePending,
priceText: pricePending ? '' : formatMoneyValue(amount)
}
}
function buildDetailTags(appointment) {
const tags = []
const productTags = splitTagValues(appointment && appointment.productTags)
for (let index = 0; index < productTags.length; index += 1) {
tags.push({ key: `product-${index}-${productTags[index]}`, label: productTags[index], type: 'product' })
}
if (appointment && appointment.fromMeituan) {
tags.push({ key: 'source-meituan', label: '美团', type: 'source' })
}
if (appointment && appointment.needRemoval) {
tags.push({ key: 'flag-need-removal', label: '需卸甲', type: 'warning' })
}
if (appointment && appointment.depositPaid) {
tags.push({ key: 'flag-deposit-paid', label: '已交定金', type: 'paid' })
}
if (appointment && isPriceUndetermined(appointment.amount)) {
tags.push({ key: 'flag-price-pending', label: '价格未定', type: 'price' })
}
return tags
}
function isAppointmentResponse(value) {
return value && typeof value === 'object' && (value.orderItemId || value.orderId)
}
function confirmAction(title, content, confirmText, confirmColor) {
return new Promise((resolve, reject) => {
wx.showModal({
title,
content,
cancelText: '取消',
confirmText,
confirmColor,
success(result) {
resolve(Boolean(result.confirm))
},
fail(error) {
reject(new Error(`打开确认弹窗失败:${error.errMsg || '未知错误'}`))
}
})
})
}
Page({
data: {
id: '',
appointment: {},
avatarText: '',
timeText: '',
priceText: '未定',
detailTags: [],
productImageUrls: [],
productImageFileIds: '',
imageUploading: false,
canEditAppointment: false,
canTransferAppointment: false,
showActionRow: false,
showPendingActions: false,
showRestoreAction: false,
priceModalVisible: false,
priceSaving: false,
priceForm: {
priceText: '',
pricePending: false
},
loadError: ''
},
@@ -64,53 +244,95 @@ Page({
async loadDetail() {
try {
const appointment = await planningApi.appointment(this.data.id)
this.applyAppointment(appointment)
await this.applyAppointment(appointment)
} catch (error) {
this.setData({
appointment: {},
avatarText: '',
timeText: '',
priceText: '未定',
detailTags: [],
productImageUrls: [],
productImageFileIds: '',
canEditAppointment: false,
showActionRow: false,
showPendingActions: false,
showRestoreAction: false,
loadError: error.message || '预约详情加载失败'
})
}
},
applyAppointment(appointment) {
const imageUrls = resolveProductImageUrls(appointment)
async applyAppointment(appointment) {
if (!appointment || typeof appointment !== 'object') {
throw new Error('预约详情数据为空')
}
const imageUrls = await resolveDisplayImageUrls(appointment)
const status = Number(appointment.status)
const showPendingActions = status === STATUS_PENDING_SERVICE
const showRestoreAction = status === STATUS_COMPLETED || status === STATUS_CANCELLED
this.setData({
appointment,
avatarText: String(appointment.customerName || '客').slice(0, 1),
timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`,
priceText: formatAppointmentPrice(appointment.amount),
detailTags: buildDetailTags(appointment),
productImageUrls: imageUrls,
productImageFileIds: String(appointment.productImageFileIds || ''),
productImageFileIds: resolveProductImageFileIds(appointment).join(','),
canEditAppointment: Boolean(appointment.canEdit),
canTransferAppointment: canTransferAppointment(),
showActionRow: showPendingActions || showRestoreAction,
showPendingActions,
showRestoreAction,
loadError: ''
})
},
async updateStatus(status) {
try {
if (!this.data.appointment.orderId) {
throw new Error('预约订单ID为空,无法修改状态')
}
await planningApi.updateStatus(this.data.appointment.orderId, status)
markPlanningRefresh()
wx.showToast({ title: '已更新' })
this.loadDetail()
await this.loadDetail()
} catch (error) {
wx.showToast({ title: error.message || '操作失败', icon: 'none' })
}
},
confirm() {
this.updateStatus(1)
async complete() {
try {
const confirmed = await confirmAction('完成预约', '确认将此预约标记为已完成?', '完成', '#6f8f83')
if (confirmed) {
await this.updateStatus(STATUS_COMPLETED)
}
} catch (error) {
wx.showToast({ title: error.message || '操作失败', icon: 'none' })
}
},
complete() {
this.updateStatus(2)
async deleteAppointment() {
try {
const confirmed = await confirmAction('删除此订单', '确认删除此订单?删除后订单会进入已取消状态。', '删除', '#d98d8d')
if (confirmed) {
await this.updateStatus(STATUS_CANCELLED)
}
} catch (error) {
wx.showToast({ title: error.message || '操作失败', icon: 'none' })
}
},
cancel() {
this.updateStatus(3)
async restorePending() {
try {
const confirmed = await confirmAction('修改状态', '确认将此预约改回待完成?', '修改', '#6f8f83')
if (confirmed) {
await this.updateStatus(STATUS_PENDING_SERVICE)
}
} catch (error) {
wx.showToast({ title: error.message || '操作失败', icon: 'none' })
}
},
goTransfer() {
@@ -122,11 +344,15 @@ Page({
},
async persistAppointmentImages(fileIds, previewImageUrls) {
const appointment = await planningApi.updateAppointmentImages(this.data.id, {
const result = await planningApi.updateAppointmentImages(this.data.id, {
imageFileIds: fileIds.join(',')
})
markPlanningRefresh()
this.applyAppointment(appointment)
if (isAppointmentResponse(result)) {
await this.applyAppointment(result)
} else {
await this.loadDetail()
}
if (Array.isArray(previewImageUrls) && previewImageUrls.length > 0) {
this.setData({ productImageUrls: previewImageUrls })
}
@@ -136,14 +362,22 @@ Page({
if (this.data.imageUploading) {
return
}
if (!this.data.canEditAppointment) {
wx.showToast({ title: '当前预约状态不可修改图片', icon: 'none' })
return
}
const currentFileIds = splitImageValues(this.data.productImageFileIds)
const remainingCount = 9 - currentFileIds.length
const remainingCount = MAX_APPOINTMENT_IMAGE_COUNT - currentFileIds.length
if (remainingCount <= 0) {
wx.showToast({ title: '最多上传 9 张作品图片', icon: 'none' })
return
}
this.setData({ imageUploading: true })
try {
const confirmed = await confirmAction('上传图片', '确认添加作品图片到此预约?', '上传', '#6f8f83')
if (!confirmed) {
return
}
this.setData({ imageUploading: true })
const uploaded = await uploadAppointmentImageFiles(remainingCount)
if (uploaded.fileIds.length === 0) {
return
@@ -160,39 +394,33 @@ Page({
}
},
async replaceAppointmentImages() {
if (this.data.imageUploading) {
return
}
this.setData({ imageUploading: true })
try {
const uploaded = await uploadAppointmentImageFiles(9)
if (uploaded.fileIds.length === 0) {
return
}
await this.persistAppointmentImages(uploaded.fileIds, uploaded.imageUrls)
wx.showToast({ title: '图片已保存' })
} catch (error) {
wx.showToast({ title: error.message || '图片上传失败', icon: 'none' })
} finally {
this.setData({ imageUploading: false })
}
},
async removeAppointmentImage(event) {
if (this.data.imageUploading) {
return
}
if (!this.data.canEditAppointment) {
wx.showToast({ title: '当前预约状态不可删除图片', icon: 'none' })
return
}
const index = Number(event.currentTarget.dataset.index)
const currentFileIds = splitImageValues(this.data.productImageFileIds)
if (currentFileIds.length === 0) {
wx.showToast({ title: '缺少图片文件ID,无法删除', icon: 'none' })
return
}
if (!Number.isInteger(index) || index < 0 || index >= currentFileIds.length) {
wx.showToast({ title: '图片序号无效,无法删除', icon: 'none' })
return
}
const currentImageUrls = Array.isArray(this.data.productImageUrls) ? this.data.productImageUrls : []
const nextFileIds = currentFileIds.filter((item, itemIndex) => itemIndex !== index)
const nextImageUrls = currentImageUrls.filter((item, itemIndex) => itemIndex !== index)
this.setData({ imageUploading: true })
try {
const confirmed = await confirmAction('删除图片', '确认删除这张作品图片?', '删除', '#d98d8d')
if (!confirmed) {
return
}
const currentImageUrls = Array.isArray(this.data.productImageUrls) ? this.data.productImageUrls : []
const nextFileIds = currentFileIds.filter((item, itemIndex) => itemIndex !== index)
const nextImageUrls = currentImageUrls.filter((item, itemIndex) => itemIndex !== index)
this.setData({ imageUploading: true })
await this.persistAppointmentImages(nextFileIds, nextImageUrls)
wx.showToast({ title: '图片已保存' })
} catch (error) {
@@ -213,6 +441,86 @@ Page({
})
},
openPriceEditor() {
if (this.data.priceSaving) {
return
}
if (!this.data.canEditAppointment) {
wx.showToast({ title: '当前预约状态不可修改价格', icon: 'none' })
return
}
this.setData({
priceModalVisible: true,
priceForm: buildPriceForm(this.data.appointment.amount)
})
},
closePriceEditor() {
if (this.data.priceSaving) {
return
}
this.setData({ priceModalVisible: false })
},
onPriceInput(event) {
const value = sanitizePriceInput(event.detail.value)
this.setData({ 'priceForm.priceText': value })
return value
},
togglePricePending() {
if (this.data.priceSaving) {
return
}
const pricePending = !this.data.priceForm.pricePending
const patch = {
'priceForm.pricePending': pricePending
}
if (pricePending) {
patch['priceForm.priceText'] = ''
}
this.setData(patch)
},
async savePrice() {
if (this.data.priceSaving) {
return
}
const form = this.data.priceForm
const priceText = form.pricePending ? '0' : normalizeConfirmedPrice(form.priceText)
if (!priceText) {
wx.showToast({ title: '请填写正确的价格', icon: 'none' })
return
}
const price = Number(priceText)
const priceLabel = price === 0 ? '未定' : `¥${formatMoneyValue(price)}`
try {
const confirmed = await confirmAction('保存价格', `确认将本次价格保存为${priceLabel}?`, '保存', '#6f8f83')
if (!confirmed) {
return
}
this.setData({ priceSaving: true })
const result = await planningApi.updateAppointmentPrice(this.data.id, {
price
})
markPlanningRefresh()
if (isAppointmentResponse(result)) {
await this.applyAppointment(result)
} else {
await this.loadDetail()
}
this.setData({ priceModalVisible: false })
wx.showToast({ title: '价格已保存' })
} catch (error) {
wx.showToast({ title: error.message || '价格保存失败', icon: 'none' })
} finally {
this.setData({ priceSaving: false })
}
},
stopTap() {
},
back() {
wx.navigateBack()
}
@@ -15,14 +15,23 @@
</view>
<view class="detail-actions">
<text class="tag">{{appointment.statusText}}</text>
<button wx:if="{{canTransferAppointment && appointment.canEdit}}" class="small-action" bindtap="goTransfer">改派</button>
</view>
</view>
<view wx:if="{{detailTags.length}}" class="detail-tag-row">
<text wx:for="{{detailTags}}" wx:key="key" class="detail-tag {{item.type}}">{{item.label}}</text>
</view>
<view class="detail-grid">
<view>
<text class="label">项目</text>
<text class="value">{{appointment.productTitle}}</text>
</view>
<view>
<text class="label">价格</text>
<view class="price-value-row">
<text class="value price-value">{{priceText}}</text>
<button wx:if="{{canEditAppointment}}" class="price-edit-btn" bindtap="openPriceEditor">修改</button>
</view>
</view>
<view>
<text class="label">美甲师</text>
<text class="value">{{appointment.artistName}}</text>
@@ -41,19 +50,21 @@
<view wx:if="{{!loadError}}" class="section">
<view class="section-head">
<view class="section-title">作品图片</view>
<button class="text-btn image-action" loading="{{imageUploading}}" disabled="{{imageUploading}}" bindtap="replaceAppointmentImages">{{productImageUrls.length ? '重新上传' : '上传图片'}}</button>
</view>
<view class="card image-card">
<view wx:if="{{productImageUrls.length}}" class="detail-image-list">
<view wx:for="{{productImageUrls}}" wx:key="*this" class="detail-image-item">
<image class="detail-image" src="{{item}}" mode="aspectFill" data-index="{{index}}" bindtap="previewProductImage"></image>
<view class="detail-image-remove" data-index="{{index}}" catchtap="removeAppointmentImage">×</view>
<view wx:if="{{canEditAppointment}}" class="detail-image-remove" data-index="{{index}}" catchtap="removeAppointmentImage">×</view>
</view>
<view wx:if="{{productImageUrls.length < 9}}" class="detail-image-add {{imageUploading ? 'disabled' : ''}}" bindtap="chooseAppointmentImages">
<view wx:if="{{canEditAppointment && productImageUrls.length < 9}}" class="detail-image-add {{imageUploading ? 'disabled' : ''}}" bindtap="chooseAppointmentImages">
<text>{{imageUploading ? '...' : '+'}}</text>
</view>
</view>
<view wx:else class="detail-image-empty">暂无图片</view>
<view wx:else class="detail-image-empty">
<text>{{imageUploading ? '上传中...' : '暂无图片'}}</text>
<button wx:if="{{canEditAppointment}}" class="text-btn image-empty-action" loading="{{imageUploading}}" disabled="{{imageUploading}}" bindtap="chooseAppointmentImages">上传图片</button>
</view>
</view>
</view>
@@ -62,9 +73,33 @@
<view class="card note-card">{{appointment.remark || '暂无备注'}}</view>
</view>
<view wx:if="{{!loadError}}" class="fixed-bottom action-row">
<button class="secondary-btn" bindtap="confirm">确认</button>
<button class="primary-btn" bindtap="complete">完成</button>
<button class="danger-btn" bindtap="cancel">取消</button>
<view wx:if="{{priceModalVisible}}" class="detail-modal-mask" catchtap="stopTap">
<view class="price-modal" catchtap="stopTap">
<view class="price-modal-head">
<text class="price-modal-title">修改价格</text>
<view class="price-modal-close" bindtap="closePriceEditor">×</view>
</view>
<view class="price-pending-option {{priceForm.pricePending ? 'active' : ''}}" bindtap="togglePricePending">
<view class="price-pending-check">{{priceForm.pricePending ? '✓' : ''}}</view>
<text>价格未定</text>
</view>
<view class="price-field {{priceForm.pricePending ? 'disabled' : ''}}">
<text class="price-field-label">本次价格</text>
<view class="price-input-wrap">
<input value="{{priceForm.priceText}}" disabled="{{priceForm.pricePending}}" bindinput="onPriceInput" type="digit" placeholder="请输入价格" />
<text>元</text>
</view>
</view>
<view class="price-modal-actions">
<button class="secondary-btn" bindtap="closePriceEditor">取消</button>
<button class="primary-btn" loading="{{priceSaving}}" disabled="{{priceSaving}}" bindtap="savePrice">保存</button>
</view>
</view>
</view>
<view wx:if="{{!loadError && showActionRow}}" class="fixed-bottom action-row {{showRestoreAction ? 'single' : ''}}">
<button wx:if="{{showPendingActions}}" class="primary-btn" bindtap="complete">完成</button>
<button wx:if="{{showPendingActions}}" class="danger-btn" bindtap="deleteAppointment">删除此订单</button>
<button wx:if="{{showRestoreAction}}" class="secondary-btn" bindtap="restorePending">修改状态</button>
</view>
</view>
@@ -72,6 +72,45 @@
margin-top: 28rpx;
}
.detail-tag-row {
display: flex;
flex-wrap: wrap;
gap: 10rpx;
margin-top: 22rpx;
}
.detail-tag {
display: inline-flex;
align-items: center;
min-height: 40rpx;
padding: 0 16rpx;
border-radius: 999rpx;
background: #f0ece5;
color: #6d675f;
font-size: 22rpx;
font-weight: 700;
}
.detail-tag.source {
background: #e8f2f7;
color: #4c7890;
}
.detail-tag.warning {
background: #fff0e2;
color: #b36a34;
}
.detail-tag.paid {
background: #e8f3ec;
color: #5b8067;
}
.detail-tag.price {
background: #f5e8e8;
color: #a75353;
}
.label,
.value {
display: block;
@@ -89,6 +128,37 @@
font-weight: 700;
}
.price-value-row {
display: flex;
align-items: center;
min-width: 0;
gap: 12rpx;
margin-top: 8rpx;
}
.price-value {
flex: 1;
min-width: 0;
margin-top: 0;
}
.price-edit-btn {
display: inline-flex;
align-items: center;
justify-content: center;
flex: 0 0 auto;
width: 82rpx;
min-width: 82rpx;
max-width: 82rpx;
height: 42rpx;
min-height: 42rpx;
border-radius: 999rpx;
background: #e5eee9;
color: #55786d;
font-size: 22rpx;
font-weight: 800;
}
.note-card {
padding: 24rpx;
color: #6d655d;
@@ -102,15 +172,6 @@
gap: 16rpx;
}
.image-action {
flex: 0 0 auto;
width: 156rpx;
min-width: 156rpx;
max-width: 156rpx;
padding: 0;
text-align: right;
}
.image-card {
padding: 20rpx;
}
@@ -173,8 +234,10 @@
.detail-image-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 14rpx;
min-height: 142rpx;
border-radius: 16rpx;
background: #f7efe7;
@@ -182,12 +245,153 @@
font-size: 26rpx;
}
.image-empty-action {
min-height: 48rpx;
font-size: 24rpx;
}
.detail-modal-mask {
position: fixed;
inset: 0;
z-index: 30;
display: flex;
align-items: flex-end;
justify-content: center;
padding: 24rpx;
background: rgba(32, 27, 22, 0.34);
}
.price-modal {
width: 100%;
max-width: 680rpx;
padding: 26rpx;
border-radius: 24rpx 24rpx 16rpx 16rpx;
background: #fffdf8;
box-shadow: 0 -12rpx 34rpx rgba(58, 48, 34, 0.12);
}
.price-modal-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20rpx;
}
.price-modal-title {
color: #2d2924;
font-size: 30rpx;
font-weight: 900;
}
.price-modal-close {
display: flex;
align-items: center;
justify-content: center;
width: 52rpx;
height: 52rpx;
border-radius: 50%;
background: #f0ece5;
color: #6d655d;
font-size: 32rpx;
font-weight: 700;
line-height: 52rpx;
}
.price-pending-option {
display: flex;
align-items: center;
gap: 14rpx;
min-height: 76rpx;
margin-top: 24rpx;
padding: 0 18rpx;
border: 1rpx solid #eee2d5;
border-radius: 16rpx;
background: #fff8ef;
color: #554c44;
font-size: 26rpx;
font-weight: 800;
}
.price-pending-option.active {
border-color: #7d9d90;
background: #edf6f1;
color: #55786d;
}
.price-pending-check {
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 auto;
width: 34rpx;
height: 34rpx;
border: 2rpx solid #d5c6b8;
border-radius: 50%;
color: #55786d;
font-size: 22rpx;
font-weight: 900;
}
.price-pending-option.active .price-pending-check {
border-color: #7d9d90;
background: #dfeee7;
}
.price-field {
margin-top: 20rpx;
}
.price-field.disabled {
opacity: 0.55;
}
.price-field-label {
display: block;
margin-bottom: 10rpx;
color: #625c55;
font-size: 24rpx;
font-weight: 800;
}
.price-input-wrap {
display: flex;
align-items: center;
height: 76rpx;
padding: 0 18rpx;
border-radius: 16rpx;
background: #fffaf4;
}
.price-input-wrap input {
flex: 1;
min-width: 0;
color: #2d2924;
font-size: 28rpx;
}
.price-input-wrap text {
flex: 0 0 auto;
color: #9a9288;
font-size: 24rpx;
}
.price-modal-actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 14rpx;
margin-top: 28rpx;
}
.action-row {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-columns: 1fr 1fr;
gap: 14rpx;
}
.action-row.single {
grid-template-columns: 1fr;
}
.action-row .primary-btn,
.action-row .secondary-btn,
.action-row .danger-btn {
+100 -20
View File
@@ -7,6 +7,7 @@ const { markPlanningRefresh } = require('../../utils/planning-refresh')
const { chooseImageFilePaths, uploadObjectFile, resolveUploadedImagePreviewUrl } = require('../../utils/upload')
const DRAFT_STORAGE_PREFIX = 'managerAppointmentDraft'
const PLANNING_RETURN_TARGET_STORAGE_KEY = 'planningReturnTarget'
const TIME_SLOT_MINUTES = 15
const DAY_MINUTES = 24 * 60
const DAY_END_COVER_MINUTE = 23 * 60 + 59
@@ -146,6 +147,41 @@ function removeDraftForm() {
}
}
function writePlanningReturnTarget(target) {
try {
wx.setStorageSync(PLANNING_RETURN_TARGET_STORAGE_KEY, target)
} catch (error) {
throw new Error(`写入规划页返回目标失败:${error.message || error}`)
}
}
function confirmAppointmentSubmit() {
return new Promise((resolve, reject) => {
wx.showModal({
title: '确认提交预约',
content: '提交成功后将返回规划月视图。',
confirmText: '提交',
cancelText: '再检查',
success: result => resolve(!!result.confirm),
fail: error => reject(new Error(`打开预约确认弹窗失败:${error.errMsg || error.message || error}`))
})
})
}
function confirmFormAction(title, content, confirmText, confirmColor) {
return new Promise((resolve, reject) => {
wx.showModal({
title,
content,
cancelText: '取消',
confirmText,
confirmColor,
success: result => resolve(!!result.confirm),
fail: error => reject(new Error(`打开确认弹窗失败:${error.errMsg || error.message || error}`))
})
})
}
function normalizeDuration(value) {
const duration = Number(value)
return Number.isFinite(duration) && duration > 0 ? Math.floor(duration) : 0
@@ -440,12 +476,16 @@ function normalizeProduct(product, artists) {
.map(id => findArtist(artists, id).name)
.filter(Boolean)
const durationText = product.approximateDuration || (product.serviceDurationMinutes ? `${product.serviceDurationMinutes}分钟` : '')
const productPrice = formatProductPrice(product.price)
const productPriceText = productPrice === '0'
? '未定'
: productPrice ? `¥${productPrice}` : '价格待定'
return {
...product,
coverImage: imageUrls[0] || '',
tagList: parseProductTags(product).slice(0, 4),
artistText: artistNames.length > 0 ? artistNames.join('、') : '全部美甲师',
priceText: product.price || product.price === 0 ? `¥${product.price}` : '价格待定',
priceText: productPriceText,
durationText
}
}
@@ -553,8 +593,11 @@ function normalizeConfirmedPrice(value) {
return String(price)
}
function collectManualProductImages(fileIds, imageUrls) {
return splitManualImageValues(`${fileIds || ''},${imageUrls || ''}`)
function resolveAppointmentPriceText(form) {
if (form.manualProductPriceUndetermined) {
return '0'
}
return normalizeConfirmedPrice(form.manualProductPrice)
}
function normalizeCustomer(customer) {
@@ -606,6 +649,7 @@ Page({
productId: '',
manualProductTitle: '',
manualProductPrice: '',
manualProductPriceUndetermined: false,
manualProductDescription: '',
manualProductTags: '',
manualProductPrecautions: '',
@@ -740,6 +784,9 @@ Page({
const patch = {
[`form.${field}`]: value
}
if (field === 'manualProductPrice' && value) {
patch['form.manualProductPriceUndetermined'] = false
}
if (field === 'customerName' || field === 'phone') {
patch['form.customerUserId'] = ''
patch.customerDropdownVisible = true
@@ -762,6 +809,17 @@ Page({
})
},
onPriceUndeterminedChange(event) {
const checked = !!event.detail.value
const patch = {
'form.manualProductPriceUndetermined': checked
}
if (checked) {
patch['form.manualProductPrice'] = ''
}
this.setData(patch)
},
onCustomerFocus(event) {
const field = event.currentTarget.dataset.field
this.setData({
@@ -919,13 +977,15 @@ Page({
selectProduct(event) {
const selectedProduct = this.data.filteredProducts.find(item => String(item.id) === String(event.currentTarget.dataset.id)) || {}
const price = formatProductPrice(selectedProduct.price)
const priceUndetermined = price === '' || price === '0'
const productTag = resolveTagValue(this.data.tagOptions, parseProductTags(selectedProduct).join(','))
const imageUrls = Array.isArray(selectedProduct.imageUrls) ? selectedProduct.imageUrls : []
this.setData({
selectedProduct,
'form.productId': '',
'form.manualProductTitle': selectedProduct.title || '',
'form.manualProductPrice': price,
'form.manualProductPrice': priceUndetermined ? '' : price,
'form.manualProductPriceUndetermined': priceUndetermined,
'form.manualProductDescription': selectedProduct.description || '',
'form.manualProductTags': productTag,
'form.manualProductPrecautions': selectedProduct.precautions || '',
@@ -953,8 +1013,8 @@ Page({
useManualProduct() {
const title = String(this.data.form.manualProductTitle || '').trim()
const priceText = normalizeConfirmedPrice(this.data.form.manualProductPrice)
const imageValues = collectManualProductImages(this.data.form.manualProductImageFileIds, this.data.form.manualProductImageUrl)
const priceUndetermined = !!this.data.form.manualProductPriceUndetermined
const priceText = resolveAppointmentPriceText(this.data.form)
if (!title) {
wx.showToast({ title: '请填写作品名称', icon: 'none' })
return
@@ -963,15 +1023,11 @@ Page({
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': priceText,
'form.manualProductPrice': priceUndetermined ? '' : priceText,
manualProductPanelVisible: false
})
this.closeProductModal()
@@ -1225,7 +1281,7 @@ Page({
return
}
const form = this.data.form
const hasManualProduct = String(form.manualProductTitle || '').trim() && String(form.manualProductPrice || '').trim()
const hasManualProduct = String(form.manualProductTitle || '').trim()
const customerName = String(form.customerName || '').trim()
const phone = String(form.phone || '').trim()
const durationMinutes = normalizeDuration(form.durationMinutes)
@@ -1233,17 +1289,12 @@ Page({
wx.showToast({ title: '请补全预约信息', icon: 'none' })
return
}
const appointmentPriceText = normalizeConfirmedPrice(form.manualProductPrice)
const appointmentPriceText = resolveAppointmentPriceText(form)
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
@@ -1253,6 +1304,16 @@ Page({
wx.showToast({ title: availability.tip || '该时段已被预约', icon: 'none' })
return
}
let confirmed
try {
confirmed = await confirmAppointmentSubmit()
} catch (error) {
wx.showToast({ title: error.message || '确认提交失败', icon: 'none' })
return
}
if (!confirmed) {
return
}
this.setData({ loading: true })
try {
const payload = {
@@ -1267,6 +1328,7 @@ Page({
durationMinutes,
clientRequestId: buildClientRequestId('manager-appointment')
}
delete payload.manualProductPriceUndetermined
if (form.productId) {
payload.productId = String(form.productId)
payload.manualProductTitle = undefined
@@ -1282,8 +1344,16 @@ Page({
}
const result = await planningApi.createAppointment(payload)
removeDraftForm()
writePlanningReturnTarget({
source: 'appointment-create',
date: form.appointmentDate,
orderItemId: result.orderItemId || result.id || ''
})
markPlanningRefresh()
wx.redirectTo({ url: `/pages/appointment-detail/index?id=${result.orderItemId}` })
wx.switchTab({
url: '/pages/planning/index',
fail: error => wx.showToast({ title: `跳转规划页失败:${error.errMsg || error.message || error}`, icon: 'none' })
})
} catch (error) {
wx.showToast({ title: error.message || '提交失败', icon: 'none' })
} finally {
@@ -1301,7 +1371,17 @@ Page({
}
},
clearDraft() {
async clearDraft() {
let confirmed
try {
confirmed = await confirmFormAction('清空草稿', '确认清空当前本机预约草稿?', '清空', '#d98d8d')
} catch (error) {
wx.showToast({ title: error.message || '确认清空失败', icon: 'none' })
return
}
if (!confirmed) {
return
}
try {
removeDraftForm()
this.setData({ draftSavedAtText: '' })
@@ -5,10 +5,6 @@
<text class="field-label required">客户姓名</text>
<input value="{{form.customerName}}" data-field="customerName" bindinput="onInput" bindfocus="onCustomerFocus" bindblur="hideCustomerDropdown" placeholder="搜索或输入客户姓名" focus="{{customerNameFocused}}" />
</view>
<view class="field">
<text class="field-label">手机号</text>
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" bindfocus="onCustomerFocus" bindblur="hideCustomerDropdown" placeholder="可选,填写后匹配客户" />
</view>
<view wx:if="{{customerDropdownVisible}}" class="customer-dropdown">
<view wx:if="{{customerLoading}}" class="customer-option muted-option">正在搜索客户...</view>
<view wx:elif="{{customerError}}" class="customer-option muted-option">{{customerError}},可继续手动输入</view>
@@ -36,10 +32,18 @@
<text>{{form.customerName ? (form.manualProductTitle || selectedProduct.title || '请选择作品') : '请先填写客户姓名'}}</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 wx:if="{{form.productId || form.manualProductTitle}}" class="field price-field">
<text class="field-label">本次价格</text>
<view class="price-control">
<view class="price-input {{form.manualProductPriceUndetermined ? 'disabled' : ''}}">
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" disabled="{{form.manualProductPriceUndetermined}}" type="digit" placeholder="{{form.manualProductPriceUndetermined ? '未定' : '可按本次预约修改'}}" />
<text>{{form.manualProductPriceUndetermined ? '未定' : '元'}}</text>
</view>
<view class="price-toggle">
<text>价格未定</text>
<switch checked="{{form.manualProductPriceUndetermined}}" color="#6f8f83" bindchange="onPriceUndeterminedChange" />
</view>
</view>
</view>
<view class="field">
<text class="field-label required">预计时长</text>
@@ -110,16 +114,20 @@
<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>
<text class="manual-field-label">价格</text>
<view class="manual-price-input {{form.manualProductPriceUndetermined ? 'disabled' : ''}}">
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" disabled="{{form.manualProductPriceUndetermined}}" type="digit" placeholder="{{form.manualProductPriceUndetermined ? '未定' : '价格'}}" />
<text>{{form.manualProductPriceUndetermined ? '未定' : '元'}}</text>
</view>
<view class="manual-price-toggle">
<text>价格未定</text>
<switch checked="{{form.manualProductPriceUndetermined}}" color="#6f8f83" bindchange="onPriceUndeterminedChange" />
</view>
</view>
</view>
<view class="manual-image-section">
<view class="manual-image-head">
<text class="manual-image-title required-label">作品图片</text>
<text class="manual-image-title">作品图片</text>
</view>
<view class="manual-image-list">
<view wx:for="{{manualProductImageUrls}}" wx:for-item="imageUrl" wx:key="*this" class="manual-image-item">
@@ -155,10 +163,8 @@
<view wx:if="{{productModalVisible}}" class="modal-mask template-mask" catchtap="stopTap">
<view class="product-modal template-modal" catchtap="stopTap">
<view class="modal-head">
<view>
<text class="modal-title">使用已有作品模板</text>
</view>
<view class="modal-close" bindtap="closeProductModal">×</view>
<view><text class="modal-title">选择已有作品</text></view>
</view>
<input class="product-search" value="{{productKeyword}}" bindinput="onProductSearch" placeholder="搜索作品、标签、美甲师" />
<scroll-view class="product-list" scroll-y>
@@ -35,6 +35,67 @@
font-size: 24rpx;
}
.price-field {
align-items: flex-start;
}
.price-control {
display: flex;
min-width: 0;
flex: 1;
flex-direction: column;
gap: 12rpx;
}
.price-input,
.manual-price-input {
display: flex;
align-items: center;
min-height: 72rpx;
padding-right: 16rpx;
border: 1rpx solid #eadfd2;
border-radius: 18rpx;
background: #fffdf8;
}
.price-input.disabled,
.manual-price-input.disabled {
background: #f5f0ea;
color: #9a9288;
}
.form-card .price-input input {
min-height: 70rpx;
padding: 0 18rpx;
border: 0;
border-radius: 0;
background: transparent;
}
.price-input text,
.manual-price-input text {
flex: 0 0 auto;
color: #9a9288;
font-size: 22rpx;
}
.price-toggle,
.manual-price-toggle {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 8rpx;
color: #6d6258;
font-size: 24rpx;
font-weight: 800;
}
.price-toggle switch,
.manual-price-toggle switch {
transform: scale(0.72);
transform-origin: right center;
}
.customer-select {
position: relative;
}
@@ -45,7 +106,7 @@
.customer-dropdown {
position: absolute;
top: 214rpx;
top: 102rpx;
right: 0;
left: 180rpx;
z-index: 30;
@@ -927,7 +988,7 @@
.manual-field-row {
display: grid;
grid-template-columns: minmax(0, 1fr) 200rpx;
grid-template-columns: minmax(0, 1fr) 248rpx;
gap: 14rpx;
}
@@ -958,27 +1019,13 @@
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;
border: 0;
}
.manual-field picker {
+164 -7
View File
@@ -3,6 +3,7 @@ const shopApi = require('../../api/shop')
const dateUtil = require('../../utils/date')
const { markPlanningRefresh } = require('../../utils/planning-refresh')
const PLANNING_RETURN_TARGET_STORAGE_KEY = 'planningReturnTarget'
const CALENDAR_ERROR_FALLBACK_MESSAGE = '规划数据暂时不可用,请稍后重试'
const TECHNICAL_ERROR_PATTERNS = [
/###\s*Error/i,
@@ -28,6 +29,42 @@ function resolveCalendarErrorMessage(error) {
return hasTechnicalMessage ? CALENDAR_ERROR_FALLBACK_MESSAGE : message
}
function readPlanningReturnTarget() {
try {
const target = wx.getStorageSync(PLANNING_RETURN_TARGET_STORAGE_KEY)
return target && typeof target === 'object' ? target : null
} catch (error) {
throw new Error(`读取规划页返回目标失败:${error.message || error}`)
}
}
function removePlanningReturnTarget() {
try {
wx.removeStorageSync(PLANNING_RETURN_TARGET_STORAGE_KEY)
} catch (error) {
throw new Error(`清理规划页返回目标失败:${error.message || error}`)
}
}
function confirmPlanningAction(title, content, confirmText, confirmColor) {
return new Promise((resolve, reject) => {
wx.showModal({
title,
content,
cancelText: '取消',
confirmText,
confirmColor,
success: result => resolve(Boolean(result.confirm)),
fail: error => reject(new Error(`打开确认弹窗失败:${error.errMsg || error.message || error}`))
})
})
}
function normalizeReturnTargetDate(value) {
const dateText = String(value || '').slice(0, 10)
return /^\d{4}-\d{2}-\d{2}$/.test(dateText) ? dateText : dateUtil.formatDate(new Date())
}
function toLocalDate(value) {
return value instanceof Date ? new Date(value.getTime()) : new Date(String(value).replace(/-/g, '/'))
}
@@ -119,6 +156,24 @@ function appointmentStatusClass(status) {
return ''
}
function resolveAppointmentItemId(item) {
if (!item) {
return ''
}
return item.orderItemId || item.id ? String(item.orderItemId || item.id) : ''
}
function resolveAppointmentEventId(event) {
const currentDataset = event && event.currentTarget && event.currentTarget.dataset ? event.currentTarget.dataset : {}
const targetDataset = event && event.target && event.target.dataset ? event.target.dataset : {}
return currentDataset.orderItemId || currentDataset.id || targetDataset.orderItemId || targetDataset.id || ''
}
function hasAppointmentDataset(dataset) {
return Object.prototype.hasOwnProperty.call(dataset, 'orderItemId')
|| Object.prototype.hasOwnProperty.call(dataset, 'id')
}
function completedOrCancelledClass(status) {
if (isCompletedStatus(status)) return 'is-completed'
if (isCancelledStatus(status)) return 'is-cancelled'
@@ -233,6 +288,31 @@ Page({
onShow() {
const app = getApp()
try {
const returnTarget = readPlanningReturnTarget()
if (returnTarget) {
removePlanningReturnTarget()
const targetDate = normalizeReturnTargetDate(returnTarget.date)
this._needRefresh = false
app.globalData.planningNeedRefresh = false
wx.removeStorageSync('planningNeedRefresh')
this.setData({
viewMode: 'month',
currentDate: toLocalDate(targetDate),
currentDateText: targetDate,
emptyDateActionVisible: false,
pendingEmptyDate: '',
pendingEmptyDateTitle: '',
pendingEmptyDateLabel: '',
savingSpecialDate: false
})
this.prepareView()
this.loadCalendar()
return
}
} catch (error) {
wx.showToast({ title: error.message || '读取规划返回目标失败', icon: 'none' })
}
const storageRefresh = wx.getStorageSync('planningNeedRefresh') === '1'
if (this._needRefresh || app.globalData.planningNeedRefresh || storageRefresh) {
this._needRefresh = false
@@ -267,6 +347,10 @@ Page({
},
selectDate(event) {
const targetDataset = event && event.target && event.target.dataset ? event.target.dataset : {}
if (hasAppointmentDataset(targetDataset)) {
return
}
const currentDate = dateUtil.formatDate(event.currentTarget.dataset.date)
if (this.data.viewMode === 'month') {
const monthDay = this.data.monthDays.find(item => item.date === currentDate)
@@ -384,6 +468,8 @@ Page({
async loadCalendar() {
const range = this.resolveRange()
const requestSeq = (this._calendarRequestSeq || 0) + 1
this._calendarRequestSeq = requestSeq
this.setData({ loading: true })
try {
const data = await planningApi.calendar({
@@ -392,9 +478,15 @@ Page({
artistId: this.data.selectedArtistId || undefined
})
const shopSchedule = await this.loadShopSchedule(range)
if (requestSeq !== this._calendarRequestSeq) {
return
}
this.applyCalendar(data, shopSchedule)
this.setData({ calendarError: '' })
} catch (error) {
if (requestSeq !== this._calendarRequestSeq) {
return
}
this.clearCalendarView()
this.setData({
calendarError: resolveCalendarErrorMessage(error),
@@ -406,7 +498,9 @@ Page({
icon: 'none'
})
} finally {
this.setData({ loading: false })
if (requestSeq === this._calendarRequestSeq) {
this.setData({ loading: false })
}
}
},
@@ -522,8 +616,8 @@ Page({
dayStatus: summary.dayStatus || 'free',
shopRest: shopRestDates.includes(day.date),
artistCounts,
expandedBlocks: this.buildExpandedBlocks(artistCounts),
rowBlocks: this.buildRowBlocks(artistCounts),
expandedBlocks: dayAppointments.length ? this.buildAppointmentBlocks(dayAppointments, 'block') : this.buildExpandedBlocks(artistCounts),
rowBlocks: dayAppointments.length ? this.buildAppointmentBlocks(dayAppointments, 'row') : this.buildRowBlocks(artistCounts),
statusClass: resolveDayStatusClass(dayAppointments)
}
})
@@ -575,8 +669,11 @@ Page({
.filter(item => String(item.artistId) === String(artist.id))
.map(item => {
const itemStart = resolveAppointmentStartMinute(item)
const orderItemId = resolveAppointmentItemId(item)
return {
...item,
id: orderItemId,
orderItemId,
top: Math.max(0, itemStart - startMinute) + laneHeaderHeight,
height: Math.max(82, item.durationMinutes || 60),
timeText: resolveAppointmentTimeText(item),
@@ -611,6 +708,28 @@ Page({
return (this.data.appointments || []).filter(item => resolveAppointmentDate(item) === date)
},
buildAppointmentBlocks(appointments, mode) {
const artistMap = (this.data.artists || []).reduce((map, artist) => {
map[String(artist.id)] = artist
return map
}, {})
return (appointments || []).map((item, index) => {
const artist = artistMap[String(item.artistId)] || {}
const artistName = item.artistName || artist.name || ''
const orderItemId = resolveAppointmentItemId(item)
return {
key: `${mode}-${orderItemId || item.artistId || 'appointment'}-${index}`,
id: orderItemId,
orderItemId,
artistId: item.artistId,
color: item.color || artist.color || '#B8B0A6',
shortName: artist.shortName || String(artistName || '?').slice(0, 1),
artistName: artistName || '?',
statusClass: completedOrCancelledClass(item.status)
}
})
},
appointmentCountsByDate(date) {
const artistMap = (this.data.artists || []).reduce((map, artist) => {
map[String(artist.id)] = artist
@@ -621,15 +740,17 @@ Page({
const artist = artistMap[String(item.artistId)] || {}
const artistName = item.artistName || artist.name
const statusClass = completedOrCancelledClass(item.status)
const key = `${String(item.artistId || item.orderItemId)}-${statusClass || 'active'}`
const orderItemId = resolveAppointmentItemId(item)
const key = `${String(item.artistId || orderItemId)}-${statusClass || 'active'}`
const existing = grouped.get(key)
if (existing) {
grouped.set(key, { ...existing, count: existing.count + 1 })
} else {
grouped.set(key, {
key: `${key}-${index}`,
orderItemId: item.orderItemId,
artistId: item.artistId || item.orderItemId,
id: orderItemId,
orderItemId,
artistId: item.artistId || orderItemId,
artistName,
shortName: artist.shortName || String(artistName || '?').slice(0, 1),
color: artist.color || '#B8B0A6',
@@ -649,8 +770,11 @@ Page({
}, {})
return (counts || []).map(count => {
const artist = colorMap[count.artistId] || {}
const orderItemId = count.orderItemId || count.id || ''
return {
...count,
id: orderItemId,
orderItemId,
key: `${String(count.artistId)}-${count.status || 'summary'}`,
color: count.color || artist.color || '#B8B0A6',
shortName: count.shortName || artist.shortName || '?',
@@ -662,8 +786,11 @@ Page({
buildExpandedBlocks(artistCounts) {
return (artistCounts || []).reduce((blocks, count) => {
for (let index = 0; index < Number(count.count || 0); index += 1) {
const orderItemId = count.orderItemId || count.id || ''
blocks.push({
key: count.key ? `${count.key}-${index}` : `${count.artistId || count.shortName}-${index}`,
id: orderItemId,
orderItemId,
artistId: count.artistId,
color: count.color,
shortName: count.shortName,
@@ -677,8 +804,11 @@ Page({
buildRowBlocks(artistCounts) {
return (artistCounts || []).reduce((rows, count) => {
for (let index = 0; index < Number(count.count || 0); index += 1) {
const orderItemId = count.orderItemId || count.id || ''
rows.push({
key: count.key ? `${count.key}-row-${index}` : `${count.artistId || count.shortName}-row-${index}`,
id: orderItemId,
orderItemId,
artistId: count.artistId,
color: count.color,
shortName: count.shortName,
@@ -730,6 +860,16 @@ Page({
wx.showToast({ title: '请设置正确营业时间', icon: 'none' })
return
}
let confirmed
try {
confirmed = await confirmPlanningAction('保存特殊日期', `确认将 ${this.data.pendingEmptyDate} 设置为${option.label}?`, '保存', '#6f8f83')
} catch (error) {
wx.showToast({ title: error.message || '确认保存失败', icon: 'none' })
return
}
if (!confirmed) {
return
}
this.setData({ savingSpecialDate: true })
try {
await shopApi.saveScheduleException({
@@ -751,8 +891,25 @@ Page({
},
openAppointment(event) {
const currentDataset = event && event.currentTarget && event.currentTarget.dataset ? event.currentTarget.dataset : {}
const count = Number(currentDataset.count || 1)
if (this.data.viewMode === 'month' && this.data.monthDisplayMode === 'count' && count > 1) {
const date = normalizeReturnTargetDate(currentDataset.date)
this.setData({
currentDate: toLocalDate(date),
currentDateText: date,
monthDisplayMode: 'blocks'
})
wx.showToast({ title: '请点击具体预约块查看详情', icon: 'none' })
return
}
const id = resolveAppointmentEventId(event)
if (!id) {
wx.showToast({ title: '缺少预约详情ID', icon: 'none' })
return
}
wx.navigateTo({
url: `/pages/appointment-detail/index?id=${event.currentTarget.dataset.id}`
url: `/pages/appointment-detail/index?id=${encodeURIComponent(id)}`
})
}
})
+6 -6
View File
@@ -63,7 +63,7 @@
<view class="chip-dot" style="background: {{item.color}};"></view>
<text>{{item.name}}</text>
</view>
<view wx:for="{{item.blocks}}" wx:for-item="block" wx:key="orderItemId" class="appointment-block {{block.statusClass}}" style="top: {{block.top}}rpx; height: {{block.height}}rpx; border-left-color: {{item.color}};" data-id="{{block.orderItemId}}" bindtap="openAppointment">
<view wx:for="{{item.blocks}}" wx:for-item="block" wx:key="orderItemId" class="appointment-block {{block.statusClass}}" style="top: {{block.top}}rpx; height: {{block.height}}rpx; border-left-color: {{item.color}};" data-id="{{block.orderItemId || block.id}}" data-order-item-id="{{block.orderItemId || block.id}}" bindtap="openAppointment">
<text class="block-title">{{block.customerName}}</text>
<text class="block-meta">{{block.timeText}} · {{block.productTitle}}</text>
<view wx:if="{{block.badges.length}}" class="block-badges">
@@ -129,19 +129,19 @@
<text wx:elif="{{!item.isPast && item.dayStatus === 'full'}}" class="day-mark full">满</text>
</view>
<view wx:if="{{monthDisplayMode === 'count'}}" class="month-bars">
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="key" wx:if="{{count.count > 0}}" class="month-artist-bar {{count.statusClass}}" style="background: {{count.color}};">
<text>{{count.shortName}}{{count.count}}</text>
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="key" wx:if="{{count.count > 0}}" class="month-artist-bar {{count.statusClass}}" style="background: {{count.color}};" data-id="{{count.orderItemId || count.id}}" data-order-item-id="{{count.orderItemId || count.id}}" data-count="{{count.count}}" data-date="{{item.date}}" catchtap="openAppointment">
<text data-id="{{count.orderItemId || count.id}}" data-order-item-id="{{count.orderItemId || count.id}}">{{count.shortName}}{{count.count}}</text>
</view>
<view wx:if="{{item.totalCount === 0}}" class="month-empty">空</view>
</view>
<view wx:else class="month-blocks">
<block wx:if="{{monthDisplayMode === 'blocks'}}">
<view wx:for="{{item.expandedBlocks}}" wx:for-item="block" wx:key="key" class="month-order-block {{block.statusClass}}" style="background: {{block.color}};"></view>
<view wx:for="{{item.expandedBlocks}}" wx:for-item="block" wx:key="key" class="month-order-block {{block.statusClass}}" style="background: {{block.color}};" data-id="{{block.orderItemId || block.id}}" data-order-item-id="{{block.orderItemId || block.id}}" catchtap="openAppointment"></view>
<view wx:if="{{item.totalCount === 0}}" class="month-empty">空</view>
</block>
<block wx:else>
<view wx:for="{{item.rowBlocks}}" wx:for-item="block" wx:key="key" class="month-row-block {{monthRowLabelVisible ? 'named' : ''}} {{block.statusClass}}" style="background: {{block.color}};">
<text wx:if="{{monthRowLabelVisible}}">{{block.artistName}}</text>
<view wx:for="{{item.rowBlocks}}" wx:for-item="block" wx:key="key" class="month-row-block {{monthRowLabelVisible ? 'named' : ''}} {{block.statusClass}}" style="background: {{block.color}};" data-id="{{block.orderItemId || block.id}}" data-order-item-id="{{block.orderItemId || block.id}}" catchtap="openAppointment">
<text wx:if="{{monthRowLabelVisible}}" data-id="{{block.orderItemId || block.id}}" data-order-item-id="{{block.orderItemId || block.id}}">{{block.artistName}}</text>
</view>
<view wx:if="{{item.totalCount === 0}}" class="month-empty">空</view>
</block>