|
@@ -1,13 +1,12 @@
|
|
|
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
|
import { Modal, Form, Input, Divider, Select, Radio, Switch, Spin, List, Checkbox, Space, Button, message, Image } from 'antd'
|
|
|
-import { SiteSetEnum, PromotedObjectType } from '@/services/launchAdq/enum'
|
|
|
import styles from './index.less'
|
|
|
import { useAjax } from '@/Hook/useAjax'
|
|
|
import { getText, get_adcreative_template, get_adcreative_template_list, get_tools_video_capture } from '@/services/launchAdq/global'
|
|
|
import { AdcreativeTemplate, AdcreativeTemplateList } from '@/services/launchAdq'
|
|
|
import { mySet } from '@/utils/arrFn'
|
|
|
import SelectCloud from '@/pages/launchSystemNew/components/selectCloud'
|
|
|
-import { useModel } from '@/.umi/plugin-model/useModel'
|
|
|
+import { useModel } from 'umi'
|
|
|
import { ModalConfig } from '../../ad';
|
|
|
import { outAdcreativeTemplateIdFun } from '../../../localAd/adenum'
|
|
|
import { CreateAdProps } from '@/services/launchAdq/createAd'
|
|
@@ -22,6 +21,7 @@ interface Props {
|
|
|
type?: 'add' | 'look' | 'edit',//新增,查看,编辑
|
|
|
dataInfo?: any
|
|
|
}
|
|
|
+const changgui = [311, 641, 642, 643, 618, 1465, 1064, 1480, 721]
|
|
|
/**创意模板*/
|
|
|
function CreativePup(props: Props) {
|
|
|
let { visible, confirmLoading, PupFn, callback, type, dataInfo, queryForm } = props
|
|
@@ -44,6 +44,8 @@ function CreativePup(props: Props) {
|
|
|
const [videoImgsVisbile, set_videoImgsVisbile] = useState(false)
|
|
|
const [descriptionShow, setdescriptionshow] = useState(false)
|
|
|
const [endPageDescShow, setendPageDescnshow] = useState(false)
|
|
|
+ const [isShowSc, set_isShowSc] = useState(false)//是否展示素材选项
|
|
|
+ const [infoSet, set_infoSet] = useState(false)//回填设置已完成
|
|
|
const [videoImgs, set_videoImgs] = useState<{//视频封面图设置
|
|
|
activeUrl: string,//选中的视频封面图地址
|
|
|
preview: boolean,//是否开启图片点击预览
|
|
@@ -96,7 +98,7 @@ function CreativePup(props: Props) {
|
|
|
let adcreativeTemplateId = Form.useWatch('adcreativeTemplateId', form)
|
|
|
let actionBtn = Form.useWatch('actionBtn', form)
|
|
|
// let siteSet = Form.useWatch('siteSet', form)
|
|
|
- // let promotedObjectType = Form.useWatch('promotedObjectType', form)
|
|
|
+ let overrideCanvasHeadOption = Form.useWatch('overrideCanvasHeadOption', form)
|
|
|
let adcreativeElementsType = Form.useWatch('adcreativeElementsType', form)
|
|
|
let dataShow = Form.useWatch('dataShow', form)
|
|
|
let conversionDataType = Form.useWatch('conversionDataType', form)
|
|
@@ -104,6 +106,7 @@ function CreativePup(props: Props) {
|
|
|
let description = Form.useWatch('description', form)
|
|
|
let videoOver = Form.useWatch('videoOver', form)
|
|
|
let endPageDesc = Form.useWatch('endPageDesc', form)
|
|
|
+ let linkPageType = Form.useWatch('linkPageType', form)
|
|
|
|
|
|
// 确定事件
|
|
|
const handleOk = useCallback(() => {
|
|
@@ -115,14 +118,14 @@ function CreativePup(props: Props) {
|
|
|
case 'image'://图素材
|
|
|
newValues.adcreativeElements = {
|
|
|
...newValues.adcreativeElements,
|
|
|
- imageUrl: imgMaterialConfig.list[0].url,
|
|
|
+ imageUrl: imgMaterialConfig?.list[0]?.url,
|
|
|
}
|
|
|
delete newValues[key]
|
|
|
break;
|
|
|
case 'video'://视频素材
|
|
|
newValues.adcreativeElements = {
|
|
|
...newValues.adcreativeElements,
|
|
|
- videoUrl: videoMaterialConfig.list[0].url,
|
|
|
+ videoUrl: videoMaterialConfig?.list[0]?.url,
|
|
|
}
|
|
|
delete newValues[key]
|
|
|
break;
|
|
@@ -136,7 +139,7 @@ function CreativePup(props: Props) {
|
|
|
case 'short_video1'://视频素材
|
|
|
newValues.adcreativeElements = {
|
|
|
shortVideoStruct: {
|
|
|
- shortVideo1Url: videoMaterialConfig.list[0].url
|
|
|
+ shortVideo1Url: videoMaterialConfig?.list[0]?.url
|
|
|
},
|
|
|
description: newValues.description,
|
|
|
}
|
|
@@ -158,21 +161,19 @@ function CreativePup(props: Props) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- delete newValues.description //删除外层文案
|
|
|
- delete newValues.title //删除外层文案
|
|
|
- delete newValues.adcreativeElementsType //删除创意形式
|
|
|
- delete newValues.dataShow //删除数据开关
|
|
|
- delete newValues.actionBtn //删除行动开关
|
|
|
- console.log('newValues=>2', newValues)
|
|
|
if (!newValues.adcreativeElements) {
|
|
|
newValues.adcreativeElements = {}
|
|
|
}
|
|
|
- if (newValues?.overrideCanvasHeadOption?.length === 0 || !newValues?.overrideCanvasHeadOption) {
|
|
|
- newValues.overrideCanvasHeadOption = 'OPTION_KEEP_DIFFERENT'
|
|
|
+ if ((newValues?.overrideCanvasHeadOption?.length === 0 || !newValues?.overrideCanvasHeadOption) && isShowSc) {//假如不存在选择素材替换,并且当前创意形式支持,那就传入默认
|
|
|
+ console.log('==============================')
|
|
|
+ newValues.overrideCanvasHeadOption = changgui?.some(i => i === newValues.adcreativeTemplateId) ? 'OPTION_CANVAS_OVERRIDE_CREATIVE' : 'OPTION_KEEP_DIFFERENT'
|
|
|
}
|
|
|
- if (newValues?.overrideCanvasHeadOption?.length === 1 && newValues?.overrideCanvasHeadOption[0] === 'OPTION_CREATIVE_OVERRIDE_CANVAS') {
|
|
|
+ if (newValues?.overrideCanvasHeadOption?.length === 1 && newValues?.overrideCanvasHeadOption[0] === 'OPTION_CREATIVE_OVERRIDE_CANVAS' && isShowSc) {//假如存在并手动勾选替换素材
|
|
|
newValues.overrideCanvasHeadOption = 'OPTION_CREATIVE_OVERRIDE_CANVAS'
|
|
|
}
|
|
|
+ if(Array.isArray(newValues?.overrideCanvasHeadOption)){//假如是数组,去除数组
|
|
|
+ newValues.overrideCanvasHeadOption = newValues.overrideCanvasHeadOption[0]
|
|
|
+ }
|
|
|
//假如不存在promotedObjectType
|
|
|
if (!newValues?.promotedObjectType) {
|
|
|
newValues['promotedObjectType'] = queryForm.promotedObjectType
|
|
@@ -181,20 +182,52 @@ function CreativePup(props: Props) {
|
|
|
if (!newValues?.siteSet) {
|
|
|
newValues['siteSet'] = queryForm.sysAdgroup.siteSet
|
|
|
}
|
|
|
+ delete newValues.description //删除外层文案
|
|
|
+ delete newValues.title //删除外层文案
|
|
|
+ delete newValues.adcreativeElementsType //删除创意形式
|
|
|
+ delete newValues.dataShow //删除数据开关
|
|
|
+ delete newValues.actionBtn //删除行动开关
|
|
|
+ console.log('newValues.overrideCanvasHeadOption ====>',newValues.overrideCanvasHeadOption )
|
|
|
+ // 假如使用了落地页顶部素材替换外部素材
|
|
|
+ if (newValues.overrideCanvasHeadOption === 'OPTION_CANVAS_OVERRIDE_CREATIVE') {
|
|
|
+ console.log(adcreative_template?.adcreativeElements)
|
|
|
+ adcreative_template?.adcreativeElements?.filter(item => item.required && item.name === 'image_list' || item.name === 'short_video1' || item.name === 'video' || item.name === 'image').forEach(item => {
|
|
|
+ switch (item.name) {
|
|
|
+ case 'image'://图素材
|
|
|
+ newValues.adcreativeElements = {
|
|
|
+ ...newValues.adcreativeElements,
|
|
|
+ imageUrl: '',
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'video'://视频素材
|
|
|
+ newValues.adcreativeElements = {
|
|
|
+ ...newValues.adcreativeElements,
|
|
|
+ videoUrl: '',
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'image_list'://图素材
|
|
|
+ newValues.adcreativeElements = {
|
|
|
+ ...newValues.adcreativeElements,
|
|
|
+ imageUrlList: [],
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'short_video1'://视频素材
|
|
|
+ newValues.adcreativeElements = {
|
|
|
+ ...newValues.adcreativeElements,
|
|
|
+ shortVideoStruct: {
|
|
|
+ shortVideo1Url: ''
|
|
|
+ },
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log('newValues=>2', newValues)
|
|
|
newValues['isTemplate'] = template_checked
|
|
|
// // 开启存为模板开关执行
|
|
|
- // if (template_checked && type === 'add') {
|
|
|
- // addSysAdgroup.run(newValues).then(res => {
|
|
|
- // if (res) {
|
|
|
- // callback(newValues)
|
|
|
- // }
|
|
|
- // })
|
|
|
- // } else {
|
|
|
callback(newValues)
|
|
|
- // }
|
|
|
})
|
|
|
- // PupFn({ visible: false })
|
|
|
- }, [form, imgMaterialConfig, videoMaterialConfig, queryForm, template_checked])
|
|
|
+ }, [form, imgMaterialConfig, videoMaterialConfig, queryForm, template_checked, adcreative_template, isShowSc])
|
|
|
// 获取创意形式列表
|
|
|
useEffect(() => {
|
|
|
if (siteSet?.length > 0 && promotedObjectType) {
|
|
@@ -208,10 +241,11 @@ function CreativePup(props: Props) {
|
|
|
if (!res) {
|
|
|
return
|
|
|
}
|
|
|
+ //
|
|
|
Object.values(res)?.forEach((arr: any) => {
|
|
|
Array.isArray(arr) && arr?.forEach((item: any) => {
|
|
|
- if (newArr.length > 0) {
|
|
|
- if (outAdcreativeTemplateIdFun(item.adcreativeTemplateId) && newArr.every((i: { adcreativeTemplateId: any }) => i.adcreativeTemplateId !== item.adcreativeTemplateId)) {
|
|
|
+ if (newArr.length > 0) {//假如已存在ID,需要过滤相同
|
|
|
+ if (outAdcreativeTemplateIdFun(item.adcreativeTemplateId) && newArr.every((i: { adcreativeTemplateId: any }) => i.adcreativeTemplateId !== item.adcreativeTemplateId)) {//不重复的添加
|
|
|
newArr.push(item)
|
|
|
} else {
|
|
|
// 找出通用创意
|
|
@@ -222,7 +256,7 @@ function CreativePup(props: Props) {
|
|
|
return arr
|
|
|
})
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else {//不存在ID直接过滤掉即将下线的
|
|
|
if (outAdcreativeTemplateIdFun(item.adcreativeTemplateId)) {
|
|
|
newArr.push(item)
|
|
|
}
|
|
@@ -235,6 +269,7 @@ function CreativePup(props: Props) {
|
|
|
}, [siteSet, promotedObjectType, form])
|
|
|
// 获取创意形式详情
|
|
|
useEffect(() => {
|
|
|
+ console.log('获取创意形式详情=====>', { siteSet, promotedObjectType, adcreativeTemplateId })
|
|
|
// CAMPAIGN_TYPE_NORMAL
|
|
|
if (siteSet?.length > 0 && promotedObjectType && adcreativeTemplateId) {
|
|
|
if (adcreativeTemplateId) {
|
|
@@ -245,6 +280,13 @@ function CreativePup(props: Props) {
|
|
|
}).then(res => {
|
|
|
if (res?.length > 0) {
|
|
|
set_adcreative_template(res[0])
|
|
|
+ if (siteSet?.some((name: string) => name === 'SITE_SET_MOMENTS')) {
|
|
|
+ if (res[0].unsupportSitesetDetailSpec?.length > 0) {
|
|
|
+ set_isShowSc(!res[0].unsupportSitesetDetailSpec[0].siteSet?.some((name: string) => name === "SITE_SET_MOMENTS"))
|
|
|
+ } else {
|
|
|
+ set_isShowSc(true)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -276,14 +318,19 @@ function CreativePup(props: Props) {
|
|
|
return null
|
|
|
}, [pageType, pageTypeList])
|
|
|
// 切换创意形式默认选中第一个
|
|
|
- useEffect(() => {
|
|
|
- // 设置默认选中第一个
|
|
|
+ // useEffect(() => {
|
|
|
+ // // 设置默认选中第一个
|
|
|
+ // if (adcreativeElementsType && adcreative_template_list?.length > 0 ) {
|
|
|
+ // let adcreativeTemplateIdArr = adcreative_template_list?.filter(item => item.adcreativeTemplateStyle === adcreativeElementsType)
|
|
|
+ // form.setFieldsValue({ adcreativeTemplateId: adcreativeTemplateIdArr[0].adcreativeTemplateId })
|
|
|
+ // }
|
|
|
+ // }, [adcreativeElementsType, adcreative_template_list])
|
|
|
+ const typeChange = useCallback((adcreativeElementsType) => {
|
|
|
if (adcreativeElementsType && adcreative_template_list?.length > 0) {
|
|
|
let adcreativeTemplateIdArr = adcreative_template_list?.filter(item => item.adcreativeTemplateStyle === adcreativeElementsType)
|
|
|
form.setFieldsValue({ adcreativeTemplateId: adcreativeTemplateIdArr[0].adcreativeTemplateId })
|
|
|
}
|
|
|
- }, [adcreativeElementsType, adcreative_template_list])
|
|
|
-
|
|
|
+ }, [adcreative_template_list])
|
|
|
|
|
|
//每次选中创意设置该展示的界面
|
|
|
useEffect(() => {
|
|
@@ -320,10 +367,11 @@ function CreativePup(props: Props) {
|
|
|
if (states.xd_show) {
|
|
|
let linkNameList = (pageList?.filter((item: { pageType: any; }) => item.pageType === pageType)[0] as any)?.supportLinkNameType?.list
|
|
|
let linkPageList = (pageList?.filter((item: { pageType: any; }) => item.pageType === pageType)[0] as any)?.supportLinkPageType?.list
|
|
|
- if (linkNameList) {
|
|
|
+ if (linkNameList && !linkPageType) {
|
|
|
let linkNameType = linkNameList[0]?.linkNameType
|
|
|
let linkPageType = linkPageList[0]?.linkPageType
|
|
|
- values = { ...values, linkNameType, linkPageType }
|
|
|
+ values = { ...values, linkNameType, linkPageType, actionBtn: true }
|
|
|
+
|
|
|
} else {
|
|
|
states = { ...states, xd_show: false }
|
|
|
}
|
|
@@ -377,8 +425,8 @@ function CreativePup(props: Props) {
|
|
|
}, [])
|
|
|
// 数据回填
|
|
|
useEffect(() => {
|
|
|
- if (dataInfo && adcreative_template_list?.length > 0 && adcreative_template) {
|
|
|
- let { adcreativeName, adcreativeTemplateId, conversionDataType, conversionTargetType, linkNameType, linkPageType, pageType, promotedObjectType, siteSet, adcreativeElements } = dataInfo
|
|
|
+ if (!infoSet && dataInfo && adcreative_template_list?.length > 0) {
|
|
|
+ let { adcreativeName, adcreativeTemplateId, conversionDataType, conversionTargetType, linkNameType, linkPageType, pageType, promotedObjectType, siteSet, adcreativeElements, overrideCanvasHeadOption } = dataInfo
|
|
|
let { description, imageUrl, title, videoUrl, imageUrlList, endPage, shortVideoStruct } = adcreativeElements
|
|
|
let obj: any = {
|
|
|
adcreativeName,
|
|
@@ -415,6 +463,9 @@ function CreativePup(props: Props) {
|
|
|
if (endPage) {
|
|
|
obj = { ...obj, videoOver: true, ...endPage }
|
|
|
}
|
|
|
+ if (overrideCanvasHeadOption) {
|
|
|
+ obj = { ...obj, overrideCanvasHeadOption: [overrideCanvasHeadOption] }
|
|
|
+ }
|
|
|
if (videoUrl) {
|
|
|
setVideoMaterialConfig({
|
|
|
cloudSize: [],
|
|
@@ -455,12 +506,13 @@ function CreativePup(props: Props) {
|
|
|
})
|
|
|
obj = { ...obj, short_video1: shortVideoStruct.shortVideo1Url }
|
|
|
}
|
|
|
+ console.log('数据回填====>', obj)
|
|
|
form.setFieldsValue(obj)
|
|
|
+ set_infoSet(true)
|
|
|
}
|
|
|
- }, [dataInfo, adcreative_template_list, adcreative_template])
|
|
|
+ }, [dataInfo, adcreative_template_list, adcreative_template, infoSet])
|
|
|
// 生成视频封面图
|
|
|
const videoToImgs = useCallback(() => {
|
|
|
-
|
|
|
if (videoMaterialConfig.list[0]) {
|
|
|
set_videoImgsVisbile(true)
|
|
|
// let url = videoMaterialConfig.list[0].url
|
|
@@ -506,7 +558,7 @@ function CreativePup(props: Props) {
|
|
|
adcreativeElementsType: '视频',
|
|
|
// promotedObjectType:queryForm?.promotedObjectType,
|
|
|
// siteSet:queryForm?.sysAdgroup?.siteSet,
|
|
|
- // overrideCanvasHeadOption:['OPTION_KEEP_DIFFERENT'],//默认'自定义广告创意素材,和原生推广页顶部素材保持两者不同,(仅支持朋友圈非常规创意形式)'
|
|
|
+ overrideCanvasHeadOption: [],//默认'自定义广告创意素材,和原生推广页顶部素材保持两者不同,(仅支持朋友圈非常规创意形式)'
|
|
|
// actionBtn: false,//行动按钮
|
|
|
// dataShow: false,//数据展示
|
|
|
}
|
|
@@ -544,7 +596,10 @@ function CreativePup(props: Props) {
|
|
|
<Divider orientation='center'>创意形式</Divider>
|
|
|
{/* ============================================================创意形式============================================================= */}
|
|
|
<Form.Item label={<strong>创意形式</strong>} name='adcreativeElementsType'>
|
|
|
- <Radio.Group >
|
|
|
+ <Radio.Group onChange={(e) => {
|
|
|
+ let value = e.target.value
|
|
|
+ typeChange(value)
|
|
|
+ }}>
|
|
|
<Radio.Button value="视频">视频</Radio.Button>
|
|
|
<Radio.Button value="图片">图片</Radio.Button>
|
|
|
</Radio.Group>
|
|
@@ -572,8 +627,8 @@ function CreativePup(props: Props) {
|
|
|
{/* ============================================================创意内容============================================================= */}
|
|
|
<Divider orientation='center'>创意内容</Divider>
|
|
|
{/* ============================================================素材============================================================= */}
|
|
|
- {/* 优先展示视频或图片 */}
|
|
|
- <div style={{ display: 'flex', flexFlow: 'column' }}>
|
|
|
+ {/* 优先展示视频或图片,朋友圈常规不勾选使用外部素材替换内部,隐藏此选项,后期自动将落地页顶部素材添加进入 */}
|
|
|
+ {((Array.isArray(overrideCanvasHeadOption) && overrideCanvasHeadOption[0] === 'OPTION_CREATIVE_OVERRIDE_CANVAS') || !changgui.some(i => i === adcreative_template?.adcreativeTemplateId)) && <div style={{ display: 'flex', flexFlow: 'column' }}>
|
|
|
{
|
|
|
adcreative_template?.adcreativeElements?.filter(item => item.required && item.name === 'image_list' || item.name === 'short_video1' || item.name === 'video' || item.name === 'image').map(item => {
|
|
|
return <Form.Item label={<strong>{item.description === '图片' && adcreative_template?.adcreativeElements?.some(item => item.name === 'video') ? '视频封面图' : item.description}</strong>} rules={[{ required: true, message: '请选择素材!' }]} key={item.name} name={item.name} style={item.description === '图片' && adcreative_template?.adcreativeElements?.some(item => item.name === 'video') ? { order: 2 } : {}}>
|
|
@@ -660,7 +715,7 @@ function CreativePup(props: Props) {
|
|
|
</Form.Item>
|
|
|
})
|
|
|
}
|
|
|
- </div>
|
|
|
+ </div>}
|
|
|
|
|
|
{/* 标题 */}
|
|
|
{
|
|
@@ -749,7 +804,8 @@ function CreativePup(props: Props) {
|
|
|
</Radio.Group>
|
|
|
</Form.Item>
|
|
|
{
|
|
|
- pageType === 'PAGE_TYPE_CANVAS_WECHAT' && <Form.Item label={<strong>素材选项</strong>} name='overrideCanvasHeadOption'>
|
|
|
+ pageType === 'PAGE_TYPE_CANVAS_WECHAT' && isShowSc && <Form.Item label={<strong>素材选项</strong>} name='overrideCanvasHeadOption'>
|
|
|
+ {/* disabled={changgui?.some((i: any) => i == adcreative_template?.adcreativeTemplateId)} */}
|
|
|
<Checkbox.Group options={[{ label: '使用外层创意素材替换原生推广页顶部素材', value: 'OPTION_CREATIVE_OVERRIDE_CANVAS' }]} />
|
|
|
</Form.Item>
|
|
|
}
|
|
@@ -778,10 +834,10 @@ function CreativePup(props: Props) {
|
|
|
<div style={{ display: 'flex' }}>
|
|
|
<p style={{ marginBottom: 5, marginLeft: 177 }}><strong style={{ marginRight: 20 }}>跳转落地页</strong></p>
|
|
|
<Form.Item name='linkPageType'>
|
|
|
- <Radio.Group>
|
|
|
+ <Radio.Group style={{ display: 'flex' }}>
|
|
|
{
|
|
|
linkPageList?.map((item: { linkPageType: string; description: string; }, index: number) => {
|
|
|
- return <Radio.Button value={item.linkPageType} key={item.linkPageType}>{item.description}</Radio.Button>
|
|
|
+ return <Radio.Button value={item.linkPageType} key={item.linkPageType} >{item.description}</Radio.Button>
|
|
|
})
|
|
|
}
|
|
|
</Radio.Group>
|
|
@@ -882,7 +938,9 @@ function CreativePup(props: Props) {
|
|
|
{
|
|
|
selectImgVisible && <SelectCloud
|
|
|
visible={selectImgVisible}
|
|
|
- onClose={() => set_selectImgVisible(false)}
|
|
|
+ onClose={() => {
|
|
|
+ set_selectImgVisible(false)
|
|
|
+ }}
|
|
|
sliderImgContent={imgMaterialConfig.list}
|
|
|
onChange={(content) => {
|
|
|
if (content.length > 0) {
|