2795 lines
106 KiB
Vue
2795 lines
106 KiB
Vue
<template>
|
||
<div class="shops">
|
||
<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>
|
||
|
||
<a-card :bordered="false">
|
||
<template #title v-if="isMobile">
|
||
店铺列表
|
||
</template>
|
||
<template #extra>
|
||
<div class="admin-toolbar" :class="{ 'admin-toolbar--stacked': isMobile }">
|
||
<a-input-search
|
||
v-model:value="searchText"
|
||
placeholder="搜索店铺名称"
|
||
:style="isMobile ? { width: '100%' } : { width: '250px' }"
|
||
@search="handleSearch"
|
||
/>
|
||
<a-button v-if="!isMobile && hasPermission('shop:create')" type="primary" @click="showAddModal">
|
||
<template #icon>
|
||
<PlusOutlined />
|
||
</template>
|
||
新增店铺
|
||
</a-button>
|
||
</div>
|
||
</template>
|
||
|
||
<a-table
|
||
v-if="!isMobile"
|
||
:columns="columns"
|
||
:data-source="shopList"
|
||
:loading="loading"
|
||
:pagination="pagination"
|
||
:scroll="{ x: 'max-content' }"
|
||
@change="handleTableChange"
|
||
row-key="id"
|
||
>
|
||
<template #bodyCell="{ column, record }">
|
||
<template v-if="column.key === 'image'">
|
||
<div class="shop-images">
|
||
<div
|
||
v-for="(url, index) in getShopImages(record)"
|
||
:key="index"
|
||
class="shop-image-frame"
|
||
>
|
||
<a-spin v-if="isShopImageLoading(record, 'imageFileIds', index)" size="small" />
|
||
<img
|
||
:width="50"
|
||
:height="50"
|
||
:src="url"
|
||
class="shop-table-image"
|
||
alt="店铺图片"
|
||
@load="handleShopImageLoad(record, 'imageFileIds', index)"
|
||
@error="handleShopImageError(record, index)"
|
||
>
|
||
</div>
|
||
<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>
|
||
</template>
|
||
<template v-else-if="column.key === 'banner'">
|
||
<div class="shop-banner">
|
||
<div
|
||
v-for="(url, index) in getShopBannerImages(record)"
|
||
:key="index"
|
||
class="shop-image-frame shop-image-frame--banner"
|
||
>
|
||
<a-spin v-if="isShopImageLoading(record, 'coverImageFileId', index)" size="small" />
|
||
<img
|
||
:width="80"
|
||
:height="40"
|
||
:src="url"
|
||
class="shop-table-image"
|
||
alt="店铺Banner"
|
||
@load="handleShopImageLoad(record, 'coverImageFileId', index)"
|
||
@error="handleShopBannerImageError(record, index)"
|
||
>
|
||
</div>
|
||
<span v-if="getShopBannerImages(record).length === 0" class="no-banner">暂无Banner</span>
|
||
</div>
|
||
</template>
|
||
<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>
|
||
<template v-else-if="column.key === 'authorization' && false">
|
||
<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>
|
||
<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>
|
||
<template v-else-if="column.key === 'actions'">
|
||
<a-space>
|
||
<a-button v-if="hasPermission('shop:view')" type="link" size="small" @click="showViewModal(record)">
|
||
查看
|
||
</a-button>
|
||
<a-button v-if="hasPermission('shop:edit')" type="link" size="small" @click="showEditModal(record)">
|
||
编辑
|
||
</a-button>
|
||
</a-space>
|
||
</template>
|
||
</template>
|
||
</a-table>
|
||
|
||
<AdminMobileCardList v-else :items="shopList" empty-description="暂无店铺数据">
|
||
<template #item="{ item }">
|
||
<article class="admin-mobile-card">
|
||
<div class="shop-mobile-cover-frame">
|
||
<a-spin v-if="isShopCoverImageLoading(item)" size="small" />
|
||
<img
|
||
class="admin-mobile-card__cover admin-mobile-card__cover--wide"
|
||
:src="getShopBannerImages(item)[0] || getShopImages(item)[0] || DEFAULT_SHOP_IMAGE"
|
||
alt="店铺封面"
|
||
@load="handleShopCoverImageLoad(item)"
|
||
@error="handleShopCoverImageError(item)"
|
||
>
|
||
</div>
|
||
<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>
|
||
<a-button
|
||
v-if="hasPermission('shop:edit')"
|
||
size="small"
|
||
:disabled="!isAdmin"
|
||
@click="handleStatusChange(item, item.status === 0)"
|
||
>
|
||
{{ item.status === 0 ? '启用' : '停用' }}
|
||
</a-button>
|
||
</div>
|
||
</article>
|
||
</template>
|
||
</AdminMobileCardList>
|
||
</a-card>
|
||
|
||
<AdminResponsiveModal
|
||
v-model:open="modalVisible"
|
||
:title="isEdit ? '编辑店铺' : '新增店铺'"
|
||
:desktop-width="700"
|
||
@ok="handleModalOk"
|
||
@cancel="handleModalCancel"
|
||
:confirmLoading="modalLoading"
|
||
:ok-button-props="{ disabled: isUploadPending }"
|
||
>
|
||
<DraftActions
|
||
:saved-at="draftSavedAt"
|
||
:disabled="isUploadPending"
|
||
@save="handleSaveDraft"
|
||
@clear="handleClearDraft"
|
||
/>
|
||
<a-form
|
||
ref="formRef"
|
||
:model="formState"
|
||
:rules="formRules"
|
||
:label-col="{ span: 5 }"
|
||
:wrapper-col="{ span: 18 }"
|
||
>
|
||
<a-form-item label="店铺名称" name="shopName">
|
||
<a-input v-model:value="formState.shopName" placeholder="请输入店铺名称" />
|
||
</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">
|
||
<a-input v-model:value="formState.address" placeholder="可手动输入,也可点击腾讯地图选点后自动回填" />
|
||
</a-form-item>
|
||
<a-form-item label="地图位置">
|
||
<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>
|
||
</div>
|
||
<div class="map-picker-tip">选点后会自动保存位置名称、地址和坐标;用户端展示地名,并支持腾讯地图和高德地图导航。</div>
|
||
</a-form-item>
|
||
<a-form-item label="营业时间" name="businessHours">
|
||
<div class="business-hours-picker">
|
||
<a-date-picker
|
||
v-model:value="businessStartTime"
|
||
picker="time"
|
||
popup-class-name="jayucloud-salon-date-picker-panel jayucloud-salon-time-panel"
|
||
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"
|
||
popup-class-name="jayucloud-salon-date-picker-panel jayucloud-salon-time-panel"
|
||
value-format="HH:mm"
|
||
format="HH:mm"
|
||
placeholder="结束时间"
|
||
input-read-only
|
||
style="width: calc(50% - 14px)"
|
||
@change="handleBusinessHoursChange"
|
||
/>
|
||
</div>
|
||
</a-form-item>
|
||
<a-form-item v-if="false" label="授权起始日" name="authorizationStartDate">
|
||
<a-date-picker
|
||
v-model:value="formState.authorizationStartDate"
|
||
value-format="YYYY-MM-DD"
|
||
format="YYYY-MM-DD"
|
||
placeholder="为空表示长期有效"
|
||
:disabled="!isAdmin"
|
||
style="width: 100%"
|
||
/>
|
||
</a-form-item>
|
||
<a-form-item v-if="false" 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 v-if="false" label="到期时间">
|
||
<a-input :value="computedAuthorizationExpireTimeText" disabled />
|
||
</a-form-item>
|
||
<a-form-item label="Banner图片">
|
||
<div class="upload-tip">首页轮播图,建议尺寸 750x300 像素</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>
|
||
<div v-if="isUploadPending" class="upload-pending-tip">图片正在上传中,上传完成前不可提交。</div>
|
||
<a-modal v-model:open="bannerPreviewVisible" :footer="null" :mask-closable="false" @cancel="bannerPreviewVisible = false">
|
||
<img alt="预览" style="width: 100%" :src="bannerPreviewImage" />
|
||
</a-modal>
|
||
</a-form-item>
|
||
<a-form-item label="店铺图片">
|
||
<div class="upload-tip">店铺详情展示图</div>
|
||
<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>
|
||
<div v-if="isUploadPending" class="upload-pending-tip">图片正在上传中,上传完成前不可提交。</div>
|
||
<a-modal v-model:open="previewVisible" :footer="null" :mask-closable="false" @cancel="previewVisible = false">
|
||
<img alt="预览" style="width: 100%" :src="previewImage" />
|
||
</a-modal>
|
||
</a-form-item>
|
||
<div v-if="false" 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="#247B63" />
|
||
</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="#B8E4D4" />
|
||
</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="#17211F" />
|
||
</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="#F3F7F4" />
|
||
</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 }">{{ BRAND_CONFIG.appNameEn }}</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="取消"
|
||
:mask-closable="false"
|
||
@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>
|
||
</a-form>
|
||
</AdminResponsiveModal>
|
||
|
||
<!-- 查看店铺详情模态框 -->
|
||
<AdminResponsiveModal
|
||
v-model:open="viewModalVisible"
|
||
title="查看店铺详情"
|
||
:desktop-width="700"
|
||
@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>
|
||
<a-form-item label="地图位置">
|
||
<a-input :value="formatLocation(viewFormState)" :disabled="true" />
|
||
</a-form-item>
|
||
<a-form-item label="营业时间">
|
||
<a-input v-model:value="viewFormState.businessHours" :disabled="true" />
|
||
</a-form-item>
|
||
<a-form-item v-if="false" label="授权状态">
|
||
<a-input :value="viewFormState.authorizationStatusText || '有效'" :disabled="true" />
|
||
</a-form-item>
|
||
<a-form-item v-if="false" label="授权起始日">
|
||
<a-input :value="viewFormState.authorizationStartDate || '长期有效'" :disabled="true" />
|
||
</a-form-item>
|
||
<a-form-item v-if="false" label="有效期天数">
|
||
<a-input :value="viewFormState.authorizationDays ? `${viewFormState.authorizationDays} 天` : '长期有效'" :disabled="true" />
|
||
</a-form-item>
|
||
<a-form-item v-if="false" label="授权有效期">
|
||
<a-input :value="formatAuthorizationExpireTime(viewFormState.authorizationExpireTime)" :disabled="true" />
|
||
</a-form-item>
|
||
<a-form-item v-if="false" 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>
|
||
<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>
|
||
<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"
|
||
/>
|
||
<a-image
|
||
v-if="viewImageUrls.length === 0"
|
||
:width="80"
|
||
:height="80"
|
||
:src="DEFAULT_SHOP_IMAGE"
|
||
style="object-fit: cover; border-radius: 4px;"
|
||
:preview="false"
|
||
/>
|
||
</div>
|
||
</a-form-item>
|
||
</a-form>
|
||
</AdminResponsiveModal>
|
||
|
||
<a-modal
|
||
v-model:open="mapPickerVisible"
|
||
:title="mapPickerTitle"
|
||
:width="920"
|
||
:footer="null"
|
||
:mask-closable="false"
|
||
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>
|
||
|
||
<AdminMobileFab
|
||
:visible="isMobile && hasPermission('shop:create') && !modalVisible && !viewModalVisible"
|
||
label="新增店铺"
|
||
@click="showAddModal"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
/**
|
||
* 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.
|
||
*/
|
||
import { computed, ref, reactive, onMounted } from 'vue'
|
||
import { message } from 'ant-design-vue'
|
||
import type { FormInstance, UploadProps } from 'ant-design-vue'
|
||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||
import DraftActions from '@/components/DraftActions.vue'
|
||
import TableEllipsisText from '@/components/TableEllipsisText.vue'
|
||
import { DEFAULT_SHOP_IMAGE } from '@/constants'
|
||
/**
|
||
* 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.
|
||
*/
|
||
import { adminShopApi, adminFileApi, adminSystemParameterConfigApi, type Shop } from '@/api/admin'
|
||
/**
|
||
* 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.
|
||
*/
|
||
import { createChunkUploadTask, type ChunkUploadTask } from '@/utils/chunk-upload'
|
||
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
|
||
import { usePermission } from '@/utils/permission'
|
||
import { runWithGlobalLoading } from '@/utils/action-loading'
|
||
import { createAdminPagination, applyAdminTablePaginationChange, type AdminTablePaginationChange } from '@/utils/admin-table'
|
||
import { resolveUploadedFileId, type AdminUploadFileLike, type AdminUploadTaskFile } from '@/utils/admin-upload-file'
|
||
import type { IdType } from '@/utils/id'
|
||
import {
|
||
buildAdminUploadFileList,
|
||
buildSignedImageUrlMap,
|
||
getRecordImageUrls,
|
||
refreshSignedImageUrl,
|
||
resolveSignedImageUrl,
|
||
resolveSignedImageUrls
|
||
} from '@/utils/admin-image-assets'
|
||
import { parseImageFileIds } from '@/utils/signed-image-cache'
|
||
import { notifyShopThemeChanged, resolveShopTheme } from '@/utils/shop-theme'
|
||
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'
|
||
import { BRAND_CONFIG } from '@/config/brand'
|
||
|
||
const { hasPermission, loadUserPermissions } = usePermission()
|
||
const { isMobile } = useAdminViewport()
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
interface ShopThemeTemplateColors {
|
||
themePrimaryColor: string
|
||
themeSecondaryColor: string
|
||
themeAccentColor: string
|
||
themePageBgColor: string
|
||
themeCardBgColor: string
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
interface ShopThemeTemplate extends ShopThemeTemplateColors {
|
||
id: string
|
||
name: string
|
||
source: 'preset' | 'custom'
|
||
createdAt?: number
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const CUSTOM_THEME_TEMPLATE_STORAGE_KEY = 'jayucloud-salon:admin:shop-theme-templates'
|
||
/**
|
||
* 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.
|
||
*/
|
||
const CUSTOM_THEME_TEMPLATE_LIMIT = 20
|
||
|
||
const PRESET_THEME_TEMPLATES: ShopThemeTemplate[] = [
|
||
{
|
||
id: 'preset-luminous-elegance',
|
||
name: '薄荷绿清新',
|
||
source: 'preset',
|
||
themePrimaryColor: '#247B63',
|
||
themeSecondaryColor: '#B8E4D4',
|
||
themeAccentColor: '#17211F',
|
||
themePageBgColor: '#F3F7F4',
|
||
themeCardBgColor: '#FFFFFF'
|
||
},
|
||
{
|
||
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'
|
||
}
|
||
]
|
||
|
||
/** loading is a reactive state variable used by the template and event handlers. */
|
||
const loading = ref(false)
|
||
/** searchText is a reactive state variable used by the template and event handlers. */
|
||
const searchText = ref('')
|
||
/**
|
||
* 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.
|
||
*/
|
||
const shopList = ref<Shop[]>([])
|
||
/** modalVisible is a reactive state variable used by the template and event handlers. */
|
||
const modalVisible = ref(false)
|
||
/** viewModalVisible is a reactive state variable used by the template and event handlers. */
|
||
const viewModalVisible = ref(false)
|
||
/** modalLoading is a reactive state variable used by the template and event handlers. */
|
||
const modalLoading = ref(false)
|
||
/** isEdit is a reactive state variable used by the template and event handlers. */
|
||
const isEdit = ref(false)
|
||
/**
|
||
* 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.
|
||
*/
|
||
const mapPickerVisible = ref(false)
|
||
/**
|
||
* 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.
|
||
*/
|
||
const mapPickerKey = ref('')
|
||
/**
|
||
* 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.
|
||
*/
|
||
const mapPickerUrl = ref('')
|
||
/**
|
||
* 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.
|
||
*/
|
||
const mapPickerProvider = ref<'TENCENT' | 'AMAP'>('TENCENT')
|
||
/**
|
||
* 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.
|
||
*/
|
||
const locating = ref(false)
|
||
/**
|
||
* 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.
|
||
*/
|
||
const formRef = ref<FormInstance>()
|
||
/**
|
||
* 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.
|
||
*/
|
||
const currentShop = ref<Shop | null>(null)
|
||
/** isAdmin is a reactive state variable used by the template and event handlers. */
|
||
const isAdmin = ref(false)
|
||
|
||
// Banner图片相关
|
||
const bannerFileList = ref<any[]>([])
|
||
/**
|
||
* 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.
|
||
*/
|
||
const uploadedBannerIds = ref<string[]>([])
|
||
/** bannerPreviewVisible is a reactive state variable used by the template and event handlers. */
|
||
const bannerPreviewVisible = ref(false)
|
||
/** bannerPreviewImage is a reactive state variable used by the template and event handlers. */
|
||
const bannerPreviewImage = ref('')
|
||
|
||
// 店铺图片相关
|
||
const imageFileList = ref<any[]>([])
|
||
/**
|
||
* 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.
|
||
*/
|
||
const uploadedFileIds = ref<string[]>([])
|
||
/**
|
||
* 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.
|
||
*/
|
||
const themeBackgroundFileList = ref<any[]>([])
|
||
/**
|
||
* 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.
|
||
*/
|
||
const uploadedThemeBackgroundId = ref('')
|
||
/**
|
||
* 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.
|
||
*/
|
||
const shopImageUrls = ref<Record<string, string[]>>({})
|
||
/**
|
||
* 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.
|
||
*/
|
||
const shopBannerUrls = ref<Record<string, string[]>>({})
|
||
const shopImageLoadingKeys = ref<Record<string, boolean>>({})
|
||
/**
|
||
* 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.
|
||
*/
|
||
const viewImageUrls = ref<string[]>([])
|
||
/**
|
||
* 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.
|
||
*/
|
||
const viewBannerUrls = ref<string[]>([])
|
||
/** previewVisible is a reactive state variable used by the template and event handlers. */
|
||
const previewVisible = ref(false)
|
||
/** previewImage is a reactive state variable used by the template and event handlers. */
|
||
const previewImage = ref('')
|
||
/** businessStartTime is a reactive state variable used by the template and event handlers. */
|
||
const businessStartTime = ref('')
|
||
/** businessEndTime is a reactive state variable used by the template and event handlers. */
|
||
const businessEndTime = ref('')
|
||
/**
|
||
* 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.
|
||
*/
|
||
const uploadTaskMap = new Map<string, ChunkUploadTask<any>>()
|
||
/** activeUploadCount is a reactive state variable used by the template and event handlers. */
|
||
const activeUploadCount = ref(0)
|
||
/** isUploadPending is a reactive state variable used by the template and event handlers. */
|
||
const isUploadPending = computed(() => activeUploadCount.value > 0)
|
||
/**
|
||
* 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.
|
||
*/
|
||
const draftSavedAt = ref<number | null>(null)
|
||
/**
|
||
* 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.
|
||
*/
|
||
const customThemeTemplates = ref<ShopThemeTemplate[]>([])
|
||
/**
|
||
* 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.
|
||
*/
|
||
const themeTemplateSaveVisible = ref(false)
|
||
/**
|
||
* 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.
|
||
*/
|
||
const themeTemplateName = ref('')
|
||
|
||
// 查看店铺相关状态
|
||
const viewFormState = reactive({
|
||
shopName: '',
|
||
description: '',
|
||
address: '',
|
||
mapProvider: 'TENCENT',
|
||
longitude: '',
|
||
latitude: '',
|
||
businessHours: '',
|
||
status: 1,
|
||
authorizationStartDate: '',
|
||
authorizationDays: undefined as number | undefined,
|
||
authorizationExpireTime: '',
|
||
authorizationStatusText: '',
|
||
coverImageFileId: '',
|
||
imageFileIds: '',
|
||
themePrimaryColor: '',
|
||
themeSecondaryColor: '',
|
||
themeAccentColor: '',
|
||
themePageBgColor: '',
|
||
themeCardBgColor: '',
|
||
themeBackgroundImageFileId: ''
|
||
})
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const pagination = reactive(createAdminPagination())
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const formState = reactive({
|
||
shopName: '',
|
||
description: '',
|
||
address: '',
|
||
mapProvider: 'TENCENT',
|
||
longitude: '',
|
||
latitude: '',
|
||
businessHours: '',
|
||
status: 1,
|
||
authorizationStartDate: '',
|
||
authorizationDays: undefined as number | undefined,
|
||
authorizationExpireTime: '',
|
||
coverImageFileId: '',
|
||
imageFileIds: '',
|
||
themePrimaryColor: '',
|
||
themeSecondaryColor: '',
|
||
themeAccentColor: '',
|
||
themePageBgColor: '',
|
||
themeCardBgColor: '',
|
||
themeBackgroundImageFileId: ''
|
||
})
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const selectedLocationText = computed(() => {
|
||
if (formState.address) return formState.address
|
||
if (formState.longitude && formState.latitude) return '已选择地图位置'
|
||
return '暂未选择地图位置'
|
||
})
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const selectedCoordinateText = computed(() => {
|
||
if (!formState.longitude || !formState.latitude) return '点击“地图选点”搜索店铺名称或地址'
|
||
return '已选择地图位置,可重新选点'
|
||
})
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const mapPickerTitle = computed(() => mapPickerProvider.value === 'AMAP' ? '高德地图选点' : '腾讯地图选点')
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
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`
|
||
})
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const computedAuthorizationExpireTimeText = computed(() => formatAuthorizationExpireTime(computedAuthorizationExpireTime.value))
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const themePreview = computed(() => resolveShopTheme(formState))
|
||
/**
|
||
* 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.
|
||
*/
|
||
const viewThemePreview = computed(() => resolveShopTheme(viewFormState))
|
||
/**
|
||
* 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.
|
||
*/
|
||
const themePreviewStyle = computed(() => ({
|
||
color: themePreview.value.textPrimary,
|
||
borderColor: themePreview.value.borderColor,
|
||
background: themePreview.value.softGradient
|
||
}))
|
||
/**
|
||
* 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.
|
||
*/
|
||
const themePreviewButtonStyle = computed(() => ({
|
||
color: '#ffffff',
|
||
background: themePreview.value.gradient,
|
||
boxShadow: themePreview.value.cssVars['--theme-button-shadow']
|
||
}))
|
||
/**
|
||
* 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.
|
||
*/
|
||
const themeTemplates = computed(() => [...PRESET_THEME_TEMPLATES, ...customThemeTemplates.value])
|
||
/**
|
||
* 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.
|
||
*/
|
||
const currentThemeTemplateColors = computed(() => buildThemeTemplateColors(formState))
|
||
/**
|
||
* 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.
|
||
*/
|
||
const currentThemeTemplateSwatches = computed(() => getThemeTemplateSwatches(currentThemeTemplateColors.value))
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const normalizeTemplateColor = (value?: string) => {
|
||
const normalized = String(value || '').trim().toUpperCase()
|
||
return /^#[0-9A-F]{6}$/.test(normalized) ? normalized : ''
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
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
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const getThemeTemplateSwatches = (template: ShopThemeTemplateColors) => [
|
||
template.themePrimaryColor,
|
||
template.themeSecondaryColor,
|
||
template.themeAccentColor,
|
||
template.themePageBgColor,
|
||
template.themeCardBgColor
|
||
]
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
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
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const persistCustomThemeTemplates = () => {
|
||
if (typeof window === 'undefined') {
|
||
return
|
||
}
|
||
window.localStorage.setItem(getThemeTemplateStorageKey(), JSON.stringify(customThemeTemplates.value))
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
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 = []
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const isThemeTemplateActive = (template: ShopThemeTemplateColors) => {
|
||
const currentColors = currentThemeTemplateColors.value
|
||
return getThemeTemplateSwatches(template).every((color, index) => color === getThemeTemplateSwatches(currentColors)[index])
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
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 格式颜色')
|
||
}
|
||
|
||
const formRules: any = {
|
||
shopName: [{ required: true, message: '请输入店铺名称', trigger: 'blur' }],
|
||
description: [{ required: true, message: '请输入店铺描述', trigger: 'blur' }],
|
||
address: [{ required: true, message: '请输入店铺地址', trigger: 'blur' }],
|
||
businessHours: [{
|
||
validator: async () => {
|
||
if (!businessStartTime.value || !businessEndTime.value) {
|
||
return Promise.reject('请选择营业开始和结束时间')
|
||
}
|
||
if (businessStartTime.value >= businessEndTime.value) {
|
||
return Promise.reject('营业结束时间必须晚于开始时间')
|
||
}
|
||
return Promise.resolve()
|
||
},
|
||
trigger: 'change'
|
||
}],
|
||
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' }]
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const columns = [
|
||
{ title: '图片', key: 'image', width: 150 },
|
||
{ title: 'Banner', key: 'banner', width: 200 },
|
||
{ title: '店铺名称', dataIndex: 'shopName', key: 'shopName' },
|
||
{ title: '店铺描述', dataIndex: 'description', key: 'description' },
|
||
{ title: '店铺地址', dataIndex: 'address', key: 'address' },
|
||
{ title: '营业时间', dataIndex: 'businessHours', key: 'businessHours' },
|
||
{ title: '状态', key: 'status', width: 120 },
|
||
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
|
||
{ title: '操作', key: 'actions', width: 150, fixed: 'right' as const }
|
||
]
|
||
|
||
/** getCurrentUserInfo is a local helper used by this page script. */
|
||
const getCurrentUserInfo = () => {
|
||
try {
|
||
const userInfoStr = localStorage.getItem('adminUserInfo')
|
||
if (userInfoStr) {
|
||
const userInfo = JSON.parse(userInfoStr)
|
||
// 判断用户是否为管理员(类型为4)
|
||
isAdmin.value = userInfo.type === 4
|
||
return userInfo
|
||
}
|
||
} catch (error) {
|
||
console.error('获取当前用户信息失败', error)
|
||
}
|
||
return null
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const getThemeTemplateStorageKey = () => {
|
||
const currentUser = getCurrentUserInfo()
|
||
const userKey = currentUser?.id ?? currentUser?.userId ?? currentUser?.account ?? currentUser?.username ?? 'default'
|
||
return `${CUSTOM_THEME_TEMPLATE_STORAGE_KEY}:${userKey}`
|
||
}
|
||
|
||
/** loadImageUrls is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const loadImageUrls = async (shops: Shop[]) => {
|
||
const [nextShopImageUrls, nextShopBannerUrls] = await Promise.all([
|
||
buildSignedImageUrlMap(shops, 'imageFileIds', DEFAULT_SHOP_IMAGE, false, () => false),
|
||
buildSignedImageUrlMap(shops, 'coverImageFileId', DEFAULT_SHOP_IMAGE, false, () => false)
|
||
])
|
||
|
||
shopImageUrls.value = nextShopImageUrls || {}
|
||
shopBannerUrls.value = nextShopBannerUrls || {}
|
||
}
|
||
|
||
/** getShopImages is a local helper used by this page script. */
|
||
const getShopImages = (shop: { id?: IdType }): string[] =>
|
||
getRecordImageUrls(shop, shopImageUrls.value, [])
|
||
|
||
/** getShopBannerImages is a local helper used by this page script. */
|
||
const getShopBannerImages = (shop: { id?: IdType }): string[] =>
|
||
getRecordImageUrls(shop, shopBannerUrls.value, [])
|
||
|
||
const getShopImageLoadingKey = (
|
||
shop: { id?: IdType },
|
||
fieldName: 'imageFileIds' | 'coverImageFileId',
|
||
imageIndex: number
|
||
): string => `${String(shop.id ?? '')}:${fieldName}:${imageIndex}`
|
||
|
||
const setShopImageLoading = (
|
||
shop: { id?: IdType },
|
||
fieldName: 'imageFileIds' | 'coverImageFileId',
|
||
imageIndex: number,
|
||
loadingValue: boolean
|
||
): void => {
|
||
const key = getShopImageLoadingKey(shop, fieldName, imageIndex)
|
||
if (!key.startsWith(':')) {
|
||
shopImageLoadingKeys.value = {
|
||
...shopImageLoadingKeys.value,
|
||
[key]: loadingValue
|
||
}
|
||
}
|
||
}
|
||
|
||
const isShopImageLoading = (
|
||
shop: { id?: IdType },
|
||
fieldName: 'imageFileIds' | 'coverImageFileId',
|
||
imageIndex: number
|
||
): boolean => {
|
||
const key = getShopImageLoadingKey(shop, fieldName, imageIndex)
|
||
return shopImageLoadingKeys.value[key] !== false
|
||
}
|
||
|
||
const handleShopImageLoad = (
|
||
shop: { id?: IdType },
|
||
fieldName: 'imageFileIds' | 'coverImageFileId',
|
||
imageIndex: number
|
||
): void => {
|
||
setShopImageLoading(shop, fieldName, imageIndex, false)
|
||
}
|
||
|
||
const isShopCoverImageLoading = (
|
||
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string }
|
||
): boolean => {
|
||
const bannerFileIds = parseImageFileIds(shop.coverImageFileId)
|
||
if (bannerFileIds.length) {
|
||
return isShopImageLoading(shop, 'coverImageFileId', 0)
|
||
}
|
||
const imageFileIds = parseImageFileIds(shop.imageFileIds)
|
||
if (imageFileIds.length) {
|
||
return isShopImageLoading(shop, 'imageFileIds', 0)
|
||
}
|
||
return false
|
||
}
|
||
|
||
const handleShopCoverImageLoad = (
|
||
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string }
|
||
): void => {
|
||
const bannerFileIds = parseImageFileIds(shop.coverImageFileId)
|
||
if (bannerFileIds.length) {
|
||
handleShopImageLoad(shop, 'coverImageFileId', 0)
|
||
return
|
||
}
|
||
handleShopImageLoad(shop, 'imageFileIds', 0)
|
||
}
|
||
|
||
const refreshShopImageUrl = async (
|
||
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string },
|
||
fieldName: 'imageFileIds' | 'coverImageFileId',
|
||
imageIndex: number,
|
||
imageUrlMap: Record<string, string[]>
|
||
) => {
|
||
if (shop.id === undefined || shop.id === null) return null
|
||
const fileId = parseImageFileIds(shop[fieldName])[imageIndex]
|
||
if (!fileId) return null
|
||
|
||
const refreshedUrl = await refreshSignedImageUrl(fileId, DEFAULT_SHOP_IMAGE)
|
||
if (!refreshedUrl || refreshedUrl === DEFAULT_SHOP_IMAGE) return null
|
||
|
||
const shopKey = String(shop.id)
|
||
const currentUrls = imageUrlMap[shopKey] || []
|
||
const nextUrls = [...currentUrls]
|
||
nextUrls[imageIndex] = refreshedUrl
|
||
return {
|
||
...imageUrlMap,
|
||
[shopKey]: nextUrls
|
||
}
|
||
}
|
||
|
||
const handleShopImageError = async (
|
||
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string },
|
||
imageIndex: number
|
||
) => {
|
||
setShopImageLoading(shop, 'imageFileIds', imageIndex, false)
|
||
const nextImageUrls = await refreshShopImageUrl(shop, 'imageFileIds', imageIndex, shopImageUrls.value)
|
||
if (nextImageUrls) {
|
||
setShopImageLoading(shop, 'imageFileIds', imageIndex, true)
|
||
shopImageUrls.value = nextImageUrls
|
||
}
|
||
}
|
||
|
||
const handleShopBannerImageError = async (
|
||
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string },
|
||
imageIndex: number
|
||
) => {
|
||
setShopImageLoading(shop, 'coverImageFileId', imageIndex, false)
|
||
const nextBannerUrls = await refreshShopImageUrl(shop, 'coverImageFileId', imageIndex, shopBannerUrls.value)
|
||
if (nextBannerUrls) {
|
||
setShopImageLoading(shop, 'coverImageFileId', imageIndex, true)
|
||
shopBannerUrls.value = nextBannerUrls
|
||
}
|
||
}
|
||
|
||
const handleShopCoverImageError = async (
|
||
shop: { id?: IdType; imageFileIds?: string; coverImageFileId?: string }
|
||
) => {
|
||
const bannerFileIds = parseImageFileIds(shop.coverImageFileId)
|
||
if (bannerFileIds.length) {
|
||
await handleShopBannerImageError(shop, 0)
|
||
return
|
||
}
|
||
await handleShopImageError(shop, 0)
|
||
}
|
||
|
||
/** formatAuthorizationExpireTime is a local helper used by this page script. */
|
||
const formatAuthorizationExpireTime = (value?: string) => {
|
||
if (!value) {
|
||
return '长期有效'
|
||
}
|
||
return value.replace('T', ' ').slice(0, 16)
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const formatLocation = (shop?: Partial<Shop> | Record<string, any>) => {
|
||
const locationName = shop?.address || shop?.shopName || ''
|
||
if (!locationName) return '未设置地图位置'
|
||
return locationName || '未设置地图位置'
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const buildTencentLocationPickerUrl = (options: { latitude?: string | number; longitude?: string | number } = {}) => {
|
||
const params = new URLSearchParams({
|
||
search: '1',
|
||
type: '1',
|
||
key: mapPickerKey.value,
|
||
referer: 'jayucloud-salon',
|
||
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()}`
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
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()}`
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const buildMapLocationPickerUrl = (options: { latitude?: string | number; longitude?: string | number } = {}) => {
|
||
return mapPickerProvider.value === 'AMAP'
|
||
? buildAmapLocationPickerUrl(options)
|
||
: buildTencentLocationPickerUrl(options)
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const closeTencentLocationPicker = () => {
|
||
mapPickerVisible.value = false
|
||
window.removeEventListener('message', handleMapLocationMessage)
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const closeMapLocationPicker = closeTencentLocationPicker
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
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()
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
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()
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
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)
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const openMapLocationPicker = async () => {
|
||
const response = await adminSystemParameterConfigApi.getMapConfig()
|
||
const provider = response?.provider === 'AMAP' ? 'AMAP' : 'TENCENT'
|
||
const key = provider === 'AMAP' ? (response?.amapWebKey || '') : (response?.tencentWebKey || '')
|
||
if (!key) {
|
||
message.warning(provider === 'AMAP'
|
||
? '请先在参数管理中配置高德 Web Key'
|
||
: '请先在参数管理中配置腾讯 Web Key')
|
||
return
|
||
}
|
||
|
||
mapPickerProvider.value = provider
|
||
mapPickerKey.value = key
|
||
mapPickerUrl.value = buildMapLocationPickerUrl()
|
||
mapPickerVisible.value = true
|
||
window.removeEventListener('message', handleMapLocationMessage)
|
||
window.addEventListener('message', handleMapLocationMessage)
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const handleMapPickerFrameLoad = () => {
|
||
// 高德/腾讯选点页均通过 postMessage 回传结果,此处保留钩子便于后续接入加载态。
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const useCurrentLocation = () => {
|
||
if (!navigator.geolocation) {
|
||
message.warning('当前浏览器不支持定位')
|
||
return
|
||
}
|
||
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 }
|
||
)
|
||
}
|
||
|
||
/** fetchShopList is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const fetchShopList = async () => {
|
||
loading.value = true
|
||
try {
|
||
const currentUser = getCurrentUserInfo()
|
||
const params: any = {
|
||
page: pagination.current,
|
||
size: pagination.pageSize,
|
||
keyword: searchText.value
|
||
}
|
||
|
||
if (currentUser && currentUser.type !== 4 && currentUser.shopId) {
|
||
params.shopId = currentUser.shopId
|
||
}
|
||
|
||
const response = await adminShopApi.listShops(params)
|
||
const res = typeof response === 'object' && 'list' in response ? response : (response as any).data
|
||
shopList.value = res.list || []
|
||
pagination.total = res.total || 0
|
||
|
||
// 预加载所有图片签名链接
|
||
await loadImageUrls(res.list || [])
|
||
} catch (error) {
|
||
message.error('获取店铺列表失败')
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
/** handleSearch is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const handleSearch = async () => {
|
||
pagination.current = 1
|
||
await runWithGlobalLoading(() => fetchShopList())
|
||
}
|
||
|
||
/** handleTableChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const handleTableChange = async (pag: AdminTablePaginationChange) => {
|
||
const nextPagination = applyAdminTablePaginationChange(pagination, pag)
|
||
pagination.current = nextPagination.current
|
||
pagination.pageSize = nextPagination.pageSize
|
||
await runWithGlobalLoading(() => fetchShopList())
|
||
}
|
||
|
||
/** beforeUpload is a local helper used by this page script. */
|
||
const beforeUpload = (file: File) => {
|
||
const isImage = file.type.startsWith('image/')
|
||
if (!isImage) {
|
||
message.error('只能上传图片文件')
|
||
}
|
||
return isImage
|
||
}
|
||
|
||
// Banner 与门店环境图分开维护上传任务,便于表单回显和删除时分别同步 fileId 列表。
|
||
/** handleUploadBanner is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const handleUploadBanner: UploadProps['customRequest'] = async (options) => {
|
||
const { file, onSuccess, onError, onProgress } = options
|
||
const uploadFile = file as AdminUploadTaskFile
|
||
const taskKey = `banner:${String(uploadFile.uid)}`
|
||
const task = createChunkUploadTask({
|
||
file: uploadFile,
|
||
scene: 'admin-shop-banner',
|
||
concurrency: 3,
|
||
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)
|
||
syncUploadedBannerIds([...uploadedBannerIds.value, fileId])
|
||
onSuccess?.({ id: fileId, fileId })
|
||
message.success('Banner上传成功')
|
||
} catch (error) {
|
||
const errorMessage = (error as Error)?.message || 'Banner上传失败'
|
||
if (errorMessage !== '上传已取消' && errorMessage !== 'canceled') {
|
||
console.error('Banner上传失败:', error)
|
||
message.error(errorMessage)
|
||
onError?.(error as never)
|
||
}
|
||
} finally {
|
||
uploadTaskMap.delete(taskKey)
|
||
activeUploadCount.value = Math.max(0, activeUploadCount.value - 1)
|
||
}
|
||
}
|
||
|
||
/** handleBannerPreview is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const handleBannerPreview: UploadProps['onPreview'] = async (file) => {
|
||
try {
|
||
const cachedPreviewUrl = getPreviewUrlFromFile(file as AdminUploadFileLike)
|
||
if (cachedPreviewUrl) {
|
||
bannerPreviewImage.value = cachedPreviewUrl
|
||
bannerPreviewVisible.value = true
|
||
return
|
||
}
|
||
|
||
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
|
||
if (!fileId) {
|
||
throw new Error('未找到图片文件标识')
|
||
}
|
||
|
||
bannerPreviewImage.value = await resolveSignedImageUrl(fileId, '')
|
||
bannerPreviewVisible.value = true
|
||
} catch (error) {
|
||
console.error('获取预览链接失败:', error)
|
||
message.error((error as Error)?.message || '获取预览链接失败')
|
||
}
|
||
}
|
||
|
||
/** handleBannerRemove is a local helper used by this page script. */
|
||
const handleBannerRemove: UploadProps['onRemove'] = (file) => {
|
||
const task = uploadTaskMap.get(`banner:${String(file.uid)}`)
|
||
if (task) {
|
||
task.cancel()
|
||
return true
|
||
}
|
||
|
||
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
|
||
if (fileId) {
|
||
syncUploadedBannerIds(uploadedBannerIds.value.filter(id => id !== fileId))
|
||
}
|
||
return true
|
||
}
|
||
|
||
// 店铺环境图与 Banner 走同一套分片上传协议,但写入不同业务字段。
|
||
/** handleUploadImage is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const handleUploadImage: UploadProps['customRequest'] = async (options) => {
|
||
const { file, onSuccess, onError, onProgress } = options
|
||
const uploadFile = file as AdminUploadTaskFile
|
||
const taskKey = `image:${String(uploadFile.uid)}`
|
||
const task = createChunkUploadTask({
|
||
file: uploadFile,
|
||
scene: 'admin-shop-image',
|
||
concurrency: 3,
|
||
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)
|
||
syncUploadedFileIds([...uploadedFileIds.value, 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 as never)
|
||
}
|
||
} finally {
|
||
uploadTaskMap.delete(taskKey)
|
||
activeUploadCount.value = Math.max(0, activeUploadCount.value - 1)
|
||
}
|
||
}
|
||
|
||
// 编辑态下 Upload 里的文件可能只剩 fileId,所以预览时需要兼容本地 URL 与远端签名地址两种来源。
|
||
/** handlePreview is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const handlePreview: UploadProps['onPreview'] = async (file) => {
|
||
try {
|
||
const cachedPreviewUrl = getPreviewUrlFromFile(file as AdminUploadFileLike)
|
||
if (cachedPreviewUrl) {
|
||
previewImage.value = cachedPreviewUrl
|
||
previewVisible.value = true
|
||
return
|
||
}
|
||
|
||
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
|
||
if (!fileId) {
|
||
throw new Error('未找到图片文件标识')
|
||
}
|
||
|
||
previewImage.value = await resolveSignedImageUrl(fileId, '')
|
||
previewVisible.value = true
|
||
} catch (error) {
|
||
console.error('获取预览链接失败:', error)
|
||
message.error((error as Error)?.message || '获取预览链接失败')
|
||
}
|
||
}
|
||
|
||
/** handleRemove is a local helper used by this page script. */
|
||
const handleRemove: UploadProps['onRemove'] = (file) => {
|
||
const task = uploadTaskMap.get(`image:${String(file.uid)}`)
|
||
if (task) {
|
||
task.cancel()
|
||
return true
|
||
}
|
||
|
||
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
|
||
if (fileId) {
|
||
syncUploadedFileIds(uploadedFileIds.value.filter(id => id !== fileId))
|
||
}
|
||
return true
|
||
}
|
||
|
||
/** handleUploadThemeBackground is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const handleUploadThemeBackground: UploadProps['customRequest'] = async (options) => {
|
||
const { file, onSuccess, onError, onProgress } = options
|
||
const uploadFile = file as AdminUploadTaskFile
|
||
const taskKey = `theme-bg:${String(uploadFile.uid)}`
|
||
const task = createChunkUploadTask({
|
||
file: uploadFile,
|
||
scene: 'admin-shop-theme-background',
|
||
concurrency: 3,
|
||
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 as never)
|
||
}
|
||
} 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: UploadProps['onPreview'] = async (file) => {
|
||
try {
|
||
const cachedPreviewUrl = getPreviewUrlFromFile(file as AdminUploadFileLike)
|
||
if (cachedPreviewUrl) {
|
||
bannerPreviewImage.value = cachedPreviewUrl
|
||
bannerPreviewVisible.value = true
|
||
return
|
||
}
|
||
|
||
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
|
||
if (!fileId) {
|
||
throw new Error('未找到背景图文件标识')
|
||
}
|
||
|
||
bannerPreviewImage.value = await resolveSignedImageUrl(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: UploadProps['onRemove'] = (file) => {
|
||
const task = uploadTaskMap.get(`theme-bg:${String(file.uid)}`)
|
||
if (task) {
|
||
task.cancel()
|
||
return true
|
||
}
|
||
|
||
const fileId = resolveUploadedFileId(file as AdminUploadFileLike)
|
||
if (fileId) {
|
||
syncUploadedThemeBackgroundId('')
|
||
}
|
||
return true
|
||
}
|
||
|
||
/** syncBusinessHoursValue is a local helper used by this page script. */
|
||
const syncBusinessHoursValue = () => {
|
||
formState.businessHours = businessStartTime.value && businessEndTime.value
|
||
? `${businessStartTime.value}-${businessEndTime.value}`
|
||
: ''
|
||
}
|
||
|
||
/** setBusinessHoursValue is a local helper used by this page script. */
|
||
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()
|
||
}
|
||
|
||
/** handleBusinessHoursChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const handleBusinessHoursChange = async () => {
|
||
syncBusinessHoursValue()
|
||
await formRef.value?.validateFields?.(['businessHours']).catch(() => undefined)
|
||
}
|
||
|
||
/** showAddModal is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const showAddModal = async () => {
|
||
isEdit.value = false
|
||
currentShop.value = null
|
||
Object.assign(formState, {
|
||
shopName: '',
|
||
description: '',
|
||
address: '',
|
||
mapProvider: 'TENCENT',
|
||
longitude: '',
|
||
latitude: '',
|
||
businessHours: '',
|
||
status: 1,
|
||
authorizationStartDate: '',
|
||
authorizationDays: undefined,
|
||
authorizationExpireTime: '',
|
||
coverImageFileId: '',
|
||
imageFileIds: '',
|
||
themePrimaryColor: '',
|
||
themeSecondaryColor: '',
|
||
themeAccentColor: '',
|
||
themePageBgColor: '',
|
||
themeCardBgColor: '',
|
||
themeBackgroundImageFileId: ''
|
||
})
|
||
setBusinessHoursValue('')
|
||
bannerFileList.value = []
|
||
syncUploadedBannerIds([])
|
||
imageFileList.value = []
|
||
syncUploadedFileIds([])
|
||
themeBackgroundFileList.value = []
|
||
syncUploadedThemeBackgroundId('')
|
||
await restoreDraft()
|
||
modalVisible.value = true
|
||
}
|
||
|
||
/** showEditModal is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const showEditModal = async (record: Shop | Record<string, any>) => {
|
||
isEdit.value = true
|
||
currentShop.value = record as Shop
|
||
Object.assign(formState, {
|
||
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,
|
||
mapProvider: 'TENCENT',
|
||
longitude: 'longitude' in record ? record.longitude : (record as any).longitude,
|
||
latitude: 'latitude' in record ? record.latitude : (record as any).latitude,
|
||
businessHours: 'businessHours' in record ? record.businessHours : (record as any).businessHours,
|
||
status: 'status' in record ? (record.status ?? 1) : ((record as any).status ?? 1),
|
||
authorizationStartDate: 'authorizationStartDate' in record ? record.authorizationStartDate : (record as any).authorizationStartDate,
|
||
authorizationDays: 'authorizationDays' in record ? record.authorizationDays : (record as any).authorizationDays,
|
||
authorizationExpireTime: 'authorizationExpireTime' in record ? record.authorizationExpireTime : (record as any).authorizationExpireTime,
|
||
coverImageFileId: 'coverImageFileId' in record ? record.coverImageFileId : (record as any).coverImageFileId,
|
||
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
|
||
})
|
||
setBusinessHoursValue(formState.businessHours)
|
||
|
||
// 加载Banner图片
|
||
const coverImageFileId = 'coverImageFileId' in record ? record.coverImageFileId : (record as any).coverImageFileId
|
||
if (coverImageFileId) {
|
||
const ids = coverImageFileId.split(',').filter((id: string) => id)
|
||
syncUploadedBannerIds(ids)
|
||
bannerFileList.value = await buildShopUploadFileList(ids, 'Banner')
|
||
} else {
|
||
bannerFileList.value = []
|
||
syncUploadedBannerIds([])
|
||
}
|
||
|
||
// 加载店铺图片
|
||
const imageFileIds = 'imageFileIds' in record ? record.imageFileIds : (record as any).imageFileIds
|
||
if (imageFileIds) {
|
||
const ids = imageFileIds.split(',').filter((id: string) => id)
|
||
syncUploadedFileIds(ids)
|
||
imageFileList.value = await buildShopUploadFileList(ids, '图片')
|
||
} else {
|
||
imageFileList.value = []
|
||
syncUploadedFileIds([])
|
||
}
|
||
|
||
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('')
|
||
}
|
||
|
||
await restoreDraft()
|
||
modalVisible.value = true
|
||
}
|
||
|
||
/** showViewModal is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const showViewModal = async (record: Shop | Record<string, any>) => {
|
||
Object.assign(viewFormState, {
|
||
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,
|
||
mapProvider: 'TENCENT',
|
||
longitude: 'longitude' in record ? record.longitude : (record as any).longitude,
|
||
latitude: 'latitude' in record ? record.latitude : (record as any).latitude,
|
||
businessHours: 'businessHours' in record ? record.businessHours : (record as any).businessHours,
|
||
status: 'status' in record ? (record.status ?? 1) : ((record as any).status ?? 1),
|
||
authorizationStartDate: 'authorizationStartDate' in record ? record.authorizationStartDate : (record as any).authorizationStartDate,
|
||
authorizationDays: 'authorizationDays' in record ? record.authorizationDays : (record as any).authorizationDays,
|
||
authorizationExpireTime: 'authorizationExpireTime' in record ? record.authorizationExpireTime : (record as any).authorizationExpireTime,
|
||
authorizationStatusText: 'authorizationStatusText' in record ? record.authorizationStatusText : (record as any).authorizationStatusText,
|
||
coverImageFileId: 'coverImageFileId' in record ? record.coverImageFileId : (record as any).coverImageFileId,
|
||
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
|
||
})
|
||
|
||
// 加载图片URL
|
||
const coverImageFileId = 'coverImageFileId' in record ? record.coverImageFileId : (record as any).coverImageFileId
|
||
const imageFileIds = 'imageFileIds' in record ? record.imageFileIds : (record as any).imageFileIds
|
||
viewBannerUrls.value = await resolveSignedImageUrls(coverImageFileId, DEFAULT_SHOP_IMAGE, false)
|
||
viewImageUrls.value = await resolveSignedImageUrls(imageFileIds, DEFAULT_SHOP_IMAGE, false)
|
||
|
||
viewModalVisible.value = true
|
||
}
|
||
|
||
/** handleViewModalCancel is a local helper used by this page script. */
|
||
const handleViewModalCancel = () => {
|
||
viewModalVisible.value = false
|
||
viewImageUrls.value = []
|
||
viewBannerUrls.value = []
|
||
}
|
||
|
||
/** cancelAllPendingUploads is a local helper used by this page script. */
|
||
const cancelAllPendingUploads = () => {
|
||
uploadTaskMap.forEach(task => task.cancel())
|
||
}
|
||
|
||
/** getDraftKey is a local helper used by this page script. */
|
||
const getDraftKey = () => buildDraftStorageKey('admin-shops', isEdit.value ? 'edit' : 'create', currentShop.value?.id ?? 'new')
|
||
|
||
/** buildDraftPayload is a local helper used by this page script. */
|
||
const buildDraftPayload = () => ({
|
||
formState: {
|
||
shopName: formState.shopName,
|
||
description: formState.description,
|
||
address: formState.address,
|
||
mapProvider: 'TENCENT',
|
||
longitude: formState.longitude,
|
||
latitude: formState.latitude,
|
||
businessHours: formState.businessHours,
|
||
status: formState.status,
|
||
authorizationStartDate: formState.authorizationStartDate,
|
||
authorizationDays: formState.authorizationDays,
|
||
authorizationExpireTime: formState.authorizationExpireTime,
|
||
coverImageFileId: formState.coverImageFileId,
|
||
imageFileIds: formState.imageFileIds,
|
||
themePrimaryColor: formState.themePrimaryColor,
|
||
themeSecondaryColor: formState.themeSecondaryColor,
|
||
themeAccentColor: formState.themeAccentColor,
|
||
themePageBgColor: formState.themePageBgColor,
|
||
themeCardBgColor: formState.themeCardBgColor,
|
||
themeBackgroundImageFileId: formState.themeBackgroundImageFileId
|
||
},
|
||
businessStartTime: businessStartTime.value,
|
||
businessEndTime: businessEndTime.value,
|
||
uploadedBannerIds: [...uploadedBannerIds.value],
|
||
uploadedFileIds: [...uploadedFileIds.value],
|
||
uploadedThemeBackgroundId: uploadedThemeBackgroundId.value
|
||
})
|
||
|
||
/** buildShopUploadFileList is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const buildShopUploadFileList = async (ids: string[], fileNamePrefix: string) => {
|
||
return buildAdminUploadFileList(ids, fileNamePrefix, DEFAULT_SHOP_IMAGE)
|
||
}
|
||
|
||
/** restoreDraft is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
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 || [])
|
||
syncUploadedThemeBackgroundId(draft.payload.uploadedThemeBackgroundId || '')
|
||
bannerFileList.value = await buildShopUploadFileList(uploadedBannerIds.value, 'Banner')
|
||
imageFileList.value = await buildShopUploadFileList(uploadedFileIds.value, '图片')
|
||
themeBackgroundFileList.value = uploadedThemeBackgroundId.value
|
||
? await buildShopUploadFileList([uploadedThemeBackgroundId.value], '背景图')
|
||
: []
|
||
draftSavedAt.value = draft.savedAt
|
||
message.success('已恢复暂存内容')
|
||
}
|
||
|
||
/** handleSaveDraft is a local helper used by this page script. */
|
||
const handleSaveDraft = () => {
|
||
if (isUploadPending.value) {
|
||
message.warning('图片上传完成后才能暂存')
|
||
return
|
||
}
|
||
const draft = saveDraftRecord(getDraftKey(), buildDraftPayload())
|
||
draftSavedAt.value = draft.savedAt
|
||
message.success('已暂存到本地')
|
||
}
|
||
|
||
/** handleClearDraft is a local helper used by this page script. */
|
||
const handleClearDraft = (showMessage = true) => {
|
||
clearDraftRecord(getDraftKey())
|
||
draftSavedAt.value = null
|
||
if (showMessage) {
|
||
message.success('已清除暂存')
|
||
}
|
||
}
|
||
|
||
/** syncUploadedBannerIds is a local helper used by this page script. */
|
||
const syncUploadedBannerIds = (fileIds: string[]) => {
|
||
uploadedBannerIds.value = Array.from(new Set(fileIds.filter(id => Boolean(id))))
|
||
formState.coverImageFileId = uploadedBannerIds.value.join(',')
|
||
}
|
||
|
||
/** syncUploadedFileIds is a local helper used by this page script. */
|
||
const syncUploadedFileIds = (fileIds: string[]) => {
|
||
uploadedFileIds.value = Array.from(new Set(fileIds.filter(id => Boolean(id))))
|
||
formState.imageFileIds = uploadedFileIds.value.join(',')
|
||
}
|
||
|
||
/** 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 = []
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const handleResetTheme = () => {
|
||
Object.assign(formState, {
|
||
themePrimaryColor: '',
|
||
themeSecondaryColor: '',
|
||
themeAccentColor: '',
|
||
themePageBgColor: '',
|
||
themeCardBgColor: '',
|
||
themeBackgroundImageFileId: ''
|
||
})
|
||
themeBackgroundFileList.value = []
|
||
syncUploadedThemeBackgroundId('')
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
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}」配色`)
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const openSaveThemeTemplate = () => {
|
||
themeTemplateName.value = formState.shopName ? `${formState.shopName}主题` : '我的配色模板'
|
||
themeTemplateSaveVisible.value = true
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const handleCancelSaveThemeTemplate = () => {
|
||
themeTemplateSaveVisible.value = false
|
||
themeTemplateName.value = ''
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
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 ? '已更新同名配色模板' : '已保存配色模板')
|
||
}
|
||
|
||
/**
|
||
* 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.
|
||
*/
|
||
const handleDeleteCustomThemeTemplate = (id: string) => {
|
||
customThemeTemplates.value = customThemeTemplates.value.filter(template => template.id !== id)
|
||
persistCustomThemeTemplates()
|
||
message.success('已删除配色模板')
|
||
}
|
||
|
||
/** getPreviewUrlFromFile is a local helper used by this page script. */
|
||
const getPreviewUrlFromFile = (file: AdminUploadFileLike) => {
|
||
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 ''
|
||
}
|
||
|
||
/** handleModalOk is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const handleModalOk = async () => {
|
||
try {
|
||
if (isUploadPending.value) {
|
||
message.warning('图片上传完成前不可提交')
|
||
return
|
||
}
|
||
syncBusinessHoursValue()
|
||
await formRef.value?.validate()
|
||
modalLoading.value = true
|
||
|
||
await runWithGlobalLoading(async () => {
|
||
if (isEdit.value && currentShop.value) {
|
||
await adminShopApi.updateShop(currentShop.value.id, {
|
||
...formState,
|
||
authorizationExpireTime: computedAuthorizationExpireTime.value
|
||
})
|
||
notifyShopThemeChanged()
|
||
message.success('更新成功')
|
||
} else {
|
||
await adminShopApi.createShop({
|
||
...formState,
|
||
authorizationExpireTime: computedAuthorizationExpireTime.value
|
||
})
|
||
message.success('创建成功')
|
||
}
|
||
|
||
handleClearDraft(false)
|
||
modalVisible.value = false
|
||
await fetchShopList()
|
||
})
|
||
} catch (error) {
|
||
console.error(error)
|
||
} finally {
|
||
modalLoading.value = false
|
||
}
|
||
}
|
||
|
||
/** handleModalCancel is a local helper used by this page script. */
|
||
const handleModalCancel = () => {
|
||
cancelAllPendingUploads()
|
||
modalVisible.value = false
|
||
formRef.value?.resetFields()
|
||
setBusinessHoursValue('')
|
||
bannerFileList.value = []
|
||
syncUploadedBannerIds([])
|
||
imageFileList.value = []
|
||
syncUploadedFileIds([])
|
||
themeBackgroundFileList.value = []
|
||
syncUploadedThemeBackgroundId('')
|
||
}
|
||
|
||
/** handleStatusChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||
const handleStatusChange = async (record: Shop | Record<string, any>, enabled: boolean) => {
|
||
try {
|
||
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 ? '启用' : '停用'}`)
|
||
})
|
||
} catch (error) {
|
||
message.error('店铺状态更新失败')
|
||
}
|
||
}
|
||
|
||
onMounted(async () => {
|
||
loadCustomThemeTemplates()
|
||
await loadUserPermissions()
|
||
fetchShopList()
|
||
})
|
||
</script>
|
||
|
||
<style scoped>
|
||
.shops {
|
||
padding: 0;
|
||
}
|
||
|
||
.shop-images {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
gap: 4px;
|
||
}
|
||
|
||
.shop-image-frame {
|
||
position: relative;
|
||
display: inline-grid;
|
||
width: 50px;
|
||
height: 50px;
|
||
place-items: center;
|
||
overflow: hidden;
|
||
border-radius: 4px;
|
||
background: var(--theme-primary-soft);
|
||
}
|
||
|
||
.shop-image-frame--banner {
|
||
width: 80px;
|
||
height: 40px;
|
||
}
|
||
|
||
.shop-image-frame :deep(.ant-spin) {
|
||
position: absolute;
|
||
z-index: 1;
|
||
}
|
||
|
||
.shop-table-image {
|
||
display: block;
|
||
object-fit: cover;
|
||
border-radius: 4px;
|
||
}
|
||
|
||
.shop-mobile-cover-frame {
|
||
position: relative;
|
||
}
|
||
|
||
.shop-mobile-cover-frame :deep(.ant-spin) {
|
||
position: absolute;
|
||
z-index: 1;
|
||
top: 50%;
|
||
left: 50%;
|
||
transform: translate(-50%, -50%);
|
||
}
|
||
|
||
.map-picker-card {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
padding: 10px 12px;
|
||
border: 1px solid var(--theme-border);
|
||
border-radius: 8px;
|
||
background: var(--theme-card-bg);
|
||
}
|
||
|
||
.map-picker-main {
|
||
min-width: 0;
|
||
flex: 1;
|
||
}
|
||
|
||
.map-picker-title {
|
||
color: var(--text-primary);
|
||
font-weight: 600;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.map-picker-subtitle {
|
||
margin-top: 4px;
|
||
color: var(--text-secondary);
|
||
font-size: 12px;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.map-picker-tip {
|
||
margin-top: 8px;
|
||
color: var(--text-secondary);
|
||
font-size: 12px;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.tencent-map-picker {
|
||
display: grid;
|
||
gap: 12px;
|
||
}
|
||
|
||
.tencent-map-picker__toolbar {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 16px;
|
||
}
|
||
|
||
.tencent-map-picker__toolbar p {
|
||
margin: 4px 0 0;
|
||
color: var(--text-secondary);
|
||
font-size: 13px;
|
||
}
|
||
|
||
.tencent-map-picker__frame {
|
||
width: 100%;
|
||
height: 520px;
|
||
border: 0;
|
||
border-radius: 8px;
|
||
background: var(--theme-primary-soft);
|
||
}
|
||
|
||
.shop-banner {
|
||
display: flex;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
gap: 4px;
|
||
}
|
||
|
||
.no-banner {
|
||
color: var(--text-secondary);
|
||
font-size: 12px;
|
||
}
|
||
|
||
.upload-tip {
|
||
color: var(--text-secondary);
|
||
font-size: 12px;
|
||
margin-bottom: 8px;
|
||
}
|
||
|
||
.upload-pending-tip {
|
||
color: #fa8c16;
|
||
font-size: 12px;
|
||
margin-top: 8px;
|
||
}
|
||
|
||
.business-hours-picker {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
width: 100%;
|
||
}
|
||
|
||
.business-hours-separator {
|
||
color: var(--text-secondary);
|
||
flex: 0 0 auto;
|
||
}
|
||
|
||
.theme-section {
|
||
margin: 8px 0 18px;
|
||
padding: 16px 18px;
|
||
border: 1px solid var(--theme-border);
|
||
border-radius: 8px;
|
||
background: var(--theme-primary-soft);
|
||
}
|
||
|
||
.theme-section__header {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
justify-content: space-between;
|
||
gap: 16px;
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
.theme-section__title {
|
||
color: var(--text-primary);
|
||
font-weight: 700;
|
||
}
|
||
|
||
.theme-section__desc {
|
||
margin-top: 4px;
|
||
color: var(--text-secondary);
|
||
font-size: 12px;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.theme-section__actions {
|
||
flex: 0 0 auto;
|
||
}
|
||
|
||
.theme-template-panel {
|
||
margin-bottom: 16px;
|
||
padding: 12px;
|
||
border: 1px solid var(--theme-border);
|
||
border-radius: 8px;
|
||
background: var(--theme-card-bg);
|
||
}
|
||
|
||
.theme-template-panel__header {
|
||
display: flex;
|
||
align-items: baseline;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
margin-bottom: 12px;
|
||
}
|
||
|
||
.theme-template-panel__header span {
|
||
color: var(--text-primary);
|
||
font-weight: 700;
|
||
}
|
||
|
||
.theme-template-panel__header small {
|
||
color: var(--text-secondary);
|
||
line-height: 1.5;
|
||
}
|
||
|
||
.theme-template-list {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
||
gap: 10px;
|
||
}
|
||
|
||
.theme-template-card {
|
||
position: relative;
|
||
min-height: 92px;
|
||
padding: 12px;
|
||
border: 1px solid var(--theme-border);
|
||
border-radius: 8px;
|
||
background: var(--theme-card-bg);
|
||
cursor: pointer;
|
||
transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
|
||
}
|
||
|
||
.theme-template-card:hover,
|
||
.theme-template-card:focus {
|
||
border-color: var(--theme-primary);
|
||
box-shadow: var(--theme-button-shadow);
|
||
outline: none;
|
||
transform: translateY(-1px);
|
||
}
|
||
|
||
.theme-template-card--active {
|
||
border-color: var(--theme-primary);
|
||
background: var(--theme-primary-soft);
|
||
box-shadow: var(--theme-focus-shadow);
|
||
}
|
||
|
||
.theme-template-card--custom {
|
||
padding-right: 54px;
|
||
}
|
||
|
||
.theme-template-card__top {
|
||
display: grid;
|
||
gap: 4px;
|
||
}
|
||
|
||
.theme-template-card__top strong {
|
||
color: var(--text-primary);
|
||
font-size: 13px;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.theme-template-card__top span {
|
||
color: var(--text-secondary);
|
||
font-size: 12px;
|
||
}
|
||
|
||
.theme-template-card__swatches {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 5px;
|
||
margin-top: 16px;
|
||
}
|
||
|
||
.theme-template-card__swatches span,
|
||
.theme-template-save-preview span {
|
||
width: 18px;
|
||
height: 18px;
|
||
border: 2px solid var(--theme-card-bg);
|
||
border-radius: 999px;
|
||
box-shadow: 0 0 0 1px var(--theme-border);
|
||
}
|
||
|
||
.theme-template-card__delete {
|
||
position: absolute;
|
||
top: 9px;
|
||
right: 9px;
|
||
height: 24px;
|
||
padding: 0 8px;
|
||
border: 1px solid var(--theme-border);
|
||
border-radius: 8px;
|
||
color: var(--theme-accent);
|
||
font-size: 12px;
|
||
background: var(--theme-primary-soft);
|
||
cursor: pointer;
|
||
}
|
||
|
||
.theme-template-card__delete:hover,
|
||
.theme-template-card__delete:focus {
|
||
border-color: var(--theme-primary);
|
||
color: var(--theme-primary);
|
||
outline: none;
|
||
}
|
||
|
||
.theme-template-save-form {
|
||
display: grid;
|
||
gap: 8px;
|
||
}
|
||
|
||
.theme-template-save-form label {
|
||
color: var(--text-primary);
|
||
font-weight: 600;
|
||
}
|
||
|
||
.theme-template-save-preview {
|
||
display: flex;
|
||
gap: 8px;
|
||
margin-top: 16px;
|
||
padding: 12px;
|
||
border: 1px solid var(--theme-border);
|
||
border-radius: 8px;
|
||
background: var(--theme-primary-soft);
|
||
}
|
||
|
||
.theme-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||
gap: 0 12px;
|
||
}
|
||
|
||
.theme-color-field {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
}
|
||
|
||
.theme-color-picker {
|
||
width: 42px;
|
||
height: 34px;
|
||
padding: 0;
|
||
border: 1px solid var(--theme-border);
|
||
border-radius: 8px;
|
||
background: var(--theme-card-bg);
|
||
}
|
||
|
||
.theme-preview {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 16px;
|
||
margin-top: 8px;
|
||
padding: 16px;
|
||
border: 1px solid;
|
||
border-radius: 8px;
|
||
}
|
||
|
||
.theme-preview strong,
|
||
.theme-preview p {
|
||
display: block;
|
||
margin: 4px 0 0;
|
||
}
|
||
|
||
.theme-preview p {
|
||
font-size: 12px;
|
||
opacity: .72;
|
||
}
|
||
|
||
.theme-preview__eyebrow {
|
||
display: block;
|
||
font-size: 12px;
|
||
font-weight: 700;
|
||
}
|
||
|
||
.theme-preview__button {
|
||
flex: 0 0 auto;
|
||
padding: 9px 16px;
|
||
border-radius: 999px;
|
||
font-weight: 700;
|
||
}
|
||
|
||
.theme-view-swatches {
|
||
display: flex;
|
||
gap: 8px;
|
||
}
|
||
|
||
.theme-view-swatches span {
|
||
width: 28px;
|
||
height: 28px;
|
||
border: 1px solid var(--theme-border);
|
||
border-radius: 999px;
|
||
}
|
||
|
||
@media (max-width: 768px) {
|
||
.theme-section__header,
|
||
.theme-template-panel__header {
|
||
align-items: stretch;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.theme-section__actions {
|
||
width: 100%;
|
||
}
|
||
|
||
.theme-grid {
|
||
grid-template-columns: 1fr;
|
||
}
|
||
}
|
||
</style>
|