Commit 438c61c1 authored by GuanHua's avatar GuanHua

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

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