重构店铺设置展示与编辑流程

This commit is contained in:
2026-07-23 20:22:01 +08:00
parent b965057499
commit 0996f73af6
14 changed files with 1530 additions and 567 deletions
+129 -264
View File
@@ -3,7 +3,6 @@ const tagsApi = require('../../api/tags')
const dateUtil = require('../../utils/date')
const { BRAND_CONFIG } = require('../../utils/config')
const { markPlanningRefresh } = require('../../utils/planning-refresh')
const { chooseImageFilePath, uploadObjectFile, resolveUploadedImagePreviewUrl } = require('../../utils/upload')
const PRESETS = [
{ value: 'EVERYDAY', label: '全周营业', workDays: [1, 2, 3, 4, 5, 6, 7], startTime: '10:00', endTime: '22:00' },
@@ -29,13 +28,6 @@ const EXCEPTION_TYPES = [
]
const DEFAULT_SHOP_INTRO = '专注法式、晕染与手绘设计,适合想要温柔质感的客人。'
const DEFAULT_TAG_STYLE = {
textColor: '#333333',
bgColor: '#FFFFFF',
borderColor: '#E5E5E5',
sortOrder: 100,
frontVisible: 1
}
function copyWorkDays(days) {
if (Array.isArray(days)) {
@@ -81,10 +73,6 @@ function resolveFirstImageUrl(urls) {
return Array.isArray(urls) ? String(urls[0] || '').trim() : ''
}
function introLength(value) {
return String(value || '').length
}
function normalizeTagOption(tag) {
const name = String((tag && (tag.displayName || tag.tagName || tag.name)) || '').trim()
if (!name) {
@@ -95,18 +83,15 @@ function normalizeTagOption(tag) {
name,
tagName: (tag && tag.tagName) || name,
displayName: (tag && tag.displayName) || name,
textColor: (tag && tag.textColor) || DEFAULT_TAG_STYLE.textColor,
bgColor: (tag && tag.bgColor) || DEFAULT_TAG_STYLE.bgColor,
borderColor: (tag && tag.borderColor) || DEFAULT_TAG_STYLE.borderColor,
sortOrder: (tag && tag.sortOrder) || DEFAULT_TAG_STYLE.sortOrder,
frontVisible: (tag && tag.frontVisible) === 0 ? 0 : DEFAULT_TAG_STYLE.frontVisible
textColor: (tag && tag.textColor) || '#333333',
bgColor: (tag && tag.bgColor) || '#FFFFFF',
borderColor: (tag && tag.borderColor) || '#E5E5E5'
}
}
function normalizeTagOptions(tags) {
const source = Array.isArray(tags) ? tags : []
const names = new Set()
return source
return (Array.isArray(tags) ? tags : [])
.map(normalizeTagOption)
.filter(Boolean)
.filter(item => {
@@ -118,60 +103,83 @@ function normalizeTagOptions(tags) {
})
}
function resolveCurrentShopId() {
const app = getApp()
const userInfo = (app && app.globalData && app.globalData.userInfo) || {}
return userInfo.shopId || (app && app.globalData && app.globalData.shopId) || ''
function buildWorkDaysText(days) {
const selected = copyWorkDays(days)
if (selected.length === 7) {
return '周一至周日'
}
return selected.map(day => WEEKDAYS.find(item => item.value === day)).filter(Boolean).map(item => item.label).join('、') || '未设置营业日'
}
function buildTagPayload(tagName, sourceTag) {
const shopId = resolveCurrentShopId()
const payload = {
tagName,
textColor: (sourceTag && sourceTag.textColor) || DEFAULT_TAG_STYLE.textColor,
bgColor: (sourceTag && sourceTag.bgColor) || DEFAULT_TAG_STYLE.bgColor,
borderColor: (sourceTag && sourceTag.borderColor) || DEFAULT_TAG_STYLE.borderColor,
sortOrder: (sourceTag && sourceTag.sortOrder) || DEFAULT_TAG_STYLE.sortOrder,
frontVisible: (sourceTag && sourceTag.frontVisible) === 0 ? 0 : DEFAULT_TAG_STYLE.frontVisible
function buildShopPayload(settings, form) {
const workDays = copyWorkDays(form.scheduleWorkDays)
return {
shopName: settings.shopName || settings.name || '',
description: settings.description || '',
address: settings.address || '',
mapProvider: settings.mapProvider || '',
longitude: settings.longitude,
latitude: settings.latitude,
businessHours: `${form.startTime}-${form.endTime}`,
schedulePresetType: form.schedulePresetType,
scheduleWorkDays: encodeWorkDays(workDays),
scheduleRemark: String(form.scheduleRemark || '').trim(),
coverImageFileId: String(settings.coverImageFileId || '').trim(),
imageFileIds: String(settings.imageFileIds || '').trim(),
themePrimaryColor: settings.themePrimaryColor || '',
themeSecondaryColor: settings.themeSecondaryColor || '',
themeAccentColor: settings.themeAccentColor || '',
themePageBgColor: settings.themePageBgColor || '',
themeCardBgColor: settings.themeCardBgColor || '',
themeBackgroundImageFileId: settings.themeBackgroundImageFileId || '',
status: settings.status,
authorizationStartDate: settings.authorizationStartDate,
authorizationDays: settings.authorizationDays,
authorizationExpireTime: settings.authorizationExpireTime
}
if (shopId) {
payload.shopId = shopId
}
function resolveForm(settings) {
const hours = String(settings.businessHours || '').split('-')
const preset = buildPreset(settings.schedulePresetType || 'EVERYDAY')
return {
startTime: String(settings.startTime || hours[0] || preset.startTime).slice(0, 5),
endTime: String(settings.endTime || hours[1] || preset.endTime).slice(0, 5),
schedulePresetType: settings.schedulePresetType || preset.value,
scheduleWorkDays: copyWorkDays(settings.scheduleWorkDays || preset.workDays),
scheduleRemark: settings.scheduleRemark || ''
}
return payload
}
Page({
data: {
presets: PRESETS,
loading: false,
loaded: false,
saving: false,
scheduleSheetVisible: false,
activeScheduleTab: 'RULE',
shopName: BRAND_CONFIG.defaultShopName,
shopDescription: DEFAULT_SHOP_INTRO,
coverImagePreviewUrl: '',
tagList: [],
tagCountText: '暂无标签',
scheduleSummary: '营业时间未设置',
scheduleRemarkText: '点击设置营业日和营业时间',
exceptionCountText: '特殊日期 · 0 条',
exceptionSummary: '暂无特殊日期',
exceptions: [],
settingsSnapshot: {},
presetOptions: buildPresetOptions('EVERYDAY'),
weekdays: WEEKDAYS,
weekdayOptions: buildWeekdayOptions([1, 2, 3, 4, 5, 6, 7]),
exceptionTypes: EXCEPTION_TYPES,
exceptionTypeIndex: 0,
exceptionTypeLabel: '休息',
exceptions: [],
loading: false,
saving: false,
tagsLoading: false,
tagSaving: false,
coverUploading: false,
coverImagePreviewUrl: '',
introLength: introLength(DEFAULT_SHOP_INTRO),
tagList: [],
tagForm: {
id: '',
name: ''
},
form: {
shopName: BRAND_CONFIG.defaultShopName,
startTime: '10:00',
endTime: '22:00',
defaultDuration: 60,
rule: DEFAULT_SHOP_INTRO,
schedulePresetType: 'EVERYDAY',
scheduleWorkDays: [1, 2, 3, 4, 5, 6, 7],
scheduleRemark: '',
coverImageFileId: ''
scheduleRemark: ''
},
exceptionForm: {
workDate: dateUtil.formatDate(new Date()),
@@ -186,15 +194,9 @@ Page({
this.loadSettings()
},
async loadTags() {
this.setData({ tagsLoading: true })
try {
const tagsData = await tagsApi.listAll()
this.setData({ tagList: normalizeTagOptions(tagsData.list || tagsData || []) })
} catch (error) {
wx.showToast({ title: error.message || '标签加载失败', icon: 'none' })
} finally {
this.setData({ tagsLoading: false })
onShow() {
if (this.data.loaded) {
this.loadSettings()
}
},
@@ -206,32 +208,30 @@ Page({
shopApi.scheduleExceptions(),
tagsApi.listAll()
])
const hours = String(settings.businessHours || '').split('-')
const preset = buildPreset(settings.schedulePresetType || 'EVERYDAY')
const form = {
...this.data.form,
shopName: settings.shopName || settings.name || this.data.form.shopName,
startTime: String(settings.startTime || hours[0] || preset.startTime).slice(0, 5),
endTime: String(settings.endTime || hours[1] || preset.endTime).slice(0, 5),
rule: settings.description || this.data.form.rule,
schedulePresetType: settings.schedulePresetType || preset.value,
scheduleWorkDays: copyWorkDays(settings.scheduleWorkDays || preset.workDays),
scheduleRemark: settings.scheduleRemark || '',
coverImageFileId: settings.coverImageFileId || ''
}
const form = resolveForm(settings || {})
const exceptionList = (exceptions || []).map(item => ({
...item,
startTime: item.startTime ? String(item.startTime).slice(0, 5) : '',
endTime: item.endTime ? String(item.endTime).slice(0, 5) : '',
summary: buildExceptionSummary(item)
}))
const tagList = normalizeTagOptions(tagsData.list || tagsData || [])
this.setData({
form,
introLength: introLength(form.rule),
loaded: true,
settingsSnapshot: settings || {},
shopName: settings.shopName || settings.name || this.data.shopName,
shopDescription: settings.description || DEFAULT_SHOP_INTRO,
coverImagePreviewUrl: resolveFirstImageUrl(settings.coverImageUrls),
tagList,
tagCountText: tagList.length ? `${tagList.length} 个标签` : '暂无标签',
scheduleSummary: `${buildWorkDaysText(form.scheduleWorkDays)} · ${form.startTime} - ${form.endTime}`,
scheduleRemarkText: form.scheduleRemark || '全周营业规则',
exceptionCountText: `特殊日期 · ${exceptionList.length} 条`,
exceptionSummary: exceptionList[0] ? exceptionList[0].summary : '暂无特殊日期',
exceptions: exceptionList,
form,
presetOptions: buildPresetOptions(form.schedulePresetType),
weekdayOptions: buildWeekdayOptions(form.scheduleWorkDays),
exceptions: (exceptions || []).map(item => ({
...item,
startTime: item.startTime ? String(item.startTime).slice(0, 5) : '',
endTime: item.endTime ? String(item.endTime).slice(0, 5) : '',
summary: buildExceptionSummary(item)
})),
tagList: normalizeTagOptions(tagsData.list || tagsData || [])
weekdayOptions: buildWeekdayOptions(form.scheduleWorkDays)
})
} catch (error) {
wx.showToast({ title: error.message || '店铺设置加载失败', icon: 'none' })
@@ -240,146 +240,37 @@ Page({
}
},
editProfile() {
wx.navigateTo({ url: '/pages/shop-profile-edit/index' })
},
editTags() {
wx.navigateTo({ url: '/pages/shop-tags/index' })
},
openScheduleSheet(event) {
this.setData({
scheduleSheetVisible: true,
activeScheduleTab: event.currentTarget.dataset.tab || 'RULE'
})
},
closeScheduleSheet() {
if (this.data.saving) {
return
}
this.setData({ scheduleSheetVisible: false })
},
stopPropagation() {},
switchScheduleTab(event) {
this.setData({ activeScheduleTab: event.currentTarget.dataset.tab || 'RULE' })
},
onInput(event) {
const field = event.currentTarget.dataset.field
const value = event.detail.value
const nextData = { [`form.${field}`]: value }
if (field === 'rule') {
nextData.introLength = introLength(value)
}
this.setData(nextData)
},
onTagInput(event) {
this.setData({ 'tagForm.name': event.detail.value })
},
editTag(event) {
const tagId = String(event.currentTarget.dataset.id || '')
const tag = this.data.tagList.find(item => String(item.id) === tagId)
if (!tag) {
wx.showToast({ title: '标签不存在', icon: 'none' })
return
}
this.setData({
tagForm: {
id: tag.id,
name: tag.tagName || tag.name
}
})
},
clearTagForm() {
this.setData({
tagForm: {
id: '',
name: ''
}
})
},
async saveTag() {
if (this.data.tagSaving) {
return
}
const tagName = String(this.data.tagForm.name || '').trim()
if (!tagName) {
wx.showToast({ title: '请输入标签名称', icon: 'none' })
return
}
const tagId = this.data.tagForm.id
const editingTag = tagId
? this.data.tagList.find(item => String(item.id) === String(tagId))
: null
this.setData({ tagSaving: true })
try {
if (tagId) {
await tagsApi.update(tagId, buildTagPayload(tagName, editingTag))
wx.showToast({ title: '标签已更新', icon: 'success' })
} else {
await tagsApi.create(buildTagPayload(tagName, null))
wx.showToast({ title: '标签已新增', icon: 'success' })
}
this.clearTagForm()
await this.loadTags()
} catch (error) {
wx.showToast({ title: error.message || '标签保存失败', icon: 'none' })
} finally {
this.setData({ tagSaving: false })
}
},
deleteTag(event) {
const tagId = String(event.currentTarget.dataset.id || '')
const tag = this.data.tagList.find(item => String(item.id) === tagId)
if (!tag) {
wx.showToast({ title: '标签不存在', icon: 'none' })
return
}
wx.showModal({
title: '删除标签',
content: `确认删除标签“${tag.name}”?`,
confirmText: '删除',
confirmColor: '#d98d8d',
success: async result => {
if (!result.confirm) {
return
}
this.setData({ tagSaving: true })
try {
await tagsApi.delete(tag.id)
if (String(this.data.tagForm.id) === String(tag.id)) {
this.clearTagForm()
}
await this.loadTags()
wx.showToast({ title: '标签已删除', icon: 'success' })
} catch (error) {
wx.showToast({ title: error.message || '标签删除失败', icon: 'none' })
} finally {
this.setData({ tagSaving: false })
}
}
})
},
async chooseCoverImage() {
if (this.data.coverUploading || this.data.saving) {
return
}
try {
const filePath = await chooseImageFilePath()
if (!filePath) {
return
}
this.setData({ coverUploading: true })
const uploadResult = await uploadObjectFile(filePath)
const fileId = String(uploadResult && uploadResult.id ? uploadResult.id : '').trim()
if (!fileId) {
throw new Error('店铺主图上传失败:上传接口未返回文件ID')
}
this.setData({
'form.coverImageFileId': fileId,
coverImagePreviewUrl: resolveUploadedImagePreviewUrl(uploadResult, filePath)
})
} catch (error) {
wx.showToast({ title: error.message || '店铺主图上传失败', icon: 'none' })
} finally {
this.setData({ coverUploading: false })
}
},
removeCoverImage() {
if (this.data.coverUploading || this.data.saving) {
return
}
this.setData({
'form.coverImageFileId': '',
coverImagePreviewUrl: ''
})
},
onExceptionInput(event) {
this.setData({ [`exceptionForm.${event.currentTarget.dataset.field}`]: event.detail.value })
this.setData({ [`form.${field}`]: event.detail.value })
},
selectPreset(event) {
@@ -401,8 +292,9 @@ Page({
toggleWeekday(event) {
const day = Number(event.currentTarget.dataset.value)
const workDays = copyWorkDays(this.data.form.scheduleWorkDays)
const exists = workDays.includes(day)
const nextDays = exists ? workDays.filter(item => item !== day) : [...workDays, day].sort()
const nextDays = workDays.includes(day)
? workDays.filter(item => item !== day)
: [...workDays, day].sort()
this.setData({
'form.schedulePresetType': 'CUSTOM',
'form.scheduleWorkDays': nextDays,
@@ -427,6 +319,10 @@ Page({
})
},
onExceptionInput(event) {
this.setData({ [`exceptionForm.${event.currentTarget.dataset.field}`]: event.detail.value })
},
onExceptionDateChange(event) {
this.setData({ 'exceptionForm.workDate': event.detail.value })
},
@@ -449,31 +345,9 @@ Page({
})
},
explainDefaultDuration() {
wx.showModal({
title: '默认时长',
content: '用于手动创建预约或未选择作品时的默认服务时长,会影响可约时间校验和预约结束时间估算。',
showCancel: false,
confirmText: '知道了'
})
},
explainShopIntro() {
wx.showModal({
title: '门店介绍',
content: '这里会保存为门店介绍,并展示在用户端门店详情。预约时间、容量和冲突校验仍由店铺排班、特殊日期和员工排班控制。',
showCancel: false,
confirmText: '知道了'
})
},
async save() {
async saveSchedule() {
const form = this.data.form
const workDays = copyWorkDays(form.scheduleWorkDays)
if (!form.shopName) {
wx.showToast({ title: '请填写店铺名称', icon: 'none' })
return
}
if (!workDays.length) {
wx.showToast({ title: '请选择营业日', icon: 'none' })
return
@@ -484,23 +358,13 @@ Page({
}
this.setData({ saving: true })
try {
await shopApi.saveSettings({
shopName: form.shopName,
name: form.shopName,
startTime: form.startTime,
endTime: form.endTime,
businessHours: `${form.startTime}-${form.endTime}`,
description: form.rule,
schedulePresetType: form.schedulePresetType,
scheduleWorkDays: encodeWorkDays(workDays),
scheduleRemark: String(form.scheduleRemark || '').trim(),
coverImageFileId: String(form.coverImageFileId || '').trim()
})
await shopApi.saveSettings(buildShopPayload(this.data.settingsSnapshot, form))
markPlanningRefresh()
wx.showToast({ title: '已保存', icon: 'success' })
wx.showToast({ title: '排班已保存', icon: 'success' })
this.setData({ scheduleSheetVisible: false })
await this.loadSettings()
} catch (error) {
wx.showToast({ title: error.message || '保存失败', icon: 'none' })
wx.showToast({ title: error.message || '排班保存失败', icon: 'none' })
} finally {
this.setData({ saving: false })
}
@@ -527,6 +391,7 @@ Page({
})
markPlanningRefresh()
wx.showToast({ title: '特殊日期已保存', icon: 'success' })
this.setData({ scheduleSheetVisible: false })
await this.loadSettings()
} catch (error) {
wx.showToast({ title: error.message || '特殊日期保存失败', icon: 'none' })
+140 -92
View File
@@ -3,7 +3,7 @@
<block wx:else>
<view class="page-heading">
<text class="page-title">店铺设置</text>
<text class="page-subtitle">把门店气质写进第一眼</text>
<text class="page-subtitle">先看见门店状态,再按需调整细节。</text>
</view>
<view class="cover-card">
@@ -14,119 +14,167 @@
<text class="cover-empty-title">店铺封面</text>
<text class="cover-empty-desc">上传一张能代表风格的作品图</text>
</view>
<view class="cover-badge">门店封面</view>
<view class="cover-badge">门店档案</view>
<view class="cover-shade">
<view class="cover-copy">
<text class="cover-title">{{form.shopName || '店铺主图'}}</text>
<text class="cover-desc">{{form.rule || '色彩、手作与细节管理的预约空间'}}</text>
</view>
<view class="cover-actions">
<button class="cover-btn" loading="{{coverUploading}}" bindtap="chooseCoverImage">更换主图</button>
<button wx:if="{{coverImagePreviewUrl}}" class="cover-remove" bindtap="removeCoverImage">移除</button>
<text class="cover-title">{{shopName || '店铺主图'}}</text>
<text class="cover-desc">{{shopDescription || '色彩、手作与细节管理的预约空间'}}</text>
</view>
<button class="cover-btn" bindtap="editProfile">修改档案</button>
</view>
</view>
<view class="card form-card">
<view class="form-header">
<view id="shop-profile-card" class="section">
<view class="section-head">
<view>
<text class="form-kicker">门店档案</text>
<text class="form-title">展示给客户看的第一段介绍</text>
<text class="section-title">店铺档案</text>
<text class="section-subtitle">展示给客户看的第一段介绍</text>
</view>
<text class="section-link" bindtap="editProfile">修改</text>
</view>
<view class="field"><text class="field-label">店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" /></view>
<view class="field">
<view class="label-with-help">
<text class="field-label">默认时长</text>
<text class="help-badge" catchtap="explainDefaultDuration">?</text>
<view class="card profile-summary-card" bindtap="editProfile">
<view class="summary-row">
<text class="summary-label">店铺名称</text>
<text class="summary-value">{{shopName || '未设置'}}</text>
</view>
<input type="number" value="{{form.defaultDuration}}" data-field="defaultDuration" bindinput="onInput" />
<text class="muted">分钟</text>
</view>
<view class="field">
<view class="label-with-help">
<text class="field-label">门店介绍</text>
<text class="help-badge" catchtap="explainShopIntro">?</text>
</view>
<view class="intro-editor">
<textarea
value="{{form.rule}}"
data-field="rule"
bindinput="onInput"
maxlength="120"
auto-height="{{false}}"
placeholder="写下门店风格、擅长方向、服务氛围"
placeholder-class="intro-placeholder"
></textarea>
<text class="intro-count">{{introLength}}/120</text>
<view class="summary-row summary-row-last">
<text class="summary-label">门店介绍</text>
<text class="summary-value summary-description">{{shopDescription || '暂未填写门店介绍'}}</text>
</view>
</view>
</view>
<view class="section">
<view class="section-title">标签设置</view>
<view class="card tag-setting-card">
<view class="tag-form-row">
<input class="tag-input" value="{{tagForm.name}}" bindinput="onTagInput" placeholder="输入标签名称" />
<button class="secondary-btn tag-save-btn" loading="{{tagSaving}}" disabled="{{tagSaving || tagsLoading}}" bindtap="saveTag">{{tagForm.id ? '更新' : '新增'}}</button>
<view id="shop-tag-card" class="section">
<view class="section-head">
<view>
<text class="section-title">店铺标签</text>
<text class="section-subtitle">{{tagCountText}}</text>
</view>
<view wx:if="{{tagForm.id}}" class="tag-edit-tip">
<text>正在编辑“{{tagForm.name}}”</text>
<text class="tag-clear" bindtap="clearTagForm">取消</text>
<text class="section-link" bindtap="editTags">管理</text>
</view>
<view class="card tag-summary-card" bindtap="editTags">
<view wx:if="{{tagList.length}}" class="tag-cloud">
<text
wx:for="{{tagList}}"
wx:key="id"
class="tag-preview"
style="background: {{item.bgColor}}; color: {{item.textColor}}; border-color: {{item.borderColor}};"
>{{item.name}}</text>
<text class="tag-add">+</text>
</view>
<view wx:if="{{tagsLoading}}" class="tag-empty">标签加载中</view>
<view wx:elif="{{tagList.length}}" class="tag-list">
<view wx:for="{{tagList}}" wx:key="id" class="tag-item">
<view class="tag-preview" style="background: {{item.bgColor}}; color: {{item.textColor}}; border-color: {{item.borderColor}};">{{item.name}}</view>
<view class="tag-actions">
<text data-id="{{item.id}}" bindtap="editTag">编辑</text>
<text class="danger" data-id="{{item.id}}" bindtap="deleteTag">删除</text>
</view>
<view wx:else class="empty-inline">还没有标签,点击添加门店特色</view>
<view class="summary-action-row">
<text>用于预约时快速选择和展示</text>
<text class="summary-arrow">›</text>
</view>
</view>
</view>
<view id="shop-schedule-card" class="section">
<view class="section-head">
<view>
<text class="section-title">营业安排</text>
<text class="section-subtitle">排班与特殊日期合并管理</text>
</view>
<text class="section-link" data-tab="RULE" bindtap="openScheduleSheet">修改</text>
</view>
<view class="card schedule-summary-card" data-tab="RULE" bindtap="openScheduleSheet">
<view class="schedule-summary-row">
<view class="summary-icon schedule-icon">◷</view>
<view class="summary-main">
<text class="summary-value">{{scheduleSummary}}</text>
<text class="summary-meta">{{scheduleRemarkText}}</text>
</view>
<text class="summary-arrow">›</text>
</view>
<view wx:else class="tag-empty">暂无标签,可用于新建预约时快速选择</view>
</view>
</view>
<view class="section">
<view class="section-title">店铺排班</view>
<view class="card rule-card">
<view class="preset-grid">
<view wx:for="{{presetOptions}}" wx:key="value" class="preset-chip {{item.active ? 'active' : ''}}" data-value="{{item.value}}" bindtap="selectPreset">{{item.label}}</view>
</view>
<view class="field-block">
<view class="field-title">营业日</view>
<view class="weekday-grid">
<view wx:for="{{weekdayOptions}}" wx:key="value" class="weekday-chip {{item.active ? 'active' : ''}}" data-value="{{item.value}}" bindtap="toggleWeekday">{{item.label}}</view>
<view id="shop-exception-card" class="schedule-summary-row special-summary-row" data-tab="EXCEPTION" bindtap="openScheduleSheet">
<view class="summary-icon exception-icon">●</view>
<view class="summary-main">
<text class="summary-value">{{exceptionCountText}}</text>
<text class="summary-meta">{{exceptionSummary}}</text>
</view>
</view>
<view class="field"><text class="field-label">营业开始</text><picker mode="time" value="{{form.startTime}}" bindchange="onStartChange"><view class="field-value">{{form.startTime}}</view></picker></view>
<view class="field"><text class="field-label">营业结束</text><picker mode="time" value="{{form.endTime}}" bindchange="onEndChange"><view class="field-value">{{form.endTime}}</view></picker></view>
<view class="field"><text class="field-label">排班备注</text><input value="{{form.scheduleRemark}}" data-field="scheduleRemark" bindinput="onInput" placeholder="可选" /></view>
</view>
</view>
<view class="section">
<view class="section-title">特殊日期</view>
<view class="card rule-card">
<view class="field"><text class="field-label">日期</text><picker mode="date" value="{{exceptionForm.workDate}}" bindchange="onExceptionDateChange"><view class="field-value">{{exceptionForm.workDate}}</view></picker></view>
<view class="field"><text class="field-label">类型</text><picker range="{{exceptionTypes}}" range-key="label" value="{{exceptionTypeIndex}}" bindchange="onExceptionTypeChange"><view class="field-value">{{exceptionTypeLabel}}</view></picker></view>
<view wx:if="{{exceptionForm.exceptionType !== 'REST'}}" class="field"><text class="field-label">开始时间</text><picker mode="time" value="{{exceptionForm.startTime}}" bindchange="onExceptionStartChange"><view class="field-value">{{exceptionForm.startTime}}</view></picker></view>
<view wx:if="{{exceptionForm.exceptionType !== 'REST'}}" class="field"><text class="field-label">结束时间</text><picker mode="time" value="{{exceptionForm.endTime}}" bindchange="onExceptionEndChange"><view class="field-value">{{exceptionForm.endTime}}</view></picker></view>
<view class="field"><text class="field-label">备注</text><input value="{{exceptionForm.remark}}" data-field="remark" bindinput="onExceptionInput" placeholder="可选" /></view>
<button class="secondary-btn exception-btn" loading="{{saving}}" bindtap="saveException">保存特殊日期</button>
</view>
<view wx:if="{{exceptions.length}}" class="exception-list">
<view wx:for="{{exceptions}}" wx:key="id" class="card exception-card">
<text>{{item.summary}}</text>
<text wx:if="{{item.remark}}" class="exception-remark">{{item.remark}}</text>
<text class="summary-arrow">›</text>
</view>
</view>
</view>
</block>
<view class="fixed-bottom"><button class="primary-btn" loading="{{saving}}" bindtap="save">保存设置</button></view>
<view wx:if="{{scheduleSheetVisible}}" class="sheet-mask" catchtap="closeScheduleSheet">
<view id="schedule-sheet" class="schedule-sheet" catchtap="stopPropagation">
<view class="sheet-handle"></view>
<view class="sheet-head">
<text class="sheet-title">营业安排</text>
<text class="sheet-close" bindtap="closeScheduleSheet">×</text>
</view>
<view class="sheet-tabs">
<view class="sheet-tab {{activeScheduleTab === 'RULE' ? 'active' : ''}}" data-tab="RULE" bindtap="switchScheduleTab">常规排班</view>
<view class="sheet-tab {{activeScheduleTab === 'EXCEPTION' ? 'active' : ''}}" data-tab="EXCEPTION" bindtap="switchScheduleTab">特殊日期</view>
</view>
<block wx:if="{{activeScheduleTab === 'RULE'}}">
<view class="sheet-field-block">
<text class="sheet-field-title">营业模式</text>
<view class="preset-grid">
<view wx:for="{{presetOptions}}" wx:key="value" class="preset-chip {{item.active ? 'active' : ''}}" data-value="{{item.value}}" bindtap="selectPreset">{{item.label}}</view>
</view>
</view>
<view class="sheet-field-block">
<text class="sheet-field-title">营业日</text>
<view class="weekday-grid">
<view wx:for="{{weekdayOptions}}" wx:key="value" class="weekday-chip {{item.active ? 'active' : ''}}" data-value="{{item.value}}" bindtap="toggleWeekday">{{item.label}}</view>
</view>
</view>
<view class="sheet-field">
<text class="sheet-field-label">营业开始</text>
<picker mode="time" value="{{form.startTime}}" bindchange="onStartChange"><view class="sheet-field-value">{{form.startTime}}</view></picker>
</view>
<view class="sheet-field">
<text class="sheet-field-label">营业结束</text>
<picker mode="time" value="{{form.endTime}}" bindchange="onEndChange"><view class="sheet-field-value">{{form.endTime}}</view></picker>
</view>
<view class="sheet-field">
<text class="sheet-field-label">排班备注</text>
<input value="{{form.scheduleRemark}}" data-field="scheduleRemark" bindinput="onInput" placeholder="可选" />
</view>
<button class="primary-btn sheet-save" loading="{{saving}}" disabled="{{saving}}" bindtap="saveSchedule">保存排班</button>
</block>
<block wx:else>
<view class="sheet-field">
<text class="sheet-field-label">日期</text>
<picker mode="date" value="{{exceptionForm.workDate}}" bindchange="onExceptionDateChange"><view class="sheet-field-value">{{exceptionForm.workDate}}</view></picker>
</view>
<view class="sheet-field">
<text class="sheet-field-label">类型</text>
<picker range="{{exceptionTypes}}" range-key="label" value="{{exceptionTypeIndex}}" bindchange="onExceptionTypeChange"><view class="sheet-field-value">{{exceptionTypeLabel}}</view></picker>
</view>
<view wx:if="{{exceptionForm.exceptionType !== 'REST'}}" class="sheet-field">
<text class="sheet-field-label">开始时间</text>
<picker mode="time" value="{{exceptionForm.startTime}}" bindchange="onExceptionStartChange"><view class="sheet-field-value">{{exceptionForm.startTime}}</view></picker>
</view>
<view wx:if="{{exceptionForm.exceptionType !== 'REST'}}" class="sheet-field">
<text class="sheet-field-label">结束时间</text>
<picker mode="time" value="{{exceptionForm.endTime}}" bindchange="onExceptionEndChange"><view class="sheet-field-value">{{exceptionForm.endTime}}</view></picker>
</view>
<view class="sheet-field">
<text class="sheet-field-label">备注</text>
<input value="{{exceptionForm.remark}}" data-field="remark" bindinput="onExceptionInput" placeholder="可选" />
</view>
<button class="primary-btn sheet-save" loading="{{saving}}" disabled="{{saving}}" bindtap="saveException">保存特殊日期</button>
<view class="exception-history">
<view class="exception-history-head">
<text>已配置日期</text>
<text>{{exceptions.length}} 条</text>
</view>
<view wx:if="{{exceptions.length}}" class="exception-history-list">
<view wx:for="{{exceptions}}" wx:key="id" class="exception-history-item">
<text>{{item.summary}}</text>
<text wx:if="{{item.remark}}" class="exception-history-remark">{{item.remark}}</text>
</view>
</view>
<view wx:else class="empty-inline">暂无特殊日期</view>
</view>
</block>
</view>
</view>
</view>
+327 -210
View File
@@ -1,4 +1,3 @@
.page {
background:
linear-gradient(180deg, rgba(255, 250, 242, 0.96), rgba(247, 240, 232, 0.96)),
@@ -19,16 +18,22 @@
line-height: 1.25;
}
.page-subtitle {
.page-subtitle,
.section-subtitle {
color: #8a796a;
font-size: 23rpx;
line-height: 1.4;
}
.loading-state {
padding: 48rpx 24rpx;
color: #7b7167;
text-align: center;
}
.cover-card {
position: relative;
height: 340rpx;
margin-bottom: 26rpx;
overflow: hidden;
border-radius: 28rpx;
background:
@@ -123,222 +128,120 @@
-webkit-line-clamp: 2;
}
.cover-actions {
.cover-btn {
display: flex;
flex: 0 0 auto;
flex-direction: column;
gap: 10rpx;
}
.cover-btn,
.cover-remove {
display: flex;
align-items: center;
justify-content: center;
min-width: 164rpx;
min-height: 62rpx;
padding: 0 20rpx;
border-radius: 20rpx;
background: #fff8ed;
color: #6d4d35;
font-size: 24rpx;
font-weight: 900;
}
.cover-btn {
background: #fff8ed;
color: #6d4d35;
.section {
margin-top: 26rpx;
}
.cover-remove {
background: rgba(255, 253, 248, 0.18);
color: #fffdf8;
}
.form-card,
.rule-card {
padding: 12rpx 0;
overflow: hidden;
}
.form-card {
box-shadow: 0 18rpx 36rpx rgba(83, 64, 44, 0.08);
}
.form-header {
.section-head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 26rpx 26rpx 8rpx;
gap: 16rpx;
margin: 0 4rpx 16rpx;
}
.form-header view {
.section-head view {
display: flex;
flex-direction: column;
gap: 6rpx;
}
.form-kicker {
color: #92734f;
font-size: 22rpx;
font-weight: 900;
}
.form-title {
color: #8d8175;
font-size: 23rpx;
}
.field {
min-height: 108rpx;
padding: 12rpx 24rpx;
}
.field-label,
.label-with-help {
width: 180rpx;
min-width: 180rpx;
}
.field input,
.field-value,
.intro-editor {
min-height: 70rpx;
padding: 0 22rpx;
border: 1rpx solid #eadfd2;
border-radius: 18rpx;
background: #fff8f2;
line-height: 70rpx;
}
.intro-editor {
position: relative;
flex: 1;
min-height: 156rpx;
padding: 18rpx 22rpx 42rpx;
line-height: 1.5;
}
.intro-editor textarea {
width: 100%;
height: 104rpx;
color: #3d3128;
font-size: 26rpx;
line-height: 1.5;
}
.intro-placeholder {
color: #b4a79b;
}
.intro-count {
position: absolute;
right: 22rpx;
bottom: 12rpx;
color: #b2a396;
font-size: 20rpx;
line-height: 1;
}
.label-with-help {
display: flex;
align-items: center;
}
.label-with-help .field-label {
min-width: 0;
}
.help-badge {
display: flex;
align-items: center;
justify-content: center;
width: 28rpx;
height: 28rpx;
margin-left: 8rpx;
border-radius: 50%;
background: #e5eee9;
color: #4e7165;
font-size: 20rpx;
font-weight: 800;
line-height: 28rpx;
}
.loading-state {
padding: 48rpx 24rpx;
color: #7b7167;
text-align: center;
}
.section {
margin-top: 24rpx;
}
.section-title {
margin: 0 0 16rpx;
color: #3f382f;
font-size: 30rpx;
font-weight: 800;
}
.tag-setting-card {
display: flex;
flex-direction: column;
gap: 18rpx;
padding: 20rpx 24rpx;
}
.tag-form-row {
display: grid;
grid-template-columns: minmax(0, 1fr) 150rpx;
gap: 12rpx;
}
.tag-input {
min-width: 0;
height: 70rpx;
padding: 0 18rpx;
border: 1rpx solid #eadfd2;
border-radius: 14rpx;
background: #fff8f2;
color: #3d3128;
font-size: 26rpx;
}
.tag-save-btn {
width: 100%;
min-width: 0;
}
.tag-edit-tip {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12rpx;
color: #7b7167;
.section-subtitle {
font-size: 22rpx;
}
.tag-clear {
color: #2f6b55;
.section-link {
flex: 0 0 auto;
color: #c86a5c;
font-size: 24rpx;
font-weight: 900;
}
.tag-list {
display: grid;
gap: 12rpx;
.profile-summary-card,
.tag-summary-card,
.schedule-summary-card {
overflow: hidden;
}
.tag-item {
.profile-summary-card {
padding: 8rpx 24rpx;
}
.summary-row {
display: flex;
align-items: flex-start;
gap: 20rpx;
min-height: 92rpx;
padding: 22rpx 0;
border-bottom: 1rpx solid #eee8df;
}
.summary-row-last {
border-bottom: 0;
}
.summary-label {
flex: 0 0 140rpx;
color: #8d8175;
font-size: 24rpx;
font-weight: 700;
}
.summary-value {
min-width: 0;
flex: 1;
color: #332c27;
font-size: 26rpx;
font-weight: 900;
line-height: 1.45;
text-align: right;
}
.summary-description {
color: #6f655d;
font-size: 24rpx;
font-weight: 600;
}
.tag-summary-card {
padding: 24rpx;
}
.tag-cloud {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 12rpx;
}
.tag-preview {
display: inline-flex;
align-items: center;
min-width: 0;
min-height: 52rpx;
max-width: 100%;
min-height: 54rpx;
padding: 0 16rpx;
padding: 0 18rpx;
overflow: hidden;
border: 1rpx solid;
border-radius: 999rpx;
@@ -348,35 +251,206 @@
white-space: nowrap;
}
.tag-actions {
display: flex;
flex: 0 0 auto;
gap: 16rpx;
color: #2f6b55;
font-size: 22rpx;
font-weight: 800;
.tag-add {
display: inline-flex;
align-items: center;
justify-content: center;
width: 52rpx;
height: 52rpx;
border: 1rpx dashed #e2b9af;
border-radius: 50%;
color: #c86a5c;
font-size: 36rpx;
font-weight: 300;
}
.tag-actions .danger {
color: #c36a6a;
}
.tag-empty {
color: #8c8177;
.empty-inline {
padding: 12rpx 0;
color: #a0968e;
font-size: 24rpx;
}
.rule-card {
.summary-action-row {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
gap: 12rpx;
margin-top: 20rpx;
padding-top: 16rpx;
border-top: 1rpx solid #eee8df;
color: #9a8f86;
font-size: 22rpx;
}
.summary-arrow {
flex: 0 0 auto;
color: #b7aca3;
font-size: 34rpx;
font-weight: 300;
line-height: 1;
}
.schedule-summary-card {
padding: 0 24rpx;
}
.schedule-summary-row {
display: flex;
align-items: center;
gap: 18rpx;
min-height: 120rpx;
padding: 20rpx 0;
border-bottom: 1rpx solid #eee8df;
}
.special-summary-row {
border-bottom: 0;
}
.summary-icon {
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 auto;
width: 64rpx;
height: 64rpx;
border-radius: 22rpx;
font-size: 28rpx;
font-weight: 900;
}
.schedule-icon {
background: #e5eee9;
color: #55786d;
}
.exception-icon {
background: #fff0ed;
color: #c86a5c;
}
.summary-main {
display: flex;
flex: 1;
flex-direction: column;
gap: 8rpx;
min-width: 0;
}
.summary-main .summary-value {
text-align: left;
}
.summary-meta {
overflow: hidden;
color: #9b9188;
font-size: 22rpx;
line-height: 1.4;
text-overflow: ellipsis;
white-space: nowrap;
}
.sheet-mask {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 30;
display: flex;
align-items: flex-end;
background: rgba(45, 35, 29, 0.36);
}
.schedule-sheet {
width: 100%;
max-height: 88vh;
padding: 14rpx 24rpx calc(22rpx + env(safe-area-inset-bottom));
overflow-y: auto;
border-radius: 28rpx 28rpx 0 0;
background: #fffdf8;
box-shadow: 0 -18rpx 38rpx rgba(45, 35, 29, 0.18);
}
.sheet-handle {
width: 68rpx;
height: 8rpx;
margin: 0 auto 20rpx;
border-radius: 8rpx;
background: #ddd3ca;
}
.sheet-head,
.exception-history-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.sheet-head {
margin-bottom: 20rpx;
}
.sheet-title {
color: #332c27;
font-size: 32rpx;
font-weight: 900;
}
.sheet-close {
color: #a59a91;
font-size: 40rpx;
font-weight: 300;
line-height: 1;
}
.sheet-tabs {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8rpx;
margin-bottom: 18rpx;
padding: 6rpx;
border-radius: 16rpx;
background: #f5efe8;
}
.sheet-tab {
padding: 14rpx;
border-radius: 12rpx;
color: #958a80;
font-size: 24rpx;
font-weight: 900;
text-align: center;
}
.sheet-tab.active {
background: #fffdf8;
color: #c86a5c;
box-shadow: 0 6rpx 14rpx rgba(67, 52, 41, 0.07);
}
.sheet-field-block {
padding: 18rpx 0;
border-bottom: 1rpx solid #eee8df;
}
.sheet-field-title {
display: block;
margin-bottom: 14rpx;
color: #6f665c;
font-size: 24rpx;
font-weight: 800;
}
.preset-grid,
.weekday-grid {
display: grid;
gap: 12rpx;
}
.preset-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16rpx;
}
.weekday-grid {
@@ -385,15 +459,15 @@
.preset-chip,
.weekday-chip {
min-height: 72rpx;
display: flex;
align-items: center;
justify-content: center;
min-height: 64rpx;
border: 2rpx solid #e3ddd2;
border-radius: 12rpx;
border-radius: 14rpx;
background: #fffaf2;
color: #5f564c;
font-size: 24rpx;
font-size: 23rpx;
font-weight: 700;
}
@@ -404,39 +478,82 @@
color: #2f6b55;
}
.field-block {
.sheet-field {
display: flex;
flex-direction: column;
gap: 12rpx;
align-items: center;
min-height: 88rpx;
gap: 18rpx;
border-bottom: 1rpx solid #eee8df;
}
.field-title {
.sheet-field-label {
flex: 0 0 160rpx;
color: #625c55;
font-size: 25rpx;
font-weight: 700;
}
.sheet-field-value,
.sheet-field input {
flex: 1;
min-width: 0;
color: #3f382f;
font-size: 26rpx;
font-weight: 800;
text-align: right;
}
.sheet-field input {
height: 58rpx;
padding: 0 18rpx;
border: 1rpx solid #eadfd2;
border-radius: 16rpx;
background: #fff8f2;
font-weight: 500;
}
.sheet-save {
margin-top: 22rpx;
}
.exception-history {
margin-top: 24rpx;
padding: 18rpx;
border-radius: 18rpx;
background: #faf5ef;
}
.exception-history-head {
color: #6f665c;
font-size: 24rpx;
font-size: 23rpx;
font-weight: 800;
}
.exception-btn {
width: 100%;
margin-top: 8rpx;
.exception-history-head text:last-child {
color: #a0968e;
font-weight: 600;
}
.exception-list {
.exception-history-list {
display: flex;
flex-direction: column;
gap: 16rpx;
margin-top: 16rpx;
gap: 12rpx;
margin-top: 14rpx;
}
.exception-card {
.exception-history-item {
display: flex;
flex-direction: column;
gap: 8rpx;
color: #3f382f;
font-size: 26rpx;
gap: 6rpx;
padding-top: 12rpx;
border-top: 1rpx solid #eee5da;
color: #4f473f;
font-size: 23rpx;
font-weight: 700;
}
.exception-remark {
color: #7b7167;
font-size: 24rpx;
.exception-history-remark {
color: #9a8f86;
font-size: 21rpx;
font-weight: 500;
}