Commit d915cca5 authored by Bill's avatar Bill

fix: 修改首页refresh

parent c1d38475
......@@ -12,20 +12,16 @@ interface Iprops {
}
const AdvertisementContainer = () => {
const [loading, setLoading] = useState(false);
const [data, setData] = useState<any[]>([]);
const getList = (params) => {
setLoading(true);
PublicApi.getManageContentAdvertFindAllByColumnType(params)
.then(({data, code}) => {
setLoading(false);
if(code === 1000) {
useEffect(() => {
async function getList(params: { columnType: string }) {
const { data, code } = await PublicApi.getManageContentAdvertFindAllByColumnType(params);
if (code === 1000) {
setData(data);
}
})
}
useEffect(() => {
getList({columnType: 1})
}
getList({columnType: '1'})
}, [])
return (
......
......@@ -30,7 +30,7 @@ const isBusiness = [1, 2];
/** memberRoleType 是否是服务消费者 */
const isConsumer = 2;
const PurchaseCenter: React.FC<Iprops> = () => {
const { loading, responseData, filterEmptyList, isError, ref, inViewPort } = useViewRequest<GetReportMemberHomeGetPurchaseTallyResponse, any>(PublicApi.getReportMemberHomeGetPurchaseTally, {})
const { loading, responseData, filterEmptyList, isError, ref, inViewPort, refresh } = useViewRequest<GetReportMemberHomeGetPurchaseTallyResponse, any>(PublicApi.getReportMemberHomeGetPurchaseTally, {})
const auth = getAuth()
useEffect(() => {
......@@ -64,6 +64,7 @@ const PurchaseCenter: React.FC<Iprops> = () => {
}
loading={loading}
isError={isError}
onRefresh={refresh}
>
<Fragment>
{
......
......@@ -40,11 +40,15 @@ interface Iprops {
* 出错是的render方法
*/
customizeErrorRender?: (() => React.ReactElement )| null
// onRefresh: () => void
onRefresh?: (params: any) => void
};
const Layout: LayoutType & React.FC<Iprops> = (props) => {
const { title, tips, extra, children, loading, isError, customizeErrorRender, viewRef } = props;
const { title, tips, extra, children, loading, isError, customizeErrorRender, viewRef, onRefresh } = props;
const handleRefresh = () => {
onRefresh?.({})
}
const renderStatus = () => {
if (loading) {
......@@ -54,7 +58,7 @@ const Layout: LayoutType & React.FC<Iprops> = (props) => {
return (
customizeErrorRender?.() || (
<div>
<Button>拉取数据时发生了错误,点击刷新</Button>
<Button onClick={handleRefresh}>拉取数据时发生了错误,点击刷新</Button>
</div>
)
)
......@@ -165,7 +169,8 @@ Layout.defaultProps = {
tips: '',
extra: null,
isError: false,
customizeErrorRender: null
customizeErrorRender: null,
onRefresh: null
}
export default Layout;
......@@ -46,7 +46,7 @@ function useViewRequest<T, P>(fn: (postData: P) => Promise<ResponseDataType & {
}, [inViewPort])
const refresh = async <T1 extends P>(refreshParams: T1) => {
fetchData(refreshParams)
fetchData(refreshParams || params)
}
const filterEmptyList = useMemo(() => {
......
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