import { resolveFileUrl } from '@/utils/image' import { formatPrice } from '@/utils/format' const GOODS_PLACEHOLDER = '/static/logo.png' /** 列表卡片展示模型(首页热销 / 分类商品共用) */ export function mapGoodsCard(row) { if (!row) return null return { goodsId: row.goodsId, goodsSn: row.goodsSn, goodsName: row.goodsName, mainPic: row.mainPic, displayPic: resolveFileUrl(row.mainPic) || GOODS_PLACEHOLDER, salePrice: row.salePrice, priceText: formatPrice(row.salePrice), shopId: row.shopId, shopName: row.shopName } } export function mapGoodsCardList(list) { if (!Array.isArray(list)) return [] return list.map(mapGoodsCard).filter(Boolean) }