diff --git a/.workbuddy/memory/2026-06-27.md b/.workbuddy/memory/2026-06-27.md new file mode 100644 index 0000000..6e9dce6 --- /dev/null +++ b/.workbuddy/memory/2026-06-27.md @@ -0,0 +1,9 @@ +# 2026-06-27 工作日志 + +## SKU选择器价格显示错误修复 +- **文件**: `src/components/business/SkuSelector/index.tsx` +- **问题**: 商品详情页价格显示 ¥1019,但点击"立即购买"后SKU弹窗显示 ¥2519 +- **根因**: `currentPrice` 计算式中 `salePrice` 优先级高于 `price`。ShopGoods 模型中 `price`=实际售价(1019),`salePrice`=市场/原价(2519)。当 SKU 未选中时回退到 product 级别,错误地优先取了 salePrice +- **修复**: + 1. 第190行: `currentPrice` 优先级改为 `selectedSku?.price || selectedSku?.salePrice || product?.price || product?.salePrice` + 2. 第160行: 单规格 fakeSku 的 price 字段同样修正为 `product.price || product.salePrice` diff --git a/src/components/business/SkuSelector/index.tsx b/src/components/business/SkuSelector/index.tsx index adbd7d8..e9c9ee0 100644 --- a/src/components/business/SkuSelector/index.tsx +++ b/src/components/business/SkuSelector/index.tsx @@ -157,7 +157,7 @@ const SkuSelector: React.FC = ({ const fakeSku: ShopGoodsSku = { id: 0, goodsId: product.goodsId!, - price: product.salePrice || product.price, + price: product.price || product.salePrice, salePrice: product.salePrice || product.price, stock: product.stock, image: product.image, @@ -187,7 +187,11 @@ const SkuSelector: React.FC = ({ } } - const currentPrice = selectedSku?.salePrice || selectedSku?.price || product?.salePrice || product?.price || '0' + // 价格优先级:SKU售价 > SKU原价 > 商品售价 > 商品原价 > 0 + // 注意:ShopGoods 模型中 price=商品价格(低), salePrice=销售/市场价(高) + // ShopGoodsSku 模型中 price=商品价格, salePrice=市场价格(高) + // 统一以 price 为准,salePrice 仅作兜底展示 + const currentPrice = selectedSku?.price || selectedSku?.salePrice || product?.price || product?.salePrice || '0' const currentStock = selectedSku?.stock ?? product?.stock ?? 0 const currentImage = selectedSku?.image || product?.image || (product?.files?.split(',')[0]) || ''