Commit 438c61c1 authored by GuanHua's avatar GuanHua

fix:无法创建渠道商城的问题

parent 7f349518
...@@ -143,7 +143,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -143,7 +143,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
message.error("店铺链接不能为空") message.error("店铺链接不能为空")
return return
} }
value.storeUrl = storeUrl value.storeUrl = storeUrl || `${siteUrl}/channelmall`
value.shopId = shopId value.shopId = shopId
setConfirmLoading(true) setConfirmLoading(true)
//@ts-ignore //@ts-ignore
...@@ -209,41 +209,56 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -209,41 +209,56 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
} }
const handleMallSelectChange = (mallId: number) => { const handleMallSelectChange = (mallId: number) => {
// let selectItem = allMallList.filter(item => item.id === mallId)
setShopId(mallId) setShopId(mallId)
if (shopInfo.shopId && shopInfo.memberId) { if (shopInfo.shopId && shopInfo.memberId) {
getMallItemAndSetUrl(mallId) let resUrl = getMallItemAndSetUrl(mallId)
setStoreUrl(resUrl)
} else { } else {
setStoreUrl(null) setStoreUrl(null)
} }
} }
const getMallItemAndSetUrl = (mallId) => { const getMallItemAndSetUrl = (mallId) => {
let result = ""
let mallItem = allMallList.filter(item => item.id === mallId)[0] let mallItem = allMallList.filter(item => item.id === mallId)[0]
if (mallItem.environment === 1) { if (mallItem.environment === 1) {
switch (mallItem.type) { switch (mallItem.type) {
case 3: case 3:
setStoreUrl(`${siteUrl}/channelmall?id=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`) result = `${siteUrl}/channelmall?id=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`
break break
case 4: case 4:
setStoreUrl(`${siteUrl}/channelmall?id=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`) result = `${siteUrl}/channelmall?id=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`
break break
case 5: case 5:
setStoreUrl(`${siteUrl}/channelmall/pointsMall?id=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`) result = `${siteUrl}/channelmall/pointsMall?id=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`
break break
default: default:
setStoreUrl(null) result = ""
break break
} }
} else { } else {
setStoreUrl(null) result = ""
} }
return result
} }
const handleFormValueChange = () => { const handleFormValueChange = () => {
setFormIsHalfFilledOut(true) setFormIsHalfFilledOut(true)
} }
const getSelectMallStoreUrl = () => {
if (shopId && shopInfo.shopId && shopInfo.memberId) {
let resUrl = getMallItemAndSetUrl(shopId)
return resUrl ? (
<div className={styles.shop_url}>
<span>当前店铺链接:</span>
<label>{resUrl}</label>
<CopyOutlined className={styles.copy_icon} onClick={() => handleCopyLinke(resUrl)} />
</div>
) : null
}
return null
}
return ( return (
<PageHeaderWrapper> <PageHeaderWrapper>
...@@ -352,7 +367,6 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -352,7 +367,6 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
labelAlign="left" labelAlign="left"
name="shopId" name="shopId"
label={<RequireItem label="店铺链接" />} label={<RequireItem label="店铺链接" />}
// rules={[{ required: true, message: "请输入客服链接" }]}
> >
<Select allowClear value={shopId} className={styles.form_item} onChange={handleMallSelectChange}> <Select allowClear value={shopId} className={styles.form_item} onChange={handleMallSelectChange}>
{ {
...@@ -362,13 +376,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -362,13 +376,7 @@ const ChannelInfo: React.FC<ShopInfoPropsType> = (props) => {
} }
</Select> </Select>
{ {
storeUrl && ( getSelectMallStoreUrl()
<div className={styles.shop_url}>
<span>当前店铺链接:</span>
<label>{storeUrl}</label>
<CopyOutlined className={styles.copy_icon} onClick={() => handleCopyLinke(storeUrl)} />
</div>
)
} }
</Form.Item> </Form.Item>
<Form.Item <Form.Item
......
...@@ -76,6 +76,9 @@ const CommodityDetail = (props) => { ...@@ -76,6 +76,9 @@ const CommodityDetail = (props) => {
fetchDetail() fetchDetail()
}, []) }, [])
/**
* 获取商品详情
*/
const fetchDetail = () => { const fetchDetail = () => {
PublicApi.getSearchShopStoreGetCommodityDetail({ commodityId: id }).then(res => { PublicApi.getSearchShopStoreGetCommodityDetail({ commodityId: id }).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
...@@ -87,6 +90,10 @@ const CommodityDetail = (props) => { ...@@ -87,6 +90,10 @@ const CommodityDetail = (props) => {
}) })
} }
/**
* 获取供货商的支付方式
* @param memberId
*/
const getPayWayListByMemberId = (memberId: number) => { const getPayWayListByMemberId = (memberId: number) => {
if (!memberId) { if (!memberId) {
return return
...@@ -99,6 +106,10 @@ const CommodityDetail = (props) => { ...@@ -99,6 +106,10 @@ const CommodityDetail = (props) => {
}) })
} }
/**
* 初始化支付方式
* @param data
*/
const initPayWayList = (data) => { const initPayWayList = (data) => {
if (!data) { if (!data) {
return [] return []
...@@ -138,6 +149,11 @@ const CommodityDetail = (props) => { ...@@ -138,6 +149,11 @@ const CommodityDetail = (props) => {
setPayWayList(result) setPayWayList(result)
} }
/**
* 获取会员权益餐宿
* @param memberId
* @param memberRoleId
*/
const getMemberCredit = (memberId, memberRoleId) => { const getMemberCredit = (memberId, memberRoleId) => {
let param = { let param = {
parentMemberId: memberId, parentMemberId: memberId,
...@@ -189,13 +205,15 @@ const CommodityDetail = (props) => { ...@@ -189,13 +205,15 @@ const CommodityDetail = (props) => {
return JSON.stringify(item) === JSON.stringify(listItem) return JSON.stringify(item) === JSON.stringify(listItem)
}) })
}) })
// console.log(result, "result")
return result return result
} else { } else {
return false return false
} }
} }
/**
* 加入进货单
*/
const handleAddToPurchase = () => { const handleAddToPurchase = () => {
if (!selectCommodityId) { if (!selectCommodityId) {
message.destroy() message.destroy()
...@@ -224,6 +242,9 @@ const CommodityDetail = (props) => { ...@@ -224,6 +242,9 @@ const CommodityDetail = (props) => {
} }
} }
/**
* 立即购买
*/
const handleToBuy = () => { const handleToBuy = () => {
if (!selectCommodityId) { if (!selectCommodityId) {
message.destroy() message.destroy()
...@@ -278,6 +299,9 @@ const CommodityDetail = (props) => { ...@@ -278,6 +299,9 @@ const CommodityDetail = (props) => {
} }
/**
* 根据条件渲染页面按钮
*/
const renderBtn = () => { const renderBtn = () => {
switch (commodityDetail?.priceType) { switch (commodityDetail?.priceType) {
case COMMODITY_TYPE.prompt: case COMMODITY_TYPE.prompt:
...@@ -312,6 +336,7 @@ const CommodityDetail = (props) => { ...@@ -312,6 +336,7 @@ const CommodityDetail = (props) => {
commodityPic: dataInfo.mainPic commodityPic: dataInfo.mainPic
}] }]
for (let item of unitPriceAndPicList) { for (let item of unitPriceAndPicList) {
// 初始化商品图片-》 商品主图加上商品属性图片
if (item.commodityPic) { if (item.commodityPic) {
let tempCommodityPic = item.commodityPic.map((picItem, picIndex) => { let tempCommodityPic = item.commodityPic.map((picItem, picIndex) => {
return { return {
...@@ -351,15 +376,17 @@ const CommodityDetail = (props) => { ...@@ -351,15 +376,17 @@ 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)
setAttributeList(tempAttrList) setAttributeList(tempAttrList)
} }
/**
* 设置当前选择的sku的价格区间
* @param uniPrice
*/
const setCurrentPriceRange = (uniPrice) => { const setCurrentPriceRange = (uniPrice) => {
// console.log(JSON.stringify(uniPrice), "item.unitPrice")
let initPriceRange = uniPrice let initPriceRange = uniPrice
let tempPriceRange = [] let tempPriceRange = []
Object.keys(initPriceRange).forEach((key) => { Object.keys(initPriceRange).forEach((key) => {
...@@ -441,12 +468,18 @@ const CommodityDetail = (props) => { ...@@ -441,12 +468,18 @@ const CommodityDetail = (props) => {
return unitPrice return unitPrice
} }
/**
* 获取合计金额
*/
const getAmount = () => { const getAmount = () => {
let unitPrice = getUnitPrice() let unitPrice = getUnitPrice()
let amount = unitPrice * (Number(buyCount) || 0) let amount = unitPrice * (Number(buyCount) || 0)
return priceFormat(amount) return priceFormat(amount)
} }
/**
* 获取金额区间中数量最大的区间
*/
const getMaxCountRange = () => { const getMaxCountRange = () => {
let maxItem: any = {} let maxItem: any = {}
for (let item of commodityPriceInfo) { for (let item of commodityPriceInfo) {
......
...@@ -60,6 +60,17 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -60,6 +60,17 @@ const Category: React.FC<CategoryPropsType> = (props) => {
} }
} }
const getBrandLink = (item) => {
switch (type) {
case LAYOUT_TYPE.shop:
return `/shop/commodity?brandId=${item.brandId}&brandName=${btoa(encodeURIComponent(item.brandName))}&shopId=${shopUrlParam}`
case LAYOUT_TYPE.channel:
return `/channelmall/commodity?brandId=${item.brandId}&brandName=${btoa(encodeURIComponent(item.brandName))}&id=${shopUrlParam}`
default:
return `/commodity?brandId=${item.brandId}&brandName=${btoa(encodeURIComponent(item.brandName))}`
}
}
return ( return (
<div className={styles.category}> <div className={styles.category}>
<div className={styles.category_type}> <div className={styles.category_type}>
...@@ -108,7 +119,7 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -108,7 +119,7 @@ const Category: React.FC<CategoryPropsType> = (props) => {
{ {
(item.brandBOList && item.brandBOList.length > 0) && item.brandBOList.map(brandItem => ( (item.brandBOList && item.brandBOList.length > 0) && item.brandBOList.map(brandItem => (
<div key={`category_advert_item_${brandItem.category_advert_item}`} className={styles.category_advert_item}> <div key={`category_advert_item_${brandItem.category_advert_item}`} className={styles.category_advert_item}>
<img src={brandItem.brandLogo} /> <Link to={getBrandLink(brandItem)}> <img src={brandItem.brandLogo} /></Link>
</div> </div>
)) ))
} }
......
...@@ -23,10 +23,9 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -23,10 +23,9 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const [categoryList, setCategoryList] = useState<any>([]) const [categoryList, setCategoryList] = useState<any>([])
const [lastCategoryId, setLastCategoryId] = useState<number>() const [lastCategoryId, setLastCategoryId] = useState<number>()
const [attributeList, setAttributeList] = useState<any>([]) const [attributeList, setAttributeList] = useState<any>([])
const [selectAttrbuteList, setSelectAttrbuteList] = useState<any>([])
useEffect(() => { useEffect(() => {
console.log(layoutType, "layoutType")
if (isEmpty(filterList)) { if (isEmpty(filterList)) {
setSelectedKeys([]) setSelectedKeys([])
} else { } else {
...@@ -64,7 +63,6 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -64,7 +63,6 @@ const Category: React.FC<CategoryPropsType> = (props) => {
break break
default: default:
break break
} }
getCategoryListFn && getCategoryListFn(param).then((res) => { getCategoryListFn && getCategoryListFn(param).then((res) => {
if (res.code === 1000) { if (res.code === 1000) {
...@@ -93,12 +91,30 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -93,12 +91,30 @@ const Category: React.FC<CategoryPropsType> = (props) => {
} }
getAttributeFn(param).then(res => { getAttributeFn(param).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
setAttributeList(initAttributeList(res.data))
} }
}) })
} }
}, [lastCategoryId]) }, [lastCategoryId])
const initAttributeList = (attrbuteList) => {
if (!attrbuteList) {
return []
}
return attrbuteList.map(item => {
return {
id: item.id,
name: item.name,
attributeValueList: item.attributeValueList ? item.attributeValueList.map(childItem => {
return {
label: childItem.value,
value: childItem.id
}
}) : []
}
})
}
const initTreeData = (list: any) => { const initTreeData = (list: any) => {
if (!list) { if (!list) {
...@@ -139,7 +155,6 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -139,7 +155,6 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const handleSelect = (selectedKeys, info) => { const handleSelect = (selectedKeys, info) => {
const { title, isLastNode, name } = info.node const { title, isLastNode, name } = info.node
console.log(info)
setSelectedKeys(selectedKeys) setSelectedKeys(selectedKeys)
if (isLastNode) { if (isLastNode) {
if (lastCategoryId !== selectedKeys[0]) { if (lastCategoryId !== selectedKeys[0]) {
...@@ -163,8 +178,32 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -163,8 +178,32 @@ const Category: React.FC<CategoryPropsType> = (props) => {
{ label: '自然摔纹', value: '3' }, { label: '自然摔纹', value: '3' },
]; ];
const handleChange = (e) => { // "customerAttributeList": [{
console.log(e) // "customerAttributeId": 1,
// "customerAttributeValueList": [{
// "id": 3
// }, {
// "id": 4
// }]
// }, {
// "customerAttributeId": 2,
// "customerAttributeValueList": [{
// "id": 5
// }, {
// "id": 6
// }]
// }]
const handleChange = (attrId, checkedList) => {
let tempItem = {
customerAttributeId: attrId,
customerAttributeValueList: checkedList.map(item => {
return {
id: item
}
})
}
console.log(tempItem, "tempItem")
} }
return ( return (
...@@ -183,15 +222,16 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -183,15 +222,16 @@ const Category: React.FC<CategoryPropsType> = (props) => {
</div> </div>
</FilterBox> </FilterBox>
{ {
showAttr && attributeList.length > 0 && ( showAttr && attributeList.length > 0 && attributeList.map((attrItem) => (
<FilterBox <FilterBox
title="风格" key={attrItem.id}
title={attrItem.name}
> >
<div className={styles.filter_style}> <div className={styles.filter_style}>
<CheckboxGroup options={styleOptions} onChange={handleChange} /> <CheckboxGroup options={attrItem.attributeValueList} onChange={(val) => handleChange(attrItem.id, val)} />
</div> </div>
</FilterBox> </FilterBox>
) ))
} }
</Fragment> </Fragment>
) )
......
...@@ -144,7 +144,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -144,7 +144,7 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
message.error("店铺链接不能为空") message.error("店铺链接不能为空")
return return
} }
value.storeUrl = storeUrl value.storeUrl = storeUrl || `${siteUrl}/shop`
value.shopId = shopId value.shopId = shopId
//@ts-ignore //@ts-ignore
PublicApi.postTemplateShopSaveShop(value).then(res => { PublicApi.postTemplateShopSaveShop(value).then(res => {
...@@ -210,35 +210,52 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -210,35 +210,52 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
// let selectItem = allMallList.filter(item => item.id === mallId) // let selectItem = allMallList.filter(item => item.id === mallId)
setShopId(mallId) setShopId(mallId)
if (shopInfo.shopId && shopInfo.memberId) { if (shopInfo.shopId && shopInfo.memberId) {
getMallItemAndSetUrl(mallId) let resUrl = getMallItemAndSetUrl(mallId)
setStoreUrl(resUrl)
} else { } else {
setStoreUrl(null) setStoreUrl(null)
} }
} }
const getMallItemAndSetUrl = (mallId) => { const getMallItemAndSetUrl = (mallId) => {
let result = ""
let mallItem = allMallList.filter(item => item.id === mallId)[0] let mallItem = allMallList.filter(item => item.id === mallId)[0]
if (mallItem.environment === 1) { if (mallItem.environment === 1) {
switch (mallItem.type) { switch (mallItem.type) {
case 1: case 1:
setStoreUrl(`${siteUrl}/shop?shopId=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`) result = `${siteUrl}/shop?shopId=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`
break break
case 2: case 2:
setStoreUrl(`${siteUrl}/shop/pointsMall?shopId=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`) result = `${siteUrl}/shop/pointsMall?shopId=${btoa(JSON.stringify({ shopId: shopInfo.shopId, memberId: shopInfo.memberId }))}`
break break
default: default:
setStoreUrl(null) result = ""
break break
} }
} else { } else {
setStoreUrl(null) result = ""
} }
return result
} }
const handleFormValueChange = () => { const handleFormValueChange = () => {
setFormIsHalfFilledOut(true) setFormIsHalfFilledOut(true)
} }
const getSelectMallStoreUrl = () => {
if (shopId && shopInfo.shopId && shopInfo.memberId) {
let resUrl = getMallItemAndSetUrl(shopId)
return resUrl ? (
<div className={styles.shop_url}>
<span>当前店铺链接:</span>
<label>{resUrl}</label>
<CopyOutlined className={styles.copy_icon} onClick={() => handleCopyLinke(resUrl)} />
</div>
) : null
}
return null
}
return ( return (
<PageHeaderWrapper> <PageHeaderWrapper>
<Prompt when={formIsHalfFilledOut} message="您还有未保存的内容,是否确定要离开?" /> <Prompt when={formIsHalfFilledOut} message="您还有未保存的内容,是否确定要离开?" />
...@@ -355,15 +372,8 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => { ...@@ -355,15 +372,8 @@ const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
} }
</Select> </Select>
{ {
storeUrl && ( getSelectMallStoreUrl()
<div className={styles.shop_url}>
<span>当前店铺链接:</span>
<label>{storeUrl}</label>
<CopyOutlined className={styles.copy_icon} onClick={() => handleCopyLinke(storeUrl)} />
</div>
)
} }
</Form.Item> </Form.Item>
<Form.Item <Form.Item
labelAlign="left" labelAlign="left"
......
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