diff --git a/JY-Salon-WeChat/pages/appointment-form/index.js b/JY-Salon-WeChat/pages/appointment-form/index.js index 184b4c1e..a201a879 100644 --- a/JY-Salon-WeChat/pages/appointment-form/index.js +++ b/JY-Salon-WeChat/pages/appointment-form/index.js @@ -8,13 +8,94 @@ const { chooseImageFilePaths, uploadObjectFile, resolveUploadedImagePreviewUrl } const DRAFT_STORAGE_PREFIX = 'managerAppointmentDraft' const TIME_SLOT_MINUTES = 15 +const ARTIST_FALLBACK_COLORS = ['#7AA9C2', '#8EB99B', '#BDA7D8', '#D7B17D', '#D98D8D'] +const ARTIST_PRESET_LABELS = { + DOUBLE_REST: '双休', + SINGLE_REST: '单休', + NINE_TO_FIVE: '朝九晚五', + LATE_SHIFT: '晚班', + CUSTOM: '自定义' +} function buildClientRequestId(prefix) { return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 10)}` } +function normalizeTimeText(value) { + return value ? String(value).slice(0, 5) : '' +} + +function buildScheduleByArtist(calendar) { + const schedules = calendar && Array.isArray(calendar.schedules) ? calendar.schedules : [] + return schedules.reduce((map, schedule) => { + if (schedule && schedule.artistId) { + map[String(schedule.artistId)] = schedule + } + return map + }, {}) +} + +function buildArtistTimeSummary(artist, schedule) { + const startTime = normalizeTimeText(schedule && schedule.startTime ? schedule.startTime : artist.workStartTime) + const endTime = normalizeTimeText(schedule && schedule.endTime ? schedule.endTime : artist.workEndTime) + return startTime && endTime ? `${startTime}-${endTime}` : '' +} + +function buildArtistScheduleSummary(artist, schedule) { + const timeText = buildArtistTimeSummary(artist, schedule) + const mode = artist.scheduleModeSummary + || artist.scheduleMode + || ARTIST_PRESET_LABELS[artist.presetType] + || (schedule ? '今日排班' : '排班未设置') + return timeText ? `${mode} ${timeText}` : mode +} + +function buildArtistStatusText(artist, schedule) { + if (schedule && Number(schedule.status) !== 1) { + return '今日休息' + } + if (schedule && Number(schedule.status) === 1) { + return '今日可约' + } + return artist.statusText || (Number(artist.status) === 0 ? '休息中' : '可预约') +} + +function buildArtistMetaText(artist, schedule) { + const orderCount = Number(artist.rangeCount) + if (Number.isFinite(orderCount) && orderCount > 0) { + return `今日已有 ${orderCount} 单` + } + if (schedule && Number(schedule.status) === 1) { + return '今日暂无预约' + } + if (schedule && Number(schedule.status) !== 1) { + return '可切换日期查看排班' + } + return '等待预约' +} + +function normalizeArtistForCard(artist, index, scheduleByArtist) { + const name = artist.name || artist.nickname || artist.artistName || `美甲师${index + 1}` + const schedule = scheduleByArtist[String(artist.id)] || null + const statusText = buildArtistStatusText(artist, schedule) + const shortName = artist.shortName || String(name || '师').slice(-1) + return { + ...artist, + name, + shortName, + avatar: artist.avatar || artist.avatarUrl || '', + color: artist.color || ARTIST_FALLBACK_COLORS[index % ARTIST_FALLBACK_COLORS.length], + scheduleSummary: buildArtistScheduleSummary(artist, schedule), + metaText: buildArtistMetaText(artist, schedule), + statusText, + statusClass: statusText.indexOf('休') >= 0 ? 'rest' : 'free' + } +} + function getCalendarArtists(calendar) { - return calendar && Array.isArray(calendar.artists) ? calendar.artists : [] + const artists = calendar && Array.isArray(calendar.artists) ? calendar.artists : [] + const scheduleByArtist = buildScheduleByArtist(calendar) + return artists.map((artist, index) => normalizeArtistForCard(artist, index, scheduleByArtist)) } function findArtist(artists, artistId) { @@ -420,6 +501,8 @@ Page({ artists: [], selectedProduct: {}, selectedArtist: {}, + artistSheetVisible: false, + pendingArtistId: '', productModalVisible: false, manualProductPanelVisible: false, manualProductImageUrls: [], @@ -836,10 +919,43 @@ Page({ onArtistChange(event) { const selectedArtist = this.data.artists[Number(event.detail.value)] || {} + this.applyArtistSelection(selectedArtist) + }, + + openArtistSheet() { + this.setData({ + artistSheetVisible: true, + pendingArtistId: this.data.form.artistId || '' + }) + }, + + closeArtistSheet() { + this.setData({ + artistSheetVisible: false, + pendingArtistId: '' + }) + }, + + selectArtistCard(event) { + this.setData({ pendingArtistId: event.currentTarget.dataset.id || '' }) + }, + + confirmArtistSheet() { + const selectedArtist = findArtist(this.data.artists, this.data.pendingArtistId) + if (!selectedArtist.id) { + wx.showToast({ title: '请选择美甲师', icon: 'none' }) + return + } + this.applyArtistSelection(selectedArtist) + }, + + applyArtistSelection(selectedArtist) { this.setData({ selectedArtist, 'form.artistId': selectedArtist.id, - 'form.appointmentTime': '' + 'form.appointmentTime': '', + artistSheetVisible: false, + pendingArtistId: '' }) this.refreshAvailableTimes() this.checkAvailability() diff --git a/JY-Salon-WeChat/pages/appointment-form/index.wxml b/JY-Salon-WeChat/pages/appointment-form/index.wxml index c30a16b6..6f32b1c3 100644 --- a/JY-Salon-WeChat/pages/appointment-form/index.wxml +++ b/JY-Salon-WeChat/pages/appointment-form/index.wxml @@ -48,9 +48,10 @@ 指定员工 - - {{selectedArtist.name || '请选择美甲师'}} - + + {{selectedArtist.name || '请选择美甲师'}} + › + 预约时间 @@ -181,6 +182,39 @@ + + + + 取消 + + 选择美甲师 + 选择后将重新计算可约时间 + + 确定 + + + 暂无可选美甲师 + + + + + + {{item.shortName}} + + + {{item.name}} + {{item.statusText}} + + {{item.scheduleSummary}} + {{item.metaText}} + + + {{pendingArtistId == item.id ? '✓' : ''}} + + + + + diff --git a/JY-Salon-WeChat/pages/appointment-form/index.wxss b/JY-Salon-WeChat/pages/appointment-form/index.wxss index 1c381ebf..97183ea1 100644 --- a/JY-Salon-WeChat/pages/appointment-form/index.wxss +++ b/JY-Salon-WeChat/pages/appointment-form/index.wxss @@ -90,6 +90,24 @@ opacity: 0.72; } +.artist-value { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16rpx; +} + +.artist-value text:first-child { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.artist-value.placeholder { + color: #aaa096; +} + .time-value { display: flex; align-items: center; @@ -300,6 +318,19 @@ max-height: 76vh; } +.artist-mask { + z-index: 95; +} + +.artist-modal { + width: 100%; + max-height: 78vh; + padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom)); + border-radius: 28rpx 28rpx 0 0; + background: #fffaf4; + box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16); +} + .time-modal { width: 100%; max-height: 82vh; @@ -334,6 +365,179 @@ font-size: 24rpx; } +.artist-modal-head { + align-items: flex-start; +} + +.artist-modal-title-block { + min-width: 0; + flex: 1; + text-align: center; +} + +.artist-modal-title-block .modal-title, +.artist-modal-title-block .modal-subtitle { + text-align: center; +} + +.artist-modal-action { + flex: 0 0 auto; + min-width: 64rpx; + padding-top: 4rpx; + font-size: 30rpx; + font-weight: 800; + line-height: 42rpx; + text-align: center; +} + +.artist-modal-action.muted { + color: #8a8178; +} + +.artist-modal-action.primary { + color: #24b86f; +} + +.artist-list { + max-height: 570rpx; + padding-right: 2rpx; +} + +.artist-card { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16rpx; + min-height: 126rpx; + margin-bottom: 16rpx; + padding: 18rpx; + border: 2rpx solid transparent; + border-radius: 18rpx; + background: #fff; + box-shadow: 0 10rpx 24rpx rgba(92, 66, 43, 0.08); + transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease; +} + +.artist-card:active { + transform: scale(0.99); +} + +.artist-card.active { + border-color: #7ea98b; + background: #f8fff8; +} + +.artist-card-left { + display: flex; + min-width: 0; + flex: 1; + align-items: center; + gap: 18rpx; +} + +.artist-avatar { + display: flex; + align-items: center; + justify-content: center; + flex: 0 0 auto; + width: 78rpx; + height: 78rpx; + border-radius: 50%; + color: #fff; + font-size: 28rpx; + font-weight: 900; + overflow: hidden; +} + +.artist-avatar image { + width: 100%; + height: 100%; +} + +.artist-info { + min-width: 0; + flex: 1; +} + +.artist-name-row { + display: flex; + min-width: 0; + align-items: center; + gap: 12rpx; +} + +.artist-name { + min-width: 0; + overflow: hidden; + color: #25211d; + font-size: 30rpx; + font-weight: 900; + line-height: 1.25; + text-overflow: ellipsis; + white-space: nowrap; +} + +.artist-option-status { + flex: 0 0 auto; + height: 34rpx; + padding: 0 14rpx; + border-radius: 999rpx; + background: #e5eee9; + color: #55786d; + font-size: 20rpx; + font-weight: 800; + line-height: 34rpx; +} + +.artist-option-status.rest { + background: #f0e7dd; + color: #9a6b46; +} + +.artist-schedule, +.artist-meta { + display: block; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.artist-schedule { + margin-top: 8rpx; + color: #55786d; + font-size: 24rpx; + font-weight: 800; + line-height: 1.25; +} + +.artist-meta { + margin-top: 6rpx; + color: #91897f; + font-size: 22rpx; + line-height: 1.25; +} + +.artist-check { + display: flex; + align-items: center; + justify-content: center; + flex: 0 0 auto; + width: 32rpx; + height: 32rpx; + border: 2rpx solid #d8cdbf; + border-radius: 50%; + color: #fff; + font-size: 22rpx; + font-weight: 900; + line-height: 1; +} + +.artist-check.active { + border-color: #6f8f83; + background: #6f8f83; +} + .modal-close { position: relative; display: flex;