Commit 37562e6a authored by GuanHua's avatar GuanHua

fix: 商品详情库存修改为通过接口获取

parent 6e9f33e7
......@@ -50,7 +50,6 @@ const TradeRecord: React.FC<TradeRecordPropsType> = (props) => {
item.id = current * 10 + index
return item
})
console.log(result, "result")
setRecordList(result)
}
......
......@@ -366,12 +366,25 @@ const CommodityDetail = (props) => {
setSelectCommodityUnitPriceId(item.commodityUnitPriceAndPicId)
setCurrentPriceRange(sortUnitPrice(item.unitPrice))
setAttrAndValList(item)
setStockCount(item.stockCount)
getStockCountByProductId(item.id)
}
}
}
}
const getStockCountByProductId = (productId: number) => {
const param: any = {
productId,
shopId: storeId,
}
PublicApi.getWarehouseStockByProductId(param).then((res => {
if (res.code === 1000) {
setStockCount(res.data)
}
}))
}
const judgeArrisCommon = (list, otherList) => {
if (list.length === otherList.length) {
const result = list.every(listItem => {
......@@ -815,7 +828,6 @@ const CommodityDetail = (props) => {
})
})
try {
console.log(tempPriceRange, "tempPriceRange")
tempPriceRange = tempPriceRange.sort((a, b) => a.min > b.max ? 1: -1)
} catch (error) {
console.log(error)
......@@ -939,49 +951,6 @@ const CommodityDetail = (props) => {
return result[0]
}
/**
* 判断商品是否含有该属性
*/
const judgeHasAttr = (attrId: number, attrValId: number) => {
let result = true
const newSelectAttrVal = JSON.parse(JSON.stringify(selectAttrVal))
if (selectAttrVal.length > 0) {
// newSelectAttrVal.pop()
if (commodityDetail?.unitPricePicList) {
const tempList = []
for (const item of commodityDetail?.unitPricePicList) {
const temp = item.attributeAndValueList.map(attrItem => {
return {
attrId: attrItem.customerAttribute.id,
attrValId: attrItem.customerAttributeValue.id
}
})
if (judegeListInList(temp, newSelectAttrVal)) {
tempList.push(temp)
}
}
if (newSelectAttrVal.length <= attributeList.length && selectAttrVal[0].attrId === attrId) {
return true
}
result = tempList.some(item => item.some(childItem => childItem.attrId === attrId && childItem.attrValId === attrValId))
}
}
return result
}
/**
* 判断选的的数组是有在商品属性数组中
*/
const judegeListInList = (mainList, subList) => {
const result = subList.every(listItem => {
const subRes = mainList.some(item => {
return JSON.stringify(item) === JSON.stringify(listItem)
})
return subRes
})
return result
}
const checkItemInRang = (item) => {
if(Number(item.min) <= Number(buyCount) && Number(item.max) >= Number(buyCount)) {
return true
......@@ -1068,7 +1037,6 @@ const CommodityDetail = (props) => {
key={`product_info_line_list_item_${childItem.id}_${index}`}
className={cx(styles.product_info_line_list_item,
judgeSelectAttrInList(selectAttrVal, childItem.id, 'attrValId') ? styles.active : '',
// judgeHasAttr(item.customerAttribute.id, childItem.id) ? '' : styles.disabled
)}
onClick={() => handleSelectAttrVal(item.customerAttribute.id, childItem.id)} >
{
......
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