商品模板功能上传
This commit is contained in:
@@ -86,6 +86,11 @@ export const AROMA_TYPE_LABELS: Record<string, string> = {
|
||||
NONGXIANG: '浓香型',
|
||||
};
|
||||
|
||||
export const DETAIL_TEMPLATE_STATUS_LABELS: Record<string, string> = {
|
||||
ACTIVE: '启用',
|
||||
DISABLED: '停用',
|
||||
};
|
||||
|
||||
export const LEDGER_TYPE_LABELS: Record<string, string> = {
|
||||
GRANT: '发放',
|
||||
REDEEM: '核销',
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/** 商品详情页文案模板(Admin 一键套用) */
|
||||
export const TEMPLATE_MAX_DETAIL_IMAGES = 20;
|
||||
|
||||
export type ProductDetailTemplateContent = {
|
||||
storyTitle?: string;
|
||||
storyText?: string;
|
||||
features?: Array<{ icon: string; title: string; desc: string }>;
|
||||
/** 模板内置详情长图 URL 列表 */
|
||||
detailImageUrls?: string[];
|
||||
/** 建议详情长图张数(与 detailImageUrls 数量同步,供展示) */
|
||||
suggestedDetailImageCount?: number;
|
||||
};
|
||||
|
||||
export type ProductDetailTemplate = {
|
||||
id: string;
|
||||
code: string;
|
||||
label: string;
|
||||
description: string;
|
||||
aromaType?: string;
|
||||
content: ProductDetailTemplateContent;
|
||||
};
|
||||
|
||||
/** API 返回的详情模板 DTO(与 shared-types ProductDetailTemplateDto 对齐) */
|
||||
export type ProductDetailTemplateDto = {
|
||||
id: string;
|
||||
code: string;
|
||||
name: string;
|
||||
description?: string | null;
|
||||
aromaType?: string | null;
|
||||
storyTitle?: string | null;
|
||||
storyText?: string | null;
|
||||
features?: Array<{ icon: string; title: string; desc: string }>;
|
||||
detailImageUrls?: string[];
|
||||
suggestedDetailImageCount: number;
|
||||
sortOrder: number;
|
||||
status: 'ACTIVE' | 'DISABLED';
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export function mapDtoToProductDetailTemplate(dto: ProductDetailTemplateDto): ProductDetailTemplate {
|
||||
const detailImageUrls = (dto.detailImageUrls ?? []).filter(Boolean);
|
||||
return {
|
||||
id: dto.code,
|
||||
code: dto.code,
|
||||
label: dto.name,
|
||||
description: dto.description ?? '',
|
||||
aromaType: dto.aromaType ?? undefined,
|
||||
content: {
|
||||
storyTitle: dto.storyTitle ?? undefined,
|
||||
storyText: dto.storyText ?? undefined,
|
||||
features: dto.features ?? [],
|
||||
detailImageUrls,
|
||||
suggestedDetailImageCount: detailImageUrls.length || dto.suggestedDetailImageCount,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function getProductDetailTemplate(
|
||||
templates: ProductDetailTemplate[],
|
||||
code: string,
|
||||
) {
|
||||
return templates.find((t) => t.code === code || t.id === code);
|
||||
}
|
||||
Reference in New Issue
Block a user