|
@@ -0,0 +1,223 @@
|
|
|
+import { useAjax } from "@/Hook/useAjax"
|
|
|
+import { CreateAdProps } from "@/services/launchAdq/createAd"
|
|
|
+import { BidModeEnum, BidStrategyEnum, OptimizationGoalEnum, PromotedObjectType, SiteSetEnum } from "@/services/launchAdq/enum"
|
|
|
+import { getSysAdgroupsInfo } from "@/services/launchAdq/localAd"
|
|
|
+import { getsysTargetingInfo } from "@/services/launchAdq/targeting"
|
|
|
+import { Card, Col, Empty, Row, Select, Space, Spin, Tooltip } from "antd"
|
|
|
+import React, { useEffect, useState } from "react"
|
|
|
+import { useModel } from "umi"
|
|
|
+import AdModal from "../../components/adModal"
|
|
|
+import TargetingModal from "../../components/targetingModal"
|
|
|
+import style from './index.less'
|
|
|
+import Selector from "./selector"
|
|
|
+
|
|
|
+const CreateAd: React.FC = () => {
|
|
|
+
|
|
|
+ /*************************/
|
|
|
+ const { getAdAccount } = useModel('useLaunchAdq.useAdAuthorize')
|
|
|
+ const [queryForm, setQueryForm] = useState<Partial<CreateAdProps>>({
|
|
|
+ campaignName: '',
|
|
|
+ campaignType: 'CAMPAIGN_TYPE_NORMAL', // 计划类型 CAMPAIGN_TYPE_NORMAL CAMPAIGN_TYPE_SEARCH
|
|
|
+ promotedObjectType: 'PROMOTED_OBJECT_TYPE_WECHAT_OFFICIAL_ACCOUNT', // 推广目标类型
|
|
|
+ speedMode: 'SPEED_MODE_STANDARD', // 投放速度模式
|
|
|
+ sysAdgroupsId: undefined, // 广告组内容
|
|
|
+ sysTargetingId: undefined, // 定向包 id
|
|
|
+ adName: undefined, // 广告名称
|
|
|
+ configuredStatus: 'AD_STATUS_SUSPEND', // 广告状态
|
|
|
+ sysAdcreativeId: undefined, // 创意ID
|
|
|
+ sysPageId: undefined, // 落地页Id
|
|
|
+ })
|
|
|
+ const [accountCreateLogs, setAccountCreateLogs] = useState<{ adAccountId: number, id: number, userActionSets?: number }[]>([]) // 账户
|
|
|
+
|
|
|
+ const [adVisible, setAdVisible] = useState<boolean>(false) // 选择广告弹窗控制
|
|
|
+ const [dxVisible, setDxVisible] = useState<boolean>(false) // 选择定向弹窗控制
|
|
|
+ const getSysAdgroups = useAjax((params) => getSysAdgroupsInfo(params))
|
|
|
+ const getsysTargeting = useAjax((params) => getsysTargetingInfo(params))
|
|
|
+ /*************************/
|
|
|
+
|
|
|
+ // 获取账户列表
|
|
|
+ useEffect(() => {
|
|
|
+ getAdAccount.run()
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ /** 获取广告详情 */
|
|
|
+ useEffect(() => {
|
|
|
+ if (queryForm?.sysAdgroupsId) {
|
|
|
+ getSysAdgroups.run(queryForm?.sysAdgroupsId)
|
|
|
+ }
|
|
|
+ }, [queryForm?.sysAdgroupsId])
|
|
|
+ /** 获取定向详情 */
|
|
|
+ useEffect(() => {
|
|
|
+ if (queryForm?.sysTargetingId) {
|
|
|
+ getsysTargeting.run(queryForm?.sysTargetingId)
|
|
|
+ }
|
|
|
+ }, [queryForm?.sysTargetingId])
|
|
|
+
|
|
|
+ console.log('==========>', accountCreateLogs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return <Card title={<div className={style.cardTitle}>配置区</div>} className={style.createAd} hoverable>
|
|
|
+ <Space>
|
|
|
+ <Selector label="媒体账户">
|
|
|
+ <Select
|
|
|
+ mode="multiple"
|
|
|
+ style={{ minWidth: 200 }}
|
|
|
+ placeholder="请选择媒体账户"
|
|
|
+ maxTagCount={1}
|
|
|
+ allowClear
|
|
|
+ bordered={false}
|
|
|
+ filterOption={(input: any, option: any) =>
|
|
|
+ (option!.children as unknown as string).toLowerCase().includes(input.toLowerCase())
|
|
|
+ }
|
|
|
+ onChange={(e, option) => {
|
|
|
+ setAccountCreateLogs(option?.map((item: any) => ({ adAccountId: item?.children, id: item?.value })))
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {getAdAccount?.data?.data?.map((item: any) => <Select.Option value={item.id} key={item.id}>{item.accountId}</Select.Option>)}
|
|
|
+ {/* <Select.OptGroup label="Engineer">
|
|
|
+ <Select.Option value="20632113">20632113</Select.Option>
|
|
|
+ </Select.OptGroup> */}
|
|
|
+ </Select>
|
|
|
+ </Selector>
|
|
|
+
|
|
|
+ <Selector label="推广目标">
|
|
|
+ <Select style={{ width: 200 }} value={queryForm?.promotedObjectType} placeholder="请选择推广目标" bordered={false} showSearch filterOption={(input: any, option: any) =>
|
|
|
+ (option!.children as unknown as string).toLowerCase().includes(input.toLowerCase())
|
|
|
+ } onChange={(e) => { setQueryForm({ ...queryForm, promotedObjectType: e }) }}>
|
|
|
+ {Object.keys(PromotedObjectType).map(key => {
|
|
|
+ return <Select.Option value={key} key={key}>{PromotedObjectType[key]}</Select.Option>
|
|
|
+ })}
|
|
|
+ </Select>
|
|
|
+ </Selector>
|
|
|
+ </Space>
|
|
|
+
|
|
|
+ <div className={style.cardBody}>
|
|
|
+ <Row className={style.content}>
|
|
|
+ <Col span={18} className={style.conLeft}>
|
|
|
+ <Row className={`${style.conTitle} ${style.conRightBorder}`}><Col span={24}>广告</Col></Row>
|
|
|
+ <Row className={style.items}>
|
|
|
+ {/* =============广告基本信息=========== */}
|
|
|
+ <Col span={6} className={style.conRightBorder}>
|
|
|
+ <div className={style.top}>广告基本信息</div>
|
|
|
+ <div className={style.center}>
|
|
|
+ <Spin spinning={getSysAdgroups.loading}>
|
|
|
+ <div className={style.centerContent}>
|
|
|
+ {getSysAdgroups?.data ? <>
|
|
|
+ <div>广告名称: {getSysAdgroups?.data?.adgroupName}</div>
|
|
|
+ <div>推广目标: {PromotedObjectType[getSysAdgroups?.data?.promotedObjectType]}</div>
|
|
|
+ <div>广告版位: {getSysAdgroups?.data?.siteSet?.map((item: string) => SiteSetEnum[item]).toString()}</div>
|
|
|
+ <div>投放日期: {getSysAdgroups?.data?.endDate ? getSysAdgroups?.data?.beginDate + '~' + getSysAdgroups?.data?.endDate : getSysAdgroups?.data?.beginDate + '~' + '长期投放'}</div>
|
|
|
+ <div>出价方式: {BidModeEnum[getSysAdgroups?.data?.bidMode]}</div>
|
|
|
+ <div>优化目标: {OptimizationGoalEnum[getSysAdgroups?.data?.optimizationGoal]}</div>
|
|
|
+ <div>出价类型: {getSysAdgroups?.data?.smartBidType === 'SMART_BID_TYPE_CUSTOM' ? '手动出价' : '自动出价'}</div>
|
|
|
+ <div>出价策略: {BidStrategyEnum[getSysAdgroups?.data?.bidStrategy]}</div>
|
|
|
+ <div>广告出价: {getSysAdgroups?.data?.bidAmount}</div>
|
|
|
+ <div>广告日预算: {getSysAdgroups?.data?.dailyBudget || '不限'}</div>
|
|
|
+ </> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />}
|
|
|
+ </div>
|
|
|
+ </Spin>
|
|
|
+ </div>
|
|
|
+ <div className={style.bottom}>
|
|
|
+ {queryForm?.promotedObjectType ? <span onClick={() => { setAdVisible(true) }}>{getSysAdgroups?.data ? '修改' : '添加'}</span> : <Tooltip title="请先选择推广目标">
|
|
|
+ <span>添加</span>
|
|
|
+ </Tooltip>}
|
|
|
+ </div>
|
|
|
+ </Col>
|
|
|
+ {/* =============定向包=========== */}
|
|
|
+ <Col span={6} className={style.conRightBorder}>
|
|
|
+ <div className={style.top}>
|
|
|
+ 定向{/* <span>已选:{1}</span> */}
|
|
|
+ </div>
|
|
|
+ <div className={style.center}>
|
|
|
+ <Spin spinning={getsysTargeting.loading}>
|
|
|
+ <div className={style.centerContent}>
|
|
|
+ {getsysTargeting?.data ? <>
|
|
|
+ <div>定向名称: {getsysTargeting?.data?.targetingName}</div>
|
|
|
+ <div>定向描述: {getsysTargeting?.data?.description}</div>
|
|
|
+ <div>定向描述: {getsysTargeting?.data?.description}</div>
|
|
|
+ </> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />}
|
|
|
+ </div>
|
|
|
+ </Spin>
|
|
|
+ </div>
|
|
|
+ <div className={style.bottom}><span onClick={() => { setDxVisible(true) }}>{getsysTargeting?.data ? '修改' : '添加'}</span></div>
|
|
|
+ </Col>
|
|
|
+ {/* =============商品=========== */}
|
|
|
+ <Col span={6} className={style.conRightBorder}>
|
|
|
+ <div className={style.top}>
|
|
|
+ 商品<span>已选:{1}</span>
|
|
|
+ </div>
|
|
|
+ <div className={style.center}>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <div className={style.bottom}>
|
|
|
+ {accountCreateLogs?.length > 0 ? <span onClick={() => { }}>添加</span> : <Tooltip title="请先选择媒体账户">
|
|
|
+ <span>添加</span>
|
|
|
+ </Tooltip>}
|
|
|
+ </div>
|
|
|
+ </Col>
|
|
|
+ {/* 数据源 */}
|
|
|
+ <Col span={6} className={style.conRightBorder}>
|
|
|
+ <div className={style.top}>
|
|
|
+ 数据源<span>已选:{1}</span>
|
|
|
+ </div>
|
|
|
+ <div className={style.center}>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <div className={style.bottom}>
|
|
|
+ {accountCreateLogs?.length > 0 ? <span onClick={() => { }}>添加</span> : <Tooltip title="请先选择媒体账户">
|
|
|
+ <span>添加</span>
|
|
|
+ </Tooltip>}
|
|
|
+ </div>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+ </Col>
|
|
|
+ {/* =============广告创意=========== */}
|
|
|
+ <Col span={6} className={style.conRight}>
|
|
|
+ <Row className={style.conTitle}><Col span={24}>广告创意</Col></Row>
|
|
|
+ <Row className={style.items}>
|
|
|
+ <Col span={24}>
|
|
|
+ <div className={style.top}>创意基本信息</div>
|
|
|
+ <div className={style.center}>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <div className={style.bottom}><span onClick={() => { }}>编辑</span></div>
|
|
|
+ </Col>
|
|
|
+ {/* <Col span={6}>
|
|
|
+ <div className={style.top}>创意素材<span>已选:0</span></div>
|
|
|
+ <div className={style.center}>
|
|
|
+ </div>
|
|
|
+ <div className={style.bottom}><span>添加</span></div>
|
|
|
+ </Col>
|
|
|
+ <Col span={6}>
|
|
|
+ <div className={style.top}>创意文案</div>
|
|
|
+ <div className={style.center}>
|
|
|
+ </div>
|
|
|
+ <div className={style.bottom}><span>添加</span></div>
|
|
|
+ </Col>
|
|
|
+ <Col span={6}>
|
|
|
+ <div className={style.top}>落地页<span>已选:0</span></div>
|
|
|
+ <div className={style.center}>
|
|
|
+ </div>
|
|
|
+ <div className={style.bottom}><span>添加</span></div>
|
|
|
+ </Col> */}
|
|
|
+ </Row>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+ {/* =============广告底部按钮=========== */}
|
|
|
+ {/* <Space className={style.bts}>
|
|
|
+ <Button type='primary' onClick={severBd}>暂存到本地</Button>
|
|
|
+ <Button type='primary' onClick={preview}><SearchOutlined /> 批量预览广告</Button>
|
|
|
+ <Button onClick={delBdPlan}>清空本地配置</Button>
|
|
|
+ </Space> */}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {/* 选择广告 */}
|
|
|
+ {adVisible && <AdModal visible={adVisible} onClose={() => setAdVisible(false)} promotedObjectType={queryForm.promotedObjectType as string} onChange={(e) => { setQueryForm({ ...queryForm, sysAdgroupsId: e }); setAdVisible(false) }} />}
|
|
|
+ {/* 选择定向 */}
|
|
|
+ {dxVisible && <TargetingModal visible={dxVisible} onClose={() => setDxVisible(false)} onChange={(e) => { setQueryForm({ ...queryForm, sysTargetingId: e }); setDxVisible(false) }} />}
|
|
|
+ </Card>
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+export default CreateAd
|