newCreateAd.tsx 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. import { Button, Form, Modal, Space, message } from "antd"
  2. import React, { useEffect, useState } from "react"
  3. import '../../index.less'
  4. import { defaultGameMarketingGoal, defaultMarketingGoal, defaultSiteSet } from "../../const"
  5. import AdgroupsMarketingContent from "./adgroupsMarketingContent"
  6. import AdgroupsSitSet from "./adgroupsSitSet"
  7. import AdgroupsPrice from "./adgroupsPrice"
  8. import AdgroupsAdSetting from "./adgroupsAdSetting"
  9. import moment from "moment"
  10. import { getTimeSeriesList } from "@/pages/launchSystemNew/adq/ad/const"
  11. export const DispatchAd = React.createContext<PULLIN.AdReactContent | null>(null);
  12. interface Props {
  13. putInType?: 'NOVEL' | 'GAME'
  14. value?: any,
  15. visible?: boolean
  16. onClose?: () => void
  17. onChange?: (value: any) => void
  18. }
  19. /**
  20. * 广告
  21. * @param param0
  22. * @returns
  23. */
  24. const NewCreateAd: React.FC<Props> = ({ value, visible, onChange, onClose, putInType }) => {
  25. /***********************************/
  26. const [form] = Form.useForm();
  27. // 深度优化副作用参数
  28. const [OGPParams, setOGPparams] = useState<PULLIN.OGPParamsProps>({ bidMode: 'BID_MODE_OCPM', siteSet: defaultSiteSet, automaticSiteEnabled: false, marketingGoal: putInType === 'NOVEL' ? defaultMarketingGoal : defaultGameMarketingGoal, marketingSubGoal: putInType === 'GAME' ? 'MARKETING_SUB_GOAL_MINI_GAME_NEW_CUSTOMER_GROWTH' : undefined })
  29. /***********************************/
  30. const handleOk = (values: any) => {
  31. if (["OPTIMIZATIONGOAL_FOLLOW", "OPTIMIZATIONGOAL_PAGE_SCAN_CODE"].includes(values?.optimizationGoal) && !values?.depthConversionEnabled) {
  32. message.error('应公司要求,”关注和加企微“请开启深度转化优化')
  33. return
  34. }
  35. const {
  36. wechatPositionType, // 微信公众号与小程序定投
  37. wechatChannelsSceneType, // 微信视频号定投
  38. wechatSceneType, // 微信公众号与小程序场景
  39. marketingTargetType, // 推广产品
  40. tencentNewsType,
  41. displaySceneType,
  42. date, // 开始时间 结束时间
  43. timeSeriesType, // 选择时段类型
  44. timeSeries, // 时段
  45. isSetfirstDayBeginTime, // 首日开始时间是否开启
  46. ...surplusValues
  47. } = values
  48. console.log(values)
  49. return
  50. let adgroupsValues: any = {
  51. ...surplusValues,
  52. beginDate: moment(date?.[0]).format('YYYY-MM-DD'),
  53. endDate: moment(date?.[1]).format('YYYY-MM-DD'),
  54. }
  55. if (marketingTargetType) {
  56. adgroupsValues.marketingAssetOuterSpec = {
  57. marketingTargetType
  58. }
  59. }
  60. // 投放时段处理
  61. if (timeSeriesType === '0') {
  62. adgroupsValues.timeSeries = Array(336).fill(1).join('');
  63. } else {
  64. adgroupsValues.timeSeries = timeSeries.join('');
  65. }
  66. Object.keys(adgroupsValues).forEach(key => {
  67. if (adgroupsValues[key] === undefined || adgroupsValues === null) {
  68. delete adgroupsValues[key]
  69. }
  70. })
  71. onChange?.(adgroupsValues)
  72. }
  73. // 数据回填
  74. useEffect(() => {
  75. if (value && Object.keys(value).length > 0) {
  76. const {
  77. firstDayBeginTime,
  78. timeSeries,
  79. beginDate,
  80. endDate,
  81. sceneSpec,
  82. marketingAssetOuterSpec,
  83. autoDerivedCreativeEnabled,
  84. ...surplusValues
  85. } = JSON.parse(JSON.stringify(value))
  86. let adgroupsValues: any = {
  87. ...surplusValues,
  88. sceneSpec,
  89. marketingTargetType: marketingAssetOuterSpec?.marketingTargetType,
  90. autoDerivedCreativeEnabled: autoDerivedCreativeEnabled ? true : false
  91. }
  92. // 首日开始时间
  93. if (firstDayBeginTime) {
  94. adgroupsValues.firstDayBeginTime = firstDayBeginTime
  95. adgroupsValues.isSetfirstDayBeginTime = true
  96. } else {
  97. adgroupsValues.isSetfirstDayBeginTime = false
  98. }
  99. // 时段
  100. if (timeSeries && timeSeries.includes('0')) {
  101. adgroupsValues.timeSeriesType = '2'
  102. } else {
  103. adgroupsValues.timeSeriesType = '0'
  104. }
  105. adgroupsValues.timeSeries = timeSeries?.split('') || getTimeSeriesList()
  106. // 投放时间
  107. adgroupsValues.date = [moment(beginDate), moment(endDate)]
  108. // 微信公众号与小程序定投
  109. if (sceneSpec?.wechatPosition?.length > 0) {
  110. adgroupsValues.wechatPositionType = '1'
  111. } else {
  112. adgroupsValues.wechatPositionType = '0'
  113. }
  114. // 微信视频号定投
  115. if (sceneSpec?.wechatChannelsScene?.length > 0) {
  116. adgroupsValues.wechatChannelsSceneType = '1'
  117. } else {
  118. adgroupsValues.wechatChannelsSceneType = '0'
  119. }
  120. // 微信公众号与小程序场景
  121. if (sceneSpec?.wechatScene && Object.keys(sceneSpec.wechatScene).length > 0) {
  122. adgroupsValues.wechatSceneType = '1'
  123. } else {
  124. adgroupsValues.wechatSceneType = '0'
  125. }
  126. // 腾讯新闻流量场景
  127. if (sceneSpec?.tencentNews && sceneSpec.tencentNews?.length > 0) {
  128. adgroupsValues.tencentNewsType = '1'
  129. } else {
  130. adgroupsValues.tencentNewsType = '0'
  131. }
  132. // 优量汇广告展示场景
  133. if (sceneSpec?.displayScene && sceneSpec.displayScene?.length > 0) {
  134. adgroupsValues.displaySceneType = '1'
  135. } else {
  136. adgroupsValues.displaySceneType = '0'
  137. }
  138. setOGPparams({
  139. bidMode: adgroupsValues.bidMode,
  140. siteSet: adgroupsValues.siteSet,
  141. automaticSiteEnabled: adgroupsValues.automaticSiteEnabled,
  142. marketingGoal: adgroupsValues.marketingGoal,
  143. marketingCarrierType: adgroupsValues?.marketingCarrierType,
  144. marketingTargetType: adgroupsValues?.marketingTargetType
  145. })
  146. form.setFieldsValue({ ...adgroupsValues })
  147. }
  148. }, [value])
  149. return <Modal
  150. title={<strong style={{ fontSize: 20 }}>广告的基本信息</strong>}
  151. open={visible}
  152. onCancel={onClose}
  153. footer={null}
  154. width={900}
  155. className={`modalResetCss`}
  156. bodyStyle={{ padding: '0 0 40px', position: 'relative', borderRadius: '0 0 8px 8px' }}
  157. maskClosable={false}
  158. >
  159. <Form
  160. form={form}
  161. name="newAd"
  162. labelAlign='left'
  163. layout="vertical"
  164. colon={false}
  165. style={{ backgroundColor: '#f1f4fc', maxHeight: 650, overflow: 'hidden', overflowY: 'auto', padding: '0 10px 10px', borderRadius: '0 0 8px 8px' }}
  166. scrollToFirstError={{
  167. behavior: 'smooth',
  168. block: 'center'
  169. }}
  170. onFinishFailed={({ errorFields }) => {
  171. message.error(errorFields?.[0]?.errors?.[0])
  172. }}
  173. onFinish={handleOk}
  174. initialValues={{
  175. marketingGoal: putInType === 'NOVEL' ? defaultMarketingGoal : putInType === 'GAME' ? defaultGameMarketingGoal : undefined,
  176. marketingSubGoal: putInType === 'GAME' ? 'MARKETING_SUB_GOAL_MINI_GAME_NEW_CUSTOMER_GROWTH' : undefined,
  177. automaticSiteEnabled: false,
  178. siteSet: defaultSiteSet,
  179. searchExpandTargetingSwitch: 'SEARCH_EXPAND_TARGETING_SWITCH_OPEN',
  180. bidMode: 'BID_MODE_OCPM',
  181. smartBidType: 'SMART_BID_TYPE_CUSTOM',
  182. optimizationGoal: 'OPTIMIZATIONGOAL_ECOMMERCE_ORDER',
  183. depthConversionEnabled: true,
  184. deepConversionSpec: {
  185. deepConversionType: 'DEEP_CONVERSION_WORTH'
  186. },
  187. // bidAmount: 1000,
  188. timeSeries: getTimeSeriesList(),
  189. autoAcquisitionEnabled: false,
  190. configuredStatus: 'AD_STATUS_SUSPEND',
  191. // adgroupName: '<营销目的>-<推广产品>-<日期>-<时分秒>',
  192. // marketingTargetType: 'MARKETING_TARGET_TYPE_FICTION'
  193. // 自定义字段
  194. date: [moment().startOf('day').add(7, 'day'), moment().startOf('day').add(20, 'day')],
  195. wechatPositionType: '0',
  196. wechatSceneType: '0',
  197. displaySceneType: '0',
  198. tencentNewsType: '0',
  199. wechatChannelsSceneType: '0',
  200. timeSeriesType: '0',
  201. isSetfirstDayBeginTime: false,
  202. autoDerivedCreativeEnabled: false,
  203. isConversion: false
  204. }}
  205. >
  206. <DispatchAd.Provider value={{ form, OGPParams, setOGPparams, putInType }}>
  207. <Space direction="vertical" style={{ width: '100%' }}>
  208. {/* 营销内容 */}
  209. <AdgroupsMarketingContent value={value} />
  210. {/* 广告版位 */}
  211. <AdgroupsSitSet />
  212. {/* 出价与预算 */}
  213. <AdgroupsPrice />
  214. {/* 广告设置 */}
  215. <AdgroupsAdSetting value={value} />
  216. </Space>
  217. </DispatchAd.Provider>
  218. <Form.Item className="submit_pull">
  219. <Space>
  220. <Button onClick={onClose}>取消</Button>
  221. <Button type="primary" htmlType="submit" className="modalResetCss">
  222. 确定
  223. </Button>
  224. </Space>
  225. </Form.Item>
  226. </Form>
  227. </Modal>
  228. }
  229. export default React.memo(NewCreateAd)