Commit 9bf90d17 authored by GuanHua's avatar GuanHua

feat:无属性商品购买

parent e3e0109f
...@@ -189,12 +189,12 @@ const CommodityDetail = (props) => { ...@@ -189,12 +189,12 @@ const CommodityDetail = (props) => {
} }
} }
}, [selectAttrVal]) }, [selectAttrVal, commodityDetail])
const getCommodityPriceRange = () => { const getCommodityPriceRange = () => {
if (commodityDetail?.unitPriceAndPicList) { if (commodityDetail?.unitPriceAndPicList) {
for (let item of commodityDetail?.unitPriceAndPicList) { for (let item of commodityDetail?.unitPriceAndPicList) {
let temp = item.attributeAndValueList.map(attrItem => { let temp = item.attributeAndValueList.map(attrItem => {
return { return {
attrId: attrItem.customerAttribute.id, attrId: attrItem.customerAttribute.id,
...@@ -371,6 +371,11 @@ const CommodityDetail = (props) => { ...@@ -371,6 +371,11 @@ const CommodityDetail = (props) => {
} }
} }
const judegeImageExist = (list, pic) => {
return list.every(item => item.commodityPic !== pic.commodityPic)
}
/** /**
* 初始化商品详情数据 * 初始化商品详情数据
* @param unitPriceAndPicList * @param unitPriceAndPicList
...@@ -394,8 +399,10 @@ const CommodityDetail = (props) => { ...@@ -394,8 +399,10 @@ const CommodityDetail = (props) => {
commodityPic: picItem commodityPic: picItem
} }
}) })
if (!judegeImageExist(tempImgList, tempCommodityPic)) {
tempImgList = [...tempImgList, ...tempCommodityPic]
}
tempImgList = [...tempImgList, ...tempCommodityPic]
} }
for (let attrListItem of item.attributeAndValueList) { for (let attrListItem of item.attributeAndValueList) {
if (judgeAttrInList(tempAttrList, attrListItem.customerAttribute.id)) { if (judgeAttrInList(tempAttrList, attrListItem.customerAttribute.id)) {
...@@ -427,7 +434,7 @@ const CommodityDetail = (props) => { ...@@ -427,7 +434,7 @@ const CommodityDetail = (props) => {
} }
} }
setCurrentPriceRange(unitPriceAndPicList[0].unitPrice) setCurrentPriceRange(unitPriceAndPicList[0].unitPrice)
setStockCount(unitPriceAndPicList[0].stockCount) setStockCount(unitPriceAndPicList[0].stockCount || 200)
setCommodityImgList(tempImgList) setCommodityImgList(tempImgList)
setAttributeList(tempAttrList) 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