2026-02-25 10:37:16 +08:00
< template >
< div class = "shops" >
2026-05-13 12:43:01 +08:00
< a-page-header v-if = "!isMobile" title="店铺管理" sub-title="管理美甲店铺" />
< section v-else class = "admin-page-intro" >
< span class = "admin-page-intro__eyebrow" > 经营 </ span >
< h1 class = "admin-page-intro__title" > 店铺管理 </ h1 >
< p class = "admin-page-intro__subtitle" >
移动端优先展示 Banner 、 营业时间 、 地址和启停状态 , 让店铺信息在手机上也能完整维护 。
</ p >
< div class = "admin-page-intro__meta" >
< span class = "admin-page-chip" > 店铺 {{ shopList . length }}</ span >
</ div >
</ section >
2026-02-25 10:37:16 +08:00
< a-card :bordered = "false" >
2026-05-13 12:43:01 +08:00
< template # title v-if = "isMobile" >
店铺列表
</ template >
2026-02-25 10:37:16 +08:00
< template # extra >
2026-05-13 12:43:01 +08:00
< div class = "admin-toolbar" : class = "{ 'admin-toolbar--stacked': isMobile }" >
2026-02-25 10:37:16 +08:00
< a-input-search
v -model:value = "searchText"
placeholder = "搜索店铺名称"
2026-05-13 12:43:01 +08:00
: style = "isMobile ? { width: '100%' } : { width: '250px' }"
2026-02-25 10:37:16 +08:00
@search ="handleSearch"
/>
2026-05-13 12:43:01 +08:00
< a-button v-if = "!isMobile && hasPermission('shop:create')" type="primary" @click="showAddModal" >
2026-02-25 10:37:16 +08:00
< template # icon >
< PlusOutlined />
</ template >
新增店铺
</ a-button >
2026-05-13 12:43:01 +08:00
</ div >
2026-02-25 10:37:16 +08:00
</ template >
< a-table
2026-05-13 12:43:01 +08:00
v-if = "!isMobile"
2026-02-25 10:37:16 +08:00
:columns = "columns"
:data-source = "shopList"
:loading = "loading"
:pagination = "pagination"
2026-03-27 12:29:36 +08:00
: scroll = "{ x: 1380 }"
2026-02-25 10:37:16 +08:00
@change ="handleTableChange"
row -key =" id "
>
< template # bodyCell = "{ column, record }" >
< template v-if = "column.key === 'image'" >
2026-02-26 14:20:35 +08:00
< div class = "shop-images" >
< a-image
v-for = "(url, index) in getShopImages(record)"
:key = "index"
:width = "50"
:height = "50"
:src = "url"
style = "object-fit: cover; border-radius: 4px; margin-right: 4px;"
:preview = "false"
/>
< a-image
v-if = "getShopImages(record).length === 0"
:width = "50"
:height = "50"
:src = "DEFAULT_SHOP_IMAGE"
style = "object-fit: cover; border-radius: 4px;"
:preview = "false"
/>
</ div >
2026-02-25 10:37:16 +08:00
</ template >
2026-03-04 10:14:45 +08:00
< template v-else-if = "column.key === 'banner'" >
< div class = "shop-banner" >
< a-image
v-for = "(url, index) in getShopBannerImages(record)"
:key = "index"
:width = "80"
:height = "40"
:src = "url"
style = "object-fit: cover; border-radius: 4px; margin-right: 4px;"
:preview = "false"
/>
< span v-if = "getShopBannerImages(record).length === 0" class="no-banner" > 暂无Banner </ span >
</ div >
</ template >
2026-03-26 10:28:28 +08:00
< template v-else-if = "column.key === 'status'" >
< a-switch
: checked = "record.status !== 0"
: disabled = "!hasPermission('shop:edit') || !isAdmin"
checked -children =" 启用 "
un -checked-children =" 停用 "
@change ="(checked: any) => handleStatusChange(record, checked === true)"
/>
</ template >
2026-05-18 09:46:11 +08:00
< template v-else-if = "column.key === 'authorization'" >
< a-space direction = "vertical" size = "small" >
< a-tag : color = "record.authorizationExpired ? 'red' : 'green'" >
{{ record . authorizationStatusText || ( record . authorizationExpired ? '已到期' : '有效' ) }}
</ a-tag >
< span >{{ formatAuthorizationExpireTime ( record . authorizationExpireTime ) }}</ span >
</ a-space >
</ template >
2026-03-27 12:29:36 +08:00
< template v-else-if = "column.key === 'shopName'" >
< div style = "max-width: 180px;" >
< TableEllipsisText :text = "record.shopName" />
</ div >
</ template >
< template v-else-if = "column.key === 'description'" >
< div style = "max-width: 280px;" >
< TableEllipsisText :text = "record.description" :lines = "2" />
</ div >
</ template >
< template v-else-if = "column.key === 'address'" >
< div style = "max-width: 260px;" >
< TableEllipsisText :text = "record.address" :lines = "2" />
</ div >
</ template >
< template v-else-if = "column.key === 'businessHours'" >
< div style = "max-width: 140px;" >
< TableEllipsisText :text = "record.businessHours" />
</ div >
</ template >
2026-02-25 10:37:16 +08:00
< template v-else-if = "column.key === 'actions'" >
< a-space >
2026-02-28 14:32:28 +08:00
< a-button v-if = "hasPermission('shop:view')" type="link" size="small" @click="showViewModal(record)" >
查看
</ a -button >
2026-02-26 22:51:56 +08:00
< a-button v-if = "hasPermission('shop:edit')" type="link" size="small" @click="showEditModal(record)" >
2026-02-25 10:37:16 +08:00
编辑
</ a -button >
</ a-space >
</ template >
</ template >
</ a-table >
2026-05-13 12:43:01 +08:00
< AdminMobileCardList v-else :items = "shopList" empty -description =" 暂无店铺数据 " >
< template # item = "{ item }" >
< article class = "admin-mobile-card" >
< a-image
class = "admin-mobile-card__cover admin-mobile-card__cover--wide"
: src = "getShopBannerImages(item)[0] || getShopImages(item)[0] || DEFAULT_SHOP_IMAGE"
:preview = "false"
/>
< div class = "admin-mobile-card__head" style = "margin-top: 14px" >
< div class = "admin-mobile-card__body" >
< div class = "admin-mobile-card__title" >{{ item . shopName }}</ div >
< div class = "admin-mobile-card__subtitle" >{{ item . businessHours || '未设置营业时间' }}</ div >
</ div >
< a-tag : color = "item.status !== 0 ? 'green' : 'default'" >
{{ item . status !== 0 ? '启用' : '停用' }}
</ a-tag >
</ div >
< div class = "admin-mobile-card__description" >{{ item . description || '暂无店铺描述' }}</ div >
< div class = "admin-mobile-card__rows" >
< div class = "admin-mobile-card__row" >
< span > 地址 </ span >
< strong >{{ item . address || '--' }}</ strong >
</ div >
</ div >
< div class = "admin-mobile-card__actions" >
< a-button size = "small" @click ="showViewModal(item)" > 查看 </ a -button >
< a-button v-if = "hasPermission('shop:edit')" size="small" @click="showEditModal(item)" > 编辑 </ a -button >
2026-05-23 15:16:40 +08:00
< a-button
v-if = "hasPermission('shop:edit')"
size = "small"
:disabled = "!isAdmin"
@click ="handleStatusChange(item, item.status === 0)"
>
{{ item . status === 0 ? '启用' : '停用' }}
</ a-button >
2026-05-13 12:43:01 +08:00
</ div >
</ article >
</ template >
</ AdminMobileCardList >
2026-02-25 10:37:16 +08:00
</ a-card >
2026-05-13 12:43:01 +08:00
< AdminResponsiveModal
2026-02-25 10:37:16 +08:00
v -model:open = "modalVisible"
: title = "isEdit ? '编辑店铺' : '新增店铺'"
2026-05-13 12:43:01 +08:00
:desktop-width = "700"
2026-02-25 10:37:16 +08:00
@ok ="handleModalOk"
@cancel ="handleModalCancel"
:confirmLoading = "modalLoading"
2026-03-26 11:41:38 +08:00
: ok -button-props =" { disabled : isUploadPending } "
2026-02-25 10:37:16 +08:00
>
2026-03-26 12:04:02 +08:00
< DraftActions
:saved-at = "draftSavedAt"
:disabled = "isUploadPending"
@save ="handleSaveDraft"
@clear ="handleClearDraft"
/>
2026-02-25 10:37:16 +08:00
< a-form
ref = "formRef"
:model = "formState"
:rules = "formRules"
: label -col =" { span : 5 } "
: wrapper -col =" { span : 18 } "
>
2026-02-25 14:44:50 +08:00
< a-form-item label = "店铺名称" name = "shopName" >
< a-input v -model:value = "formState.shopName" placeholder = "请输入店铺名称" />
2026-02-25 10:37:16 +08:00
</ a-form-item >
< a-form-item label = "店铺描述" name = "description" >
< a-textarea
v -model:value = "formState.description"
placeholder = "请输入店铺描述"
:rows = "3"
/>
</ a-form-item >
< a-form-item label = "店铺地址" name = "address" >
2026-05-21 18:43:59 +08:00
< a-input v -model:value = "formState.address" placeholder = "可手动输入,也可点击腾讯地图选点后自动回填" />
2026-02-25 10:37:16 +08:00
</ a-form-item >
2026-05-18 09:46:11 +08:00
< a-form-item label = "地图位置" >
2026-05-21 18:43:59 +08:00
< div class = "map-picker-card" >
< div class = "map-picker-main" >
< div class = "map-picker-title" >{{ selectedLocationText }}</ div >
< div class = "map-picker-subtitle" >{{ selectedCoordinateText }}</ div >
</ div >
< a-button @click ="openMapLocationPicker" > 地图选点 </ a -button >
2026-05-18 09:46:11 +08:00
</ div >
2026-05-21 18:43:59 +08:00
< div class = "map-picker-tip" > 选点后会自动保存位置名称 、 地址和坐标 ; 用户端展示地名 , 并支持腾讯地图和高德地图导航 。 </ div >
2026-05-18 09:46:11 +08:00
</ a-form-item >
2026-02-25 10:37:16 +08:00
< a-form-item label = "营业时间" name = "businessHours" >
2026-03-21 13:16:39 +08:00
< div class = "business-hours-picker" >
< a-date-picker
v -model:value = "businessStartTime"
picker = "time"
2026-05-18 09:46:11 +08:00
popup -class-name =" yumi -date-picker-panel yumi -time-panel "
2026-03-21 13:16:39 +08:00
value -format =" HH : mm "
format = "HH:mm"
placeholder = "开始时间"
input -read-only
style = "width: calc(50% - 14px)"
@change ="handleBusinessHoursChange"
/>
< span class = "business-hours-separator" > 至 </ span >
< a-date-picker
v -model:value = "businessEndTime"
picker = "time"
2026-05-18 09:46:11 +08:00
popup -class-name =" yumi -date-picker-panel yumi -time-panel "
2026-03-21 13:16:39 +08:00
value -format =" HH : mm "
format = "HH:mm"
placeholder = "结束时间"
input -read-only
style = "width: calc(50% - 14px)"
@change ="handleBusinessHoursChange"
/>
</ div >
2026-02-25 10:37:16 +08:00
</ a-form-item >
2026-05-21 18:43:59 +08:00
< a-form-item label = "授权起始日" name = "authorizationStartDate" >
2026-05-18 09:46:11 +08:00
< a-date-picker
2026-05-21 18:43:59 +08:00
v -model:value = "formState.authorizationStartDate"
value -format =" YYYY -MM-DD "
format = "YYYY-MM-DD"
2026-05-18 09:46:11 +08:00
placeholder = "为空表示长期有效"
:disabled = "!isAdmin"
style = "width: 100%"
/>
</ a-form-item >
2026-05-21 18:43:59 +08:00
< a-form-item label = "有效期天数" name = "authorizationDays" >
< a-input-number
v -model:value = "formState.authorizationDays"
:min = "1"
:precision = "0"
placeholder = "例如 30"
: disabled = "!isAdmin || !formState.authorizationStartDate"
style = "width: 100%"
/>
</ a-form-item >
< a-form-item label = "到期时间" >
< a-input :value = "computedAuthorizationExpireTimeText" disabled />
</ a-form-item >
2026-03-04 10:14:45 +08:00
< a-form-item label = "Banner图片" >
< div class = "upload-tip" > 首页轮播图 , 建议尺寸 750 x300 像素 </ div >
< a-upload
v -model:file-list = "bannerFileList"
list -type =" picture -card "
:custom-request = "handleUploadBanner"
:before-upload = "beforeUpload"
@preview ="handleBannerPreview"
@remove ="handleBannerRemove"
:max-count = "5"
>
< div v-if = "bannerFileList.length < 5" >
< plus-outlined />
< div style = "margin-top: 8px" > 上传Banner </ div >
</ div >
</ a-upload >
2026-03-26 11:41:38 +08:00
< div v-if = "isUploadPending" class="upload-pending-tip" > 图片正在上传中 , 上传完成前不可提交 。 </ div >
2026-03-04 10:14:45 +08:00
< a-modal v -model:open = "bannerPreviewVisible" :footer = "null" @cancel ="bannerPreviewVisible = false" >
< img alt = "预览" style = "width: 100%" :src = "bannerPreviewImage" />
</ a-modal >
</ a-form-item >
2026-02-26 14:20:35 +08:00
< a-form-item label = "店铺图片" >
2026-03-04 10:14:45 +08:00
< div class = "upload-tip" > 店铺详情展示图 </ div >
2026-02-26 14:20:35 +08:00
< a-upload
v -model:file-list = "imageFileList"
list -type =" picture -card "
:custom-request = "handleUploadImage"
:before-upload = "beforeUpload"
@preview ="handlePreview"
@remove ="handleRemove"
:max-count = "5"
>
< div v-if = "imageFileList.length < 5" >
< plus-outlined />
< div style = "margin-top: 8px" > 上传图片 </ div >
</ div >
</ a-upload >
2026-03-26 11:41:38 +08:00
< div v-if = "isUploadPending" class="upload-pending-tip" > 图片正在上传中 , 上传完成前不可提交 。 </ div >
2026-02-26 14:20:35 +08:00
< a-modal v -model:open = "previewVisible" :footer = "null" @cancel ="previewVisible = false" >
< img alt = "预览" style = "width: 100%" :src = "previewImage" />
</ a-modal >
2026-02-25 10:37:16 +08:00
</ a-form-item >
2026-05-21 18:43:59 +08:00
< div class = "theme-section" >
< div class = "theme-section__header" >
< div >
< div class = "theme-section__title" > 前台主题 </ div >
< div class = "theme-section__desc" > 用户按该店铺登录后 , 前台按钮 、 卡片和渐变会跟随这里的主色调 。 </ div >
</ div >
< a-space class = "theme-section__actions" >
< a-button size = "small" @click ="openSaveThemeTemplate" > 保存为模板 </ a -button >
< a-button size = "small" @click ="handleResetTheme" > 恢复默认 </ a -button >
</ a-space >
</ div >
< div class = "theme-template-panel" >
< div class = "theme-template-panel__header" >
< span > 配色模板 </ span >
< small > 选择预设快速应用 , 也可以把当前 5 个颜色保存成自己的模板 。 </ small >
</ div >
< div class = "theme-template-list" >
< div
v-for = "template in themeTemplates"
:key = "template.id"
class = "theme-template-card"
: class = "{
'theme-template-card--active': isThemeTemplateActive(template),
'theme-template-card--custom': template.source === 'custom'
}"
role = "button"
tabindex = "0"
@click ="applyThemeTemplate(template)"
@keydown.enter.prevent ="applyThemeTemplate(template)"
@keydown.space.prevent ="applyThemeTemplate(template)"
>
< div class = "theme-template-card__top" >
< strong >{{ template . name }}</ strong >
< span >{{ template . source === 'custom' ? '自定义' : '预设' }}</ span >
</ div >
< div class = "theme-template-card__swatches" >
< span
v-for = "(color, index) in getThemeTemplateSwatches(template)"
:key = "`${template.id}-${index}`"
: style = "{ background: color }"
></ span >
</ div >
< a-popconfirm
v-if = "template.source === 'custom'"
title = "删除这个自定义模板?"
ok -text =" 删除 "
cancel -text =" 取消 "
@confirm ="handleDeleteCustomThemeTemplate(template.id)"
>
< button class = "theme-template-card__delete" type = "button" @click.stop > 删除 </ button >
</ a -popconfirm >
</ div >
</ div >
</ div >
< div class = "theme-grid" >
< a-form-item label = "主色" name = "themePrimaryColor" >
< div class = "theme-color-field" >
< input v-model = "formState.themePrimaryColor" class="theme-color-picker" type="color" />
< a-input v -model:value = "formState.themePrimaryColor" placeholder = "#C6597D" />
</ div >
</ a-form-item >
< a-form-item label = "辅色" name = "themeSecondaryColor" >
< div class = "theme-color-field" >
< input v-model = "formState.themeSecondaryColor" class="theme-color-picker" type="color" />
< a-input v -model:value = "formState.themeSecondaryColor" placeholder = "#E9B7C7" />
</ div >
</ a-form-item >
< a-form-item label = "强调色" name = "themeAccentColor" >
< div class = "theme-color-field" >
< input v-model = "formState.themeAccentColor" class="theme-color-picker" type="color" />
< a-input v -model:value = "formState.themeAccentColor" placeholder = "#9F4967" />
</ div >
</ a-form-item >
< a-form-item label = "页面背景" name = "themePageBgColor" >
< div class = "theme-color-field" >
< input v-model = "formState.themePageBgColor" class="theme-color-picker" type="color" />
< a-input v -model:value = "formState.themePageBgColor" placeholder = "#FFF7F9" />
</ div >
</ a-form-item >
< a-form-item label = "卡片背景" name = "themeCardBgColor" >
< div class = "theme-color-field" >
< input v-model = "formState.themeCardBgColor" class="theme-color-picker" type="color" />
< a-input v -model:value = "formState.themeCardBgColor" placeholder = "#FFFFFF" />
</ div >
</ a-form-item >
</ div >
< a-form-item label = "背景图" >
< a-upload
v -model:file-list = "themeBackgroundFileList"
list -type =" picture -card "
:custom-request = "handleUploadThemeBackground"
:before-upload = "beforeUpload"
@preview ="handleThemeBackgroundPreview"
@remove ="handleThemeBackgroundRemove"
:max-count = "1"
>
< div v-if = "themeBackgroundFileList.length < 1" >
< plus-outlined />
< div style = "margin-top: 8px" > 上传背景图 </ div >
</ div >
</ a-upload >
</ a-form-item >
< div class = "theme-preview" :style = "themePreviewStyle" >
< div >
< span class = "theme-preview__eyebrow" : style = "{ color: themePreview.primaryColor }" > Yumi Nail </ span >
< strong > 店铺前台预览 </ strong >
< p > 按钮 、 标签和柔和渐变都会围绕主色延展 。 </ p >
</ div >
< span class = "theme-preview__button" :style = "themePreviewButtonStyle" > 立即预约 </ span >
</ div >
</ div >
< a-modal
v -model:open = "themeTemplateSaveVisible"
title = "保存配色模板"
ok -text =" 保存 "
cancel -text =" 取消 "
@ok ="handleConfirmSaveThemeTemplate"
@cancel ="handleCancelSaveThemeTemplate"
>
< div class = "theme-template-save-form" >
< label for = "theme-template-name" > 模板名称 </ label >
< a-input
id = "theme-template-name"
v -model:value = "themeTemplateName"
:maxlength = "20"
show -count
placeholder = "例如:春日玫瑰"
@ press -enter =" handleConfirmSaveThemeTemplate "
/>
</ div >
< div class = "theme-template-save-preview" >
< span
v-for = "(color, index) in currentThemeTemplateSwatches"
:key = "`current-${index}`"
: style = "{ background: color }"
></ span >
</ div >
</ a-modal >
2026-02-25 10:37:16 +08:00
</ a-form >
2026-05-13 12:43:01 +08:00
</ AdminResponsiveModal >
2026-02-28 14:32:28 +08:00
<!-- 查看店铺详情模态框 -->
2026-05-13 12:43:01 +08:00
< AdminResponsiveModal
2026-02-28 14:32:28 +08:00
v -model:open = "viewModalVisible"
title = "查看店铺详情"
2026-05-13 12:43:01 +08:00
:desktop-width = "700"
2026-02-28 14:32:28 +08:00
@cancel ="handleViewModalCancel"
>
< a-form
:model = "viewFormState"
: label -col =" { span : 5 } "
: wrapper -col =" { span : 18 } "
>
< a-form-item label = "店铺名称" >
< a-input v -model:value = "viewFormState.shopName" :disabled = "true" />
</ a-form-item >
< a-form-item label = "店铺描述" >
< a-textarea
v -model:value = "viewFormState.description"
:rows = "3"
:disabled = "true"
/>
</ a-form-item >
< a-form-item label = "店铺地址" >
< a-input v -model:value = "viewFormState.address" :disabled = "true" />
</ a-form-item >
2026-05-18 09:46:11 +08:00
< a-form-item label = "地图位置" >
2026-05-21 18:43:59 +08:00
< a-input :value = "formatLocation(viewFormState)" :disabled = "true" />
2026-05-18 09:46:11 +08:00
</ a-form-item >
2026-02-28 14:32:28 +08:00
< a-form-item label = "营业时间" >
< a-input v -model:value = "viewFormState.businessHours" :disabled = "true" />
</ a-form-item >
2026-05-18 09:46:11 +08:00
< a-form-item label = "授权状态" >
< a-input : value = "viewFormState.authorizationStatusText || '有效'" :disabled = "true" />
</ a-form-item >
2026-05-21 18:43:59 +08:00
< a-form-item label = "授权起始日" >
< a-input : value = "viewFormState.authorizationStartDate || '长期有效'" :disabled = "true" />
</ a-form-item >
< a-form-item label = "有效期天数" >
< a-input : value = "viewFormState.authorizationDays ? `${viewFormState.authorizationDays} 天` : '长期有效'" :disabled = "true" />
</ a-form-item >
2026-05-18 09:46:11 +08:00
< a-form-item label = "授权有效期" >
< a-input :value = "formatAuthorizationExpireTime(viewFormState.authorizationExpireTime)" :disabled = "true" />
</ a-form-item >
2026-05-21 18:43:59 +08:00
< a-form-item label = "前台主题" >
< div class = "theme-view-swatches" >
< span : style = "{ background: viewThemePreview.primaryColor }" ></ span >
< span : style = "{ background: viewThemePreview.secondaryColor }" ></ span >
< span : style = "{ background: viewThemePreview.accentColor }" ></ span >
< span : style = "{ background: viewThemePreview.pageBgColor }" ></ span >
< span : style = "{ background: viewThemePreview.cardBgColor }" ></ span >
</ div >
</ a-form-item >
2026-03-04 10:14:45 +08:00
< a-form-item label = "Banner图片" >
< div class = "shop-images" >
< a-image
v-for = "(url, index) in viewBannerUrls"
:key = "index"
:width = "120"
:height = "60"
:src = "url"
style = "object-fit: cover; border-radius: 4px; margin-right: 8px; margin-bottom: 8px;"
:preview = "false"
/>
< span v-if = "viewBannerUrls.length === 0" class="no-banner" > 暂无Banner </ span >
</ div >
</ a -form-item >
2026-02-28 14:32:28 +08:00
< a-form-item label = "店铺图片" >
< div class = "shop-images" >
< a-image
v-for = "(url, index) in viewImageUrls"
:key = "index"
:width = "80"
:height = "80"
:src = "url"
style = "object-fit: cover; border-radius: 4px; margin-right: 8px; margin-bottom: 8px;"
:preview = "false"
/>
2026-03-04 10:14:45 +08:00
< a-image
v-if = "viewImageUrls.length === 0"
:width = "80"
:height = "80"
:src = "DEFAULT_SHOP_IMAGE"
style = "object-fit: cover; border-radius: 4px;"
:preview = "false"
/>
2026-02-28 14:32:28 +08:00
</ div >
</ a-form-item >
</ a-form >
2026-05-13 12:43:01 +08:00
</ AdminResponsiveModal >
2026-05-21 18:43:59 +08:00
< a-modal
v -model:open = "mapPickerVisible"
:title = "mapPickerTitle"
:width = "920"
:footer = "null"
destroy -on-close
class = "tencent-map-picker-modal"
@cancel ="closeMapLocationPicker"
>
< div class = "tencent-map-picker" >
< div class = "tencent-map-picker__toolbar" >
< div >
< strong > 搜索并选择店铺位置 </ strong >
< p > 在地图中搜索位置后点击确认 , 系统会自动回填地址和坐标 。 </ p >
</ div >
< a-button :loading = "locating" @click ="useCurrentLocation" > 一键获取当前位置 </ a -button >
</ div >
< iframe
v-if = "mapPickerUrl"
ref = "mapPickerFrame"
class = "tencent-map-picker__frame"
:src = "mapPickerUrl"
:title = "mapPickerTitle"
@load ="handleMapPickerFrameLoad"
></ iframe >
</ div >
</ a-modal >
2026-05-13 12:43:01 +08:00
< AdminMobileFab
: visible = "isMobile && hasPermission('shop:create') && !modalVisible && !viewModalVisible"
2026-05-15 21:10:41 +08:00
label = "新增店铺"
2026-05-13 12:43:01 +08:00
@click ="showAddModal"
/>
2026-02-25 10:37:16 +08:00
</ div >
</ template >
< script setup lang = "ts" >
2026-05-18 09:46:11 +08:00
/**
* ShopsView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
2026-03-26 11:41:38 +08:00
import { computed , ref , reactive , onMounted } from 'vue'
2026-02-25 10:37:16 +08:00
import { message } from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue'
2026-03-02 10:13:20 +08:00
import { PlusOutlined } from '@ant-design/icons-vue'
2026-03-26 12:04:02 +08:00
import DraftActions from '@/components/DraftActions.vue'
2026-03-27 12:29:36 +08:00
import TableEllipsisText from '@/components/TableEllipsisText.vue'
2026-02-25 10:37:16 +08:00
import { DEFAULT_SHOP_IMAGE } from '@/constants'
2026-05-23 18:44:57 +08:00
/**
* Purpose: Shop supports ShopsView.vue by holding or executing the shop page or API role.
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-18 09:46:11 +08:00
import { adminShopApi , adminFileApi , adminSystemParameterConfigApi , type Shop } from '@/api/admin'
2026-05-23 18:44:57 +08:00
/**
* Purpose: ChunkUploadTask supports ShopsView.vue by holding or executing the chunk upload task page or API role.
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-26 11:41:38 +08:00
import { createChunkUploadTask , type ChunkUploadTask } from '@/utils/chunk-upload'
2026-03-26 12:04:02 +08:00
import { buildDraftStorageKey , clearDraftRecord , loadDraftRecord , saveDraftRecord } from '@/utils/form-draft'
2026-02-26 17:54:18 +08:00
import { usePermission } from '@/utils/permission'
2026-05-13 12:43:01 +08:00
import { runWithGlobalLoading } from '@/utils/action-loading'
2026-05-21 18:43:59 +08:00
import { resolveShopTheme } from '@/utils/shop-theme'
2026-05-13 12:43:01 +08:00
import { useAdminViewport } from '@/composables/useAdminViewport'
import AdminMobileCardList from '@/components/admin/AdminMobileCardList.vue'
import AdminMobileFab from '@/components/admin/AdminMobileFab.vue'
import AdminResponsiveModal from '@/components/admin/AdminResponsiveModal.vue'
2026-02-26 17:54:18 +08:00
2026-02-26 18:44:47 +08:00
const { hasPermission , loadUserPermissions } = usePermission ()
2026-05-13 12:43:01 +08:00
const { isMobile } = useAdminViewport ()
2026-02-25 10:37:16 +08:00
2026-05-23 18:44:57 +08:00
/**
* Purpose: ShopThemeTemplateColors supports ShopsView.vue by holding or executing the shop theme template colors page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
interface ShopThemeTemplateColors {
themePrimaryColor : string
themeSecondaryColor : string
themeAccentColor : string
themePageBgColor : string
themeCardBgColor : string
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: ShopThemeTemplate supports ShopsView.vue by holding or executing the shop theme template page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
interface ShopThemeTemplate extends ShopThemeTemplateColors {
id : string
name : string
source : 'preset' | 'custom'
createdAt ?: number
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: CUSTOM_THEME_TEMPLATE_STORAGE_KEY supports ShopsView.vue by holding or executing the custom theme template storage key page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const CUSTOM_THEME_TEMPLATE_STORAGE_KEY = 'yuminail:admin:shop-theme-templates'
2026-05-23 18:44:57 +08:00
/**
* Purpose: CUSTOM_THEME_TEMPLATE_LIMIT supports ShopsView.vue by holding or executing the custom theme template limit page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const CUSTOM_THEME_TEMPLATE_LIMIT = 20
const PRESET_THEME_TEMPLATES : ShopThemeTemplate [] = [
{
id : 'preset-soft-nude' ,
name : '柔雾裸粉' ,
source : 'preset' ,
themePrimaryColor : '#C6597D' ,
themeSecondaryColor : '#E9B7C7' ,
themeAccentColor : '#9F4967' ,
themePageBgColor : '#FFF7F9' ,
themeCardBgColor : '#FFFFFF'
},
{
id : 'preset-rose-milk-tea' ,
name : '玫瑰奶茶' ,
source : 'preset' ,
themePrimaryColor : '#B96D79' ,
themeSecondaryColor : '#E6C0B7' ,
themeAccentColor : '#8D4D58' ,
themePageBgColor : '#FFF8F5' ,
themeCardBgColor : '#FFFFFF'
},
{
id : 'preset-peach-velvet' ,
name : '蜜桃绒光' ,
source : 'preset' ,
themePrimaryColor : '#D87986' ,
themeSecondaryColor : '#F0C6B4' ,
themeAccentColor : '#B85C6D' ,
themePageBgColor : '#FFF6F2' ,
themeCardBgColor : '#FFFFFF'
},
{
id : 'preset-misty-berry' ,
name : '雾莓豆沙' ,
source : 'preset' ,
themePrimaryColor : '#A85F76' ,
themeSecondaryColor : '#D7A9B8' ,
themeAccentColor : '#7E4258' ,
themePageBgColor : '#FBF4F7' ,
themeCardBgColor : '#FFFFFF'
},
{
id : 'preset-champagne-coral' ,
name : '香槟珊瑚' ,
source : 'preset' ,
themePrimaryColor : '#C97865' ,
themeSecondaryColor : '#EBC7AA' ,
themeAccentColor : '#A4574D' ,
themePageBgColor : '#FFF8F1' ,
themeCardBgColor : '#FFFFFF'
},
{
id : 'preset-magnolia-cream' ,
name : '玉兰米白' ,
source : 'preset' ,
themePrimaryColor : '#A46E79' ,
themeSecondaryColor : '#E7D4CC' ,
themeAccentColor : '#7C555F' ,
themePageBgColor : '#FBF7F2' ,
themeCardBgColor : '#FFFFFF'
},
{
id : 'preset-smoky-mauve' ,
name : '烟粉灰调' ,
source : 'preset' ,
themePrimaryColor : '#9B6A78' ,
themeSecondaryColor : '#D8BCC4' ,
themeAccentColor : '#72505B' ,
themePageBgColor : '#F8F4F5' ,
themeCardBgColor : '#FFFFFF'
},
{
id : 'preset-berry-brown' ,
name : '莓果红棕' ,
source : 'preset' ,
themePrimaryColor : '#9E5366' ,
themeSecondaryColor : '#D9A0AD' ,
themeAccentColor : '#6F3948' ,
themePageBgColor : '#FFF5F7' ,
themeCardBgColor : '#FFFFFF'
},
{
id : 'preset-cream-rose' ,
name : '奶油玫瑰' ,
source : 'preset' ,
themePrimaryColor : '#D28A9C' ,
themeSecondaryColor : '#F0CFD6' ,
themeAccentColor : '#A85A71' ,
themePageBgColor : '#FFF9FA' ,
themeCardBgColor : '#FFFFFF'
},
{
id : 'preset-sakura-salon' ,
name : '静谧樱花' ,
source : 'preset' ,
themePrimaryColor : '#BF7892' ,
themeSecondaryColor : '#E8C6D2' ,
themeAccentColor : '#8E5369' ,
themePageBgColor : '#FFF7FA' ,
themeCardBgColor : '#FFFFFF'
}
]
2026-05-18 09:46:11 +08:00
/** loading is a reactive state variable used by the template and event handlers. */
2026-02-25 10:37:16 +08:00
const loading = ref ( false )
2026-05-18 09:46:11 +08:00
/** searchText is a reactive state variable used by the template and event handlers. */
2026-02-25 10:37:16 +08:00
const searchText = ref ( '' )
2026-05-23 18:44:57 +08:00
/**
* Purpose: shopList supports ShopsView.vue by holding or executing the shop list page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-25 14:44:50 +08:00
const shopList = ref < Shop [] >([])
2026-05-18 09:46:11 +08:00
/** modalVisible is a reactive state variable used by the template and event handlers. */
2026-02-25 10:37:16 +08:00
const modalVisible = ref ( false )
2026-05-18 09:46:11 +08:00
/** viewModalVisible is a reactive state variable used by the template and event handlers. */
2026-02-28 14:32:28 +08:00
const viewModalVisible = ref ( false )
2026-05-18 09:46:11 +08:00
/** modalLoading is a reactive state variable used by the template and event handlers. */
2026-02-25 10:37:16 +08:00
const modalLoading = ref ( false )
2026-05-18 09:46:11 +08:00
/** isEdit is a reactive state variable used by the template and event handlers. */
2026-02-25 10:37:16 +08:00
const isEdit = ref ( false )
2026-05-23 18:44:57 +08:00
/**
* Purpose: mapPickerVisible supports ShopsView.vue by holding or executing the map picker visible page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const mapPickerVisible = ref ( false )
2026-05-23 18:44:57 +08:00
/**
* Purpose: mapPickerKey supports ShopsView.vue by holding or executing the map picker key page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const mapPickerKey = ref ( '' )
2026-05-23 18:44:57 +08:00
/**
* Purpose: mapPickerUrl supports ShopsView.vue by holding or executing the map picker url page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const mapPickerUrl = ref ( '' )
2026-05-23 18:44:57 +08:00
/**
* Purpose: mapPickerProvider supports ShopsView.vue by holding or executing the map picker provider page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const mapPickerProvider = ref < 'TENCENT' | 'AMAP' > ( 'TENCENT' )
2026-05-23 18:44:57 +08:00
/**
* Purpose: locating supports ShopsView.vue by holding or executing the locating page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const locating = ref ( false )
2026-05-23 18:44:57 +08:00
/**
* Purpose: formRef supports ShopsView.vue by holding or executing the form ref page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-25 10:37:16 +08:00
const formRef = ref < FormInstance >()
2026-05-23 18:44:57 +08:00
/**
* Purpose: currentShop supports ShopsView.vue by holding or executing the current shop page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-25 14:44:50 +08:00
const currentShop = ref < Shop | null >( null )
2026-05-18 09:46:11 +08:00
/** isAdmin is a reactive state variable used by the template and event handlers. */
2026-02-26 18:44:47 +08:00
const isAdmin = ref ( false )
2026-02-25 10:37:16 +08:00
2026-03-04 10:14:45 +08:00
// Banner图片相关
const bannerFileList = ref < any [] >([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: uploadedBannerIds supports ShopsView.vue by holding or executing the uploaded banner ids page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-04 10:14:45 +08:00
const uploadedBannerIds = ref < string [] >([])
2026-05-18 09:46:11 +08:00
/** bannerPreviewVisible is a reactive state variable used by the template and event handlers. */
2026-03-04 10:14:45 +08:00
const bannerPreviewVisible = ref ( false )
2026-05-18 09:46:11 +08:00
/** bannerPreviewImage is a reactive state variable used by the template and event handlers. */
2026-03-04 10:14:45 +08:00
const bannerPreviewImage = ref ( '' )
// 店铺图片相关
2026-02-26 14:20:35 +08:00
const imageFileList = ref < any [] >([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: uploadedFileIds supports ShopsView.vue by holding or executing the uploaded file ids page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-26 14:20:35 +08:00
const uploadedFileIds = ref < string [] >([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: themeBackgroundFileList supports ShopsView.vue by holding or executing the theme background file list page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const themeBackgroundFileList = ref < any [] >([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: uploadedThemeBackgroundId supports ShopsView.vue by holding or executing the uploaded theme background id page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const uploadedThemeBackgroundId = ref ( '' )
2026-05-23 18:44:57 +08:00
/**
* Purpose: imageIdCache supports ShopsView.vue by holding or executing the image id cache page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-26 14:20:35 +08:00
const imageIdCache = ref < Record < string , string > > ({})
2026-05-23 18:44:57 +08:00
/**
* Purpose: shopImageUrls supports ShopsView.vue by holding or executing the shop image urls page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-27 14:55:41 +08:00
const shopImageUrls = ref < Record < string , string [] > > ({})
2026-05-23 18:44:57 +08:00
/**
* Purpose: shopBannerUrls supports ShopsView.vue by holding or executing the shop banner urls page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-27 14:55:41 +08:00
const shopBannerUrls = ref < Record < string , string [] > > ({})
2026-05-23 18:44:57 +08:00
/**
* Purpose: viewImageUrls supports ShopsView.vue by holding or executing the view image urls page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-28 14:32:28 +08:00
const viewImageUrls = ref < string [] >([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: viewBannerUrls supports ShopsView.vue by holding or executing the view banner urls page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-04 10:14:45 +08:00
const viewBannerUrls = ref < string [] >([])
2026-05-18 09:46:11 +08:00
/** previewVisible is a reactive state variable used by the template and event handlers. */
2026-02-26 14:20:35 +08:00
const previewVisible = ref ( false )
2026-05-18 09:46:11 +08:00
/** previewImage is a reactive state variable used by the template and event handlers. */
2026-02-26 14:20:35 +08:00
const previewImage = ref ( '' )
2026-05-18 09:46:11 +08:00
/** businessStartTime is a reactive state variable used by the template and event handlers. */
2026-03-21 13:16:39 +08:00
const businessStartTime = ref ( '' )
2026-05-18 09:46:11 +08:00
/** businessEndTime is a reactive state variable used by the template and event handlers. */
2026-03-21 13:16:39 +08:00
const businessEndTime = ref ( '' )
2026-05-23 18:44:57 +08:00
/**
* Purpose: uploadTaskMap supports ShopsView.vue by holding or executing the upload task map page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-26 11:41:38 +08:00
const uploadTaskMap = new Map < string , ChunkUploadTask < any > > ()
2026-05-18 09:46:11 +08:00
/** activeUploadCount is a reactive state variable used by the template and event handlers. */
2026-03-26 11:41:38 +08:00
const activeUploadCount = ref ( 0 )
2026-05-18 09:46:11 +08:00
/** isUploadPending is a reactive state variable used by the template and event handlers. */
2026-03-26 11:41:38 +08:00
const isUploadPending = computed (() => activeUploadCount . value > 0 )
2026-05-23 18:44:57 +08:00
/**
* Purpose: draftSavedAt supports ShopsView.vue by holding or executing the draft saved at page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-26 12:04:02 +08:00
const draftSavedAt = ref < number | null >( null )
2026-05-23 18:44:57 +08:00
/**
* Purpose: customThemeTemplates supports ShopsView.vue by holding or executing the custom theme templates page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const customThemeTemplates = ref < ShopThemeTemplate [] >([])
2026-05-23 18:44:57 +08:00
/**
* Purpose: themeTemplateSaveVisible supports ShopsView.vue by holding or executing the theme template save visible page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const themeTemplateSaveVisible = ref ( false )
2026-05-23 18:44:57 +08:00
/**
* Purpose: themeTemplateName supports ShopsView.vue by holding or executing the theme template name page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const themeTemplateName = ref ( '' )
2026-02-26 14:20:35 +08:00
2026-02-28 14:32:28 +08:00
// 查看店铺相关状态
const viewFormState = reactive ({
shopName : '' ,
description : '' ,
address : '' ,
2026-05-18 09:46:11 +08:00
mapProvider : 'TENCENT' ,
longitude : '' ,
latitude : '' ,
2026-02-28 14:32:28 +08:00
businessHours : '' ,
2026-03-26 10:28:28 +08:00
status : 1 ,
2026-05-21 18:43:59 +08:00
authorizationStartDate : '' ,
authorizationDays : undefined as number | undefined ,
2026-05-18 09:46:11 +08:00
authorizationExpireTime : '' ,
authorizationStatusText : '' ,
2026-03-04 10:14:45 +08:00
coverImageFileId : '' ,
2026-05-21 18:43:59 +08:00
imageFileIds : '' ,
themePrimaryColor : '' ,
themeSecondaryColor : '' ,
themeAccentColor : '' ,
themePageBgColor : '' ,
themeCardBgColor : '' ,
themeBackgroundImageFileId : ''
2026-02-28 14:32:28 +08:00
})
2026-05-23 18:44:57 +08:00
/**
* Purpose: pagination supports ShopsView.vue by holding or executing the pagination page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-25 10:37:16 +08:00
const pagination = reactive ({
current : 1 ,
pageSize : 10 ,
total : 0 ,
showSizeChanger : true ,
showQuickJumper : true ,
showTotal : ( total : number ) => `共 ${ total } 条`
})
2026-05-23 18:44:57 +08:00
/**
* Purpose: formState supports ShopsView.vue by holding or executing the form state page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-25 10:37:16 +08:00
const formState = reactive ({
2026-02-25 14:44:50 +08:00
shopName : '' ,
2026-02-25 10:37:16 +08:00
description : '' ,
address : '' ,
2026-05-18 09:46:11 +08:00
mapProvider : 'TENCENT' ,
longitude : '' ,
latitude : '' ,
2026-02-25 10:37:16 +08:00
businessHours : '' ,
2026-03-26 10:28:28 +08:00
status : 1 ,
2026-05-21 18:43:59 +08:00
authorizationStartDate : '' ,
authorizationDays : undefined as number | undefined ,
2026-05-18 09:46:11 +08:00
authorizationExpireTime : '' ,
2026-03-04 10:14:45 +08:00
coverImageFileId : '' ,
2026-05-21 18:43:59 +08:00
imageFileIds : '' ,
themePrimaryColor : '' ,
themeSecondaryColor : '' ,
themeAccentColor : '' ,
themePageBgColor : '' ,
themeCardBgColor : '' ,
themeBackgroundImageFileId : ''
2026-02-25 10:37:16 +08:00
})
2026-05-23 18:44:57 +08:00
/**
* Purpose: selectedLocationText supports ShopsView.vue by holding or executing the selected location text page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const selectedLocationText = computed (() => {
if ( formState . address ) return formState . address
if ( formState . longitude && formState . latitude ) return '已选择地图位置'
return '暂未选择地图位置'
})
2026-05-23 18:44:57 +08:00
/**
* Purpose: selectedCoordinateText supports ShopsView.vue by holding or executing the selected coordinate text page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const selectedCoordinateText = computed (() => {
if ( ! formState . longitude || ! formState . latitude ) return '点击“地图选点”搜索店铺名称或地址'
return '已选择地图位置,可重新选点'
})
2026-05-23 18:44:57 +08:00
/**
* Purpose: mapPickerTitle supports ShopsView.vue by holding or executing the map picker title page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const mapPickerTitle = computed (() => mapPickerProvider . value === 'AMAP' ? '高德地图选点' : '腾讯地图选点' )
2026-05-23 18:44:57 +08:00
/**
* Purpose: computedAuthorizationExpireTime supports ShopsView.vue by holding or executing the computed authorization expire time page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const computedAuthorizationExpireTime = computed (() => {
if ( ! formState . authorizationStartDate || ! formState . authorizationDays || formState . authorizationDays <= 0 ) {
return formState . authorizationExpireTime || ''
}
const start = new Date ( ` ${ formState . authorizationStartDate } T00:00:00` )
start . setDate ( start . getDate () + Number ( formState . authorizationDays ) - 1 )
const yyyy = start . getFullYear ()
const mm = String ( start . getMonth () + 1 ). padStart ( 2 , '0' )
const dd = String ( start . getDate ()). padStart ( 2 , '0' )
return ` ${ yyyy } - ${ mm } - ${ dd } 23:59:59`
})
2026-05-23 18:44:57 +08:00
/**
* Purpose: computedAuthorizationExpireTimeText supports ShopsView.vue by holding or executing the computed authorization expire time text page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const computedAuthorizationExpireTimeText = computed (() => formatAuthorizationExpireTime ( computedAuthorizationExpireTime . value ))
2026-05-23 18:44:57 +08:00
/**
* Purpose: themePreview supports ShopsView.vue by holding or executing the theme preview page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const themePreview = computed (() => resolveShopTheme ( formState ))
2026-05-23 18:44:57 +08:00
/**
* Purpose: viewThemePreview supports ShopsView.vue by holding or executing the view theme preview page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const viewThemePreview = computed (() => resolveShopTheme ( viewFormState ))
2026-05-23 18:44:57 +08:00
/**
* Purpose: themePreviewStyle supports ShopsView.vue by holding or executing the theme preview style page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const themePreviewStyle = computed (() => ({
color : themePreview . value . textPrimary ,
borderColor : themePreview . value . borderColor ,
background : themePreview . value . softGradient
}))
2026-05-23 18:44:57 +08:00
/**
* Purpose: themePreviewButtonStyle supports ShopsView.vue by holding or executing the theme preview button style page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const themePreviewButtonStyle = computed (() => ({
color : '#ffffff' ,
background : themePreview . value . gradient ,
boxShadow : themePreview . value . cssVars [ '--theme-button-shadow' ]
}))
2026-05-23 18:44:57 +08:00
/**
* Purpose: themeTemplates supports ShopsView.vue by holding or executing the theme templates page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const themeTemplates = computed (() => [... PRESET_THEME_TEMPLATES , ... customThemeTemplates . value ])
2026-05-23 18:44:57 +08:00
/**
* Purpose: currentThemeTemplateColors supports ShopsView.vue by holding or executing the current theme template colors page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const currentThemeTemplateColors = computed (() => buildThemeTemplateColors ( formState ))
2026-05-23 18:44:57 +08:00
/**
* Purpose: currentThemeTemplateSwatches supports ShopsView.vue by holding or executing the current theme template swatches page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const currentThemeTemplateSwatches = computed (() => getThemeTemplateSwatches ( currentThemeTemplateColors . value ))
2026-05-23 18:44:57 +08:00
/**
* Purpose: normalizeTemplateColor supports ShopsView.vue by holding or executing the normalize template color page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const normalizeTemplateColor = ( value ?: string ) => {
const normalized = String ( value || '' ). trim (). toUpperCase ()
return /^#[0-9A-F]{6}$/ . test ( normalized ) ? normalized : ''
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: buildThemeTemplateColors supports ShopsView.vue by holding or executing the build theme template colors page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const buildThemeTemplateColors = ( source : Record < string , any >) : ShopThemeTemplateColors => {
const resolvedTheme = resolveShopTheme ( source )
return {
themePrimaryColor : resolvedTheme . primaryColor ,
themeSecondaryColor : resolvedTheme . secondaryColor ,
themeAccentColor : resolvedTheme . accentColor ,
themePageBgColor : resolvedTheme . pageBgColor ,
themeCardBgColor : resolvedTheme . cardBgColor
}
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: getThemeTemplateSwatches supports ShopsView.vue by holding or executing the get theme template swatches page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const getThemeTemplateSwatches = ( template : ShopThemeTemplateColors ) => [
template . themePrimaryColor ,
template . themeSecondaryColor ,
template . themeAccentColor ,
template . themePageBgColor ,
template . themeCardBgColor
]
2026-05-23 18:44:57 +08:00
/**
* Purpose: normalizeThemeTemplate supports ShopsView.vue by holding or executing the normalize theme template page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const normalizeThemeTemplate = ( value : any ) : ShopThemeTemplate | null => {
if ( ! value || typeof value !== 'object' ) {
return null
}
const name = String ( value . name || '' ). trim ()
const colors = {
themePrimaryColor : normalizeTemplateColor ( value . themePrimaryColor ),
themeSecondaryColor : normalizeTemplateColor ( value . themeSecondaryColor ),
themeAccentColor : normalizeTemplateColor ( value . themeAccentColor ),
themePageBgColor : normalizeTemplateColor ( value . themePageBgColor ),
themeCardBgColor : normalizeTemplateColor ( value . themeCardBgColor )
}
if ( ! name || Object . values ( colors ). some ( color => ! color )) {
return null
}
return {
id : String ( value . id || `custom- ${ Date . now () } ` ),
name ,
source : 'custom' ,
createdAt : Number ( value . createdAt ) || Date . now (),
... colors
}
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: persistCustomThemeTemplates supports ShopsView.vue by holding or executing the persist custom theme templates page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const persistCustomThemeTemplates = () => {
if ( typeof window === 'undefined' ) {
return
}
window . localStorage . setItem ( getThemeTemplateStorageKey (), JSON . stringify ( customThemeTemplates . value ))
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: loadCustomThemeTemplates supports ShopsView.vue by holding or executing the load custom theme templates page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const loadCustomThemeTemplates = () => {
if ( typeof window === 'undefined' ) {
return
}
try {
const rawValue = window . localStorage . getItem ( getThemeTemplateStorageKey ())
const parsedValue = rawValue ? JSON . parse ( rawValue ) : []
customThemeTemplates . value = Array . isArray ( parsedValue )
? parsedValue . map ( normalizeThemeTemplate ). filter (( item ) : item is ShopThemeTemplate => Boolean ( item ))
: []
} catch {
customThemeTemplates . value = []
}
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: isThemeTemplateActive supports ShopsView.vue by holding or executing the is theme template active page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const isThemeTemplateActive = ( template : ShopThemeTemplateColors ) => {
const currentColors = currentThemeTemplateColors . value
return getThemeTemplateSwatches ( template ). every (( color , index ) => color === getThemeTemplateSwatches ( currentColors )[ index ])
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: themeColorValidator supports ShopsView.vue by holding or executing the theme color validator page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const themeColorValidator = async ( _rule : any , value ?: string ) => {
if ( ! value ) {
return Promise . resolve ()
}
if ( /^#[0-9a-fA-F]{6}$/ . test ( value . trim ())) {
return Promise . resolve ()
}
return Promise . reject ( '请输入 #RRGGBB 格式颜色' )
}
2026-03-02 10:13:20 +08:00
const formRules : any = {
2026-02-25 14:44:50 +08:00
shopName : [{ required : true , message : '请输入店铺名称' , trigger : 'blur' }],
2026-02-25 10:37:16 +08:00
description : [{ required : true , message : '请输入店铺描述' , trigger : 'blur' }],
address : [{ required : true , message : '请输入店铺地址' , trigger : 'blur' }],
2026-03-21 13:16:39 +08:00
businessHours : [{
validator : async () => {
if ( ! businessStartTime . value || ! businessEndTime . value ) {
return Promise . reject ( '请选择营业开始和结束时间' )
}
if ( businessStartTime . value >= businessEndTime . value ) {
return Promise . reject ( '营业结束时间必须晚于开始时间' )
}
return Promise . resolve ()
},
trigger : 'change'
2026-05-21 18:43:59 +08:00
}],
authorizationDays : [{
validator : async () => {
if ( formState . authorizationStartDate && ( ! formState . authorizationDays || formState . authorizationDays <= 0 )) {
return Promise . reject ( '请输入授权有效期天数' )
}
return Promise . resolve ()
},
trigger : 'change'
}],
themePrimaryColor : [{ validator : themeColorValidator , trigger : 'blur' }],
themeSecondaryColor : [{ validator : themeColorValidator , trigger : 'blur' }],
themeAccentColor : [{ validator : themeColorValidator , trigger : 'blur' }],
themePageBgColor : [{ validator : themeColorValidator , trigger : 'blur' }],
themeCardBgColor : [{ validator : themeColorValidator , trigger : 'blur' }]
2026-02-25 10:37:16 +08:00
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: columns supports ShopsView.vue by holding or executing the columns page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-02-25 10:37:16 +08:00
const columns = [
2026-02-26 14:20:35 +08:00
{ title : '图片' , key : 'image' , width : 150 },
2026-03-04 10:14:45 +08:00
{ title : 'Banner' , key : 'banner' , width : 200 },
2026-02-25 14:44:50 +08:00
{ title : '店铺名称' , dataIndex : 'shopName' , key : 'shopName' },
{ title : '店铺描述' , dataIndex : 'description' , key : 'description' },
2026-02-25 10:37:16 +08:00
{ title : '店铺地址' , dataIndex : 'address' , key : 'address' },
{ title : '营业时间' , dataIndex : 'businessHours' , key : 'businessHours' },
2026-03-26 10:28:28 +08:00
{ title : '状态' , key : 'status' , width : 120 },
2026-05-18 09:46:11 +08:00
{ title : '授权' , key : 'authorization' , width : 180 },
2026-02-25 10:37:16 +08:00
{ title : '创建时间' , dataIndex : 'createTime' , key : 'createTime' },
{ title : '操作' , key : 'actions' , width : 150 , fixed : 'right' as const }
]
2026-05-18 09:46:11 +08:00
/** getCurrentUserInfo is a local helper used by this page script. */
2026-02-25 16:50:32 +08:00
const getCurrentUserInfo = () => {
try {
const userInfoStr = localStorage . getItem ( 'adminUserInfo' )
if ( userInfoStr ) {
2026-02-26 18:44:47 +08:00
const userInfo = JSON . parse ( userInfoStr )
// 判断用户是否为管理员(类型为4)
isAdmin . value = userInfo . type === 4
return userInfo
2026-02-25 16:50:32 +08:00
}
} catch ( error ) {
console . error ( '获取当前用户信息失败' , error )
}
return null
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: getThemeTemplateStorageKey supports ShopsView.vue by holding or executing the get theme template storage key page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const getThemeTemplateStorageKey = () => {
const currentUser = getCurrentUserInfo ()
const userKey = currentUser ? . id ?? currentUser ? . userId ?? currentUser ? . account ?? currentUser ? . username ?? 'default'
return ` ${ CUSTOM_THEME_TEMPLATE_STORAGE_KEY } : ${ userKey } `
}
2026-05-18 09:46:11 +08:00
/** loadImageUrls is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-02-26 14:20:35 +08:00
const loadImageUrls = async ( shops : Shop []) => {
for ( const shop of shops ) {
2026-03-04 10:14:45 +08:00
// 加载店铺图片
2026-02-26 14:20:35 +08:00
if ( shop . imageFileIds ) {
const ids = shop . imageFileIds . split ( ',' )
const urls : string [] = []
for ( const id of ids ) {
if ( id ) {
try {
// 检查缓存
if ( ! imageIdCache . value [ id ]) {
2026-03-27 14:55:41 +08:00
const response = await adminFileApi . getSignedUrl ( id . trim ()) as any
2026-03-02 10:13:20 +08:00
imageIdCache . value [ id ] = response
2026-02-26 14:20:35 +08:00
}
2026-03-10 23:23:15 +08:00
urls . push ( imageIdCache . value [ id ] ! )
2026-02-26 14:20:35 +08:00
} catch ( error ) {
console . error ( '获取签名链接失败:' , error )
urls . push ( DEFAULT_SHOP_IMAGE )
}
}
}
2026-03-10 23:23:15 +08:00
if ( shop . id !== undefined ) {
2026-03-27 14:55:41 +08:00
shopImageUrls . value [ String ( shop . id )] = urls
2026-03-10 23:23:15 +08:00
}
2026-02-26 14:20:35 +08:00
} else {
2026-03-10 23:23:15 +08:00
if ( shop . id !== undefined ) {
2026-03-27 14:55:41 +08:00
shopImageUrls . value [ String ( shop . id )] = []
2026-03-10 23:23:15 +08:00
}
2026-03-04 10:14:45 +08:00
}
// 加载Banner图片
if ( shop . coverImageFileId ) {
const ids = shop . coverImageFileId . split ( ',' )
const urls : string [] = []
for ( const id of ids ) {
if ( id ) {
try {
// 检查缓存
if ( ! imageIdCache . value [ id ]) {
2026-03-27 14:55:41 +08:00
const response = await adminFileApi . getSignedUrl ( id . trim ()) as any
2026-03-04 10:14:45 +08:00
imageIdCache . value [ id ] = response
}
2026-03-10 23:23:15 +08:00
urls . push ( imageIdCache . value [ id ] ! )
2026-03-04 10:14:45 +08:00
} catch ( error ) {
console . error ( '获取签名链接失败:' , error )
urls . push ( DEFAULT_SHOP_IMAGE )
}
}
}
2026-03-10 23:23:15 +08:00
if ( shop . id !== undefined ) {
2026-03-27 14:55:41 +08:00
shopBannerUrls . value [ String ( shop . id )] = urls
2026-03-10 23:23:15 +08:00
}
2026-03-04 10:14:45 +08:00
} else {
2026-03-10 23:23:15 +08:00
if ( shop . id !== undefined ) {
2026-03-27 14:55:41 +08:00
shopBannerUrls . value [ String ( shop . id )] = []
2026-03-10 23:23:15 +08:00
}
2026-02-26 14:20:35 +08:00
}
}
}
2026-05-18 09:46:11 +08:00
/** getShopImages is a local helper used by this page script. */
2026-03-02 10:13:20 +08:00
const getShopImages = ( shop : Shop | Record < string , any >) : string [] => {
const shopId = 'id' in shop ? shop . id : ( shop as any ). id
2026-03-10 23:23:15 +08:00
if ( shopId !== undefined ) {
2026-03-27 14:55:41 +08:00
return shopImageUrls . value [ String ( shopId )] || []
2026-03-10 23:23:15 +08:00
}
return []
2026-03-04 10:14:45 +08:00
}
2026-05-18 09:46:11 +08:00
/** getShopBannerImages is a local helper used by this page script. */
2026-03-04 10:14:45 +08:00
const getShopBannerImages = ( shop : Shop | Record < string , any >) : string [] => {
const shopId = 'id' in shop ? shop . id : ( shop as any ). id
2026-03-10 23:23:15 +08:00
if ( shopId !== undefined ) {
2026-03-27 14:55:41 +08:00
return shopBannerUrls . value [ String ( shopId )] || []
2026-03-10 23:23:15 +08:00
}
return []
2026-02-26 14:20:35 +08:00
}
2026-05-18 09:46:11 +08:00
/** formatAuthorizationExpireTime is a local helper used by this page script. */
const formatAuthorizationExpireTime = ( value ?: string ) => {
if ( ! value ) {
return '长期有效'
}
return value . replace ( 'T' , ' ' ). slice ( 0 , 16 )
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: formatLocation supports ShopsView.vue by holding or executing the format location page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const formatLocation = ( shop ?: Partial < Shop > | Record < string , any >) => {
const locationName = shop ? . address || shop ? . shopName || ''
if ( ! locationName ) return '未设置地图位置'
return locationName || '未设置地图位置'
2026-05-18 09:46:11 +08:00
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: buildTencentLocationPickerUrl supports ShopsView.vue by holding or executing the build tencent location picker url page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const buildTencentLocationPickerUrl = ( options : { latitude ?: string | number ; longitude ?: string | number } = {}) => {
const params = new URLSearchParams ({
search : '1' ,
type : '1' ,
key : mapPickerKey . value ,
referer : 'yuminail' ,
keyword : formState . address || formState . shopName || ''
})
const latitude = options . latitude || formState . latitude
const longitude = options . longitude || formState . longitude
if ( latitude && longitude ) {
params . set ( 'coord' , ` ${ latitude } , ${ longitude } ` )
}
return `https://apis.map.qq.com/tools/locpicker? ${ params . toString () } `
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: buildAmapLocationPickerUrl supports ShopsView.vue by holding or executing the build amap location picker url page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const buildAmapLocationPickerUrl = ( options : { latitude ?: string | number ; longitude ?: string | number } = {}) => {
const params = new URLSearchParams ({
key : mapPickerKey . value ,
keywords : formState . address || formState . shopName || '' ,
zoom : '16'
})
const latitude = options . latitude || formState . latitude
const longitude = options . longitude || formState . longitude
if ( latitude && longitude ) {
params . set ( 'center' , ` ${ longitude } , ${ latitude } ` )
}
return `https://m.amap.com/picker/? ${ params . toString () } `
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: buildMapLocationPickerUrl supports ShopsView.vue by holding or executing the build map location picker url page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const buildMapLocationPickerUrl = ( options : { latitude ?: string | number ; longitude ?: string | number } = {}) => {
return mapPickerProvider . value === 'AMAP'
? buildAmapLocationPickerUrl ( options )
: buildTencentLocationPickerUrl ( options )
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: closeTencentLocationPicker supports ShopsView.vue by holding or executing the close tencent location picker page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const closeTencentLocationPicker = () => {
mapPickerVisible . value = false
window . removeEventListener ( 'message' , handleMapLocationMessage )
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: closeMapLocationPicker supports ShopsView.vue by holding or executing the close map location picker page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const closeMapLocationPicker = closeTencentLocationPicker
2026-05-23 18:44:57 +08:00
/**
* Purpose: applyTencentLocation supports ShopsView.vue by holding or executing the apply tencent location page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const applyTencentLocation = ( data : any ) => {
const location = data . loclatlng || data . latlng || data . location
if ( ! location ) return
formState . latitude = String ( location . lat || location . latitude || '' )
formState . longitude = String ( location . lng || location . longitude || '' )
formState . mapProvider = mapPickerProvider . value
const placeName = data . poiname || data . name || data . title || ''
const placeAddress = data . poiaddress || data . addr || data . address || ''
if ( placeName && placeAddress ) {
formState . address = ` ${ placeName } - ${ placeAddress } `
} else if ( placeAddress || placeName ) {
formState . address = placeAddress || placeName
}
if ( placeName && ! formState . shopName ) {
formState . shopName = placeName
}
message . success ( `已选择: ${ placeName || placeAddress || '地图位置' } ` )
closeTencentLocationPicker ()
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: applyAmapLocation supports ShopsView.vue by holding or executing the apply amap location page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const applyAmapLocation = ( data : any ) => {
const rawLocation = data . location || data . lnglat || data . position
let longitude = ''
let latitude = ''
if ( typeof rawLocation === 'string' ) {
const [ lng , lat ] = rawLocation . split ( ',' ). map ( item => item . trim ())
longitude = lng || ''
latitude = lat || ''
} else if ( rawLocation && typeof rawLocation === 'object' ) {
longitude = String ( rawLocation . lng || rawLocation . longitude || rawLocation . lon || rawLocation . x || '' )
latitude = String ( rawLocation . lat || rawLocation . latitude || rawLocation . y || '' )
}
if ( ! longitude || ! latitude ) return
formState . latitude = latitude
formState . longitude = longitude
formState . mapProvider = 'AMAP'
const placeName = data . name || data . poiname || data . title || ''
const placeAddress = data . address || data . poiaddress || data . addr || ''
if ( placeName && placeAddress ) {
formState . address = ` ${ placeName } - ${ placeAddress } `
} else if ( placeAddress || placeName ) {
formState . address = placeAddress || placeName
}
if ( placeName && ! formState . shopName ) {
formState . shopName = placeName
}
message . success ( `已选择: ${ placeName || placeAddress || '地图位置' } ` )
closeTencentLocationPicker ()
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: handleMapLocationMessage supports ShopsView.vue by holding or executing the handle map location message page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const handleMapLocationMessage = ( event : MessageEvent ) => {
const data = event . data || {}
if ( ! data || typeof data !== 'object' ) return
if ( data . module === 'locationPicker' || data . module === 'locationPicker_v2' ) {
applyTencentLocation ( data )
return
}
if ( mapPickerProvider . value === 'AMAP' ) {
applyAmapLocation ( data )
}
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: openMapLocationPicker supports ShopsView.vue by holding or executing the open map location picker page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const openMapLocationPicker = async () => {
const response = await adminSystemParameterConfigApi . getMapConfig ()
const provider = response ? . provider === 'AMAP' ? 'AMAP' : 'TENCENT'
const key = provider === 'AMAP' ? ( response ? . amapWebKey || '' ) : ( response ? . tencentWebKey || '' )
2026-05-18 09:46:11 +08:00
if ( ! key ) {
2026-05-21 18:43:59 +08:00
message . warning ( provider === 'AMAP'
? '请先在参数管理中配置高德 Web Key'
: '请先在参数管理中配置腾讯 Web Key' )
2026-05-18 09:46:11 +08:00
return
}
2026-05-21 18:43:59 +08:00
mapPickerProvider . value = provider
mapPickerKey . value = key
mapPickerUrl . value = buildMapLocationPickerUrl ()
mapPickerVisible . value = true
window . removeEventListener ( 'message' , handleMapLocationMessage )
window . addEventListener ( 'message' , handleMapLocationMessage )
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: handleMapPickerFrameLoad supports ShopsView.vue by holding or executing the handle map picker frame load page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const handleMapPickerFrameLoad = () => {
// 高德/腾讯选点页均通过 postMessage 回传结果,此处保留钩子便于后续接入加载态。
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: useCurrentLocation supports ShopsView.vue by holding or executing the use current location page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const useCurrentLocation = () => {
if ( ! navigator . geolocation ) {
message . warning ( '当前浏览器不支持定位' )
return
2026-05-18 09:46:11 +08:00
}
2026-05-21 18:43:59 +08:00
if ( ! mapPickerKey . value ) {
message . warning ( '请先打开地图选点' )
return
}
locating . value = true
navigator . geolocation . getCurrentPosition (
position => {
const accuracy = Number ( position . coords . accuracy )
if ( Number . isFinite ( accuracy ) && accuracy > 1000 ) {
locating . value = false
message . warning ( `当前位置误差约 ${ Math . round ( accuracy ) } 米,定位不够准确,请直接在地图中搜索或点选店铺位置` )
return
}
const latitude = position . coords . latitude . toFixed ( 6 )
const longitude = position . coords . longitude . toFixed ( 6 )
mapPickerUrl . value = buildMapLocationPickerUrl ({ latitude , longitude })
locating . value = false
const accuracyText = Number . isFinite ( accuracy ) ? `,当前位置约有 ${ Math . round ( accuracy ) } 米误差` : ''
message . info ( `已定位到当前位置附近 ${ accuracyText } ,请在地图中确认后保存` )
},
() => {
locating . value = false
message . error ( '获取当前位置失败,请检查浏览器定位权限' )
},
{ enableHighAccuracy : true , timeout : 10000 , maximumAge : 60000 }
)
2026-05-18 09:46:11 +08:00
}
/** fetchShopList is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-02-25 10:37:16 +08:00
const fetchShopList = async () => {
loading . value = true
try {
2026-02-25 16:50:32 +08:00
const currentUser = getCurrentUserInfo ()
const params : any = {
2026-02-25 10:37:16 +08:00
page : pagination . current ,
size : pagination . pageSize ,
keyword : searchText . value
2026-02-25 16:50:32 +08:00
}
if ( currentUser && currentUser . type !== 4 && currentUser . shopId ) {
params . shopId = currentUser . shopId
}
2026-03-02 10:13:20 +08:00
const response = await adminShopApi . listShops ( params )
const res = typeof response === 'object' && 'list' in response ? response : ( response as any ). data
2026-02-25 10:37:16 +08:00
shopList . value = res . list || []
pagination . total = res . total || 0
2026-02-26 14:20:35 +08:00
// 预加载所有图片签名链接
await loadImageUrls ( res . list || [])
2026-02-25 10:37:16 +08:00
} catch ( error ) {
message . error ( '获取店铺列表失败' )
} finally {
loading . value = false
}
}
2026-05-18 09:46:11 +08:00
/** handleSearch is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-05-13 12:43:01 +08:00
const handleSearch = async () => {
2026-02-25 10:37:16 +08:00
pagination . current = 1
2026-05-13 12:43:01 +08:00
await runWithGlobalLoading (() => fetchShopList ())
2026-02-25 10:37:16 +08:00
}
2026-05-18 09:46:11 +08:00
/** handleTableChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-05-13 12:43:01 +08:00
const handleTableChange = async ( pag : any ) => {
2026-02-25 10:37:16 +08:00
pagination . current = pag . current
pagination . pageSize = pag . pageSize
2026-05-13 12:43:01 +08:00
await runWithGlobalLoading (() => fetchShopList ())
2026-02-25 10:37:16 +08:00
}
2026-05-18 09:46:11 +08:00
/** beforeUpload is a local helper used by this page script. */
2026-02-26 14:20:35 +08:00
const beforeUpload = ( file : File ) => {
const isImage = file . type . startsWith ( 'image/' )
if ( ! isImage ) {
message . error ( '只能上传图片文件!' )
}
const isLt2M = file . size / 1024 / 1024 < 2
if ( ! isLt2M ) {
message . error ( '图片大小不能超过 2MB!' )
}
return isImage && isLt2M
}
2026-03-27 15:04:58 +08:00
// Banner 与门店环境图分开维护上传任务,便于表单回显和删除时分别同步 fileId 列表。
2026-05-18 09:46:11 +08:00
/** handleUploadBanner is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-04 10:14:45 +08:00
const handleUploadBanner = async ( options : any ) => {
2026-03-26 11:41:38 +08:00
const { file , onSuccess , onError , onProgress } = options
const taskKey = `banner: ${ String ( file . uid ) } `
const task = createChunkUploadTask ({
file : file as File ,
scene : 'admin-shop-banner' ,
api : {
initUpload : adminFileApi . initChunkUpload ,
uploadChunk : adminFileApi . uploadChunk ,
completeUpload : adminFileApi . completeChunkUpload ,
cancelUpload : adminFileApi . cancelChunkUpload
},
onProgress : ( percent ) => {
onProgress ? .({ percent })
}
})
uploadTaskMap . set ( taskKey , task )
activeUploadCount . value += 1
2026-03-04 10:14:45 +08:00
try {
2026-03-26 11:41:38 +08:00
const { response } = await task . promise
const fileId = String (( response as any ). id )
syncUploadedBannerIds ([... uploadedBannerIds . value , fileId ])
onSuccess ? .({ id : fileId , fileId })
2026-03-04 10:14:45 +08:00
message . success ( 'Banner上传成功' )
} catch ( error ) {
2026-03-26 11:41:38 +08:00
const errorMessage = ( error as Error ) ? . message || 'Banner上传失败'
if ( errorMessage !== '上传已取消' && errorMessage !== 'canceled' ) {
console . error ( 'Banner上传失败:' , error )
message . error ( errorMessage )
onError ? .( error )
}
} finally {
uploadTaskMap . delete ( taskKey )
activeUploadCount . value = Math . max ( 0 , activeUploadCount . value - 1 )
2026-03-04 10:14:45 +08:00
}
}
2026-05-18 09:46:11 +08:00
/** handleBannerPreview is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-04 10:14:45 +08:00
const handleBannerPreview = async ( file : any ) => {
try {
2026-03-26 11:41:38 +08:00
const cachedPreviewUrl = getPreviewUrlFromFile ( file )
if ( cachedPreviewUrl ) {
bannerPreviewImage . value = cachedPreviewUrl
bannerPreviewVisible . value = true
return
2026-03-04 10:14:45 +08:00
}
2026-03-26 11:41:38 +08:00
const fileId = resolveUploadedFileId ( file )
if ( ! fileId ) {
throw new Error ( '未找到图片文件标识' )
}
if ( ! imageIdCache . value [ fileId ]) {
2026-03-27 14:55:41 +08:00
const response = await adminFileApi . getSignedUrl ( fileId ) as any
2026-03-26 11:41:38 +08:00
imageIdCache . value [ fileId ] = response
}
bannerPreviewImage . value = imageIdCache . value [ fileId ] || ''
2026-03-04 10:14:45 +08:00
bannerPreviewVisible . value = true
} catch ( error ) {
console . error ( '获取预览链接失败:' , error )
2026-03-26 11:41:38 +08:00
message . error (( error as Error ) ? . message || '获取预览链接失败' )
2026-03-04 10:14:45 +08:00
}
}
2026-05-18 09:46:11 +08:00
/** handleBannerRemove is a local helper used by this page script. */
2026-03-04 10:14:45 +08:00
const handleBannerRemove = ( file : any ) => {
2026-03-26 11:41:38 +08:00
const task = uploadTaskMap . get ( `banner: ${ String ( file . uid ) } ` )
if ( task ) {
task . cancel ()
return true
2026-03-04 10:14:45 +08:00
}
2026-03-26 11:41:38 +08:00
const fileId = resolveUploadedFileId ( file )
if ( fileId ) {
syncUploadedBannerIds ( uploadedBannerIds . value . filter ( id => id !== fileId ))
}
return true
2026-03-04 10:14:45 +08:00
}
2026-03-27 15:04:58 +08:00
// 店铺环境图与 Banner 走同一套分片上传协议,但写入不同业务字段。
2026-05-18 09:46:11 +08:00
/** handleUploadImage is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-02-26 14:20:35 +08:00
const handleUploadImage = async ( options : any ) => {
2026-03-26 11:41:38 +08:00
const { file , onSuccess , onError , onProgress } = options
const taskKey = `image: ${ String ( file . uid ) } `
const task = createChunkUploadTask ({
file : file as File ,
scene : 'admin-shop-image' ,
api : {
initUpload : adminFileApi . initChunkUpload ,
uploadChunk : adminFileApi . uploadChunk ,
completeUpload : adminFileApi . completeChunkUpload ,
cancelUpload : adminFileApi . cancelChunkUpload
},
onProgress : ( percent ) => {
onProgress ? .({ percent })
}
})
uploadTaskMap . set ( taskKey , task )
activeUploadCount . value += 1
2026-02-26 14:20:35 +08:00
try {
2026-03-26 11:41:38 +08:00
const { response } = await task . promise
const fileId = String (( response as any ). id )
syncUploadedFileIds ([... uploadedFileIds . value , fileId ])
onSuccess ? .({ id : fileId , fileId })
2026-02-26 14:20:35 +08:00
message . success ( '图片上传成功' )
} catch ( error ) {
2026-03-26 11:41:38 +08:00
const errorMessage = ( error as Error ) ? . message || '图片上传失败'
if ( errorMessage !== '上传已取消' && errorMessage !== 'canceled' ) {
console . error ( '图片上传失败:' , error )
message . error ( errorMessage )
onError ? .( error )
}
} finally {
uploadTaskMap . delete ( taskKey )
activeUploadCount . value = Math . max ( 0 , activeUploadCount . value - 1 )
2026-02-26 14:20:35 +08:00
}
}
2026-03-27 15:04:58 +08:00
// 编辑态下 Upload 里的文件可能只剩 fileId,所以预览时需要兼容本地 URL 与远端签名地址两种来源。
2026-05-18 09:46:11 +08:00
/** handlePreview is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-02-26 14:20:35 +08:00
const handlePreview = async ( file : any ) => {
try {
2026-03-26 11:41:38 +08:00
const cachedPreviewUrl = getPreviewUrlFromFile ( file )
if ( cachedPreviewUrl ) {
previewImage . value = cachedPreviewUrl
previewVisible . value = true
return
2026-02-26 14:20:35 +08:00
}
2026-03-26 11:41:38 +08:00
const fileId = resolveUploadedFileId ( file )
if ( ! fileId ) {
throw new Error ( '未找到图片文件标识' )
}
if ( ! imageIdCache . value [ fileId ]) {
2026-03-27 14:55:41 +08:00
const response = await adminFileApi . getSignedUrl ( fileId ) as any
2026-03-26 11:41:38 +08:00
imageIdCache . value [ fileId ] = response
}
previewImage . value = imageIdCache . value [ fileId ] || ''
2026-02-26 14:20:35 +08:00
previewVisible . value = true
} catch ( error ) {
console . error ( '获取预览链接失败:' , error )
2026-03-26 11:41:38 +08:00
message . error (( error as Error ) ? . message || '获取预览链接失败' )
2026-02-26 14:20:35 +08:00
}
}
2026-05-18 09:46:11 +08:00
/** handleRemove is a local helper used by this page script. */
2026-02-26 14:20:35 +08:00
const handleRemove = ( file : any ) => {
2026-03-26 11:41:38 +08:00
const task = uploadTaskMap . get ( `image: ${ String ( file . uid ) } ` )
if ( task ) {
task . cancel ()
return true
2026-02-26 14:20:35 +08:00
}
2026-03-26 11:41:38 +08:00
const fileId = resolveUploadedFileId ( file )
if ( fileId ) {
syncUploadedFileIds ( uploadedFileIds . value . filter ( id => id !== fileId ))
}
return true
2026-02-26 14:20:35 +08:00
}
2026-05-21 18:43:59 +08:00
/** handleUploadThemeBackground is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleUploadThemeBackground = async ( options : any ) => {
const { file , onSuccess , onError , onProgress } = options
const taskKey = `theme-bg: ${ String ( file . uid ) } `
const task = createChunkUploadTask ({
file : file as File ,
scene : 'admin-shop-theme-background' ,
api : {
initUpload : adminFileApi . initChunkUpload ,
uploadChunk : adminFileApi . uploadChunk ,
completeUpload : adminFileApi . completeChunkUpload ,
cancelUpload : adminFileApi . cancelChunkUpload
},
onProgress : ( percent ) => {
onProgress ? .({ percent })
}
})
uploadTaskMap . set ( taskKey , task )
activeUploadCount . value += 1
try {
const { response } = await task . promise
const fileId = String (( response as any ). id )
syncUploadedThemeBackgroundId ( fileId )
onSuccess ? .({ id : fileId , fileId })
message . success ( '背景图上传成功' )
} catch ( error ) {
const errorMessage = ( error as Error ) ? . message || '背景图上传失败'
if ( errorMessage !== '上传已取消' && errorMessage !== 'canceled' ) {
console . error ( '背景图上传失败:' , error )
message . error ( errorMessage )
onError ? .( error )
}
} finally {
uploadTaskMap . delete ( taskKey )
activeUploadCount . value = Math . max ( 0 , activeUploadCount . value - 1 )
}
}
/** handleThemeBackgroundPreview is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleThemeBackgroundPreview = async ( file : any ) => {
try {
const cachedPreviewUrl = getPreviewUrlFromFile ( file )
if ( cachedPreviewUrl ) {
bannerPreviewImage . value = cachedPreviewUrl
bannerPreviewVisible . value = true
return
}
const fileId = resolveUploadedFileId ( file )
if ( ! fileId ) {
throw new Error ( '未找到背景图文件标识' )
}
if ( ! imageIdCache . value [ fileId ]) {
const response = await adminFileApi . getSignedUrl ( fileId ) as any
imageIdCache . value [ fileId ] = response
}
bannerPreviewImage . value = imageIdCache . value [ fileId ] || ''
bannerPreviewVisible . value = true
} catch ( error ) {
console . error ( '获取背景图预览链接失败:' , error )
message . error (( error as Error ) ? . message || '获取背景图预览链接失败' )
}
}
/** handleThemeBackgroundRemove is a local helper used by this page script. */
const handleThemeBackgroundRemove = ( file : any ) => {
const task = uploadTaskMap . get ( `theme-bg: ${ String ( file . uid ) } ` )
if ( task ) {
task . cancel ()
return true
}
const fileId = resolveUploadedFileId ( file )
if ( fileId ) {
syncUploadedThemeBackgroundId ( '' )
}
return true
}
2026-05-18 09:46:11 +08:00
/** syncBusinessHoursValue is a local helper used by this page script. */
2026-03-21 13:16:39 +08:00
const syncBusinessHoursValue = () => {
formState . businessHours = businessStartTime . value && businessEndTime . value
? ` ${ businessStartTime . value } - ${ businessEndTime . value } `
: ''
}
2026-05-18 09:46:11 +08:00
/** setBusinessHoursValue is a local helper used by this page script. */
2026-03-21 13:16:39 +08:00
const setBusinessHoursValue = ( value ?: string ) => {
const matched = ( value || '' ). match ( /(\d{2}:\d{2})\s*-\s*(\d{2}:\d{2})/ )
businessStartTime . value = matched ? .[ 1 ] || ''
businessEndTime . value = matched ? .[ 2 ] || ''
syncBusinessHoursValue ()
}
2026-05-18 09:46:11 +08:00
/** handleBusinessHoursChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-21 13:16:39 +08:00
const handleBusinessHoursChange = async () => {
syncBusinessHoursValue ()
await formRef . value ? . validateFields ? .([ 'businessHours' ]). catch (() => undefined )
}
2026-05-18 09:46:11 +08:00
/** showAddModal is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-26 12:04:02 +08:00
const showAddModal = async () => {
2026-02-25 10:37:16 +08:00
isEdit . value = false
2026-03-26 12:04:02 +08:00
currentShop . value = null
2026-02-25 10:37:16 +08:00
Object . assign ( formState , {
2026-02-25 14:44:50 +08:00
shopName : '' ,
2026-02-25 10:37:16 +08:00
description : '' ,
address : '' ,
2026-05-18 09:46:11 +08:00
mapProvider : 'TENCENT' ,
longitude : '' ,
latitude : '' ,
2026-02-25 10:37:16 +08:00
businessHours : '' ,
2026-03-26 10:28:28 +08:00
status : 1 ,
2026-05-21 18:43:59 +08:00
authorizationStartDate : '' ,
authorizationDays : undefined ,
2026-05-18 09:46:11 +08:00
authorizationExpireTime : '' ,
2026-03-04 10:14:45 +08:00
coverImageFileId : '' ,
2026-05-21 18:43:59 +08:00
imageFileIds : '' ,
themePrimaryColor : '' ,
themeSecondaryColor : '' ,
themeAccentColor : '' ,
themePageBgColor : '' ,
themeCardBgColor : '' ,
themeBackgroundImageFileId : ''
2026-02-25 10:37:16 +08:00
})
2026-03-21 13:16:39 +08:00
setBusinessHoursValue ( '' )
2026-03-04 10:14:45 +08:00
bannerFileList . value = []
2026-03-26 11:41:38 +08:00
syncUploadedBannerIds ([])
2026-02-26 14:20:35 +08:00
imageFileList . value = []
2026-03-26 11:41:38 +08:00
syncUploadedFileIds ([])
2026-05-21 18:43:59 +08:00
themeBackgroundFileList . value = []
syncUploadedThemeBackgroundId ( '' )
2026-03-26 12:04:02 +08:00
await restoreDraft ()
2026-02-25 10:37:16 +08:00
modalVisible . value = true
}
2026-05-18 09:46:11 +08:00
/** showEditModal is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-02 10:13:20 +08:00
const showEditModal = async ( record : Shop | Record < string , any >) => {
2026-02-25 10:37:16 +08:00
isEdit . value = true
2026-03-02 10:13:20 +08:00
currentShop . value = record as Shop
2026-02-25 10:37:16 +08:00
Object . assign ( formState , {
2026-03-02 10:13:20 +08:00
shopName : 'shopName' in record ? record . shopName : ( record as any ). shopName ,
description : 'description' in record ? record . description : ( record as any ). description ,
address : 'address' in record ? record . address : ( record as any ). address ,
2026-05-18 09:46:11 +08:00
mapProvider : 'TENCENT' ,
longitude : 'longitude' in record ? record . longitude : ( record as any ). longitude ,
latitude : 'latitude' in record ? record . latitude : ( record as any ). latitude ,
2026-03-02 10:13:20 +08:00
businessHours : 'businessHours' in record ? record . businessHours : ( record as any ). businessHours ,
2026-03-26 10:28:28 +08:00
status : 'status' in record ? ( record . status ?? 1 ) : (( record as any ). status ?? 1 ),
2026-05-21 18:43:59 +08:00
authorizationStartDate : 'authorizationStartDate' in record ? record . authorizationStartDate : ( record as any ). authorizationStartDate ,
authorizationDays : 'authorizationDays' in record ? record . authorizationDays : ( record as any ). authorizationDays ,
2026-05-18 09:46:11 +08:00
authorizationExpireTime : 'authorizationExpireTime' in record ? record . authorizationExpireTime : ( record as any ). authorizationExpireTime ,
2026-03-04 10:14:45 +08:00
coverImageFileId : 'coverImageFileId' in record ? record . coverImageFileId : ( record as any ). coverImageFileId ,
2026-05-21 18:43:59 +08:00
imageFileIds : 'imageFileIds' in record ? record . imageFileIds : ( record as any ). imageFileIds ,
themePrimaryColor : 'themePrimaryColor' in record ? record . themePrimaryColor : ( record as any ). themePrimaryColor ,
themeSecondaryColor : 'themeSecondaryColor' in record ? record . themeSecondaryColor : ( record as any ). themeSecondaryColor ,
themeAccentColor : 'themeAccentColor' in record ? record . themeAccentColor : ( record as any ). themeAccentColor ,
themePageBgColor : 'themePageBgColor' in record ? record . themePageBgColor : ( record as any ). themePageBgColor ,
themeCardBgColor : 'themeCardBgColor' in record ? record . themeCardBgColor : ( record as any ). themeCardBgColor ,
themeBackgroundImageFileId : 'themeBackgroundImageFileId' in record ? record . themeBackgroundImageFileId : ( record as any ). themeBackgroundImageFileId
2026-02-25 10:37:16 +08:00
})
2026-03-21 13:16:39 +08:00
setBusinessHoursValue ( formState . businessHours )
2026-02-26 14:20:35 +08:00
2026-03-04 10:14:45 +08:00
// 加载Banner图片
const coverImageFileId = 'coverImageFileId' in record ? record . coverImageFileId : ( record as any ). coverImageFileId
if ( coverImageFileId ) {
2026-03-26 11:41:38 +08:00
const ids = coverImageFileId . split ( ',' ). filter (( id : string ) => id )
syncUploadedBannerIds ( ids )
2026-03-26 12:04:02 +08:00
bannerFileList . value = await buildShopUploadFileList ( ids , 'Banner' )
2026-03-04 10:14:45 +08:00
} else {
bannerFileList . value = []
2026-03-26 11:41:38 +08:00
syncUploadedBannerIds ([])
2026-03-04 10:14:45 +08:00
}
// 加载店铺图片
2026-03-02 10:13:20 +08:00
const imageFileIds = 'imageFileIds' in record ? record . imageFileIds : ( record as any ). imageFileIds
if ( imageFileIds ) {
2026-03-26 11:41:38 +08:00
const ids = imageFileIds . split ( ',' ). filter (( id : string ) => id )
syncUploadedFileIds ( ids )
2026-03-26 12:04:02 +08:00
imageFileList . value = await buildShopUploadFileList ( ids , '图片' )
2026-02-26 14:20:35 +08:00
} else {
imageFileList . value = []
2026-03-26 11:41:38 +08:00
syncUploadedFileIds ([])
2026-02-26 14:20:35 +08:00
}
2026-05-21 18:43:59 +08:00
const themeBackgroundImageFileId = 'themeBackgroundImageFileId' in record
? record . themeBackgroundImageFileId
: ( record as any ). themeBackgroundImageFileId
if ( themeBackgroundImageFileId ) {
const id = String ( themeBackgroundImageFileId )
syncUploadedThemeBackgroundId ( id )
themeBackgroundFileList . value = await buildShopUploadFileList ([ id ], '背景图' )
} else {
themeBackgroundFileList . value = []
syncUploadedThemeBackgroundId ( '' )
}
2026-02-26 14:20:35 +08:00
2026-03-26 12:04:02 +08:00
await restoreDraft ()
2026-02-25 10:37:16 +08:00
modalVisible . value = true
}
2026-05-18 09:46:11 +08:00
/** showViewModal is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-02 10:13:20 +08:00
const showViewModal = async ( record : Shop | Record < string , any >) => {
2026-02-28 14:32:28 +08:00
Object . assign ( viewFormState , {
2026-03-02 10:13:20 +08:00
shopName : 'shopName' in record ? record . shopName : ( record as any ). shopName ,
description : 'description' in record ? record . description : ( record as any ). description ,
address : 'address' in record ? record . address : ( record as any ). address ,
2026-05-18 09:46:11 +08:00
mapProvider : 'TENCENT' ,
longitude : 'longitude' in record ? record . longitude : ( record as any ). longitude ,
latitude : 'latitude' in record ? record . latitude : ( record as any ). latitude ,
2026-03-02 10:13:20 +08:00
businessHours : 'businessHours' in record ? record . businessHours : ( record as any ). businessHours ,
2026-03-26 10:28:28 +08:00
status : 'status' in record ? ( record . status ?? 1 ) : (( record as any ). status ?? 1 ),
2026-05-21 18:43:59 +08:00
authorizationStartDate : 'authorizationStartDate' in record ? record . authorizationStartDate : ( record as any ). authorizationStartDate ,
authorizationDays : 'authorizationDays' in record ? record . authorizationDays : ( record as any ). authorizationDays ,
2026-05-18 09:46:11 +08:00
authorizationExpireTime : 'authorizationExpireTime' in record ? record . authorizationExpireTime : ( record as any ). authorizationExpireTime ,
authorizationStatusText : 'authorizationStatusText' in record ? record . authorizationStatusText : ( record as any ). authorizationStatusText ,
2026-03-04 10:14:45 +08:00
coverImageFileId : 'coverImageFileId' in record ? record . coverImageFileId : ( record as any ). coverImageFileId ,
2026-05-21 18:43:59 +08:00
imageFileIds : 'imageFileIds' in record ? record . imageFileIds : ( record as any ). imageFileIds ,
themePrimaryColor : 'themePrimaryColor' in record ? record . themePrimaryColor : ( record as any ). themePrimaryColor ,
themeSecondaryColor : 'themeSecondaryColor' in record ? record . themeSecondaryColor : ( record as any ). themeSecondaryColor ,
themeAccentColor : 'themeAccentColor' in record ? record . themeAccentColor : ( record as any ). themeAccentColor ,
themePageBgColor : 'themePageBgColor' in record ? record . themePageBgColor : ( record as any ). themePageBgColor ,
themeCardBgColor : 'themeCardBgColor' in record ? record . themeCardBgColor : ( record as any ). themeCardBgColor ,
themeBackgroundImageFileId : 'themeBackgroundImageFileId' in record ? record . themeBackgroundImageFileId : ( record as any ). themeBackgroundImageFileId
2026-02-28 14:32:28 +08:00
})
2026-03-04 10:14:45 +08:00
// 加载Banner图片URL
const coverImageFileId = 'coverImageFileId' in record ? record . coverImageFileId : ( record as any ). coverImageFileId
if ( coverImageFileId ) {
2026-03-26 11:41:38 +08:00
const ids = coverImageFileId . split ( ',' ). filter (( id : string ) => id )
2026-03-04 10:14:45 +08:00
const urls : string [] = []
for ( const id of ids ) {
try {
// 检查缓存
if ( ! imageIdCache . value [ id ]) {
2026-03-27 14:55:41 +08:00
const response = await adminFileApi . getSignedUrl ( id . trim ()) as any
2026-03-04 10:14:45 +08:00
imageIdCache . value [ id ] = response
}
2026-03-10 23:23:15 +08:00
urls . push ( imageIdCache . value [ id ] ! )
2026-03-04 10:14:45 +08:00
} catch ( error ) {
console . error ( '获取签名链接失败:' , error )
urls . push ( DEFAULT_SHOP_IMAGE )
}
}
viewBannerUrls . value = urls
} else {
viewBannerUrls . value = []
}
// 加载店铺图片URL
2026-03-02 10:13:20 +08:00
const imageFileIds = 'imageFileIds' in record ? record . imageFileIds : ( record as any ). imageFileIds
if ( imageFileIds ) {
2026-03-26 11:41:38 +08:00
const ids = imageFileIds . split ( ',' ). filter (( id : string ) => id )
2026-02-28 14:32:28 +08:00
const urls : string [] = []
for ( const id of ids ) {
try {
// 检查缓存
if ( ! imageIdCache . value [ id ]) {
2026-03-27 14:55:41 +08:00
const response = await adminFileApi . getSignedUrl ( id . trim ()) as any
2026-03-02 10:13:20 +08:00
imageIdCache . value [ id ] = response
2026-02-28 14:32:28 +08:00
}
2026-03-10 23:23:15 +08:00
urls . push ( imageIdCache . value [ id ] ! )
2026-02-28 14:32:28 +08:00
} catch ( error ) {
console . error ( '获取签名链接失败:' , error )
urls . push ( DEFAULT_SHOP_IMAGE )
}
}
viewImageUrls . value = urls
} else {
2026-03-04 10:14:45 +08:00
viewImageUrls . value = []
2026-02-28 14:32:28 +08:00
}
viewModalVisible . value = true
}
2026-05-18 09:46:11 +08:00
/** handleViewModalCancel is a local helper used by this page script. */
2026-02-28 14:32:28 +08:00
const handleViewModalCancel = () => {
viewModalVisible . value = false
viewImageUrls . value = []
2026-03-04 10:14:45 +08:00
viewBannerUrls . value = []
2026-02-28 14:32:28 +08:00
}
2026-05-18 09:46:11 +08:00
/** cancelAllPendingUploads is a local helper used by this page script. */
2026-03-26 11:41:38 +08:00
const cancelAllPendingUploads = () => {
uploadTaskMap . forEach ( task => task . cancel ())
}
2026-05-18 09:46:11 +08:00
/** getDraftKey is a local helper used by this page script. */
2026-03-26 12:04:02 +08:00
const getDraftKey = () => buildDraftStorageKey ( 'admin-shops' , isEdit . value ? 'edit' : 'create' , currentShop . value ? . id ?? 'new' )
2026-05-18 09:46:11 +08:00
/** buildDraftPayload is a local helper used by this page script. */
2026-03-26 12:04:02 +08:00
const buildDraftPayload = () => ({
formState : {
shopName : formState . shopName ,
description : formState . description ,
address : formState . address ,
2026-05-18 09:46:11 +08:00
mapProvider : 'TENCENT' ,
longitude : formState . longitude ,
latitude : formState . latitude ,
2026-03-26 12:04:02 +08:00
businessHours : formState . businessHours ,
status : formState . status ,
2026-05-21 18:43:59 +08:00
authorizationStartDate : formState . authorizationStartDate ,
authorizationDays : formState . authorizationDays ,
2026-05-18 09:46:11 +08:00
authorizationExpireTime : formState . authorizationExpireTime ,
2026-03-26 12:04:02 +08:00
coverImageFileId : formState . coverImageFileId ,
2026-05-21 18:43:59 +08:00
imageFileIds : formState . imageFileIds ,
themePrimaryColor : formState . themePrimaryColor ,
themeSecondaryColor : formState . themeSecondaryColor ,
themeAccentColor : formState . themeAccentColor ,
themePageBgColor : formState . themePageBgColor ,
themeCardBgColor : formState . themeCardBgColor ,
themeBackgroundImageFileId : formState . themeBackgroundImageFileId
2026-03-26 12:04:02 +08:00
},
businessStartTime : businessStartTime . value ,
businessEndTime : businessEndTime . value ,
uploadedBannerIds : [... uploadedBannerIds . value ],
2026-05-21 18:43:59 +08:00
uploadedFileIds : [... uploadedFileIds . value ],
uploadedThemeBackgroundId : uploadedThemeBackgroundId . value
2026-03-26 12:04:02 +08:00
})
2026-05-18 09:46:11 +08:00
/** buildShopUploadFileList is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-26 12:04:02 +08:00
const buildShopUploadFileList = async ( ids : string [], fileNamePrefix : string ) => {
const fileList = []
for ( const [ index , id ] of ids . entries ()) {
try {
if ( ! imageIdCache . value [ id ]) {
2026-03-27 14:55:41 +08:00
const response = await adminFileApi . getSignedUrl ( id . trim ()) as any
2026-03-26 12:04:02 +08:00
imageIdCache . value [ id ] = response
}
fileList . push ({
uid : id ,
fileId : id ,
name : ` ${ fileNamePrefix }${ index + 1 } ` ,
status : 'done' ,
url : imageIdCache . value [ id ]
})
} catch ( error ) {
console . error ( '获取签名链接失败:' , error )
fileList . push ({
uid : id ,
fileId : id ,
name : ` ${ fileNamePrefix }${ index + 1 } ` ,
status : 'done' ,
url : ''
})
}
}
return fileList
}
2026-05-18 09:46:11 +08:00
/** restoreDraft is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-26 12:04:02 +08:00
const restoreDraft = async () => {
const draft = loadDraftRecord < ReturnType < typeof buildDraftPayload > > ( getDraftKey ())
if ( ! draft ) {
draftSavedAt . value = null
return
}
Object . assign ( formState , draft . payload . formState )
businessStartTime . value = draft . payload . businessStartTime || ''
businessEndTime . value = draft . payload . businessEndTime || ''
syncUploadedBannerIds ( draft . payload . uploadedBannerIds || [])
syncUploadedFileIds ( draft . payload . uploadedFileIds || [])
2026-05-21 18:43:59 +08:00
syncUploadedThemeBackgroundId ( draft . payload . uploadedThemeBackgroundId || '' )
2026-03-26 12:04:02 +08:00
bannerFileList . value = await buildShopUploadFileList ( uploadedBannerIds . value , 'Banner' )
imageFileList . value = await buildShopUploadFileList ( uploadedFileIds . value , '图片' )
2026-05-21 18:43:59 +08:00
themeBackgroundFileList . value = uploadedThemeBackgroundId . value
? await buildShopUploadFileList ([ uploadedThemeBackgroundId . value ], '背景图' )
: []
2026-03-26 12:04:02 +08:00
draftSavedAt . value = draft . savedAt
message . success ( '已恢复暂存内容' )
}
2026-05-18 09:46:11 +08:00
/** handleSaveDraft is a local helper used by this page script. */
2026-03-26 12:04:02 +08:00
const handleSaveDraft = () => {
if ( isUploadPending . value ) {
message . warning ( '图片上传完成后才能暂存' )
return
}
const draft = saveDraftRecord ( getDraftKey (), buildDraftPayload ())
draftSavedAt . value = draft . savedAt
message . success ( '已暂存到本地' )
}
2026-05-18 09:46:11 +08:00
/** handleClearDraft is a local helper used by this page script. */
2026-03-26 12:04:02 +08:00
const handleClearDraft = ( showMessage = true ) => {
clearDraftRecord ( getDraftKey ())
draftSavedAt . value = null
if ( showMessage ) {
message . success ( '已清除暂存' )
}
}
2026-05-18 09:46:11 +08:00
/** syncUploadedBannerIds is a local helper used by this page script. */
2026-03-26 11:41:38 +08:00
const syncUploadedBannerIds = ( fileIds : string []) => {
uploadedBannerIds . value = Array . from ( new Set ( fileIds . filter ( id => Boolean ( id ))))
formState . coverImageFileId = uploadedBannerIds . value . join ( ',' )
}
2026-05-18 09:46:11 +08:00
/** syncUploadedFileIds is a local helper used by this page script. */
2026-03-26 11:41:38 +08:00
const syncUploadedFileIds = ( fileIds : string []) => {
uploadedFileIds . value = Array . from ( new Set ( fileIds . filter ( id => Boolean ( id ))))
formState . imageFileIds = uploadedFileIds . value . join ( ',' )
}
2026-05-21 18:43:59 +08:00
/** syncUploadedThemeBackgroundId is a local helper used by this page script. */
const syncUploadedThemeBackgroundId = ( fileId : string ) => {
uploadedThemeBackgroundId . value = fileId || ''
formState . themeBackgroundImageFileId = uploadedThemeBackgroundId . value
if ( ! uploadedThemeBackgroundId . value ) {
themeBackgroundFileList . value = []
}
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: handleResetTheme supports ShopsView.vue by holding or executing the handle reset theme page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const handleResetTheme = () => {
Object . assign ( formState , {
themePrimaryColor : '' ,
themeSecondaryColor : '' ,
themeAccentColor : '' ,
themePageBgColor : '' ,
themeCardBgColor : '' ,
themeBackgroundImageFileId : ''
})
themeBackgroundFileList . value = []
syncUploadedThemeBackgroundId ( '' )
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: applyThemeTemplate supports ShopsView.vue by holding or executing the apply theme template page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const applyThemeTemplate = ( template : ShopThemeTemplate ) => {
Object . assign ( formState , {
themePrimaryColor : template . themePrimaryColor ,
themeSecondaryColor : template . themeSecondaryColor ,
themeAccentColor : template . themeAccentColor ,
themePageBgColor : template . themePageBgColor ,
themeCardBgColor : template . themeCardBgColor
})
message . success ( `已应用「 ${ template . name } 」配色` )
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: openSaveThemeTemplate supports ShopsView.vue by holding or executing the open save theme template page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const openSaveThemeTemplate = () => {
themeTemplateName . value = formState . shopName ? ` ${ formState . shopName } 主题` : '我的配色模板'
themeTemplateSaveVisible . value = true
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: handleCancelSaveThemeTemplate supports ShopsView.vue by holding or executing the handle cancel save theme template page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const handleCancelSaveThemeTemplate = () => {
themeTemplateSaveVisible . value = false
themeTemplateName . value = ''
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: handleConfirmSaveThemeTemplate supports ShopsView.vue by holding or executing the handle confirm save theme template page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const handleConfirmSaveThemeTemplate = () => {
const name = themeTemplateName . value . trim ()
if ( ! name ) {
message . warning ( '请输入模板名称' )
return
}
if ( PRESET_THEME_TEMPLATES . some ( template => template . name === name )) {
message . warning ( '这个名称已被预设模板占用,请换一个' )
return
}
const existedIndex = customThemeTemplates . value . findIndex ( template => template . name === name )
const template : ShopThemeTemplate = {
id : existedIndex >= 0 ? customThemeTemplates . value [ existedIndex ] ! . id : `custom- ${ Date . now () } ` ,
name ,
source : 'custom' ,
createdAt : Date . now (),
... currentThemeTemplateColors . value
}
customThemeTemplates . value = existedIndex >= 0
? customThemeTemplates . value . map (( item , index ) => index === existedIndex ? template : item )
: [ template , ... customThemeTemplates . value ]. slice ( 0 , CUSTOM_THEME_TEMPLATE_LIMIT )
persistCustomThemeTemplates ()
themeTemplateSaveVisible . value = false
themeTemplateName . value = ''
message . success ( existedIndex >= 0 ? '已更新同名配色模板' : '已保存配色模板' )
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: handleDeleteCustomThemeTemplate supports ShopsView.vue by holding or executing the handle delete custom theme template page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-21 18:43:59 +08:00
const handleDeleteCustomThemeTemplate = ( id : string ) => {
customThemeTemplates . value = customThemeTemplates . value . filter ( template => template . id !== id )
persistCustomThemeTemplates ()
message . success ( '已删除配色模板' )
}
2026-05-18 09:46:11 +08:00
/** getUploadResponse is a local helper used by this page script. */
2026-03-26 11:41:38 +08:00
const getUploadResponse = ( file : any ) => {
if ( ! file || typeof file !== 'object' ) {
return null
}
return file . response || null
}
2026-05-18 09:46:11 +08:00
/** resolveUploadedFileId is a local helper used by this page script. */
2026-03-26 11:41:38 +08:00
const resolveUploadedFileId = ( file : any ) => {
const response = getUploadResponse ( file )
const responseId = response ? . id ?? response ? . data ? . id ?? file ? . fileId
if ( responseId !== undefined && responseId !== null && responseId !== '' ) {
return String ( responseId )
}
const fileUid = String ( file ? . uid || '' )
if ( /^\d+$/ . test ( fileUid )) {
return fileUid
}
const fileUrl = String ( file ? . url || '' )
if ( /^\d+$/ . test ( fileUrl )) {
return fileUrl
}
return ''
}
2026-05-18 09:46:11 +08:00
/** getPreviewUrlFromFile is a local helper used by this page script. */
2026-03-26 11:41:38 +08:00
const getPreviewUrlFromFile = ( file : any ) => {
const fileUrl = typeof file ? . url === 'string' ? file . url : ''
if ( fileUrl && ! /^\d+$/ . test ( fileUrl )) {
return fileUrl
}
const thumbUrl = typeof file ? . thumbUrl === 'string' ? file . thumbUrl : ''
if ( thumbUrl ) {
return thumbUrl
}
return ''
}
2026-05-18 09:46:11 +08:00
/** handleModalOk is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-02-25 10:37:16 +08:00
const handleModalOk = async () => {
try {
2026-03-26 11:41:38 +08:00
if ( isUploadPending . value ) {
message . warning ( '图片上传完成前不可提交' )
return
}
2026-03-21 13:16:39 +08:00
syncBusinessHoursValue ()
2026-02-25 10:37:16 +08:00
await formRef . value ? . validate ()
modalLoading . value = true
2026-05-13 12:43:01 +08:00
await runWithGlobalLoading ( async () => {
if ( isEdit . value && currentShop . value ) {
2026-05-21 18:43:59 +08:00
await adminShopApi . updateShop ( currentShop . value . id , {
... formState ,
authorizationExpireTime : computedAuthorizationExpireTime . value
})
2026-05-13 12:43:01 +08:00
message . success ( '更新成功' )
} else {
2026-05-21 18:43:59 +08:00
await adminShopApi . createShop ({
... formState ,
authorizationExpireTime : computedAuthorizationExpireTime . value
})
2026-05-13 12:43:01 +08:00
message . success ( '创建成功' )
}
handleClearDraft ( false )
modalVisible . value = false
await fetchShopList ()
})
2026-02-25 10:37:16 +08:00
} catch ( error ) {
console . error ( error )
} finally {
modalLoading . value = false
}
}
2026-05-18 09:46:11 +08:00
/** handleModalCancel is a local helper used by this page script. */
2026-02-25 10:37:16 +08:00
const handleModalCancel = () => {
2026-03-26 11:41:38 +08:00
cancelAllPendingUploads ()
2026-02-25 10:37:16 +08:00
modalVisible . value = false
formRef . value ? . resetFields ()
2026-03-21 13:16:39 +08:00
setBusinessHoursValue ( '' )
2026-03-04 10:14:45 +08:00
bannerFileList . value = []
2026-03-26 11:41:38 +08:00
syncUploadedBannerIds ([])
2026-02-26 14:20:35 +08:00
imageFileList . value = []
2026-03-26 11:41:38 +08:00
syncUploadedFileIds ([])
2026-05-21 18:43:59 +08:00
themeBackgroundFileList . value = []
syncUploadedThemeBackgroundId ( '' )
2026-02-25 10:37:16 +08:00
}
2026-05-18 09:46:11 +08:00
/** handleStatusChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-26 10:28:28 +08:00
const handleStatusChange = async ( record : Shop | Record < string , any >, enabled : boolean ) => {
try {
2026-05-13 12:43:01 +08:00
await runWithGlobalLoading ( async () => {
const shopId = 'id' in record ? record . id : ( record as any ). id
await adminShopApi . updateShopStatus ( shopId , enabled ? 1 : 0 )
;( record as any ). status = enabled ? 1 : 0
message . success ( `店铺已 ${ enabled ? '启用' : '停用' } ` )
})
2026-03-26 10:28:28 +08:00
} catch ( error ) {
message . error ( '店铺状态更新失败' )
}
}
2026-02-26 18:44:47 +08:00
onMounted ( async () => {
2026-05-21 18:43:59 +08:00
loadCustomThemeTemplates ()
2026-02-26 18:44:47 +08:00
await loadUserPermissions ()
2026-02-25 10:37:16 +08:00
fetchShopList ()
})
</ script >
< style scoped >
. shops {
padding : 0 ;
}
2026-02-26 14:20:35 +08:00
. shop - images {
display : flex ;
align - items : center ;
flex - wrap : wrap ;
gap : 4 px ;
}
2026-05-21 18:43:59 +08:00
. map - picker - card {
display : flex ;
align - items : center ;
justify - content : space - between ;
gap : 12 px ;
padding : 10 px 12 px ;
border : 1 px solid # d9d9d9 ;
border - radius : 8 px ;
background : # fafafa ;
}
. map - picker - main {
min - width : 0 ;
flex : 1 ;
}
. map - picker - title {
color : # 1 f2937 ;
font - weight : 600 ;
overflow : hidden ;
text - overflow : ellipsis ;
white - space : nowrap ;
}
. map - picker - subtitle {
margin - top : 4 px ;
color : # 8 c8c8c ;
font - size : 12 px ;
overflow : hidden ;
text - overflow : ellipsis ;
white - space : nowrap ;
2026-05-18 09:46:11 +08:00
}
. map - picker - tip {
margin - top : 8 px ;
color : # 8 c8c8c ;
font - size : 12 px ;
line - height : 1.6 ;
}
2026-05-21 18:43:59 +08:00
. tencent - map - picker {
display : grid ;
gap : 12 px ;
}
. tencent - map - picker__toolbar {
display : flex ;
align - items : center ;
justify - content : space - between ;
gap : 16 px ;
}
. tencent - map - picker__toolbar p {
margin : 4 px 0 0 ;
color : # 8 c8c8c ;
font - size : 13 px ;
}
. tencent - map - picker__frame {
width : 100 % ;
height : 520 px ;
border : 0 ;
border - radius : 8 px ;
background : # f5f5f5 ;
}
2026-03-04 10:14:45 +08:00
. shop - banner {
display : flex ;
align - items : center ;
flex - wrap : wrap ;
gap : 4 px ;
2026-02-26 14:20:35 +08:00
}
2026-03-04 10:14:45 +08:00
. no - banner {
color : # 999 ;
font - size : 12 px ;
}
. upload - tip {
color : # 999 ;
font - size : 12 px ;
margin - bottom : 8 px ;
2026-02-26 14:20:35 +08:00
}
2026-03-21 13:16:39 +08:00
2026-03-26 11:41:38 +08:00
. upload - pending - tip {
color : # fa8c16 ;
font - size : 12 px ;
margin - top : 8 px ;
}
2026-03-21 13:16:39 +08:00
. business - hours - picker {
display : flex ;
align - items : center ;
gap : 12 px ;
width : 100 % ;
}
. business - hours - separator {
color : # 666 ;
flex : 0 0 auto ;
}
2026-05-21 18:43:59 +08:00
. theme - section {
margin : 8 px 0 18 px ;
padding : 16 px 18 px ;
border : 1 px solid # f0dce4 ;
border - radius : 8 px ;
background : # fffafb ;
}
. theme - section__header {
display : flex ;
align - items : flex - start ;
justify - content : space - between ;
gap : 16 px ;
margin - bottom : 16 px ;
}
. theme - section__title {
color : # 2 d2430 ;
font - weight : 700 ;
}
. theme - section__desc {
margin - top : 4 px ;
color : # 7 a6871 ;
font - size : 12 px ;
line - height : 1.6 ;
}
. theme - section__actions {
flex : 0 0 auto ;
}
. theme - template - panel {
margin - bottom : 16 px ;
padding : 12 px ;
border : 1 px solid # f0dce4 ;
border - radius : 8 px ;
background : # ffffff ;
}
. theme - template - panel__header {
display : flex ;
align - items : baseline ;
justify - content : space - between ;
gap : 12 px ;
margin - bottom : 12 px ;
}
. theme - template - panel__header span {
color : # 2 d2430 ;
font - weight : 700 ;
}
. theme - template - panel__header small {
color : # 8 a737d ;
line - height : 1.5 ;
}
. theme - template - list {
display : grid ;
grid - template - columns : repeat ( auto - fill , minmax ( 150 px , 1 fr ));
gap : 10 px ;
}
. theme - template - card {
position : relative ;
min - height : 92 px ;
padding : 12 px ;
border : 1 px solid # efdee5 ;
border - radius : 8 px ;
background : # fffdfd ;
cursor : pointer ;
transition : border - color .2 s ease , box - shadow .2 s ease , transform .2 s ease ;
}
. theme - template - card : hover ,
. theme - template - card : focus {
border - color : # c6597d ;
box - shadow : 0 10 px 24 px rgba ( 198 , 89 , 125 , .12 );
outline : none ;
transform : translateY ( - 1 px );
}
. theme - template - card -- active {
border - color : # c6597d ;
background : # fff7f9 ;
box - shadow : 0 0 0 2 px rgba ( 198 , 89 , 125 , .14 );
}
. theme - template - card -- custom {
padding - right : 54 px ;
}
. theme - template - card__top {
display : grid ;
gap : 4 px ;
}
. theme - template - card__top strong {
color : # 2 d2430 ;
font - size : 13 px ;
overflow : hidden ;
text - overflow : ellipsis ;
white - space : nowrap ;
}
. theme - template - card__top span {
color : # 9 a7b87 ;
font - size : 12 px ;
}
. theme - template - card__swatches {
display : flex ;
align - items : center ;
gap : 5 px ;
margin - top : 16 px ;
}
. theme - template - card__swatches span ,
. theme - template - save - preview span {
width : 18 px ;
height : 18 px ;
border : 2 px solid # ffffff ;
border - radius : 999 px ;
box - shadow : 0 0 0 1 px # ead6de ;
}
. theme - template - card__delete {
position : absolute ;
top : 9 px ;
right : 9 px ;
height : 24 px ;
padding : 0 8 px ;
border : 1 px solid # efdee5 ;
border - radius : 8 px ;
color : # 9 f4967 ;
font - size : 12 px ;
background : # fff8fa ;
cursor : pointer ;
}
. theme - template - card__delete : hover ,
. theme - template - card__delete : focus {
border - color : # c6597d ;
color : # c6597d ;
outline : none ;
}
. theme - template - save - form {
display : grid ;
gap : 8 px ;
}
. theme - template - save - form label {
color : # 2 d2430 ;
font - weight : 600 ;
}
. theme - template - save - preview {
display : flex ;
gap : 8 px ;
margin - top : 16 px ;
padding : 12 px ;
border : 1 px solid # f0dce4 ;
border - radius : 8 px ;
background : # fffafb ;
}
. theme - grid {
display : grid ;
grid - template - columns : repeat ( 2 , minmax ( 0 , 1 fr ));
gap : 0 12 px ;
}
. theme - color - field {
display : flex ;
align - items : center ;
gap : 10 px ;
}
. theme - color - picker {
width : 42 px ;
height : 34 px ;
padding : 0 ;
border : 1 px solid # efd8e0 ;
border - radius : 8 px ;
background : # fff ;
}
. theme - preview {
display : flex ;
align - items : center ;
justify - content : space - between ;
gap : 16 px ;
margin - top : 8 px ;
padding : 16 px ;
border : 1 px solid ;
border - radius : 8 px ;
}
. theme - preview strong ,
. theme - preview p {
display : block ;
margin : 4 px 0 0 ;
}
. theme - preview p {
font - size : 12 px ;
opacity : .72 ;
}
. theme - preview__eyebrow {
display : block ;
font - size : 12 px ;
font - weight : 700 ;
}
. theme - preview__button {
flex : 0 0 auto ;
padding : 9 px 16 px ;
border - radius : 999 px ;
font - weight : 700 ;
}
. theme - view - swatches {
display : flex ;
gap : 8 px ;
}
. theme - view - swatches span {
width : 28 px ;
height : 28 px ;
border : 1 px solid # efdee5 ;
border - radius : 999 px ;
}
@ media ( max - width : 768 px ) {
. theme - section__header ,
. theme - template - panel__header {
align - items : stretch ;
flex - direction : column ;
}
. theme - section__actions {
width : 100 % ;
}
. theme - grid {
grid - template - columns : 1 fr ;
}
}
2026-02-25 10:37:16 +08:00
</ style >