Commit 9bf90d17 authored by GuanHua's avatar GuanHua

feat:无属性商品购买

parent e3e0109f
......@@ -189,12 +189,12 @@ const CommodityDetail = (props) => {
}
}
}, [selectAttrVal])
}, [selectAttrVal, commodityDetail])
const getCommodityPriceRange = () => {
if (commodityDetail?.unitPriceAndPicList) {
for (let item of commodityDetail?.unitPriceAndPicList) {
let temp = item.attributeAndValueList.map(attrItem => {
return {
attrId: attrItem.customerAttribute.id,
......@@ -371,6 +371,11 @@ const CommodityDetail = (props) => {
}
}
const judegeImageExist = (list, pic) => {
return list.every(item => item.commodityPic !== pic.commodityPic)
}
/**
* 初始化商品详情数据
* @param unitPriceAndPicList
......@@ -394,8 +399,10 @@ const CommodityDetail = (props) => {
commodityPic: picItem
}
})
if (!judegeImageExist(tempImgList, tempCommodityPic)) {
tempImgList = [...tempImgList, ...tempCommodityPic]
}
tempImgList = [...tempImgList, ...tempCommodityPic]
}
for (let attrListItem of item.attributeAndValueList) {
if (judgeAttrInList(tempAttrList, attrListItem.customerAttribute.id)) {
......@@ -427,7 +434,7 @@ const CommodityDetail = (props) => {
}
}
setCurrentPriceRange(unitPriceAndPicList[0].unitPrice)
setStockCount(unitPriceAndPicList[0].stockCount)
setStockCount(unitPriceAndPicList[0].stockCount || 200)
setCommodityImgList(tempImgList)
setAttributeList(tempAttrList)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment