diff --git a/JY-Salon-WeChat/app.json b/JY-Salon-WeChat/app.json index 08b44afb..62165db8 100644 --- a/JY-Salon-WeChat/app.json +++ b/JY-Salon-WeChat/app.json @@ -17,6 +17,8 @@ "pages/profile/index", "pages/profile-settings/index", "pages/shop-settings/index", + "pages/shop-profile-edit/index", + "pages/shop-tags/index", "pages/export/index", "pages/password/index", "pages/about/index" diff --git a/JY-Salon-WeChat/pages/shop-profile-edit/index.js b/JY-Salon-WeChat/pages/shop-profile-edit/index.js new file mode 100644 index 00000000..6bef2acd --- /dev/null +++ b/JY-Salon-WeChat/pages/shop-profile-edit/index.js @@ -0,0 +1,150 @@ +const shopApi = require('../../api/shop') +const { BRAND_CONFIG } = require('../../utils/config') +const { chooseImageFilePath, uploadObjectFile, resolveUploadedImagePreviewUrl } = require('../../utils/upload') + +const DEFAULT_SHOP_INTRO = '专注法式、晕染与手绘设计,适合想要温柔质感的客人。' + +function resolveFirstImageUrl(urls) { + return Array.isArray(urls) ? String(urls[0] || '').trim() : '' +} + +function introLength(value) { + return String(value || '').length +} + +function buildShopPayload(settings, form) { + return { + shopName: String(form.shopName || '').trim(), + description: String(form.rule || '').trim(), + address: settings.address || '', + mapProvider: settings.mapProvider || '', + longitude: settings.longitude, + latitude: settings.latitude, + businessHours: settings.businessHours || '', + schedulePresetType: settings.schedulePresetType || '', + scheduleWorkDays: settings.scheduleWorkDays || '', + scheduleRemark: settings.scheduleRemark || '', + coverImageFileId: String(form.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 + } +} + +Page({ + data: { + loading: false, + saving: false, + coverUploading: false, + coverImagePreviewUrl: '', + introLength: introLength(DEFAULT_SHOP_INTRO), + settingsSnapshot: {}, + form: { + shopName: BRAND_CONFIG.defaultShopName, + rule: DEFAULT_SHOP_INTRO, + coverImageFileId: '' + } + }, + + onLoad() { + this.loadSettings() + }, + + async loadSettings() { + this.setData({ loading: true }) + try { + const settings = await shopApi.settings() + const form = { + shopName: settings.shopName || settings.name || this.data.form.shopName, + rule: settings.description || DEFAULT_SHOP_INTRO, + coverImageFileId: settings.coverImageFileId || '' + } + this.setData({ + settingsSnapshot: settings || {}, + form, + introLength: introLength(form.rule), + coverImagePreviewUrl: resolveFirstImageUrl(settings.coverImageUrls) + }) + } catch (error) { + wx.showToast({ title: error.message || '店铺档案加载失败', icon: 'none' }) + } finally { + this.setData({ loading: false }) + } + }, + + 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) + }, + + 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: '' + }) + }, + + async save() { + const shopName = String(this.data.form.shopName || '').trim() + if (!shopName) { + wx.showToast({ title: '请填写店铺名称', icon: 'none' }) + return + } + this.setData({ saving: true }) + try { + await shopApi.saveSettings(buildShopPayload(this.data.settingsSnapshot, this.data.form)) + wx.showToast({ title: '店铺档案已保存', icon: 'success' }) + wx.navigateBack() + } catch (error) { + wx.showToast({ title: error.message || '店铺档案保存失败', icon: 'none' }) + } finally { + this.setData({ saving: false }) + } + }, + + back() { + wx.navigateBack() + } +}) diff --git a/JY-Salon-WeChat/pages/shop-profile-edit/index.json b/JY-Salon-WeChat/pages/shop-profile-edit/index.json new file mode 100644 index 00000000..cb82d610 --- /dev/null +++ b/JY-Salon-WeChat/pages/shop-profile-edit/index.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "编辑店铺档案" +} diff --git a/JY-Salon-WeChat/pages/shop-profile-edit/index.wxml b/JY-Salon-WeChat/pages/shop-profile-edit/index.wxml new file mode 100644 index 00000000..6750e723 --- /dev/null +++ b/JY-Salon-WeChat/pages/shop-profile-edit/index.wxml @@ -0,0 +1,60 @@ + + 店铺档案加载中 + + + 编辑店铺档案 + 让客人先认识你的店,再决定要不要预约。 + + + + 门店第一眼 + 店铺名称、介绍和封面会展示在用户端门店详情页。 + + + + + + + + 店铺封面 + 上传一张能代表风格的作品图 + + 门店封面 + + + + + + + + + 门店档案 + 保存后返回主页面查看展示效果 + + + 店铺名称 + + + + 门店介绍 + + + {{introLength}}/120 + + + + + + + + + + diff --git a/JY-Salon-WeChat/pages/shop-profile-edit/index.wxss b/JY-Salon-WeChat/pages/shop-profile-edit/index.wxss new file mode 100644 index 00000000..ef42545d --- /dev/null +++ b/JY-Salon-WeChat/pages/shop-profile-edit/index.wxss @@ -0,0 +1,239 @@ +.shop-profile-page { + background: + linear-gradient(180deg, rgba(255, 250, 242, 0.96), rgba(247, 240, 232, 0.96)), + linear-gradient(135deg, rgba(89, 121, 102, 0.14), rgba(181, 134, 86, 0.12)); +} + +.page-heading { + display: flex; + flex-direction: column; + gap: 8rpx; + margin: 4rpx 0 22rpx; +} + +.page-title { + color: #2f2a25; + font-size: 36rpx; + font-weight: 900; + line-height: 1.25; +} + +.page-subtitle, +.form-title { + color: #8a796a; + font-size: 23rpx; + line-height: 1.4; +} + +.loading-state { + padding: 48rpx 24rpx; + color: #7b7167; + text-align: center; +} + +.edit-tip-card { + display: flex; + flex-direction: column; + gap: 8rpx; + margin-bottom: 20rpx; + padding: 22rpx 24rpx; + border-radius: 22rpx; + background: #fff0ed; +} + +.edit-tip-title { + color: #3e312d; + font-size: 29rpx; + font-weight: 900; +} + +.edit-tip-text { + color: #9f6c64; + font-size: 23rpx; + line-height: 1.55; +} + +.cover-card { + position: relative; + height: 340rpx; + overflow: hidden; + border-radius: 28rpx; + background: + linear-gradient(135deg, rgba(73, 101, 85, 0.95), rgba(179, 131, 90, 0.95)), + radial-gradient(circle at 24% 22%, rgba(255, 245, 223, 0.28), transparent 36%); + box-shadow: 0 22rpx 46rpx rgba(83, 64, 44, 0.18); +} + +.cover-preview, +.cover-preview image { + width: 100%; + height: 100%; +} + +.cover-empty { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 10rpx; + color: rgba(255, 255, 255, 0.82); +} + +.cover-empty-title { + font-size: 36rpx; + font-weight: 900; +} + +.cover-empty-desc { + font-size: 23rpx; + font-weight: 600; + opacity: 0.86; +} + +.cover-badge { + position: absolute; + top: 26rpx; + left: 28rpx; + z-index: 2; + padding: 8rpx 20rpx; + border-radius: 999rpx; + background: rgba(255, 244, 222, 0.88); + color: #5b4635; + font-size: 22rpx; + font-weight: 900; +} + +.cover-actions { + position: absolute; + right: 28rpx; + bottom: 26rpx; + left: 28rpx; + display: flex; + gap: 12rpx; +} + +.cover-btn, +.cover-remove { + display: flex; + align-items: center; + justify-content: center; + min-height: 64rpx; + padding: 0 20rpx; + border-radius: 20rpx; + font-size: 24rpx; + font-weight: 900; +} + +.cover-btn { + flex: 1; + background: #fff8ed; + color: #6d4d35; +} + +.cover-remove { + min-width: 150rpx; + background: rgba(255, 253, 248, 0.18); + color: #fffdf8; +} + +.form-card { + margin-top: 24rpx; + padding: 12rpx 0; + overflow: hidden; +} + +.form-header { + display: flex; + flex-direction: column; + gap: 6rpx; + padding: 26rpx 26rpx 8rpx; +} + +.form-kicker { + color: #92734f; + font-size: 22rpx; + font-weight: 900; +} + +.field { + display: flex; + align-items: center; + min-height: 108rpx; + gap: 18rpx; + padding: 12rpx 24rpx; + border-bottom: 1rpx solid #eee8df; +} + +.field:last-child { + border-bottom: 0; +} + +.field-column { + align-items: stretch; + flex-direction: column; + gap: 12rpx; + min-height: 232rpx; +} + +.field-label { + flex: 0 0 160rpx; + color: #625c55; + font-size: 26rpx; + font-weight: 700; +} + +.field-column .field-label { + flex: 0 0 auto; +} + +.field input, +.intro-editor { + flex: 1; + min-width: 0; + min-height: 70rpx; + padding: 0 22rpx; + border: 1rpx solid #eadfd2; + border-radius: 18rpx; + background: #fff8f2; + color: #3d3128; + font-size: 28rpx; + line-height: 70rpx; +} + +.intro-editor { + position: relative; + width: 100%; + 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; +} + +.fixed-bottom { + display: flex; + gap: 14rpx; +} + +.bottom-half-btn { + flex: 1; +} diff --git a/JY-Salon-WeChat/pages/shop-settings/index.js b/JY-Salon-WeChat/pages/shop-settings/index.js index 16cf92a1..f16996b4 100644 --- a/JY-Salon-WeChat/pages/shop-settings/index.js +++ b/JY-Salon-WeChat/pages/shop-settings/index.js @@ -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' }) diff --git a/JY-Salon-WeChat/pages/shop-settings/index.wxml b/JY-Salon-WeChat/pages/shop-settings/index.wxml index c0478c66..f9dedbff 100644 --- a/JY-Salon-WeChat/pages/shop-settings/index.wxml +++ b/JY-Salon-WeChat/pages/shop-settings/index.wxml @@ -3,7 +3,7 @@ 店铺设置 - 把门店气质写进第一眼 + 先看见门店状态,再按需调整细节。 @@ -14,119 +14,167 @@ 店铺封面 上传一张能代表风格的作品图 - 门店封面 + 门店档案 - {{form.shopName || '店铺主图'}} - {{form.rule || '色彩、手作与细节管理的预约空间'}} - - - - + {{shopName || '店铺主图'}} + {{shopDescription || '色彩、手作与细节管理的预约空间'}} + - - + + - 门店档案 - 展示给客户看的第一段介绍 + 店铺档案 + 展示给客户看的第一段介绍 + 修改 - 店铺名称 - - - 默认时长 - ? + + + 店铺名称 + {{shopName || '未设置'}} - - 分钟 - - - - 门店介绍 - ? - - - - {{introLength}}/120 + + 门店介绍 + {{shopDescription || '暂未填写门店介绍'}} - - 标签设置 - - - - + + + + 店铺标签 + {{tagCountText}} - - 正在编辑“{{tagForm.name}}” - 取消 + 管理 + + + + {{item.name}} + + - 标签加载中 - - - {{item.name}} - - 编辑 - 删除 - + 还没有标签,点击添加门店特色 + + 用于预约时快速选择和展示 + › + + + + + + + + 营业安排 + 排班与特殊日期合并管理 + + 修改 + + + + ◷ + + {{scheduleSummary}} + {{scheduleRemarkText}} + › - 暂无标签,可用于新建预约时快速选择 - - - - - 店铺排班 - - - {{item.label}} - - - - 营业日 - - {{item.label}} + + ● + + {{exceptionCountText}} + {{exceptionSummary}} - - - 营业开始{{form.startTime}} - 营业结束{{form.endTime}} - 排班备注 - - - - - 特殊日期 - - 日期{{exceptionForm.workDate}} - 类型{{exceptionTypeLabel}} - 开始时间{{exceptionForm.startTime}} - 结束时间{{exceptionForm.endTime}} - 备注 - - - - - - {{item.summary}} - {{item.remark}} + › - + + + + + 营业安排 + × + + + 常规排班 + 特殊日期 + + + + + 营业模式 + + {{item.label}} + + + + 营业日 + + {{item.label}} + + + + 营业开始 + {{form.startTime}} + + + 营业结束 + {{form.endTime}} + + + 排班备注 + + + + + + + + 日期 + {{exceptionForm.workDate}} + + + 类型 + {{exceptionTypeLabel}} + + + 开始时间 + {{exceptionForm.startTime}} + + + 结束时间 + {{exceptionForm.endTime}} + + + 备注 + + + + + + 已配置日期 + {{exceptions.length}} 条 + + + + {{item.summary}} + {{item.remark}} + + + 暂无特殊日期 + + + + diff --git a/JY-Salon-WeChat/pages/shop-settings/index.wxss b/JY-Salon-WeChat/pages/shop-settings/index.wxss index 457a19cf..2e47f673 100644 --- a/JY-Salon-WeChat/pages/shop-settings/index.wxss +++ b/JY-Salon-WeChat/pages/shop-settings/index.wxss @@ -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; } diff --git a/JY-Salon-WeChat/pages/shop-tags/index.js b/JY-Salon-WeChat/pages/shop-tags/index.js new file mode 100644 index 00000000..7b70eaef --- /dev/null +++ b/JY-Salon-WeChat/pages/shop-tags/index.js @@ -0,0 +1,224 @@ +const tagsApi = require('../../api/tags') + +const DEFAULT_TAG_STYLE = { + textColor: '#A84F47', + bgColor: '#FFF0ED', + borderColor: '#F0CFC8', + sortOrder: 100, + frontVisible: 1 +} + +const TAG_STYLES = [ + { key: 'coral', textColor: '#A84F47', bgColor: '#FFF0ED', borderColor: '#F0CFC8' }, + { key: 'sage', textColor: '#4E7A63', bgColor: '#EEF7F0', borderColor: '#D1E2D7' }, + { key: 'gold', textColor: '#9A7137', bgColor: '#FFF8E5', borderColor: '#E8D8AE' }, + { key: 'plum', textColor: '#80628A', bgColor: '#F6EFF9', borderColor: '#DBCBE1' } +] + +function normalizeTagOption(tag) { + const name = String((tag && (tag.displayName || tag.tagName || tag.name)) || '').trim() + if (!name) { + return null + } + return { + id: (tag && tag.id) || name, + 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 + } +} + +function normalizeTagOptions(tags) { + const names = new Set() + return (Array.isArray(tags) ? tags : []) + .map(normalizeTagOption) + .filter(Boolean) + .filter(item => { + if (names.has(item.name)) { + return false + } + names.add(item.name) + return true + }) +} + +function resolveStyleKey(tag) { + const style = TAG_STYLES.find(item => item.bgColor === tag.bgColor && item.borderColor === tag.borderColor) + return style ? style.key : TAG_STYLES[0].key +} + +function resolveCurrentShopId() { + const app = getApp() + const userInfo = (app && app.globalData && app.globalData.userInfo) || {} + return userInfo.shopId || (app && app.globalData && app.globalData.shopId) || '' +} + +function buildTagPayload(form) { + const style = TAG_STYLES.find(item => item.key === form.styleKey) || TAG_STYLES[0] + const payload = { + tagName: String(form.name || '').trim(), + textColor: style.textColor, + bgColor: style.bgColor, + borderColor: style.borderColor, + sortOrder: form.sortOrder || DEFAULT_TAG_STYLE.sortOrder, + frontVisible: form.frontVisible === 0 ? 0 : DEFAULT_TAG_STYLE.frontVisible + } + const shopId = resolveCurrentShopId() + if (shopId) { + payload.shopId = shopId + } + return payload +} + +function buildEmptyForm() { + return { + id: '', + name: '', + styleKey: TAG_STYLES[0].key, + sortOrder: DEFAULT_TAG_STYLE.sortOrder, + frontVisible: DEFAULT_TAG_STYLE.frontVisible + } +} + +Page({ + data: { + loading: false, + saving: false, + tagList: [], + tagStyles: TAG_STYLES.map(item => ({ ...item, active: item.key === TAG_STYLES[0].key })), + tagForm: buildEmptyForm() + }, + + onLoad() { + this.loadTags() + }, + + onShow() { + if (this.data.tagList.length) { + this.loadTags() + } + }, + + async loadTags() { + this.setData({ loading: 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({ loading: false }) + } + }, + + onTagInput(event) { + this.setData({ 'tagForm.name': event.detail.value }) + }, + + selectStyle(event) { + const styleKey = event.currentTarget.dataset.key + this.setData({ + 'tagForm.styleKey': styleKey, + tagStyles: TAG_STYLES.map(item => ({ ...item, active: item.key === styleKey })) + }) + }, + + 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 + } + const styleKey = resolveStyleKey(tag) + this.setData({ + tagForm: { + id: tag.id, + name: tag.tagName || tag.name, + styleKey, + sortOrder: tag.sortOrder, + frontVisible: tag.frontVisible + }, + tagStyles: TAG_STYLES.map(item => ({ ...item, active: item.key === styleKey })) + }) + }, + + clearTagForm() { + const tagForm = buildEmptyForm() + this.setData({ + tagForm, + tagStyles: TAG_STYLES.map(item => ({ ...item, active: item.key === tagForm.styleKey })) + }) + }, + + async saveTag() { + if (this.data.saving) { + return + } + const tagName = String(this.data.tagForm.name || '').trim() + if (!tagName) { + wx.showToast({ title: '请输入标签名称', icon: 'none' }) + return + } + const tagId = this.data.tagForm.id + this.setData({ saving: true }) + try { + const payload = buildTagPayload({ ...this.data.tagForm, name: tagName }) + if (tagId) { + await tagsApi.update(tagId, payload) + wx.showToast({ title: '标签已更新', icon: 'success' }) + } else { + await tagsApi.create(payload) + wx.showToast({ title: '标签已新增', icon: 'success' }) + } + this.clearTagForm() + await this.loadTags() + } catch (error) { + wx.showToast({ title: error.message || '标签保存失败', icon: 'none' }) + } finally { + this.setData({ saving: 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({ saving: 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({ saving: false }) + } + } + }) + }, + + back() { + wx.navigateBack() + } +}) diff --git a/JY-Salon-WeChat/pages/shop-tags/index.json b/JY-Salon-WeChat/pages/shop-tags/index.json new file mode 100644 index 00000000..8a7e46e2 --- /dev/null +++ b/JY-Salon-WeChat/pages/shop-tags/index.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "店铺标签" +} diff --git a/JY-Salon-WeChat/pages/shop-tags/index.wxml b/JY-Salon-WeChat/pages/shop-tags/index.wxml new file mode 100644 index 00000000..383751df --- /dev/null +++ b/JY-Salon-WeChat/pages/shop-tags/index.wxml @@ -0,0 +1,50 @@ + + 店铺标签加载中 + + + 店铺标签 + 把门店特色整理成可以快速选择的标签。 + + + + {{tagForm.id ? '编辑标签' : '新增标签'}} + + + 标签颜色 + + ● + + + + + + + + + + + 当前标签 + + + + + + {{item.name}} + + 编辑 + 删除 + + + + 暂无标签,先添加一个门店特色吧。 + + + + diff --git a/JY-Salon-WeChat/pages/shop-tags/index.wxss b/JY-Salon-WeChat/pages/shop-tags/index.wxss new file mode 100644 index 00000000..1092820e --- /dev/null +++ b/JY-Salon-WeChat/pages/shop-tags/index.wxss @@ -0,0 +1,174 @@ +.shop-tags-page { + background: + linear-gradient(180deg, rgba(255, 250, 242, 0.96), rgba(247, 240, 232, 0.96)), + linear-gradient(135deg, rgba(89, 121, 102, 0.14), rgba(181, 134, 86, 0.12)); +} + +.page-heading { + display: flex; + flex-direction: column; + gap: 8rpx; + margin: 4rpx 0 22rpx; +} + +.page-title { + color: #2f2a25; + font-size: 36rpx; + font-weight: 900; + line-height: 1.25; +} + +.page-subtitle { + color: #8a796a; + font-size: 23rpx; + line-height: 1.4; +} + +.loading-state { + padding: 48rpx 24rpx; + color: #7b7167; + text-align: center; +} + +.tag-form-card, +.tag-list-card { + padding: 24rpx; +} + +.form-kicker { + color: #92734f; + font-size: 22rpx; + font-weight: 900; +} + +.tag-input { + width: 100%; + height: 78rpx; + margin-top: 16rpx; + padding: 0 22rpx; + border: 1rpx solid #eadfd2; + border-radius: 18rpx; + background: #fff8f2; + color: #3d3128; + font-size: 28rpx; + line-height: 78rpx; +} + +.style-row { + display: flex; + align-items: center; + gap: 18rpx; + margin-top: 20rpx; +} + +.style-label { + color: #6f665c; + font-size: 24rpx; + font-weight: 800; +} + +.style-swatch { + display: flex; + align-items: center; + justify-content: center; + width: 42rpx; + height: 42rpx; + border: 4rpx solid; + border-radius: 50%; + box-shadow: 0 0 0 1rpx rgba(55, 44, 35, 0.08); + font-size: 22rpx; +} + +.style-swatch.active { + box-shadow: 0 0 0 4rpx rgba(200, 106, 92, 0.18); +} + +.tag-form-actions { + display: flex; + gap: 12rpx; + margin-top: 22rpx; +} + +.cancel-edit-btn, +.tag-save-btn { + flex: 1; +} + +.section { + margin-top: 26rpx; +} + +.section-head { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16rpx; + margin: 0 4rpx 16rpx; +} + +.section-title { + color: #3f382f; + font-size: 30rpx; + font-weight: 800; +} + +.section-meta { + color: #a0968e; + font-size: 23rpx; +} + +.tag-list { + display: flex; + flex-direction: column; + gap: 14rpx; +} + +.tag-item { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16rpx; + padding-bottom: 14rpx; + border-bottom: 1rpx solid #eee8df; +} + +.tag-item:last-child { + padding-bottom: 0; + border-bottom: 0; +} + +.tag-preview { + display: inline-flex; + align-items: center; + min-width: 0; + max-width: 100%; + min-height: 54rpx; + padding: 0 18rpx; + overflow: hidden; + border: 1rpx solid; + border-radius: 999rpx; + font-size: 24rpx; + font-weight: 800; + text-overflow: ellipsis; + white-space: nowrap; +} + +.tag-actions { + display: flex; + flex: 0 0 auto; + gap: 18rpx; + color: #2f6b55; + font-size: 23rpx; + font-weight: 800; +} + +.tag-actions .danger { + color: #c36a6a; +} + +.empty-state { + padding: 42rpx 18rpx; + color: #a0968e; + font-size: 24rpx; + text-align: center; +} diff --git a/docs/项目变更记录.md b/docs/项目变更记录.md index d6659d16..ae769c61 100644 --- a/docs/项目变更记录.md +++ b/docs/项目变更记录.md @@ -412,3 +412,11 @@ - 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。 - 影响范围:影响 `JY-Salon-WeChat/pages/shop-settings/`、`JY-Salon-WeChat/pages/appointment-form/` 与标签 API 封装;预约详情页继续通过既有 `appointment.productTags` 渲染标签。 - 验证方式:`JY-Salon-WeChat/api/tags.js`、预约表单页、店铺设置页 JS 语法检查通过;相关文件 `git diff --check` 通过;微信开发者工具运行态验证 `pages/shop-settings/index` 可见“标签设置”区,`pages/appointment-form/index` 可打开手工预约面板并展示标签输入/添加控件;GitNexus staged `detect-changes` 结果为 low risk、0 affected processes。 + +## 2026-07-23 店务小程序店铺设置改为展示与按需编辑 + +- 变更原因:店务端店铺设置需要降低主页面表单密度,让店铺档案、标签、排班和特殊日期先以信息卡片展示,再按需进入编辑。 +- 处理方式:`shop-settings` 主页面改为店铺档案、标签和营业安排摘要展示;新增 `shop-profile-edit` 店铺档案二级页,复用店铺设置和封面上传接口;新增 `shop-tags` 标签二级页,复用标签列表、创建、编辑和删除接口;排班与特殊日期在主页面通过同一底部弹层分段表单编辑。排班保存携带当前店铺已有字段,避免后端更新接口清空未编辑字段。 +- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。 +- 影响范围:影响 `JY-Salon-WeChat/app.json`、`pages/shop-settings/`、新增 `pages/shop-profile-edit/` 和 `pages/shop-tags/`;不影响后端、接口契约和预约业务。 +- 验证方式:三个新增/修改页面 JavaScript 语法检查通过,四份 JSON 配置可解析,相关文件 `git diff --check` 通过;GitNexus `impact` 对 `shop-settings.loadSettings` 返回 LOW 风险、3 个直接依赖、0 个受影响流程;微信开发者工具连接和主页面运行态结构可见,但当前 AppService 未及时加载新增页面路由,新增路由待开发者工具重新编译后复验。 diff --git a/memory/progress.md b/memory/progress.md index c7fdf89d..9e4f6f7f 100644 --- a/memory/progress.md +++ b/memory/progress.md @@ -2,7 +2,27 @@ ## 当前任务 -店务小程序预约日期和时间选择入口主题样式调整。 +店务小程序店铺设置展示与按需编辑改造。 + +## 当前任务已完成 + +- 已完成效果稿并获得用户确认。 +- 已提交设计说明 `docs/superpowers/specs/2026-07-23-店铺设置展示与编辑设计.md`。 +- `pages/shop-settings/` 已改为店铺档案、标签、营业安排摘要展示。 +- 新增 `pages/shop-profile-edit/` 店铺档案二级编辑页。 +- 新增 `pages/shop-tags/` 标签二级管理页。 +- 排班与特殊日期合并为主页面底部弹层表单。 +- 三个页面 JS 语法检查、JSON 解析和 `git diff --check` 已通过。 + +## 当前阻塞点 + +- 微信开发者工具自动化连接健康,但 AppService 仍缓存旧页面配置;运行态主页面 WXML 已出现新结构,新增页面路由暂未被当前实例识别。提交前以源码、配置和静态检查为主,后续需重新编译/重启开发者工具后复验新增路由。 + +## 下一步 + +- 暂存本次需求相关页面、路由、项目记录和进度文件。 +- 运行 GitNexus `detect-changes --scope staged`。 +- 创建中文提交并核对提交文件清单。 ## 已完成