Commit f54b2f9b authored by Bill's avatar Bill

feat: 对接新增活动页接口

parent 96e30ebb
...@@ -108,7 +108,7 @@ const router = [ ...@@ -108,7 +108,7 @@ const router = [
// }, // },
// ...routeList, // ...routeList,
// merchantMarketingRoute, // merchantMarketingRoute,
// marketingRoutes, marketingRoutes,
// platformCouponManageRoute, // platformCouponManageRoute,
...asyncRoutes, ...asyncRoutes,
// purchaseBidRoute, // purchaseBidRoute,
......
...@@ -12,6 +12,7 @@ import { ItodayAdd } from '../../common/interface' ...@@ -12,6 +12,7 @@ import { ItodayAdd } from '../../common/interface'
import useViewRequest from '../../common/hooks/useViewRequest'; import useViewRequest from '../../common/hooks/useViewRequest';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
import { GetReportPlatformHomeGetNewlyAddedDayReportResponse } from '@/services/reportApi'; import { GetReportPlatformHomeGetNewlyAddedDayReportResponse } from '@/services/reportApi';
import { priceFormat } from '@/utils/numberFomat'
interface Iprops {} interface Iprops {}
...@@ -21,7 +22,7 @@ const TodayAdd: React.FC<Iprops> = (props) => { ...@@ -21,7 +22,7 @@ const TodayAdd: React.FC<Iprops> = (props) => {
const list = useMemo(() => [ const list = useMemo(() => [
{ {
title: '今日新增订单(元)', title: '今日新增订单(元)',
number: responseData?.orderAmount, number: priceFormat(responseData?.orderAmount),
icon: orderIcon, icon: orderIcon,
percent: responseData?.orderGrowthRate || 0 percent: responseData?.orderGrowthRate || 0
}, },
......
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import React, { useState } from 'react'; import React, { useEffect, useState } from 'react';
import NiceForm from '@/components/NiceForm'; import NiceForm from '@/components/NiceForm';
import RangeTime from '@/components/RangeTime/FormilyRangeTime'; import RangeTime from '@/components/RangeTime/FormilyRangeTime';
import { Button, Space } from 'antd' import { Button, Space } from 'antd'
...@@ -8,18 +8,54 @@ import schema from './schema'; ...@@ -8,18 +8,54 @@ import schema from './schema';
import ReutrnEle from '@/components/ReturnEle'; import ReutrnEle from '@/components/ReturnEle';
import { history } from 'umi'; import { history } from 'umi';
import { BgColorsOutlined, SaveOutlined } from '@ant-design/icons'; import { BgColorsOutlined, SaveOutlined } from '@ant-design/icons';
import { createFormActions } from '@formily/antd'; import { FormEffectHooks, createFormActions, FormPath } from '@formily/antd'
import FormilyTemplateDrawer from '../components/TemplateDrawer/formilyTemplateDrawer'; import FormilyTemplateDrawer from '../components/TemplateDrawer/formilyTemplateDrawer';
const actions = createFormActions() import { PublicApi } from '@/services/api';
import { useLinkageUtils } from '@/utils/formEffectUtils';
const actions = createFormActions();
const { onFieldInputChange$, onFieldChange$ } = FormEffectHooks;
const Add = () => { const Add = () => {
const [initialValue, setInitialValue] = useState<any>(null);
const onSubmit = (values: any) => { const onSubmit = (values: any) => {
} }
useEffect(() => {
setInitialValue({
environment: 1,
mall: '34',
})
}, [])
useEffect(() => {
if (!initialValue) {
return ;
}
async function setMall() {
const data = await fetchMallData({environment: initialValue.environment} as any);
actions.setFieldState("mall", state => {
state.props.enum = data;
})
}
setMall()
}, [initialValue])
const fetchMallData = async (params: { shopType: number, environment: number}) => {
const data = [{label: '123', value: '34'}];
const data2 = [{ label: 'test', value: '1' }, { label: 'test1', value: '2' }]
return new Promise((resolve) => {
setTimeout(() => {
resolve(params.environment === 1 ? data : data2)
}, 1000)
})
}
return ( return (
<PageHeaderWrapper <PageHeaderWrapper
title="账户详情" title="新增活动页"
onBack={() => history.goBack()} onBack={() => history.goBack()}
backIcon={<ReutrnEle />} backIcon={<ReutrnEle />}
extra={ extra={
...@@ -36,13 +72,34 @@ const Add = () => { ...@@ -36,13 +72,34 @@ const Add = () => {
schema={schema} schema={schema}
actions={actions} actions={actions}
components={{RangeTime, FormilyTemplateDrawer}} components={{RangeTime, FormilyTemplateDrawer}}
value={{ effects={($, formAction) => {
template: { const linkage = useLinkageUtils()
id: 1, onFieldInputChange$('environment').subscribe((fieldState) => {
template: '嘻嘻嘻', const value = fieldState.value;
image: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201601%2F19%2F20160119142753_dB5a3.thumb.700_0.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1630132740&t=c7f669f0e84521b179cb6776f98ffccb' formAction.setFieldState('mall', state => {
} FormPath.setIn(state, 'props.x-props.hasFeedback', true)
})
linkage.loading('mall');
fetchMallData({environment: value} as any)
.then((data) => {
formAction.setFieldState("mall", state => {
state.originAsyncData = data;
state.value = "";
})
linkage.loaded("mall")
linkage.enum("mall", data);
})
});
}} }}
// value={{
// template: {
// id: 1,
// template: '嘻嘻嘻',
// image: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201601%2F19%2F20160119142753_dB5a3.thumb.700_0.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1630132740&t=c7f669f0e84521b179cb6776f98ffccb'
// }
// }}
value={initialValue}
/> />
</div> </div>
......
...@@ -28,7 +28,24 @@ const schema: ISchema = { ...@@ -28,7 +28,24 @@ const schema: ISchema = {
}, },
environment: { environment: {
type: 'string', type: 'string',
enum: [], enum: [
{
label: 'WEB',
value: 1,
},
{
label: 'H5',
value: 2,
},
{
label: '小程序',
value: 3,
},
{
label: 'APP',
value: 4,
}
],
title: '活动页使用环境', title: '活动页使用环境',
required: true, required: true,
}, },
......
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