From a3240d2323a88595d26accf63aa4dfdc4b841f86 Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Wed, 22 Jul 2026 19:15:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A7=84=E5=88=92=E6=9C=88?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E7=A9=BA=E6=97=A5=E6=9C=9F=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JY-Salon-WeChat/pages/planning/index.js | 110 +++++++++++++- JY-Salon-WeChat/pages/planning/index.wxml | 31 +++- JY-Salon-WeChat/pages/planning/index.wxss | 172 ++++++++++++++++++++++ 3 files changed, 307 insertions(+), 6 deletions(-) diff --git a/JY-Salon-WeChat/pages/planning/index.js b/JY-Salon-WeChat/pages/planning/index.js index 6521be55..72823051 100644 --- a/JY-Salon-WeChat/pages/planning/index.js +++ b/JY-Salon-WeChat/pages/planning/index.js @@ -1,6 +1,7 @@ const planningApi = require('../../api/planning') const shopApi = require('../../api/shop') const dateUtil = require('../../utils/date') +const { markPlanningRefresh } = require('../../utils/planning-refresh') const CALENDAR_ERROR_FALLBACK_MESSAGE = '规划数据暂时不可用,请稍后重试' const TECHNICAL_ERROR_PATTERNS = [ @@ -36,6 +37,21 @@ function formatMonthDay(value) { return `${target.getMonth() + 1}月${target.getDate()}日` } +function formatActionDate(value) { + const target = toLocalDate(value) + const weekLabels = ['日', '一', '二', '三', '四', '五', '六'] + return `${target.getMonth() + 1}月${target.getDate()}日 周${weekLabels[target.getDay()]}` +} + +function formatShortDate(value) { + const target = toLocalDate(value) + return `${target.getMonth() + 1}月${target.getDate()}日` +} + +function buildAppointmentFormUrl(date, artistId) { + return `/pages/appointment-form/index?date=${date}&artistId=${artistId || ''}` +} + function resolveAppointmentDate(item) { if (item.date) return item.date return String(item.startTime || '').slice(0, 10) @@ -141,9 +157,9 @@ Page({ data: { viewMode: 'month', viewModes: [ - { value: 'day', label: '日' }, + { value: 'month', label: '月' }, { value: 'week', label: '周' }, - { value: 'month', label: '月' } + { value: 'day', label: '日' } ], monthDisplayMode: 'count', monthDisplayModes: [ @@ -179,7 +195,12 @@ Page({ pendingCount: 0, canCreateAppointment: true, loading: false, - calendarError: '' + calendarError: '', + emptyDateActionVisible: false, + pendingEmptyDate: '', + pendingEmptyDateTitle: '', + pendingEmptyDateLabel: '', + savingRestDate: false }, onLoad() { @@ -224,14 +245,50 @@ Page({ selectDate(event) { const currentDate = dateUtil.formatDate(event.currentTarget.dataset.date) + if (this.data.viewMode === 'month') { + const monthDay = this.data.monthDays.find(item => item.date === currentDate) + if (monthDay && monthDay.isCurrentMonth && Number(monthDay.totalCount || 0) === 0 && !monthDay.shopRest) { + this.openEmptyDateAction(currentDate) + return + } + } this.setData({ currentDate, currentDateText: currentDate, - viewMode: this.data.viewMode === 'month' ? 'day' : this.data.viewMode + viewMode: this.data.viewMode === 'month' ? 'day' : this.data.viewMode, + emptyDateActionVisible: false, + pendingEmptyDate: '', + pendingEmptyDateTitle: '', + pendingEmptyDateLabel: '' }) this.prepareView() }, + openEmptyDateAction(date) { + const currentDate = dateUtil.formatDate(date) + this.setData({ + currentDate, + currentDateText: currentDate, + emptyDateActionVisible: true, + pendingEmptyDate: currentDate, + pendingEmptyDateTitle: formatActionDate(currentDate), + pendingEmptyDateLabel: formatShortDate(currentDate) + }) + this.prepareView() + }, + + closeEmptyDateAction() { + this.setData({ + emptyDateActionVisible: false, + pendingEmptyDate: '', + pendingEmptyDateTitle: '', + pendingEmptyDateLabel: '', + savingRestDate: false + }) + }, + + stopTap() {}, + prevRange() { this.shiftRange(-1) }, @@ -579,10 +636,53 @@ Page({ return } wx.navigateTo({ - url: `/pages/appointment-form/index?date=${this.data.currentDateText}&artistId=${this.data.selectedArtistId || ''}` + url: buildAppointmentFormUrl(this.data.currentDateText, this.data.selectedArtistId) }) }, + createAppointmentFromEmptyDate() { + if (!this.data.pendingEmptyDate) { + wx.showToast({ title: '请选择预约日期', icon: 'none' }) + return + } + if (!this.data.canCreateAppointment) { + wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' }) + return + } + this.setData({ emptyDateActionVisible: false }) + wx.navigateTo({ + url: buildAppointmentFormUrl(this.data.pendingEmptyDate, this.data.selectedArtistId) + }) + }, + + async setEmptyDateAsRest() { + if (!this.data.pendingEmptyDate) { + wx.showToast({ title: '请选择休息日期', icon: 'none' }) + return + } + if (this.data.savingRestDate) { + return + } + this.setData({ savingRestDate: true }) + try { + await shopApi.saveScheduleException({ + workDate: this.data.pendingEmptyDate, + exceptionType: 'REST', + startTime: null, + endTime: null, + remark: '规划页快速设置' + }) + markPlanningRefresh() + wx.showToast({ title: '已设为休息日', icon: 'success' }) + this.closeEmptyDateAction() + await this.loadCalendar() + } catch (error) { + wx.showToast({ title: error.message || '休息日设置失败', icon: 'none' }) + } finally { + this.setData({ savingRestDate: false }) + } + }, + openAppointment(event) { wx.navigateTo({ url: `/pages/appointment-detail/index?id=${event.currentTarget.dataset.id}` diff --git a/JY-Salon-WeChat/pages/planning/index.wxml b/JY-Salon-WeChat/pages/planning/index.wxml index f70cb668..67a14abc 100644 --- a/JY-Salon-WeChat/pages/planning/index.wxml +++ b/JY-Salon-WeChat/pages/planning/index.wxml @@ -122,7 +122,7 @@ {{item}} - + {{item.day}} 休 @@ -153,4 +153,33 @@ + + + + + + + {{pendingEmptyDateTitle}} + 当前日期暂无预约,可以直接创建预约或设为特殊休息日 + + + + + + + + + diff --git a/JY-Salon-WeChat/pages/planning/index.wxss b/JY-Salon-WeChat/pages/planning/index.wxss index 9baeee31..30860bae 100644 --- a/JY-Salon-WeChat/pages/planning/index.wxss +++ b/JY-Salon-WeChat/pages/planning/index.wxss @@ -724,6 +724,16 @@ background: #eef5f1; } +.month-cell.action-target { + background: #fbfff8; + outline: 3rpx solid #6f8f83; + outline-offset: -3rpx; +} + +.month-cell.is-rest { + background: #fff8f6; +} + .month-cell-head { display: flex; align-items: center; @@ -827,6 +837,157 @@ text-align: center; } +.empty-date-mask { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 80; + display: flex; + align-items: flex-end; + background: rgba(38, 35, 31, 0.36); +} + +.empty-date-sheet { + width: 100%; + padding: 22rpx 28rpx calc(28rpx + env(safe-area-inset-bottom)); + border-radius: 22px 22px 0 0; + background: #fffdf8; + box-shadow: 0 -18rpx 44rpx rgba(38, 35, 31, 0.18); + animation: emptyDateSheetIn 180ms ease both; +} + +.sheet-grabber { + width: 84rpx; + height: 8rpx; + margin: 0 auto 22rpx; + border-radius: 999rpx; + background: #ded6cb; +} + +.empty-date-head { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 20rpx; +} + +.empty-date-title-wrap { + display: flex; + flex: 1; + min-width: 0; + flex-direction: column; + gap: 8rpx; +} + +.empty-date-title { + color: #25211d; + font-size: 36rpx; + font-weight: 900; + line-height: 1.2; +} + +.empty-date-subtitle { + color: #8f877e; + font-size: 24rpx; + font-weight: 700; + line-height: 1.35; +} + +.empty-date-close { + display: flex; + align-items: center; + justify-content: center; + width: 60rpx; + min-width: 60rpx; + max-width: 60rpx; + height: 60rpx; + min-height: 60rpx; + padding: 0; + border-radius: 50%; + background: #f0ece5; + color: #5f5951; + font-size: 38rpx; + font-weight: 700; + line-height: 60rpx; +} + +.empty-date-actions { + display: flex; + flex-direction: column; + gap: 18rpx; + margin-top: 30rpx; +} + +.empty-date-action { + display: flex; + align-items: center; + width: 100%; + min-height: 136rpx; + padding: 22rpx; + border-radius: 12px; + text-align: left; +} + +.empty-date-action.primary { + background: #6f8f83; + color: #fffdf8; + box-shadow: 0 8rpx 18rpx rgba(111, 143, 131, 0.24); +} + +.empty-date-action.rest { + border: 1rpx solid #f0d7d3; + background: #fff8f6; + color: #6a4743; +} + +.empty-date-action-icon { + display: flex; + align-items: center; + justify-content: center; + width: 80rpx; + min-width: 80rpx; + max-width: 80rpx; + height: 80rpx; + margin-right: 24rpx; + border-radius: 12px; + font-size: 38rpx; + font-weight: 900; + line-height: 1; +} + +.empty-date-action.primary .empty-date-action-icon { + background: rgba(255, 255, 255, 0.18); + color: #fff; +} + +.empty-date-action.rest .empty-date-action-icon { + background: #ffe9e5; + color: #c56f6f; +} + +.empty-date-action-copy { + display: flex; + flex: 1; + min-width: 0; + flex-direction: column; + gap: 8rpx; +} + +.empty-date-action-title { + font-size: 30rpx; + font-weight: 900; + line-height: 1.2; +} + +.empty-date-action-desc { + font-size: 24rpx; + font-weight: 700; + line-height: 1.35; + opacity: 0.82; +} + @keyframes pageFadeIn { from { opacity: 0; @@ -837,3 +998,14 @@ transform: translateY(0); } } + +@keyframes emptyDateSheetIn { + from { + opacity: 0; + transform: translateY(24rpx); + } + to { + opacity: 1; + transform: translateY(0); + } +}