Commit 21512abe authored by GuanHua's avatar GuanHua

feat:进货单推荐商品跳转

parent 517b09fb
...@@ -40,12 +40,23 @@ const Recommand: React.FC<RecommandPropsType> = (props) => { ...@@ -40,12 +40,23 @@ const Recommand: React.FC<RecommandPropsType> = (props) => {
break break
} }
} }
console.log(result, "result")
if (result.length <= 0) { if (result.length <= 0) {
getCategoryComponents() 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) => { const getListById = (categoryId: number) => {
return new Promise((resolve) => { return new Promise((resolve) => {
let param: any = { let param: any = {
...@@ -118,20 +129,20 @@ const Recommand: React.FC<RecommandPropsType> = (props) => { ...@@ -118,20 +129,20 @@ const Recommand: React.FC<RecommandPropsType> = (props) => {
const getCategoryComponents = async () => { const getCategoryComponents = async () => {
let firstCategory: any = await fetchFirstCategory() let firstCategory: any = await fetchFirstCategory()
let categoryDetail: any = await fetchCategoryById(firstCategory[0].id) let categoryDetail: any = await fetchCategoryById(firstCategory[0].id)
setList(categoryDetail.goodsBOList) setList(changeDataKey(categoryDetail.goodsBOList))
} }
const getCommodityDetailLink = (item) => { const getCommodityDetailLink = (item) => {
let link = "" let link = ""
switch (layoutType) { switch (layoutType) {
case LAYOUT_TYPE.channel: 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 break
case LAYOUT_TYPE.ichannel: 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 break
default: 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 break
} }
return link return link
...@@ -146,13 +157,13 @@ const Recommand: React.FC<RecommandPropsType> = (props) => { ...@@ -146,13 +157,13 @@ const Recommand: React.FC<RecommandPropsType> = (props) => {
<a href={getCommodityDetailLink(item)} key={`recommand_list_item_${index}`} target="_blank"> <a href={getCommodityDetailLink(item)} key={`recommand_list_item_${index}`} target="_blank">
<div className={styles.recommand_list_item}> <div className={styles.recommand_list_item}>
<div className={styles.recommand_list_item_img}> <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>
<div className={styles.recommand_list_item_price}> <div className={styles.recommand_list_item_price}>
<span></span> <span></span>
{priceFormat(item.goodsPrice)} {priceFormat(item.min)}
</div> </div>
<div className={styles.recommand_list_item_name}>{item.goodsName}</div> <div className={styles.recommand_list_item_name}>{item.name}</div>
</div> </div>
</a> </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