修复我的页身份和规划日周视图

This commit is contained in:
2026-06-27 01:46:44 +08:00
parent 223cd755a2
commit 28219e5fc2
7 changed files with 107 additions and 16 deletions
+42 -9
View File
@@ -11,6 +11,36 @@ function resolveCalendarErrorMessage(error) {
return error && error.message ? error.message : '规划数据加载失败'
}
function toLocalDate(value) {
return value instanceof Date ? new Date(value.getTime()) : new Date(String(value).replace(/-/g, '/'))
}
function formatMonthDay(value) {
const target = toLocalDate(value)
return `${target.getMonth() + 1}月${target.getDate()}日`
}
function resolveAppointmentDate(item) {
if (item.date) return item.date
return String(item.startTime || '').slice(0, 10)
}
function resolveAppointmentStartMinute(item) {
if (item.startMinute !== undefined && item.startMinute !== null) {
return Number(item.startMinute)
}
const timeText = String(item.startTime || '').slice(11, 16)
return dateUtil.minutesOfDay(timeText)
}
function resolveAppointmentTimeText(item) {
const startMinute = resolveAppointmentStartMinute(item)
const duration = Number(item.durationMinutes || 60)
const startText = String(item.startTime || '').slice(11, 16) || dateUtil.timeFromMinutes(startMinute)
const endText = String(item.endTime || '').slice(11, 16) || dateUtil.timeFromMinutes(startMinute + duration)
return `${startText}-${endText}`
}
Page({
data: {
viewMode: 'month',
@@ -46,6 +76,7 @@ Page({
timelineHeight: 720,
laneWidth: 720,
laneItemWidth: 240,
laneHeaderHeight: 54,
dayTotal: 0,
freeArtistCount: 0,
pendingCount: 0,
@@ -216,12 +247,12 @@ Page({
const title = this.data.viewMode === 'month'
? dateUtil.formatMonth(current)
: this.data.viewMode === 'week'
? `${range.start.replace(/-/g, '/')} - ${range.end.replace(/-/g, '/')}`
? `${formatMonthDay(range.start)} - ${formatMonthDay(range.end)}`
: dateUtil.formatCnDate(current)
this.setData({
dateTitle: title,
rangeText: this.data.viewMode === 'month' ? '月视图' : this.data.viewMode === 'week' ? '周视图' : '日视图',
weekRange: `${range.start.replace(/-/g, '/')} - ${range.end.replace(/-/g, '/')}`,
weekRange: `${formatMonthDay(range.start)} - ${formatMonthDay(range.end)}`,
monthDays: this.buildMonthDays(),
weekDays: this.buildWeekDays(),
...this.buildDayView()
@@ -259,7 +290,7 @@ Page({
const target = dateUtil.addDays(start, index)
const date = dateUtil.formatDate(target)
const summary = summaryMap[date] || { artistCounts: [], totalCount: 0 }
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || [])
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || []).filter(count => count.count > 0)
return {
date,
weekName: `周${label}`,
@@ -278,28 +309,29 @@ Page({
const startMinute = dateUtil.minutesOfDay(this.data.businessStartTime)
const endMinute = dateUtil.minutesOfDay(this.data.businessEndTime)
const timelineHeight = Math.max(560, endMinute - startMinute)
const laneHeaderHeight = 54
const hours = []
for (let cursor = startMinute; cursor <= endMinute; cursor += 60) {
hours.push({
value: cursor,
label: dateUtil.timeFromMinutes(cursor),
top: cursor - startMinute
top: cursor - startMinute + laneHeaderHeight
})
}
const filteredArtists = this.data.selectedArtistId
? this.data.artists.filter(item => String(item.id) === String(this.data.selectedArtistId))
: this.data.artists
const dayAppointments = this.data.appointments.filter(item => item.date === this.data.currentDateText)
const dayAppointments = this.data.appointments.filter(item => resolveAppointmentDate(item) === this.data.currentDateText)
const lanes = filteredArtists.map(artist => {
const blocks = dayAppointments
.filter(item => String(item.artistId) === String(artist.id))
.map(item => {
const itemStart = item.startMinute || dateUtil.minutesOfDay((item.startTime || '').slice(11, 16))
const itemStart = resolveAppointmentStartMinute(item)
return {
...item,
top: Math.max(0, itemStart - startMinute),
top: Math.max(0, itemStart - startMinute) + laneHeaderHeight,
height: Math.max(64, item.durationMinutes || 60),
timeText: `${(item.startTime || '').slice(11, 16)}-${(item.endTime || '').slice(11, 16)}`
timeText: resolveAppointmentTimeText(item)
}
})
return { ...artist, blocks }
@@ -308,7 +340,8 @@ Page({
return {
dayLanes: lanes,
hours,
timelineHeight,
timelineHeight: timelineHeight + laneHeaderHeight,
laneHeaderHeight,
laneItemWidth: 248,
laneWidth: Math.max(720, lanes.length * 248),
dayTotal: dayAppointments.length,
+2 -2
View File
@@ -82,7 +82,7 @@
<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">
<view class="week-bars {{item.totalCount === 0 ? 'empty' : ''}}">
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="artistId" class="week-bar" style="background: {{count.color}}; width: {{count.width}}%;"></view>
</view>
</view>
@@ -94,7 +94,7 @@
</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">
<view class="week-line-bars {{item.totalCount === 0 ? 'empty' : ''}}">
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="artistId" class="week-count-bar" style="background: {{count.color}}; width: {{count.barWidth}}%;">
<text>{{count.shortName}}{{count.count}}</text>
</view>
@@ -232,6 +232,12 @@
background: #fffdf8;
}
.time-axis::before {
display: block;
height: 54rpx;
content: '';
}
.time-label {
position: absolute;
right: 12rpx;
@@ -363,6 +369,11 @@
flex-direction: column;
gap: 6rpx;
margin-top: 12rpx;
min-height: 22rpx;
}
.week-bars.empty {
min-height: 22rpx;
}
.week-bar {
@@ -403,6 +414,11 @@
display: flex;
flex-direction: column;
gap: 6rpx;
min-height: 28rpx;
}
.week-line-bars.empty {
min-height: 28rpx;
}
.week-count-bar {
+12 -1
View File
@@ -1,9 +1,18 @@
const { BRAND_CONFIG } = require('../../utils/config')
function resolveRoleText(type) {
const role = Number(type)
if (role === 2) return '店长'
if (role === 3) return '美甲师'
if (role === 4) return '管理员'
return '管理端'
}
Page({
data: {
shopName: BRAND_CONFIG.defaultShopName,
phone: '店长端',
roleText: '管理端',
menus: [
{ title: '店铺设置', url: '/pages/shop-settings/index' },
{ title: '数据导出', url: '/pages/export/index' },
@@ -14,9 +23,11 @@ Page({
onShow() {
const app = getApp()
const userInfo = app.globalData.userInfo || {}
this.setData({
shopName: app.globalData.shopName || BRAND_CONFIG.appName,
phone: (app.globalData.userInfo && (app.globalData.userInfo.phone || app.globalData.userInfo.account)) || '店长端'
phone: userInfo.phone || userInfo.account || '店长端',
roleText: resolveRoleText(userInfo.type)
})
},
+7 -4
View File
@@ -1,10 +1,13 @@
<view class="page">
<view class="card profile-card">
<view class="shop-logo">指</view>
<view>
<text class="shop-name">{{shopName}}</text>
<text class="phone">{{phone}}</text>
<view class="profile-main">
<view class="shop-logo">指</view>
<view class="profile-copy">
<text class="shop-name">{{shopName}}</text>
<text class="phone">{{phone}}</text>
</view>
</view>
<text class="role-badge">{{roleText}}</text>
</view>
<view class="section menu-list card">
@@ -1,14 +1,27 @@
.profile-card {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20rpx;
padding: 28rpx;
}
.profile-main {
display: flex;
align-items: center;
min-width: 0;
gap: 20rpx;
}
.profile-copy {
min-width: 0;
}
.shop-logo {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 96rpx;
height: 96rpx;
border-radius: 24rpx;
@@ -26,6 +39,9 @@
.shop-name {
font-size: 34rpx;
font-weight: 800;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.phone {
@@ -34,6 +50,17 @@
font-size: 24rpx;
}
.role-badge {
flex-shrink: 0;
padding: 8rpx 18rpx;
border-radius: 999rpx;
background: #e5eee9;
color: #4e7165;
font-size: 23rpx;
font-weight: 800;
line-height: 1.2;
}
.menu-list {
overflow: hidden;
}
+1
View File
@@ -631,6 +631,7 @@ rtk node WeChatProgram/utils/theme.test.js
- 小程序很多页面只做过 `node --check`,真机交互仍需微信开发者工具验证。
- 用户端文案必须中文,不要出现英文测试提示或英文占位验收数据。
- 小程序自动化的 `mp_evaluate` 在部分会话会对任意函数报 `(intermediate value) is not a function`;验证页面状态时改用 `page_setData`、`page_getData`、`page_snapshot` 等不依赖 evaluate 的工具。
- 小程序自动化健康检查可能连接到旧项目路径(如 `FD-WeChat-Fronted`)而不是当前 `FM-Wechat-Fronted`,导致 automator session missing;先用正确 `projectPath` 恢复,恢复不完整时记录为连接层验证缺口,不要循环重连。
## Web 体验坑