236 lines
6.4 KiB
TypeScript
236 lines
6.4 KiB
TypeScript
import { ClothesItem } from '../types/models'
|
||
import { ProcessStatus } from '../utils/config'
|
||
|
||
/**
|
||
* damo 示例素材(游客态唯一数据源)。
|
||
*
|
||
* 合规背景(微信审核整改):未登录用户必须能完整浏览与点击体验功能服务,
|
||
* 因此衣橱示例卡片可点开「示例衣物详情」,详情完全由本地数据渲染,零请求、只读。
|
||
*
|
||
* 素材来源:项目根目录 damo/damo.json 与 damo/image/(原图 1024×1024),
|
||
* 图片已压缩为 512px / quality 82 并复制到 miniprogram/damo/image/ 随包发布,
|
||
* 页面通过包内绝对路径引用(如 /damo/image/01_cream_sweater.jpg)。
|
||
*/
|
||
|
||
// 包内图片目录(绝对路径,结尾不带斜杠)
|
||
const DAMO_IMAGE = '/damo/image'
|
||
|
||
// 衣物属性:与 ClothesItem 除 uuid / 图片 / 处理状态之外的字段一一对应
|
||
interface DamoAttr {
|
||
category_main: string
|
||
category_sub: string
|
||
style: string
|
||
color_main: string
|
||
color_sub: string
|
||
thickness: string
|
||
version: string
|
||
material: string
|
||
pattern: string
|
||
sleeve_type: string
|
||
clothes_type: string
|
||
neckline_type: string
|
||
formality: string
|
||
occasions: string
|
||
visual_impact: string
|
||
name: string
|
||
remark: string
|
||
}
|
||
|
||
interface DamoRaw {
|
||
uuid: string
|
||
file: string
|
||
attr: DamoAttr
|
||
}
|
||
|
||
const DAMO_RAW: DamoRaw[] = [
|
||
{
|
||
uuid: 'damo-01',
|
||
file: '01_cream_sweater.jpg',
|
||
attr: {
|
||
category_main: '上装',
|
||
category_sub: '毛衣',
|
||
style: '休闲风',
|
||
color_main: '米色',
|
||
color_sub: '红色',
|
||
thickness: '厚',
|
||
version: '宽松',
|
||
material: '针织',
|
||
pattern: 'logo图案',
|
||
sleeve_type: '长袖',
|
||
clothes_type: '短款',
|
||
neckline_type: '圆领',
|
||
formality: '2',
|
||
occasions: '日常通勤,校园上课',
|
||
visual_impact: '3',
|
||
name: '米色圆领针织毛衣',
|
||
remark: '可见红色胸前图案。',
|
||
},
|
||
},
|
||
{
|
||
uuid: 'damo-02',
|
||
file: '02_ivory_strap_dress.jpg',
|
||
attr: {
|
||
category_main: '连衣裙',
|
||
category_sub: '吊带裙',
|
||
style: '优雅风',
|
||
color_main: '米色',
|
||
color_sub: '金色',
|
||
thickness: '适中',
|
||
version: '修身',
|
||
material: '',
|
||
pattern: '纯色',
|
||
sleeve_type: '吊带',
|
||
clothes_type: '短款',
|
||
neckline_type: '',
|
||
formality: '3',
|
||
occasions: '约会聚会',
|
||
visual_impact: '4',
|
||
name: '象牙白金扣吊带连衣短裙',
|
||
remark: '象牙白偏米色;胸部为心形领。',
|
||
},
|
||
},
|
||
{
|
||
uuid: 'damo-03',
|
||
file: '03_white_jk_blouse.jpg',
|
||
attr: {
|
||
category_main: '上装',
|
||
category_sub: '衬衫',
|
||
style: '学院风',
|
||
color_main: '白色',
|
||
color_sub: '藏青色',
|
||
thickness: '适中',
|
||
version: '常规合身',
|
||
material: '',
|
||
pattern: '条纹',
|
||
sleeve_type: '长袖',
|
||
clothes_type: '短款',
|
||
neckline_type: '翻领',
|
||
formality: '2',
|
||
occasions: '校园上课,约会聚会',
|
||
visual_impact: '4',
|
||
name: '白色长袖JK水手服上衣',
|
||
remark: '藏青领口及袖口配白条纹,另有酒红色蝴蝶结;水手领归入翻领。',
|
||
},
|
||
},
|
||
{
|
||
uuid: 'damo-04',
|
||
file: '04_pink_plaid_skirt.jpg',
|
||
attr: {
|
||
category_main: '下装',
|
||
category_sub: '半身裙',
|
||
style: '学院风',
|
||
color_main: '粉色',
|
||
color_sub: '黑色',
|
||
thickness: '适中',
|
||
version: '常规合身',
|
||
material: '',
|
||
pattern: '格纹',
|
||
sleeve_type: '',
|
||
clothes_type: '短款',
|
||
neckline_type: '',
|
||
formality: '2',
|
||
occasions: '校园上课,约会聚会',
|
||
visual_impact: '4',
|
||
name: '粉色格纹百褶短裙',
|
||
remark: '另有白色格纹;百褶A字廓形。',
|
||
},
|
||
},
|
||
{
|
||
uuid: 'damo-05',
|
||
file: '05_black_jk_blouse.jpg',
|
||
attr: {
|
||
category_main: '上装',
|
||
category_sub: '衬衫',
|
||
style: '学院风',
|
||
color_main: '黑色',
|
||
color_sub: '酒红色',
|
||
thickness: '适中',
|
||
version: '常规合身',
|
||
material: '',
|
||
pattern: '条纹',
|
||
sleeve_type: '短袖',
|
||
clothes_type: '常规',
|
||
neckline_type: '翻领',
|
||
formality: '2',
|
||
occasions: '校园上课,约会聚会',
|
||
visual_impact: '4',
|
||
name: '黑色短袖JK水手服上衣',
|
||
remark: '酒红色蝴蝶结,领口另有白条纹;水手领归入翻领。',
|
||
},
|
||
},
|
||
{
|
||
uuid: 'damo-06',
|
||
file: '06_navy_pleated_skirt.jpg',
|
||
attr: {
|
||
category_main: '下装',
|
||
category_sub: '半身裙',
|
||
style: '学院风',
|
||
color_main: '藏青色',
|
||
color_sub: '',
|
||
thickness: '适中',
|
||
version: '常规合身',
|
||
material: '',
|
||
pattern: '纯色',
|
||
sleeve_type: '',
|
||
clothes_type: '短款',
|
||
neckline_type: '',
|
||
formality: '2',
|
||
occasions: '校园上课,日常通勤',
|
||
visual_impact: '2',
|
||
name: '藏青色百褶半身裙',
|
||
remark: '',
|
||
},
|
||
},
|
||
{
|
||
uuid: 'damo-07',
|
||
file: '07_ivory_pearl_high_heels.jpg',
|
||
attr: {
|
||
category_main: '鞋',
|
||
category_sub: '高跟鞋',
|
||
style: '优雅风',
|
||
color_main: '米色',
|
||
color_sub: '银色',
|
||
thickness: '',
|
||
version: '',
|
||
material: '',
|
||
pattern: '纯色',
|
||
sleeve_type: '',
|
||
clothes_type: '',
|
||
neckline_type: '',
|
||
formality: '4',
|
||
occasions: '婚礼宴会,约会聚会',
|
||
visual_impact: '4',
|
||
name: '米白色珍珠踝链尖头细高跟鞋',
|
||
remark: '可见珍珠式踝链、银色链条和同色立体纹理。',
|
||
},
|
||
},
|
||
]
|
||
|
||
// 示例衣物:处理状态固定为成功,详情页据此直接渲染正常视图
|
||
export const DAMO_CLOTHES: ClothesItem[] = DAMO_RAW.map(
|
||
(it): ClothesItem => ({
|
||
...it.attr,
|
||
clothes_uuid: it.uuid,
|
||
processed_image: `${DAMO_IMAGE}/${it.file}`,
|
||
image_process_status: ProcessStatus.SUCCESS,
|
||
}),
|
||
)
|
||
|
||
const DAMO_MAP: Record<string, ClothesItem> = DAMO_CLOTHES.reduce(
|
||
(acc, it) => {
|
||
acc[it.clothes_uuid] = it
|
||
return acc
|
||
},
|
||
{} as Record<string, ClothesItem>,
|
||
)
|
||
|
||
// 按 uuid 取示例衣物:未命中返回 null,由调用方决定降级展示
|
||
export function findDamoClothes(uuid: string): ClothesItem | null {
|
||
return DAMO_MAP[uuid] || null
|
||
}
|
||
|
||
// 游客态唯一一套示例搭配(黑色短袖JK水手服上衣 + 藏青色百褶半身裙)
|
||
export const DAMO_OUTFIT_ITEMS: ClothesItem[] = ['damo-05', 'damo-06']
|
||
.map((uuid) => findDamoClothes(uuid))
|
||
.filter((it): it is ClothesItem => !!it)
|