Commit da845132 authored by GuanHua's avatar GuanHua

feat:商品详情图片的显示

parent 9127cbda
...@@ -80,7 +80,7 @@ const CommodityDetail = (props) => { ...@@ -80,7 +80,7 @@ const CommodityDetail = (props) => {
PublicApi.getSearchShopStoreGetCommodityDetail({ commodityId: id }).then(res => { PublicApi.getSearchShopStoreGetCommodityDetail({ commodityId: id }).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
setCommodityDetail(res.data) setCommodityDetail(res.data)
initAttributeAndValueList(res.data?.unitPriceAndPicList) initAttributeAndValueList(res.data)
getPayWayListByMemberId(res.data?.memberId) getPayWayListByMemberId(res.data?.memberId)
res.data?.isMemberPrice && getMemberCredit(res.data?.memberId, res.data?.memberRoleId) res.data?.isMemberPrice && getMemberCredit(res.data?.memberId, res.data?.memberRoleId)
} }
...@@ -301,18 +301,26 @@ const CommodityDetail = (props) => { ...@@ -301,18 +301,26 @@ const CommodityDetail = (props) => {
* 初始化商品详情数据 * 初始化商品详情数据
* @param unitPriceAndPicList * @param unitPriceAndPicList
*/ */
const initAttributeAndValueList = (unitPriceAndPicList: any) => { const initAttributeAndValueList = (dataInfo: any) => {
let tempAttrList = [] let unitPriceAndPicList = dataInfo?.unitPriceAndPicList
let tempImgList = []
if (!unitPriceAndPicList) { if (!unitPriceAndPicList) {
return return
} }
let tempAttrList = []
let tempImgList: any = [{
id: dataInfo.id,
commodityPic: dataInfo.mainPic
}]
for (let item of unitPriceAndPicList) { for (let item of unitPriceAndPicList) {
if (item.commodityPic) { if (item.commodityPic) {
tempImgList = [...tempImgList, { let tempCommodityPic = item.commodityPic.map((picItem, picIndex) => {
id: item.id, return {
commodityPic: item.commodityPic[0] id: `${item.id}-${picIndex}`,
}] commodityPic: picItem
}
})
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)) {
...@@ -343,7 +351,7 @@ const CommodityDetail = (props) => { ...@@ -343,7 +351,7 @@ const CommodityDetail = (props) => {
} }
} }
} }
console.log(tempImgList, "tempImgList")
setCurrentPriceRange(unitPriceAndPicList[0].unitPrice) setCurrentPriceRange(unitPriceAndPicList[0].unitPrice)
setStockCount(unitPriceAndPicList[0].stockCount || 2000) setStockCount(unitPriceAndPicList[0].stockCount || 2000)
setCommodityImgList(tempImgList) setCommodityImgList(tempImgList)
......
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