diff --git a/JY-Salon-WeChat/assets/images/default-avatar-1.png b/JY-Salon-WeChat/assets/images/default-avatar-1.png new file mode 100644 index 00000000..725706ef Binary files /dev/null and b/JY-Salon-WeChat/assets/images/default-avatar-1.png differ diff --git a/JY-Salon-WeChat/assets/images/default-avatar-2.png b/JY-Salon-WeChat/assets/images/default-avatar-2.png new file mode 100644 index 00000000..289b65e1 Binary files /dev/null and b/JY-Salon-WeChat/assets/images/default-avatar-2.png differ diff --git a/JY-Salon-WeChat/assets/images/default-avatar-3.png b/JY-Salon-WeChat/assets/images/default-avatar-3.png new file mode 100644 index 00000000..8615c996 Binary files /dev/null and b/JY-Salon-WeChat/assets/images/default-avatar-3.png differ diff --git a/JY-Salon-WeChat/assets/images/default-avatar-4.png b/JY-Salon-WeChat/assets/images/default-avatar-4.png new file mode 100644 index 00000000..d17b9730 Binary files /dev/null and b/JY-Salon-WeChat/assets/images/default-avatar-4.png differ diff --git a/JY-Salon-WeChat/pages/customers/index.js b/JY-Salon-WeChat/pages/customers/index.js index 4806c9b7..bb52b0dd 100644 --- a/JY-Salon-WeChat/pages/customers/index.js +++ b/JY-Salon-WeChat/pages/customers/index.js @@ -1,9 +1,76 @@ const customersApi = require('../../api/customers') +const DEFAULT_CUSTOMER_AVATARS = [ + '/assets/images/default-avatar-1.png', + '/assets/images/default-avatar-2.png', + '/assets/images/default-avatar-3.png', + '/assets/images/default-avatar-4.png' +] + +function formatCustomerAmount(value) { + const amount = Number(value || 0) + return Number.isFinite(amount) ? amount.toFixed(2) : '0.00' +} + +function formatCustomerDate(value) { + if (!value) { + return '-' + } + return String(value).replace('T', ' ').slice(0, 10) +} + +function resolveCustomerAmount(item) { + return item.lastOrderAmount + || item.lastConsumeAmount + || item.totalAmount + || item.amount + || 0 +} + +function resolveCustomerMonthAmount(item) { + return item.monthAmount + || item.monthConsumeAmount + || item.monthConsumption + || item.totalAmount + || 0 +} + +function resolveCustomerTag(item) { + return item.memberLevelName + || item.levelName + || item.tagName + || (item.member ? '会员' : '普通客户') +} + +function isToday(value) { + if (!value) { + return false + } + return formatCustomerDate(value) === new Date().toISOString().slice(0, 10) +} + +function mapCustomer(item, index) { + const name = item.nickname || item.name || item.account || '客户' + return { + id: item.id, + name, + avatar: item.avatar || item.avatarUrl || item.customerAvatar || DEFAULT_CUSTOMER_AVATARS[index % DEFAULT_CUSTOMER_AVATARS.length], + tagText: resolveCustomerTag(item), + amountText: formatCustomerAmount(resolveCustomerAmount(item)), + lastDateText: formatCustomerDate(item.lastOrderTime || item.lastConsumeTime), + arrivedToday: isToday(item.lastOrderTime || item.lastConsumeTime) + } +} + Page({ data: { keyword: '', customers: [], + customerStats: { + todayArrival: 0, + monthAmount: '0.00', + memberCount: 0 + }, loadError: '', createModalVisible: false, creating: false, @@ -27,15 +94,16 @@ Page({ try { const data = await customersApi.list({ keyword: this.data.keyword, page: 1, size: 30 }) const list = data.list || data || [] + const customers = list.map(mapCustomer) + const monthAmount = list.reduce((total, item) => total + Number(resolveCustomerMonthAmount(item) || 0), 0) this.setData({ loadError: '', - customers: list.map(item => ({ - id: item.id, - name: item.nickname || item.name || item.account || '客户', - shortName: (item.nickname || item.name || item.account || '客户').slice(-1), - phone: item.contactPhone || item.phone || '未填写', - lastTime: item.lastOrderTime || item.lastConsumeTime || '-' - })) + customers, + customerStats: { + todayArrival: customers.filter(item => item.arrivedToday).length, + monthAmount: formatCustomerAmount(monthAmount), + memberCount: list.filter(item => item.member || item.memberLevelName || item.levelName).length + } }) } catch (error) { this.setData({ diff --git a/JY-Salon-WeChat/pages/customers/index.wxml b/JY-Salon-WeChat/pages/customers/index.wxml index 086ba34e..f64551ad 100644 --- a/JY-Salon-WeChat/pages/customers/index.wxml +++ b/JY-Salon-WeChat/pages/customers/index.wxml @@ -1,9 +1,27 @@ - - - - + + + 客户 + + + + + ⌕ + + + + + + {{customerStats.todayArrival}} + 今日到店 + + + ¥{{customerStats.monthAmount}} + 本月消费 + + + {{customerStats.memberCount}} + 会员人数 - @@ -13,16 +31,20 @@ 暂无客户 - - {{item.shortName}} - - - {{item.name}} - 已建档 - - {{item.phone}} - 最近消费 {{item.lastTime}} + + + + + + + {{item.name}} + {{item.tagText}} + + 最近消费 + ¥{{item.amountText}} + + 最近到店 {{item.lastDateText}} › @@ -32,7 +54,7 @@ 新增客户 - × + diff --git a/JY-Salon-WeChat/pages/customers/index.wxss b/JY-Salon-WeChat/pages/customers/index.wxss index 216937ff..e5f54185 100644 --- a/JY-Salon-WeChat/pages/customers/index.wxss +++ b/JY-Salon-WeChat/pages/customers/index.wxss @@ -1,75 +1,130 @@ -.customer-toolbar { +.customer-page { + padding-top: 30rpx; +} + +.customer-header { display: flex; align-items: center; - gap: 14rpx; - margin-bottom: 8rpx; + justify-content: space-between; + margin: 0 4rpx 26rpx; +} + +.customer-title { + color: #302a25; + font-size: 42rpx; + font-weight: 900; +} + +.customer-edit-btn { + width: 112rpx; + min-width: 112rpx; + max-width: 112rpx; + height: 58rpx; + font-size: 23rpx; } .search-card { - flex: 1; - padding: 0 24rpx; - height: 84rpx; display: flex; align-items: center; - border-color: rgba(111, 143, 131, 0.12); - background: rgba(255, 255, 255, 0.82); + gap: 12rpx; + width: 100%; + height: 82rpx; + padding: 0 24rpx; + border-color: rgba(111, 143, 131, 0.1); + background: rgba(255, 255, 255, 0.8); box-shadow: 0 8rpx 22rpx rgba(78, 96, 78, 0.05); } +.search-icon { + color: #a49b91; + font-size: 42rpx; + line-height: 1; + transform: rotate(-18deg); +} + .search-card input { - width: 100%; + flex: 1; + min-width: 0; font-size: 26rpx; } -.add-customer-btn { - width: 84rpx; - min-width: 84rpx; - max-width: 84rpx; - height: 84rpx; - min-height: 84rpx; - padding: 0; - border-radius: 50%; - background: #6f8f83; - color: #fffdf8; - font-size: 42rpx; - font-weight: 400; - line-height: 84rpx; - box-shadow: 0 10rpx 22rpx rgba(111, 143, 131, 0.2); +.customer-stats { + display: flex; + align-items: stretch; + margin-top: 22rpx; + padding: 22rpx 0; + border-color: rgba(111, 143, 131, 0.08); + background: rgba(255, 255, 255, 0.72); +} + +.customer-stat { + display: flex; + flex: 1; + align-items: center; + flex-direction: column; + gap: 8rpx; + border-right: 1rpx solid #eee8df; +} + +.customer-stat:last-child { + border-right: 0; +} + +.customer-stat-value { + color: #3d594e; + font-size: 30rpx; + font-weight: 900; +} + +.customer-stat-label { + color: #9c948b; + font-size: 20rpx; +} + +.list { + margin-top: 28rpx; } .customer-card { display: flex; align-items: center; - justify-content: space-between; - padding: 22rpx 20rpx; - border-color: rgba(111, 143, 131, 0.1); - background: rgba(255, 255, 255, 0.86); + gap: 18rpx; + min-height: 132rpx; + padding: 20rpx; + border-color: rgba(111, 143, 131, 0.08); + background: rgba(255, 255, 255, 0.84); box-shadow: 0 8rpx 20rpx rgba(78, 96, 78, 0.045); } -.customer-identity { - display: flex; - align-items: center; - min-width: 0; - gap: 18rpx; +.customer-avatar-wrap { + position: relative; + flex: 0 0 auto; + width: 84rpx; + height: 84rpx; } -.customer-avatar { - display: flex; - align-items: center; - justify-content: center; - flex: 0 0 auto; - width: 76rpx; - height: 76rpx; - border: 4rpx solid #f4faf2; +.customer-avatar-image { + display: block; + width: 84rpx; + height: 84rpx; + border: 4rpx solid #f5faf3; border-radius: 50%; - background: #dcece0; - color: #4f8068; - font-size: 30rpx; - font-weight: 900; + background: #e3eee2; +} + +.customer-online-dot { + position: absolute; + right: 0; + bottom: 2rpx; + width: 16rpx; + height: 16rpx; + border: 3rpx solid #fffdf8; + border-radius: 50%; + background: #85b58a; } .customer-copy { + flex: 1; min-width: 0; } @@ -77,40 +132,60 @@ display: flex; align-items: center; gap: 10rpx; + min-width: 0; +} + +.name { + overflow: hidden; + color: #292520; + font-size: 29rpx; + font-weight: 800; + text-overflow: ellipsis; + white-space: nowrap; } .customer-status { display: inline-flex; align-items: center; + flex: 0 0 auto; min-height: 32rpx; padding: 0 10rpx; border-radius: 999rpx; - background: #eff7ef; - color: #6a9876; + background: #fff0df; + color: #bd7a4d; font-size: 18rpx; font-weight: 800; } -.name, +.customer-detail-row { + display: flex; + align-items: baseline; + gap: 12rpx; + margin-top: 10rpx; +} + +.meta-label, +.meta { + color: #9b938a; + font-size: 21rpx; +} + +.amount { + color: #557c69; + font-size: 25rpx; + font-weight: 900; +} + .meta { display: block; -} - -.name { - color: #292520; - font-size: 29rpx; - font-weight: 800; -} - -.meta { - margin-top: 8rpx; - color: #928a81; - font-size: 24rpx; + margin-top: 6rpx; } .arrow { + flex: 0 0 auto; color: #b0a79e; font-size: 48rpx; + line-height: 1; } .retry-btn { @@ -163,19 +238,16 @@ border: 1rpx solid #e4d8ca; border-radius: 50%; background: #fffaf4; - color: transparent; - font-size: 0; - line-height: 0; } .modal-close::before, .modal-close::after { - content: ""; position: absolute; width: 22rpx; height: 3rpx; border-radius: 999rpx; background: #61554c; + content: ""; } .modal-close::before { diff --git a/JY-Salon-WeChat/pages/planning/index.js b/JY-Salon-WeChat/pages/planning/index.js index aecb8f8e..9d60ddb5 100644 --- a/JY-Salon-WeChat/pages/planning/index.js +++ b/JY-Salon-WeChat/pages/planning/index.js @@ -255,6 +255,9 @@ Page({ shopRestDates: [], monthDays: [], weekDays: [], + weekHours: [], + weekTimelineHeight: 720, + weekGridWidth: 720, dayLanes: [], hours: [], timelineHeight: 720, @@ -599,6 +602,7 @@ Page({ prepareView() { const current = this.data.currentDateText const range = this.resolveRange() + const weekDays = this.buildWeekDays() const title = this.data.viewMode === 'month' ? dateUtil.formatMonth(current) : this.data.viewMode === 'week' @@ -609,7 +613,7 @@ Page({ rangeText: this.data.viewMode === 'month' ? '月视图' : this.data.viewMode === 'week' ? '周视图' : '日视图', weekRange: `${formatMonthDay(range.start)} - ${formatMonthDay(range.end)}`, monthDays: this.buildMonthDays(), - weekDays: this.buildWeekDays(), + ...this.buildWeekTimeline(weekDays), ...this.buildDayView() }) }, @@ -650,6 +654,10 @@ Page({ buildWeekDays() { const start = dateUtil.startOfWeek(this.data.currentDateText) const summaryMap = this.summaryMap() + const artistMap = (this.data.artists || []).reduce((map, artist) => { + map[String(artist.id)] = artist + return map + }, {}) return this.data.weekLabels.map((label, index) => { const target = dateUtil.addDays(start, index) const date = dateUtil.formatDate(target) @@ -662,6 +670,22 @@ Page({ day: target.getDate(), totalCount: summary.totalCount || 0, statusClass: resolveDayStatusClass(dayAppointments), + blocks: dayAppointments.map((item, appointmentIndex) => { + const startMinute = resolveAppointmentStartMinute(item) + const orderItemId = resolveAppointmentItemId(item) + const artist = artistMap[String(item.artistId)] || {} + return { + ...item, + key: `${date}-${orderItemId || 'appointment'}-${appointmentIndex}`, + id: orderItemId, + orderItemId, + top: startMinute, + height: Math.max(76, Number(item.durationMinutes || 60)), + timeText: resolveAppointmentTimeText(item), + statusClass: appointmentStatusClass(item.status), + color: artist.color || item.color || '#B8B0A6' + } + }), artistCounts: artistCounts.map(count => ({ ...count, width: Math.max(12, Math.min(100, count.count * 22)), @@ -756,6 +780,33 @@ Page({ }) }, + buildWeekTimeline(weekDays) { + const startMinute = dateUtil.minutesOfDay(this.data.businessStartTime) + const endMinute = dateUtil.minutesOfDay(this.data.businessEndTime) + const timelineHeight = Math.max(560, endMinute - startMinute) + const hours = [] + for (let cursor = startMinute; cursor <= endMinute; cursor += 60) { + hours.push({ + value: cursor, + label: dateUtil.timeFromMinutes(cursor), + top: cursor - startMinute + }) + } + const timelineDays = weekDays.map(day => ({ + ...day, + blocks: day.blocks.map(block => ({ + ...block, + top: Math.max(0, block.top - startMinute) + })) + })) + return { + weekDays: timelineDays, + weekHours: hours, + weekTimelineHeight: timelineHeight, + weekGridWidth: 92 + (timelineDays.length * 116) + } + }, + appointmentCountsByDate(date) { const artistMap = (this.data.artists || []).reduce((map, artist) => { map[String(artist.id)] = artist diff --git a/JY-Salon-WeChat/pages/planning/index.wxml b/JY-Salon-WeChat/pages/planning/index.wxml index dd5f96d5..1dd437d6 100644 --- a/JY-Salon-WeChat/pages/planning/index.wxml +++ b/JY-Salon-WeChat/pages/planning/index.wxml @@ -80,26 +80,37 @@ - - - {{item.weekName}} - {{item.day}} - - - - - 本周排班密度 - {{weekRange}} - - - {{item.weekName}} {{item.day}} - - - {{count.shortName}}{{count.count}} + + 周排班 + {{weekRange}} + + + + + 排班 + + {{item.weekName}} + {{item.day}} + {{item.totalCount || 0}} + + + + + {{item.label}} + + + + + {{block.timeText}} + {{block.customerName}} + {{block.productTitle}} + + — + - + diff --git a/JY-Salon-WeChat/pages/planning/index.wxss b/JY-Salon-WeChat/pages/planning/index.wxss index aadd735f..0b06f91d 100644 --- a/JY-Salon-WeChat/pages/planning/index.wxss +++ b/JY-Salon-WeChat/pages/planning/index.wxss @@ -576,6 +576,211 @@ 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='%23c64e5b' stroke-opacity='.92' stroke-width='2' stroke-linecap='square' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E"); } +.week-toolbar { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 16rpx; + margin: 20rpx 8rpx 14rpx; +} + +.week-toolbar-title { + color: #4c4740; + font-size: 26rpx; + font-weight: 800; +} + +.week-toolbar-range { + color: #9a9288; + font-size: 22rpx; +} + +.week-board { + height: 900rpx; + margin-top: 0; + padding: 0; + overflow: hidden; + border-color: rgba(111, 143, 131, 0.1); + background: #fffdf8; + box-shadow: 0 8rpx 20rpx rgba(78, 96, 78, 0.04); +} + +.week-calendar { + min-width: 904rpx; +} + +.week-calendar-head { + position: sticky; + top: 0; + z-index: 6; + display: flex; + height: 104rpx; + border-bottom: 1rpx solid #eee8df; + background: rgba(255, 253, 248, 0.96); +} + +.week-time-corner { + display: flex; + align-items: center; + justify-content: center; + flex: 0 0 92rpx; + color: #9a9288; + font-size: 20rpx; +} + +.week-date-column { + position: relative; + display: flex; + align-items: center; + justify-content: center; + flex: 0 0 116rpx; + flex-direction: column; + gap: 4rpx; + border-left: 1rpx solid #f0ebe4; + color: #8f877e; +} + +.week-date-column.active { + background: #eef7f0; + color: #2f6f62; +} + +.week-date-column.active::after { + position: absolute; + right: 18rpx; + bottom: 10rpx; + left: 18rpx; + height: 5rpx; + border-radius: 999rpx; + background: #6f8f83; + content: ""; +} + +.week-name { + color: inherit; + font-size: 20rpx; +} + +.week-date { + margin-top: 0; + color: #292520; + font-size: 30rpx; + font-weight: 800; +} + +.week-date-column.active .week-date { + color: #2f6f62; +} + +.week-count { + color: #aaa198; + font-size: 17rpx; +} + +.week-calendar-body { + position: relative; + display: flex; + min-height: 560rpx; +} + +.week-time-axis { + position: relative; + z-index: 3; + flex: 0 0 92rpx; + border-right: 1rpx solid #eee8df; + background: #fffdf8; +} + +.week-time-label { + position: absolute; + right: 12rpx; + color: #aaa198; + font-size: 18rpx; + line-height: 1; + transform: translateY(-50%); +} + +.week-day-columns { + display: flex; + flex: 1; + min-width: 0; +} + +.week-day-column { + position: relative; + flex: 0 0 116rpx; + border-right: 1rpx solid #f0ebe4; + background-image: linear-gradient(to bottom, rgba(214, 207, 197, 0.32) 1rpx, transparent 1rpx); + background-size: 100% 60rpx; +} + +.week-day-column.active { + background-color: rgba(238, 247, 240, 0.34); +} + +.week-appointment-block { + position: absolute; + right: 10rpx; + left: 10rpx; + display: flex; + flex-direction: column; + gap: 2rpx; + overflow: hidden; + padding: 8rpx 8rpx; + border-left: 5rpx solid rgba(255, 255, 255, 0.78); + border-radius: 9rpx; + color: #355849; + box-shadow: 0 6rpx 12rpx rgba(70, 92, 75, 0.1); +} + +.week-appointment-block.pending { + color: #986b2f; +} + +.week-appointment-block.is-completed { + opacity: 0.74; +} + +.week-appointment-block.is-cancelled { + opacity: 0.56; +} + +.week-block-time, +.week-block-title, +.week-block-meta { + display: block; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.week-block-time { + color: inherit; + font-size: 16rpx; + font-weight: 800; +} + +.week-block-title { + color: #2f4d3d; + font-size: 22rpx; + font-weight: 900; +} + +.week-block-meta { + color: rgba(47, 77, 61, 0.72); + font-size: 16rpx; +} + +.week-column-empty { + position: absolute; + top: 40rpx; + right: 0; + left: 0; + color: #d3ccc3; + font-size: 22rpx; + text-align: center; +} + .month-card { overflow: hidden; } diff --git a/docs/项目变更记录.md b/docs/项目变更记录.md index eaab4cbd..2933773e 100644 --- a/docs/项目变更记录.md +++ b/docs/项目变更记录.md @@ -612,3 +612,12 @@ - 影响范围:`JY-Salon-WeChat/pages/planning/`、`pages/customers/`、`pages/employees/`、`pages/profile/`;不涉及后端、SQL、接口和其他端。 - 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。 - 验证结果:店务小程序 21 个 JS 文件语法检查通过;120 个 JSON/WXML/WXSS 文件 BOM 检查通过;`git diff --check` 通过;微信开发者工具 `JY-Salon-WeChat` 在 `ws://127.0.0.1:9420` 下四个 tabBar 页面路由和关键元素验收 16/16 通过;GitNexus unstaged 变更检测为 low risk、0 个受影响流程。 + +## 2026-07-25 店务小程序周视图与客户页 UI 改造 + +- 变更原因:依据用户提供的周视图和客户页设计图,让排班按日期与时间轴展示,并让客户列表更接近头像卡片、统计摘要和轻量编辑入口的参考样式。 +- 处理方式:规划周视图新增七列日期、时间轴和按预约开始时间定位的预约块;预约块底色优先读取对应美甲师颜色。客户页新增搜索区、今日到店/本月消费/会员人数统计、默认头像、客户标签、最近消费和最近到店信息;保留客户详情跳转和新增客户弹窗。 +- 资源说明:新增 `JY-Salon-WeChat/assets/images/default-avatar-1.png` 至 `default-avatar-4.png` 四张默认头像,客户没有头像时按列表序号循环使用。 +- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。 +- 影响范围:`JY-Salon-WeChat/pages/planning/`、`pages/customers/` 和客户默认头像资源;不涉及后端、SQL 和其他端。 +- 验证结果:规划页与客户页 JS 语法检查通过,修改文件无 UTF-8 BOM,`git diff --check` 通过;微信开发者工具运行态确认周视图 7 个日期列、时间轴和预约块正常渲染,客户页标题、编辑入口、搜索框和三项统计正常渲染。