调整周视图和客户页展示样式

This commit is contained in:
2026-07-25 18:12:02 +08:00
parent 87862a3c36
commit c24b2725be
11 changed files with 541 additions and 103 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

+75 -7
View File
@@ -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({
+37 -15
View File
@@ -1,9 +1,27 @@
<view class="page">
<view class="customer-toolbar">
<view class="search-card card">
<input value="{{keyword}}" bindinput="onSearchInput" placeholder="搜索客户姓名或手机号" />
<view class="page customer-page">
<view class="customer-header">
<text class="customer-title">客户</text>
<button class="compact-btn customer-edit-btn" bindtap="addCustomer">编辑</button>
</view>
<view class="search-card card">
<text class="search-icon">⌕</text>
<input value="{{keyword}}" bindinput="onSearchInput" placeholder="搜索客户姓名或手机号" />
</view>
<view class="customer-stats card">
<view class="customer-stat">
<text class="customer-stat-value">{{customerStats.todayArrival}}</text>
<text class="customer-stat-label">今日到店</text>
</view>
<view class="customer-stat">
<text class="customer-stat-value">¥{{customerStats.monthAmount}}</text>
<text class="customer-stat-label">本月消费</text>
</view>
<view class="customer-stat">
<text class="customer-stat-value">{{customerStats.memberCount}}</text>
<text class="customer-stat-label">会员人数</text>
</view>
<button class="compact-btn add-customer-btn" bindtap="addCustomer">+</button>
</view>
<view class="list section">
@@ -13,16 +31,20 @@
</view>
<view wx:elif="{{customers.length === 0}}" class="empty card">暂无客户</view>
<view wx:for="{{customers}}" wx:key="id" class="card list-card customer-card" data-id="{{item.id}}" bindtap="openDetail">
<view class="customer-identity">
<view class="customer-avatar">{{item.shortName}}</view>
<view class="customer-copy">
<view class="customer-name-row">
<text class="name">{{item.name}}</text>
<text class="customer-status">已建档</text>
</view>
<text class="meta">{{item.phone}}</text>
<text class="meta">最近消费 {{item.lastTime}}</text>
<view class="customer-avatar-wrap">
<image class="customer-avatar-image" src="{{item.avatar}}" mode="aspectFill"></image>
<view class="customer-online-dot"></view>
</view>
<view class="customer-copy">
<view class="customer-name-row">
<text class="name">{{item.name}}</text>
<text class="customer-status">{{item.tagText}}</text>
</view>
<view class="customer-detail-row">
<text class="meta-label">最近消费</text>
<text class="amount">¥{{item.amountText}}</text>
</view>
<text class="meta">最近到店 {{item.lastDateText}}</text>
</view>
<text class="arrow">›</text>
</view>
@@ -32,7 +54,7 @@
<view class="customer-modal" catchtap="stopTap">
<view class="modal-head">
<text class="modal-title">新增客户</text>
<view class="modal-close" bindtap="closeCreateModal">×</view>
<view class="modal-close" bindtap="closeCreateModal"></view>
</view>
<view class="form-grid">
<view class="modal-field">
+135 -63
View File
@@ -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 {
+52 -1
View File
@@ -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
+28 -17
View File
@@ -80,26 +80,37 @@
</view>
<view wx:if="{{viewMode === 'week'}}" class="section">
<scroll-view class="week-strip" scroll-x enable-flex>
<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>
</view>
</scroll-view>
<view class="card week-grid">
<view class="week-grid-head">
<text>本周排班密度</text>
<text class="muted">{{weekRange}}</text>
</view>
<view wx:for="{{weekDays}}" wx:key="date" class="week-line">
<view class="week-line-date">{{item.weekName}} {{item.day}}</view>
<view class="week-line-bars {{item.totalCount === 0 ? 'empty' : ''}}">
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="key" class="week-count-bar {{count.statusClass}}" style="background: {{count.color}}; width: {{count.barWidth}}%;">
<text>{{count.shortName}}{{count.count}}</text>
<view class="week-toolbar">
<text class="week-toolbar-title">周排班</text>
<text class="week-toolbar-range">{{weekRange}}</text>
</view>
<scroll-view class="week-board card" scroll-x scroll-y enable-flex>
<view class="week-calendar" style="width: {{weekGridWidth}}rpx;">
<view class="week-calendar-head">
<view class="week-time-corner">排班</view>
<view wx:for="{{weekDays}}" wx:key="date" class="week-date-column {{item.date === currentDateText ? 'active' : ''}}" data-date="{{item.date}}" bindtap="selectDate">
<text class="week-name">{{item.weekName}}</text>
<text class="week-date">{{item.day}}</text>
<text class="week-count">{{item.totalCount || 0}}</text>
</view>
</view>
<view class="week-calendar-body" style="height: {{weekTimelineHeight}}rpx;">
<view class="week-time-axis">
<view wx:for="{{weekHours}}" wx:key="value" class="week-time-label" style="top: {{item.top}}rpx;">{{item.label}}</view>
</view>
<view class="week-day-columns">
<view wx:for="{{weekDays}}" wx:key="date" class="week-day-column {{item.date === currentDateText ? 'active' : ''}}" style="height: {{weekTimelineHeight}}rpx;">
<view wx:for="{{item.blocks}}" wx:for-item="block" wx:key="key" class="week-appointment-block {{block.statusClass}}" style="top: {{block.top}}rpx; height: {{block.height}}rpx; background: {{block.color}};" data-id="{{block.orderItemId || block.id}}" data-order-item-id="{{block.orderItemId || block.id}}" bindtap="openAppointment">
<text class="week-block-time">{{block.timeText}}</text>
<text class="week-block-title">{{block.customerName}}</text>
<text class="week-block-meta">{{block.productTitle}}</text>
</view>
<view wx:if="{{item.blocks.length === 0}}" class="week-column-empty">—</view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
</view>
<view wx:if="{{viewMode === 'month'}}" class="section">
+205
View File
@@ -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;
}
+9
View File
@@ -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 个日期列、时间轴和预约块正常渲染,客户页标题、编辑入口、搜索框和三项统计正常渲染。