fix(sku-selector): 修正价格字段逻辑区分到手价和市场价
- 调整 fakeSku 中 price 和 salePrice 字段赋值,price 为实际到手价,salePrice 为划掉的市场价 - 更新 currentPrice 计算逻辑,优先显示实际到手价,避免弹窗误将市场价作为售价 - 添加注释说明价格字段的约定,明确 price 和 salePrice 的含义及使用场景
This commit is contained in:
@@ -157,8 +157,9 @@ const SkuSelector: React.FC<SkuSelectorProps> = ({
|
|||||||
const fakeSku: ShopGoodsSku = {
|
const fakeSku: ShopGoodsSku = {
|
||||||
id: 0,
|
id: 0,
|
||||||
goodsId: product.goodsId!,
|
goodsId: product.goodsId!,
|
||||||
price: product.salePrice || product.price,
|
// price 字段是到手价(主价格),salePrice 是划掉的"市场价"
|
||||||
salePrice: product.salePrice || product.price,
|
price: product.price,
|
||||||
|
salePrice: product.salePrice,
|
||||||
stock: product.stock,
|
stock: product.stock,
|
||||||
image: product.image,
|
image: product.image,
|
||||||
}
|
}
|
||||||
@@ -187,7 +188,11 @@ const SkuSelector: React.FC<SkuSelectorProps> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentPrice = selectedSku?.salePrice || selectedSku?.price || product?.salePrice || product?.price || '0'
|
// 价格字段约定:
|
||||||
|
// - product.salePrice / sku.salePrice : 划掉的"市场价"
|
||||||
|
// - product.price / sku.price : 实际"到手价"(详情页主价格)
|
||||||
|
// 弹窗应展示到手价,避免误把市场价当成售价
|
||||||
|
const currentPrice = selectedSku?.price || product?.price || selectedSku?.salePrice || product?.salePrice || '0'
|
||||||
const currentStock = selectedSku?.stock ?? product?.stock ?? 0
|
const currentStock = selectedSku?.stock ?? product?.stock ?? 0
|
||||||
const currentImage = selectedSku?.image || product?.image || (product?.files?.split(',')[0]) || ''
|
const currentImage = selectedSku?.image || product?.image || (product?.files?.split(',')[0]) || ''
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user