Commit 21512abe authored by GuanHua's avatar GuanHua

feat:进货单推荐商品跳转

parent 517b09fb
......@@ -40,12 +40,23 @@ const Recommand: React.FC<RecommandPropsType> = (props) => {
break
}
}
console.log(result, "result")
if (result.length <= 0) {
getCategoryComponents()
}
}
const changeDataKey = (data) => {
return data.map(item => {
item.id = item.goodsId
item.mainPic = item.goodsPicUrl
item.name = item.goodsName
item.min = item.goodsPrice
item.storeId = item.shopId
return item
})
}
const getListById = (categoryId: number) => {
return new Promise((resolve) => {
let param: any = {
......@@ -118,20 +129,20 @@ const Recommand: React.FC<RecommandPropsType> = (props) => {
const getCategoryComponents = async () => {
let firstCategory: any = await fetchFirstCategory()
let categoryDetail: any = await fetchCategoryById(firstCategory[0].id)
setList(categoryDetail.goodsBOList)
setList(changeDataKey(categoryDetail.goodsBOList))
}
const getCommodityDetailLink = (item) => {
let link = ""
switch (layoutType) {
case LAYOUT_TYPE.channel:
link = `/channelmall/commodity/detail?id=${item.goodsId}&channelId=${btoa(JSON.stringify({ shopId: item.shopId, memberId: item.memberId }))}`
link = `/channelmall/commodity/detail?id=${item.id}&channelId=${btoa(JSON.stringify({ shopId: item.storeId, memberId: item.memberId }))}`
break
case LAYOUT_TYPE.ichannel:
link = `/ichannelmall/commodity/detail?id=${item.goodsId}&channelId=${btoa(JSON.stringify({ shopId: item.shopId, memberId: item.memberId }))}`
link = `/ichannelmall/commodity/detail?id=${item.id}&channelId=${btoa(JSON.stringify({ shopId: item.storeId, memberId: item.memberId }))}`
break
default:
link = `/shop/commodity/detail?id=${item.goodsId}&shopId=${btoa(JSON.stringify({ shopId: item.shopId, memberId: item.memberId }))}`
link = `/shop/commodity/detail?id=${item.id}&shopId=${btoa(JSON.stringify({ shopId: item.storeId, memberId: item.memberId }))}`
break
}
return link
......@@ -146,13 +157,13 @@ const Recommand: React.FC<RecommandPropsType> = (props) => {
<a href={getCommodityDetailLink(item)} key={`recommand_list_item_${index}`} target="_blank">
<div className={styles.recommand_list_item}>
<div className={styles.recommand_list_item_img}>
<ImageBox width={224} height={224} imgUrl={item.goodsPicUrl} direction="column" />
<ImageBox width={224} height={224} imgUrl={item.mainPic} direction="column" />
</div>
<div className={styles.recommand_list_item_price}>
<span></span>
{priceFormat(item.goodsPrice)}
{priceFormat(item.min)}
</div>
<div className={styles.recommand_list_item_name}>{item.goodsName}</div>
<div className={styles.recommand_list_item_name}>{item.name}</div>
</div>
</a>
))
......
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