优化店务小程序规划视图与表单加载
This commit is contained in:
@@ -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' })
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user