diff --git a/JY-Salon-WeChat/app.json b/JY-Salon-WeChat/app.json index 62165db8..d093a6bc 100644 --- a/JY-Salon-WeChat/app.json +++ b/JY-Salon-WeChat/app.json @@ -17,7 +17,6 @@ "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", diff --git a/JY-Salon-WeChat/pages/shop-profile-edit/index.js b/JY-Salon-WeChat/pages/shop-profile-edit/index.js deleted file mode 100644 index a4b47971..00000000 --- a/JY-Salon-WeChat/pages/shop-profile-edit/index.js +++ /dev/null @@ -1,233 +0,0 @@ -const shopApi = require('../../api/shop') -const { BRAND_CONFIG } = require('../../utils/config') -const { chooseImageFilePaths, 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 parseFileIds(value) { - return String(value || '') - .split(',') - .map(item => String(item || '').trim()) - .filter(Boolean) -} - -function joinFileIds(fileIds) { - return (Array.isArray(fileIds) ? fileIds : []).map(item => String(item || '').trim()).filter(Boolean).join(',') -} - -function normalizeGalleryItems(fileIds, urls) { - const normalizedFileIds = parseFileIds(fileIds) - const normalizedUrls = Array.isArray(urls) ? urls.map(url => String(url || '').trim()) : [] - return normalizedFileIds.map((fileId, index) => ({ - fileId, - url: normalizedUrls[index] || '' - })) -} - -function buildShopPayload(settings, form) { - return { - shopName: String(form.shopName || '').trim(), - description: String(form.rule || '').trim(), - address: String(form.address || '').trim(), - 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: joinFileIds(form.galleryFileIds), - 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, - galleryUploading: false, - galleryItems: [], - coverImagePreviewUrl: '', - introLength: introLength(DEFAULT_SHOP_INTRO), - settingsSnapshot: {}, - form: { - shopName: BRAND_CONFIG.defaultShopName, - rule: DEFAULT_SHOP_INTRO, - address: '', - galleryFileIds: [], - coverImageFileId: '' - } - }, - - onLoad() { - this.loadSettings() - }, - - async loadSettings() { - this.setData({ loading: true }) - try { - const settings = await shopApi.settings() - const galleryItems = normalizeGalleryItems(settings.imageFileIds, settings.imageUrls) - const form = { - shopName: settings.shopName || settings.name || this.data.form.shopName, - rule: settings.description || DEFAULT_SHOP_INTRO, - address: settings.address || '', - galleryFileIds: galleryItems.map(item => item.fileId), - coverImageFileId: settings.coverImageFileId || '' - } - this.setData({ - settingsSnapshot: settings || {}, - form, - introLength: introLength(form.rule), - galleryItems, - 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.galleryUploading || 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.galleryUploading || this.data.saving) { - return - } - this.setData({ - 'form.coverImageFileId': '', - coverImagePreviewUrl: '' - }) - }, - - async chooseGalleryImages() { - if (this.data.galleryUploading || this.data.saving || this.data.coverUploading) { - return - } - const remainingCount = 9 - this.data.galleryItems.length - if (remainingCount <= 0) { - wx.showToast({ title: '最多上传 9 张环境照片', icon: 'none' }) - return - } - try { - const filePaths = await chooseImageFilePaths(remainingCount) - if (!filePaths.length) { - return - } - this.setData({ galleryUploading: true }) - const uploadedItems = [] - for (const filePath of filePaths) { - const uploadResult = await uploadObjectFile(filePath) - const fileId = String(uploadResult && uploadResult.id ? uploadResult.id : '').trim() - if (!fileId) { - throw new Error('环境照片上传失败:上传接口未返回文件ID') - } - uploadedItems.push({ - fileId, - url: resolveUploadedImagePreviewUrl(uploadResult, filePath) - }) - } - const galleryItems = this.data.galleryItems.concat(uploadedItems) - this.setData({ - galleryItems, - 'form.galleryFileIds': galleryItems.map(item => item.fileId) - }) - } catch (error) { - wx.showToast({ title: error.message || '环境照片上传失败', icon: 'none' }) - } finally { - this.setData({ galleryUploading: false }) - } - }, - - removeGalleryImage(event) { - if (this.data.galleryUploading || this.data.saving) { - return - } - const index = Number(event.currentTarget.dataset.index) - if (!Number.isInteger(index) || index < 0 || index >= this.data.galleryItems.length) { - wx.showToast({ title: '环境照片不存在', icon: 'none' }) - return - } - const galleryItems = this.data.galleryItems.filter((item, itemIndex) => itemIndex !== index) - this.setData({ - galleryItems, - 'form.galleryFileIds': galleryItems.map(item => item.fileId) - }) - }, - - 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 deleted file mode 100644 index cb82d610..00000000 --- a/JY-Salon-WeChat/pages/shop-profile-edit/index.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "navigationBarTitleText": "编辑店铺档案" -} diff --git a/JY-Salon-WeChat/pages/shop-profile-edit/index.wxml b/JY-Salon-WeChat/pages/shop-profile-edit/index.wxml deleted file mode 100644 index b8e7cb92..00000000 --- a/JY-Salon-WeChat/pages/shop-profile-edit/index.wxml +++ /dev/null @@ -1,84 +0,0 @@ - - 店铺档案加载中 - - - 编辑店铺档案 - 让客人先认识你的店,再决定要不要预约。 - - - - 门店第一眼 - 店铺名称、介绍、地址和封面会展示在用户端门店详情页。 - - - - - - - - 店铺封面 - 上传一张能代表风格的作品图 - - 门店封面 - - - - - - - - - 门店档案 - 保存后返回主页面查看展示效果 - - - 店铺名称 - - - - 店铺地址 - - - - 门店介绍 - - - {{introLength}}/120 - - - - - - - - 环境照片 - 用于店铺展示区,最多 9 张 - - {{galleryItems.length}}/9 - - - - - 图片 - × - - - + - {{galleryUploading ? '上传中' : '添加'}} - - - - - - - - - diff --git a/JY-Salon-WeChat/pages/shop-profile-edit/index.wxss b/JY-Salon-WeChat/pages/shop-profile-edit/index.wxss deleted file mode 100644 index df714274..00000000 --- a/JY-Salon-WeChat/pages/shop-profile-edit/index.wxss +++ /dev/null @@ -1,335 +0,0 @@ -.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, -.gallery-subtitle { - 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: #edf6ea; -} - -.edit-tip-title { - color: #2d392f; - font-size: 29rpx; - font-weight: 900; -} - -.edit-tip-text { - color: #668268; - 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, -.gallery-card { - margin-top: 24rpx; - overflow: hidden; -} - -.form-card { - padding: 12rpx 0; -} - -.gallery-card { - padding: 24rpx; -} - -.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; -} - -.gallery-head { - display: flex; - align-items: flex-start; - justify-content: space-between; - gap: 16rpx; - margin-bottom: 18rpx; -} - -.gallery-head view { - display: flex; - flex-direction: column; - gap: 8rpx; - min-width: 0; -} - -.gallery-count { - flex: 0 0 auto; - color: #7c9a82; - font-size: 24rpx; - font-weight: 900; -} - -.gallery-grid { - display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - gap: 14rpx; -} - -.gallery-item, -.gallery-add { - position: relative; - display: flex; - align-items: center; - justify-content: center; - aspect-ratio: 1 / 1; - min-width: 0; - overflow: hidden; - border-radius: 18rpx; - background: #f5efe8; -} - -.gallery-item image { - width: 100%; - height: 100%; -} - -.gallery-placeholder { - color: #9d968e; - font-size: 24rpx; -} - -.gallery-remove { - position: absolute; - top: 8rpx; - right: 8rpx; - display: flex; - align-items: center; - justify-content: center; - width: 38rpx; - height: 38rpx; - border-radius: 50%; - background: rgba(39, 35, 31, 0.58); - color: #fffdf8; - font-size: 30rpx; - font-weight: 300; - line-height: 1; -} - -.gallery-add { - flex-direction: column; - gap: 8rpx; - border: 2rpx dashed #cfdccf; - background: #f8fbf6; - color: #6f8f83; - font-size: 23rpx; - font-weight: 800; -} - -.gallery-add-icon { - font-size: 42rpx; - font-weight: 300; - line-height: 1; -} - -.fixed-bottom { - display: flex; - gap: 14rpx; -} - -.bottom-half-btn { - flex: 1 1 0; - width: auto; - min-width: 0; - max-width: none; -}