删除店铺档案独立编辑页

This commit is contained in:
2026-07-24 17:00:42 +08:00
parent 32ba6b6d64
commit 4f9962ec71
5 changed files with 0 additions and 656 deletions
-1
View File
@@ -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",
@@ -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()
}
})
@@ -1,3 +0,0 @@
{
"navigationBarTitleText": "编辑店铺档案"
}
@@ -1,84 +0,0 @@
<view class="page no-tab shop-profile-page">
<view wx:if="{{loading}}" class="loading-state">店铺档案加载中</view>
<block wx:else>
<view class="page-heading">
<text class="page-title">编辑店铺档案</text>
<text class="page-subtitle">让客人先认识你的店,再决定要不要预约。</text>
</view>
<view class="edit-tip-card">
<text class="edit-tip-title">门店第一眼</text>
<text class="edit-tip-text">店铺名称、介绍、地址和封面会展示在用户端门店详情页。</text>
</view>
<view class="cover-card">
<view wx:if="{{coverImagePreviewUrl}}" class="cover-preview">
<image src="{{coverImagePreviewUrl}}" mode="aspectFill"></image>
</view>
<view wx:else class="cover-preview cover-empty">
<text class="cover-empty-title">店铺封面</text>
<text class="cover-empty-desc">上传一张能代表风格的作品图</text>
</view>
<view class="cover-badge">门店封面</view>
<view class="cover-actions">
<button class="cover-btn" loading="{{coverUploading}}" disabled="{{coverUploading || galleryUploading || saving}}" bindtap="chooseCoverImage">{{coverUploading ? '上传中' : '更换主图'}}</button>
<button wx:if="{{coverImagePreviewUrl}}" class="cover-remove" disabled="{{coverUploading || galleryUploading || saving}}" bindtap="removeCoverImage">移除</button>
</view>
</view>
<view class="card form-card">
<view class="form-header">
<text class="form-kicker">门店档案</text>
<text class="form-title">保存后返回主页面查看展示效果</text>
</view>
<view class="field">
<text class="field-label">店铺名称</text>
<input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" />
</view>
<view class="field">
<text class="field-label">店铺地址</text>
<input value="{{form.address}}" data-field="address" bindinput="onInput" placeholder="请输入店铺地址" />
</view>
<view class="field field-column">
<text class="field-label">门店介绍</text>
<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>
</view>
</view>
<view class="card gallery-card">
<view class="gallery-head">
<view>
<text class="form-kicker">环境照片</text>
<text class="gallery-subtitle">用于店铺展示区,最多 9 张</text>
</view>
<text class="gallery-count">{{galleryItems.length}}/9</text>
</view>
<view class="gallery-grid">
<view wx:for="{{galleryItems}}" wx:key="fileId" class="gallery-item">
<image wx:if="{{item.url}}" src="{{item.url}}" mode="aspectFill"></image>
<view wx:else class="gallery-placeholder">图片</view>
<text class="gallery-remove" data-index="{{index}}" bindtap="removeGalleryImage">×</text>
</view>
<view wx:if="{{galleryItems.length < 9}}" class="gallery-add" bindtap="chooseGalleryImages">
<text class="gallery-add-icon">+</text>
<text>{{galleryUploading ? '上传中' : '添加'}}</text>
</view>
</view>
</view>
</block>
<view class="fixed-bottom">
<button class="primary-btn bottom-half-btn" loading="{{saving}}" disabled="{{saving || coverUploading || galleryUploading}}" bindtap="save">保存档案</button>
</view>
</view>
@@ -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;
}