|
@@ -9,12 +9,13 @@ import PageList from "./PageList";
|
|
|
import { DispatchAddelivery } from ".";
|
|
|
import { CheckOutlined, SearchOutlined } from "@ant-design/icons";
|
|
|
import WechatAccount from "../../components/WechatAccount";
|
|
|
-import { cartesianProduct, distributeArray, splitArrayIntoRandomChunks } from "@/utils/utils";
|
|
|
+import { cartesianProduct, distributeArray, processData, splitArrayIntoRandomChunks } from "@/utils/utils";
|
|
|
import { columnsAddDynamic } from "./tableConfig";
|
|
|
import { useAjax } from "@/Hook/useAjax";
|
|
|
import { createDynamicTaskApi } from "@/services/adqV3";
|
|
|
import TacticsS from "./TacticsS";
|
|
|
import VideoChannel from "../../components/VideoChannel";
|
|
|
+import { getCreativeDetailsApi } from "@/services/adqV3/global";
|
|
|
const { Text, Title } = Typography;
|
|
|
|
|
|
/**
|
|
@@ -26,6 +27,8 @@ const AddDynamic: React.FC<PULLIN.NewAddDynamic> = ({ visible, onChange, onClose
|
|
|
/****************************************/
|
|
|
const [addelivery, setAddelivery] = useState<PULLIN.AddeliveryProps>({ adgroups: {}, targeting: [], dynamic: {}, dynamicMaterialDTos: {}, dynamicCreativesTextDTOS: {}, mediaType: 0 })
|
|
|
const { adgroups, dynamic } = addelivery
|
|
|
+ const { marketingAssetOuterSpec, marketingCarrierType, marketingGoal, siteSet, automaticSiteEnabled, sceneSpec } = addelivery.adgroups
|
|
|
+ const { deliveryMode, creativeTemplateId } = addelivery.dynamic
|
|
|
const [wechatVisible, setWechatVisible] = useState<boolean>(false) // 选择微信公众号弹窗控制
|
|
|
const [channelsProfileVisible, setChannelsProfileVisible] = useState<boolean>(false) // 选择微信公众号弹窗控制
|
|
|
const [materialData, setMaterialData] = useState<any>({}) // 素材数据
|
|
@@ -36,9 +39,56 @@ const AddDynamic: React.FC<PULLIN.NewAddDynamic> = ({ visible, onChange, onClose
|
|
|
const [dynamicCount, setDynamicCount] = useState<number>(0)
|
|
|
const [adData, setAdData] = useState<any[]>(selectData)
|
|
|
const [adDataGroup, setAdDataGroup] = useState<{ [x: number]: any[] }>({})
|
|
|
+ const [creativeTemplateAppellation, setCreativeTemplateAppellation] = useState<string>()
|
|
|
+ const [creativeTemplateStyle, setCreativeTemplateStyle] = useState<string>()
|
|
|
+ const getCreativeDetails = useAjax((params) => getCreativeDetailsApi(params))
|
|
|
|
|
|
const createDynamicTask = useAjax((params) => createDynamicTaskApi(params))
|
|
|
/****************************************/
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (creativeTemplateId) {
|
|
|
+ let params: any = {
|
|
|
+ marketingGoal,
|
|
|
+ marketingTargetType: marketingAssetOuterSpec.marketingTargetType,
|
|
|
+ marketingCarrierType,
|
|
|
+ deliveryMode,
|
|
|
+ creativeTemplateId,
|
|
|
+ wechatSceneSpecPosition: sceneSpec?.wechatPosition,
|
|
|
+ dynamicCreativeType: deliveryMode === 'DELIVERY_MODE_COMPONENT' ? 'DYNAMIC_CREATIVE_TYPE_PROGRAM' : 'DYNAMIC_CREATIVE_TYPE_COMMON'
|
|
|
+ }
|
|
|
+ if (automaticSiteEnabled) {
|
|
|
+ params.automaticSiteEnabled = automaticSiteEnabled
|
|
|
+ } else {
|
|
|
+ params.siteSet = siteSet
|
|
|
+ }
|
|
|
+ getCreativeDetails.run(params).then(res => {
|
|
|
+ if (res?.adcreativeTemplateStructAdpermits?.length > 0) {
|
|
|
+ let adcreativeTemplateStructAdpermits = res?.adcreativeTemplateStructAdpermits[0]
|
|
|
+ setCreativeTemplateAppellation(adcreativeTemplateStructAdpermits.creativeTemplateAppellation)
|
|
|
+ setCreativeTemplateStyle(adcreativeTemplateStructAdpermits.creativeTemplateStyle)
|
|
|
+
|
|
|
+ let creativeComponents = adcreativeTemplateStructAdpermits?.creativeComponents || []
|
|
|
+ let result = processData(creativeComponents);
|
|
|
+
|
|
|
+ let newMaterialData: any = {};
|
|
|
+ let newTextData: any = {};
|
|
|
+
|
|
|
+ Object.keys(result).forEach(key => {
|
|
|
+ let data = result[key]
|
|
|
+ if ((key === 'image_list' || key === 'short_video' || key === 'video' || key === 'image' || key === 'element_story') && data.required) {
|
|
|
+ newMaterialData[key] = data
|
|
|
+ } else if (key === 'title' || (data.required && key === 'description')) {
|
|
|
+ newTextData[key] = data
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ setMaterialData(newMaterialData)
|
|
|
+ setTextData(newTextData)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }, [creativeTemplateId, deliveryMode, marketingGoal, marketingAssetOuterSpec, marketingCarrierType, siteSet, sceneSpec?.wechatPosition, automaticSiteEnabled])
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (adData && adData.length) {
|
|
@@ -465,7 +515,7 @@ const AddDynamic: React.FC<PULLIN.NewAddDynamic> = ({ visible, onChange, onClose
|
|
|
if (wechatChannelList && (['MARKETING_TARGET_TYPE_WECHAT_OFFICIAL_ACCOUNT'].includes(adgroups?.marketingAssetOuterSpec?.marketingTargetType) || adgroups?.marketingCarrierType === 'MARKETING_CARRIER_TYPE_WECHAT_OFFICIAL_ACCOUNT')) {
|
|
|
map.wechatChannelId = wechatChannelList?.[0]?.wechatOfficialAccountId
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (videoChannelList && dynamic?.creativeComponents?.brand?.[0]?.value?.jumpInfo?.pageType === 'PAGE_TYPE_WECHAT_CHANNELS_PROFILE') {
|
|
|
map.videoChannelId = videoChannelList?.[0]?.wechatChannelsAccountId
|
|
|
}
|
|
@@ -553,7 +603,10 @@ const AddDynamic: React.FC<PULLIN.NewAddDynamic> = ({ visible, onChange, onClose
|
|
|
</div>
|
|
|
</div>
|
|
|
{/* 创意 */}
|
|
|
- <Dynamic />
|
|
|
+ <Dynamic
|
|
|
+ creativeTemplateAppellation={creativeTemplateAppellation}
|
|
|
+ creativeTemplateStyle={creativeTemplateStyle}
|
|
|
+ />
|
|
|
{/* 创意素材 */}
|
|
|
<Material adData={adData} />
|
|
|
</div>
|