Commit 999b1347 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

🐞 fix(商家营销活动): 修复活动商品接口多次请求的问题

parent 18681003
......@@ -149,7 +149,7 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
setIdNotInList([...idNotInList, ...res.data.data.map(item => item.skuId)])
})
}
}, [activityId])
}, [!isEmpty(activityId)])
useEffect(() => {
handlesStFieldsValue()
......
import React, { useCallback, useState } from 'react';
import { Button, message, Form } from 'antd';
import { Button, Form } from 'antd';
import { history, Prompt } from 'umi';
import { useEventEmitter } from '@umijs/hooks';
import { Context } from '@/pages/transaction/components/detailLayout/components/context';
......@@ -35,8 +35,9 @@ const DetialLayout = () => {
const [form] = Form.useForm();
const [loading, setLoading] = useState<boolean>(false)
const [unsaved, setUnsaved] = useState<boolean>(false);
const [productList, setProductList] = useState<any[]>([]);
const [shopIdList, setShopIdList] = useState<number[]>([]);
const [signUpIds, setSignUpIds] = useState<number>();
const format = (text, fmt?: string) => {
return <>{moment(text).format(fmt || "YYYY-MM-DD HH:mm:ss")}</>
}
......@@ -77,7 +78,7 @@ const DetialLayout = () => {
}
}
const fetchDataSource = useCallback(async () => {
const fetchDataSource = async () => {
await PublicApi.getMarketingPlatformActivitySignupDetail({ activityId }).then((res: any) => {
if (res.code !== 1000) {
return
......@@ -94,21 +95,22 @@ const DetialLayout = () => {
})
})
data.externalLogStates = externalLogStates;
const option: any = {value: data.activityType};
const option: any = { value: data.activityType };
focus$.emit(option)
setDataSource(data);
handleBasicEffect(data);
setShopIdList(data.shopList.map(item => { return item.shopId }));
setActivityDefinedBO(data.activityDefinedBO)
handleGeneralEffect(data.activityDefinedBO, data.activityType)
setSignUpIds(signUpId)
}).catch(() => { })
}, [])
}
useEffect(() => {
fetchDataSource();
}, [])
const handleSubmit = useCallback(async () => {
const handleSubmit = () => {
form.validateFields().then(res => {
const param: any = {
activityId,
......@@ -149,7 +151,7 @@ const DetialLayout = () => {
setLoading(false)
})
})
}, [productList])
}
return (
<Context.Provider value={dataSource}>
......@@ -184,8 +186,7 @@ const DetialLayout = () => {
anchor="activityRuleLayout"
effect={generalEffect}
/>
{/* <ProductListLayout signUpId={signUpId !== 'null' && signUpId} data={dataSource} getDataSource={handleGetDataSoure} /> */}
<ProductListLayout getActivityDefinedBO={activityDefinedBO} activityId={signUpId && {signUpId: signUpId}} form={form} focus$={focus$} shopIdList={shopIdList} fieldApi={PublicApi.getMarketingPlatformActivitySignupDetailGoodsPage} />
<ProductListLayout getActivityDefinedBO={activityDefinedBO} activityId={signUpIds && { signUpId: signUpIds }} form={form} focus$={focus$} shopIdList={shopIdList} fieldApi={PublicApi.getMarketingPlatformActivitySignupDetailGoodsPage} />
<ActivityUserLayout dataScoure={dataSource} />
<DemandLayout storeList={dataSource.shopList} />
<RecordLyout />
......
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