优化店务小程序规划视图与表单加载

This commit is contained in:
2026-07-23 15:57:39 +08:00
parent 7d6929bcf6
commit 3d10affea3
8 changed files with 273 additions and 78 deletions
+86 -23
View File
@@ -773,6 +773,8 @@ Page({
customerError: '',
products: [],
filteredProducts: [],
productsLoaded: false,
productsLoading: false,
artists: [],
selectedProduct: {},
selectedArtist: {},
@@ -784,6 +786,8 @@ Page({
productKeyword: '',
productError: '',
tagOptions: [],
tagsLoaded: false,
tagsLoading: false,
tagPickerIndex: 0,
tagError: '',
conflictTip: '',
@@ -818,7 +822,6 @@ Page({
return
}
this.loadOptions()
this.searchCustomers()
wx.nextTick(() => {
this.setData({ customerNameFocused: true })
})
@@ -841,34 +844,71 @@ Page({
async loadOptions() {
this.showPageMask('正在加载预约信息')
try {
try {
const productsData = await productsApi.list({ page: 1, size: 100 })
const products = productsData.list || productsData || []
this.setData({ products, productError: '' })
} catch (error) {
this.setData({
products: [],
filteredProducts: [],
productError: error.message || '作品列表加载失败'
})
}
await this.loadTags()
await this.loadArtists()
this.refreshProductCards()
await this.refreshAvailableTimes()
this.refreshAvailableTimes()
await this.checkAvailability(this.data.form.appointmentTime)
} finally {
this.hidePageMask()
}
},
ensureProductsLoaded() {
if (this.data.productsLoaded) {
return Promise.resolve()
}
if (this._productsLoadingPromise) {
return this._productsLoadingPromise
}
this._productsLoadingPromise = this.loadProducts().finally(() => {
this._productsLoadingPromise = null
})
return this._productsLoadingPromise
},
async loadProducts() {
this.setData({ productsLoading: true })
try {
const productsData = await productsApi.list({ page: 1, size: 100 })
const products = productsData.list || productsData || []
this.setData({
products,
productsLoaded: true,
productError: ''
})
} catch (error) {
this.setData({
products: [],
filteredProducts: [],
productsLoaded: false,
productError: error.message || '作品列表加载失败'
})
} finally {
this.setData({ productsLoading: false })
}
},
ensureTagsLoaded() {
if (this.data.tagsLoaded) {
return Promise.resolve()
}
if (this._tagsLoadingPromise) {
return this._tagsLoadingPromise
}
this._tagsLoadingPromise = this.loadTags().finally(() => {
this._tagsLoadingPromise = null
})
return this._tagsLoadingPromise
},
async loadTags() {
this.setData({ tagsLoading: true })
try {
const tagsData = await tagsApi.listAll()
const tagOptions = normalizeTagOptions(tagsData.list || tagsData || [])
const selectedTag = resolveTagValue(tagOptions, this.data.form.manualProductTags)
this.setData({
tagOptions,
tagsLoaded: true,
tagPickerIndex: resolveTagPickerIndex(tagOptions, selectedTag),
'form.manualProductTags': selectedTag,
tagError: ''
@@ -876,9 +916,12 @@ Page({
} catch (error) {
this.setData({
tagOptions: [],
tagsLoaded: false,
tagPickerIndex: 0,
tagError: error.message || '标签加载失败'
})
} finally {
this.setData({ tagsLoading: false })
}
},
@@ -968,6 +1011,14 @@ Page({
const form = this.data.form
const sourceValue = preferredField === 'phone' ? form.phone : form.customerName || form.phone
const keyword = String(sourceValue || '').trim()
if (!keyword) {
this.setData({
customerOptions: [],
customerError: '',
customerLoading: false
})
return
}
this.setData({ customerLoading: true })
try {
const data = await customersApi.list({ keyword, page: 1, size: 20 })
@@ -1047,15 +1098,21 @@ Page({
wx.showToast({ title: '请先填写客户姓名', icon: 'none' })
return
}
this.openManualProductPanel()
void this.openManualProductPanel()
},
openProductTemplateSheet() {
this.setData({ productKeyword: '' })
this.refreshProductCards()
this.setData({
productModalVisible: true
})
async openProductTemplateSheet() {
this.showPageMask('正在加载作品库')
try {
await Promise.all([this.ensureProductsLoaded(), this.ensureTagsLoaded()])
this.setData({ productKeyword: '' })
this.refreshProductCards()
this.setData({
productModalVisible: true
})
} finally {
this.hidePageMask()
}
},
closeProductModal() {
@@ -1064,12 +1121,18 @@ Page({
})
},
openManualProductPanel() {
async openManualProductPanel() {
const customerName = String(this.data.form.customerName || '').trim()
if (!customerName) {
wx.showToast({ title: '请先填写客户姓名', icon: 'none' })
return
}
this.showPageMask('正在加载作品设置')
try {
await this.ensureTagsLoaded()
} finally {
this.hidePageMask()
}
const imageUrls = this.data.manualProductImageUrls.length > 0
? this.data.manualProductImageUrls
: splitManualImageValues(this.data.form.manualProductImageUrl)
@@ -84,21 +84,23 @@
}
.price-field {
align-items: flex-start;
align-items: center;
}
.price-control {
display: flex;
min-width: 0;
flex: 1;
flex-direction: column;
gap: 12rpx;
align-items: center;
gap: 10rpx;
}
.price-input,
.manual-price-input {
display: flex;
align-items: center;
flex: 1 1 0;
min-width: 0;
min-height: 72rpx;
padding-right: 16rpx;
border: 1rpx solid #eadfd2;
@@ -113,6 +115,8 @@
}
.form-card .price-input input {
min-width: 0;
flex: 1;
min-height: 70rpx;
padding: 0 18rpx;
border: 0;
@@ -138,12 +142,23 @@
font-weight: 800;
}
.price-toggle {
flex: 0 0 auto;
gap: 4rpx;
font-size: 22rpx;
white-space: nowrap;
}
.price-toggle switch,
.manual-price-toggle switch {
transform: scale(0.72);
transform-origin: right center;
}
.price-toggle switch {
transform: scale(0.68);
}
.customer-select {
position: relative;
}
+54 -5
View File
@@ -266,6 +266,9 @@ Page({
pendingCount: 0,
canCreateAppointment: true,
loading: false,
loadingText: '',
pageMaskVisible: false,
pageMaskText: '',
calendarError: '',
emptyDateActionVisible: false,
pendingEmptyDate: '',
@@ -287,6 +290,7 @@ Page({
onShow() {
const app = getApp()
this.hidePageMask()
try {
const returnTarget = readPlanningReturnTarget()
if (returnTarget) {
@@ -413,6 +417,20 @@ Page({
stopTap() {},
showPageMask(text) {
this.setData({
pageMaskVisible: true,
pageMaskText: text
})
},
hidePageMask() {
this.setData({
pageMaskVisible: false,
pageMaskText: ''
})
},
selectEmptyDateSpecialType(event) {
const value = String(event.currentTarget.dataset.value || 'REST')
const option = resolveSpecialDateType(value)
@@ -469,7 +487,10 @@ Page({
const range = this.resolveRange()
const requestSeq = (this._calendarRequestSeq || 0) + 1
this._calendarRequestSeq = requestSeq
this.setData({ loading: true })
this.setData({
loading: true,
loadingText: '正在加载规划'
})
try {
const data = await planningApi.calendar({
startDate: range.start,
@@ -498,7 +519,10 @@ Page({
})
} finally {
if (requestSeq === this._calendarRequestSeq) {
this.setData({ loading: false })
this.setData({
loading: false,
loadingText: ''
})
}
}
},
@@ -610,6 +634,7 @@ Page({
: this.normalizeArtistCounts(summary.artistCounts || artistTemplate)
return {
...day,
isToday: day.date === todayText,
isPast: day.date < todayText,
totalCount: summary.totalCount || 0,
dayStatus: summary.dayStatus || 'free',
@@ -823,16 +848,27 @@ Page({
},
createAppointment() {
if (this.data.loading || this.data.pageMaskVisible) {
return
}
if (!this.data.canCreateAppointment) {
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
return
}
this.showPageMask('正在打开预约表单')
wx.navigateTo({
url: buildAppointmentFormUrl(this.data.currentDateText, this.data.selectedArtistId)
url: buildAppointmentFormUrl(this.data.currentDateText, this.data.selectedArtistId),
fail: error => {
this.hidePageMask()
wx.showToast({ title: `打开预约表单失败:${error.errMsg || error.message || error}`, icon: 'none' })
}
})
},
createAppointmentFromEmptyDate() {
if (this.data.loading || this.data.pageMaskVisible) {
return
}
if (!this.data.pendingEmptyDate) {
wx.showToast({ title: '请选择预约日期', icon: 'none' })
return
@@ -842,8 +878,13 @@ Page({
return
}
this.setData({ emptyDateActionVisible: false })
this.showPageMask('正在打开预约表单')
wx.navigateTo({
url: buildAppointmentFormUrl(this.data.pendingEmptyDate, this.data.selectedArtistId)
url: buildAppointmentFormUrl(this.data.pendingEmptyDate, this.data.selectedArtistId),
fail: error => {
this.hidePageMask()
wx.showToast({ title: `打开预约表单失败:${error.errMsg || error.message || error}`, icon: 'none' })
}
})
},
@@ -893,13 +934,21 @@ Page({
},
openAppointment(event) {
if (this.data.loading || this.data.pageMaskVisible) {
return
}
const id = resolveAppointmentEventId(event)
if (!id) {
wx.showToast({ title: '缺少预约详情ID', icon: 'none' })
return
}
this.showPageMask('正在打开预约详情')
wx.navigateTo({
url: `/pages/appointment-detail/index?id=${encodeURIComponent(id)}`
url: `/pages/appointment-detail/index?id=${encodeURIComponent(id)}`,
fail: error => {
this.hidePageMask()
wx.showToast({ title: `打开预约详情失败:${error.errMsg || error.message || error}`, icon: 'none' })
}
})
}
})
+7 -5
View File
@@ -84,10 +84,6 @@
<view wx:for="{{weekDays}}" wx:key="date" class="week-day-card card {{item.date === currentDateText ? 'active' : ''}} {{item.statusClass}}" data-date="{{item.date}}" bindtap="selectDate">
<text class="week-name">{{item.weekName}}</text>
<text class="week-date">{{item.day}}</text>
<text class="week-total">{{item.totalCount}}单</text>
<view class="week-bars {{item.totalCount === 0 ? 'empty' : ''}}">
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="key" class="week-bar {{count.statusClass}}" style="background: {{count.color}}; width: {{count.width}}%;"></view>
</view>
</view>
</scroll-view>
<view class="card week-grid">
@@ -122,7 +118,7 @@
<text wx:for="{{weekLabels}}" wx:key="*this">{{item}}</text>
</view>
<view class="month-grid">
<view wx:for="{{monthDays}}" wx:key="date" class="month-cell {{item.isCurrentMonth ? '' : 'out-month'}} {{item.date === currentDateText ? 'selected' : ''}} {{emptyDateActionVisible && item.date === pendingEmptyDate ? 'action-target' : ''}} {{!item.isPast && item.shopRest ? 'is-rest' : ''}}" data-date="{{item.date}}" bindtap="selectDate">
<view wx:for="{{monthDays}}" wx:key="date" class="month-cell {{item.isCurrentMonth ? '' : 'out-month'}} {{item.isToday ? 'today' : ''}} {{item.date === currentDateText ? 'selected' : ''}} {{emptyDateActionVisible && item.date === pendingEmptyDate ? 'action-target' : ''}} {{!item.isPast && item.shopRest ? 'is-rest' : ''}}" data-date="{{item.date}}" bindtap="selectDate">
<view class="month-cell-head">
<text class="month-day">{{item.day}}</text>
<text wx:if="{{!item.isPast && item.shopRest}}" class="day-mark rest">休</text>
@@ -199,4 +195,10 @@
</view>
</view>
</view>
<view wx:if="{{loading || pageMaskVisible}}" class="planning-loading-mask" catchtap="stopTap">
<view class="planning-loading-card" catchtap="stopTap">
<view class="planning-loading-spinner"></view>
<text>{{pageMaskText || loadingText || '正在加载规划'}}</text>
</view>
</view>
</view>
+79 -34
View File
@@ -423,58 +423,49 @@
.week-day-card {
position: relative;
display: inline-flex;
align-items: flex-start;
justify-content: center;
flex-direction: column;
box-sizing: border-box;
width: 148rpx;
min-height: 164rpx;
height: 142rpx;
min-height: 142rpx;
max-height: 142rpx;
margin-right: 12rpx;
padding: 16rpx;
}
.week-day-card.is-completed {
background: #f5fff7;
border-color: #c8ead1;
background: #fffdf8;
border-color: #eee8df;
}
.week-day-card.is-cancelled {
background: #fff5f6;
border-color: #e8c7cc;
background: #fffdf8;
border-color: #eee8df;
}
.week-day-card.is-completed::after,
.week-day-card.is-cancelled::after {
content: none;
}
.week-day-card.active {
outline: 3rpx solid #8fb89a;
}
.week-name,
.week-total {
.week-name {
color: #8f877e;
font-size: 22rpx;
}
.week-date {
margin: 8rpx 0;
margin-top: 10rpx;
color: #211e1a;
font-size: 38rpx;
font-weight: 800;
}
.week-bars {
display: flex;
flex-direction: column;
gap: 6rpx;
margin-top: 12rpx;
min-height: 22rpx;
}
.week-bars.empty {
min-height: 22rpx;
}
.week-bar {
position: relative;
height: 8rpx;
border-radius: 999rpx;
}
.week-grid {
margin-top: 18rpx;
padding: 20rpx;
@@ -528,8 +519,6 @@
font-weight: 700;
}
.week-bar.is-completed::after,
.week-bar.is-cancelled::after,
.week-count-bar.is-completed::after,
.week-count-bar.is-cancelled::after,
.month-order-block.is-completed::after,
@@ -548,8 +537,6 @@
pointer-events: none;
}
.week-bar.is-completed::before,
.week-bar.is-cancelled::before,
.week-count-bar.is-completed::before,
.week-count-bar.is-cancelled::before,
.month-order-block.is-completed::before,
@@ -568,14 +555,12 @@
pointer-events: none;
}
.week-bar.is-completed::before,
.week-count-bar.is-completed::before,
.month-order-block.is-completed::before,
.month-row-block.is-completed::before {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none' viewBox='0 0 100 100'%3E%3Cline x1='0' y1='0' x2='100' y2='100' stroke='%2345825b' stroke-opacity='.9' stroke-width='2' stroke-linecap='square' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
}
.week-bar.is-cancelled::before,
.week-count-bar.is-cancelled::before,
.month-order-block.is-cancelled::before,
.month-row-block.is-cancelled::before {
@@ -587,9 +572,9 @@
}
.month-toolbar {
display: flex;
display: grid;
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
align-items: center;
justify-content: space-between;
gap: 8rpx;
margin-bottom: 14rpx;
padding: 0 4rpx;
@@ -603,6 +588,7 @@
.month-mode-switch {
display: inline-flex;
justify-self: center;
gap: 6rpx;
padding: 6rpx;
border-radius: 999rpx;
@@ -633,6 +619,7 @@
.row-name-switch {
display: inline-flex;
align-items: center;
justify-self: end;
gap: 8rpx;
height: 44rpx;
padding: 0 10rpx;
@@ -728,6 +715,15 @@
background: #fff8f6;
}
.month-cell.today {
background: #fff3dc;
box-shadow: inset 0 0 0 3rpx #e1b76a;
}
.month-cell.today.selected {
background: #ffefd2;
}
.month-cell-head {
display: flex;
align-items: center;
@@ -1094,6 +1090,46 @@
line-height: 88rpx;
}
.planning-loading-mask {
position: fixed;
inset: 0;
z-index: 140;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
background: rgba(36, 30, 24, 0.34);
animation: pageFadeIn 160ms ease both;
}
.planning-loading-card {
display: flex;
min-width: 248rpx;
min-height: 168rpx;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 22rpx;
padding: 32rpx 36rpx;
border: 1rpx solid rgba(255, 255, 255, 0.78);
border-radius: 20rpx;
background: rgba(255, 253, 248, 0.96);
color: #3d352f;
font-size: 26rpx;
font-weight: 900;
box-shadow: 0 24rpx 54rpx rgba(41, 31, 23, 0.2);
animation: emptyDateSheetIn 180ms ease both;
}
.planning-loading-spinner {
width: 54rpx;
height: 54rpx;
border: 6rpx solid #dfe8e2;
border-top-color: #6f8f83;
border-radius: 50%;
animation: planningSpinnerRotate 0.78s linear infinite;
}
@keyframes pageFadeIn {
from {
opacity: 0;
@@ -1115,3 +1151,12 @@
transform: translateY(0);
}
}
@keyframes planningSpinnerRotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
+8
View File
@@ -346,3 +346,11 @@
- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。
- 影响范围:影响 `JY-Salon-WeChat/pages/appointment-form/` 新建预约时间选择交互;不影响后端、接口契约、SQL 和月视图已提交改动。
- 验证方式:执行店务小程序预约表单 JS 语法检查、预约表单三件套 `git diff --check`、旧时间格子引用检索;微信开发者工具自动化验证 `picker-view` 可见、旧 `.time-chip` 数量为 0、小时数组 `00-23` 共 24 项、分钟数组 `00-59` 共 60 项、滚轮切到 `[23,59]` 后显示 `23:59`,并验证页面加载遮罩可见且展示当前加载文案。截图通道本次返回 `SCREENSHOT_TIMEOUT` 且健康检查显示无需恢复,已用数据和元素断言兜底。
## 2026-07-23 店务小程序规划视图与预约表单加载优化
- 变更原因:规划视图进入新建预约表单时体感较慢,容易重复点击;月视图和周视图还需要按最新截图反馈调整展示密度、对齐方式和今日凸显。
- 处理方式:预约表单初始加载取消作品库、标签和空客户搜索的同步预加载,作品库和标签改为点击作品库或手动作品面板时懒加载,并在加载期间显示页面遮罩;价格输入和价格未定开关调整为同一行。规划页日历加载、打开预约表单和打开预约详情增加全屏加载遮罩;月视图今日格子增加底色和描边,点状/横条切换居中,横条姓名模式继续展示顾客姓名;周视图顶部日期卡统一高度,移除顶部单量和颜色条,只展示周几与日期。
- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。
- 影响范围:影响 `JY-Salon-WeChat/pages/appointment-form/` 的表单加载与价格栏布局,影响 `JY-Salon-WeChat/pages/planning/` 的规划页加载遮罩、月视图和周视图展示;不影响后端、接口契约和 SQL。
- 验证方式:执行店务小程序预约表单与规划页 JS 语法检查、相关页面 `git diff --check`、小程序 `for...of` 检索和 GitNexus staged `detect-changes`;微信开发者工具自动化验证月视图切换按钮居中、今日格子高亮、规划加载遮罩可见,周视图顶部 7 个日期卡高度一致且只展示周几与日期。截图通道仍可能返回 `SCREENSHOT_TIMEOUT`,预约表单运行态验证遇到 AppService 旧实例缓存,源码和静态检查已通过。
+12
View File
@@ -439,3 +439,15 @@
以后避免:不要把当前页面 `page_callMethod` 的结果直接当作新代码是否生效的唯一依据;如果结果像旧逻辑,先重进页面再复测。
验证方式:重进 `pages/appointment-form/index` 后,未选员工和时长时调用 `refreshAvailableTimes` 仍能得到 `timePickerHours.length=24`、`timePickerMinutes.length=60`,并且滚轮切到 `[23,59]` 后 `timePickerValue=23:59`。
## 2026-07-23 小程序 AppService 可能需要手动编译或重启
问题:店务小程序预约表单源码已加入作品和标签懒加载字段后,自动化通过 `redirectTo`、`reLaunch` 和重连仍读不到新 data 字段,调用新增页面方法也提示方法不存在。
原因:微信开发者工具 AppService 热更新可能保留旧页面服务实例;自动化重进页面和 WebSocket 重连不一定触发完整重新编译。
处理方式:如果源码静态检查已确认新逻辑存在,但自动化页面仍缺少新增方法或 data 字段,不要继续把旧实例结果当成源码失败;先手动点开发者工具编译,必要时重启对应项目窗口后再验证。
以后避免:小程序页面 JS 改动后,自动化验证前先用源码检索确认方法存在;运行态若表现为旧代码,按“重进页面、重新编译、重启工具”顺序刷新 AppService,再继续做元素断言。
验证方式:刷新 AppService 后读取 page.data 应包含新增字段,`page_callMethod` 能调用新增方法;若截图通道超时,仍要用元素和数据断言补足验证。
+9 -8
View File
@@ -2,28 +2,29 @@
## 当前任务
店务小程序新建预约时间选择器改造。
店务小程序规划视图与预约表单加载优化。
## 已完成
- 已读取项目规则、轻量记忆、文档索引、版本基线规则和错误记忆相关条目。
- 已按用户确认后的修正要求,将 `JY-Salon-WeChat/pages/appointment-form` 的预约时间弹窗从可约时间格子改为上下滑动 `picker-view`。
- 时间选择器已改为纯 24 小时、1 分钟间隔:小时 `00-23`,分钟 `00-59`;打开选择器不再按可约时间筛选。
- 点击“确认时间”时再校验日期、员工、时长、过去时间、门店休息日、营业时间、员工排班和预约冲突,不可用时弹窗提示具体原因。
- 已为初始加载、切换日期、时间校验、提交预约和返回规划页增加全屏加载遮罩,并补充页面/弹窗进入动画,避免卡顿时重复点击。
- 已按用户反馈将预约表单本次价格与价格未定开关压到同一行。
- 已将预约表单作品库、标签和空客户搜索改为懒加载,减少从规划视图进入新建预约表单的首屏等待。
- 已为规划页日历加载、打开预约表单和打开预约详情增加全屏加载遮罩,避免卡顿时重复点击。
- 已将月视图今日格子改为高亮底色,点状/横条切换按钮居中。
- 已将周视图顶部日期卡统一高度,并移除顶部单量、颜色条和状态颜色展示,只保留周几与日期。
- 已补充 `docs/项目变更记录.md`。
## 下一步
- 暂无,等待用户验收店务小程序新建预约时间选择器。
- 暂无,等待用户验收;若需要继续复测预约表单运行态懒加载,先手动编译或重启微信开发者工具刷新 AppService。
## 当前阻塞点
- 暂无。
- 微信开发者工具预约表单 AppService 运行态仍读到旧页面实例,重进页面和重连自动化后仍未刷新;需要手动编译或重启开发者工具后再做表单运行态懒加载验证。
## 最近一次重要操作结果
2026-07-23 店务小程序预约表单 JS 语法检查通过;预约表单三件套 `git diff --check` 通过;微信开发者工具自动化确认 `picker-view` 可见、旧 `.time-chip` 数量为 0、小时 24 项、分钟 60 项,滚轮切到 `[23,59]` 后显示 `23:59`,页面加载遮罩可见且展示当前加载文案;截图通道返回 `SCREENSHOT_TIMEOUT` 且健康检查无需恢复,已用数据和元素断言兜底。
2026-07-23 店务小程序规划页自动化验证通过:月视图切换按钮居中、今日格子高亮、遮罩可见;周视图顶部 7 个日期卡高度一致且只展示周几与日期。截图通道返回 `SCREENSHOT_TIMEOUT`,已用元素和数据断言兜底。
## 2026-07-23 预约图片链路检查
- 已完成:梳理新建预约手工作品上传、预约详情上传/删除、后端 `PlanningServiceImpl` 回显链路,并修复详情页旧字段回退隐患。
- 下一步:无,等待用户验收预约图片链路。