import React, { useContext, useEffect, useState } from "react" import style from '../index.less' import { Button, Space } from "antd" import { EditOutlined } from "@ant-design/icons" import { DispatchAddelivery } from ".." import NewDynamic from "./newDynamic" import { AD_STATUS_ENUM, CONVERSION_DATA_ENUM, CONVERSION_TARGET_ENUM, DELIVERY_MODE_ENUM, PAGE_TYPE_ENUM, TEXT_LINK_TYPE_ENUM, pageSpecFieldConVertUn } from "../../const" import { getProfilesApi } from "@/services/adqV3/global" import { useAjax } from "@/Hook/useAjax" import { arraysHaveSameValues } from "@/utils/utils" /** * 创意 * @returns */ const Dynamic: React.FC<{ creativeTemplateAppellation?: string, creativeTemplateStyle?: string }> = ({ creativeTemplateAppellation, creativeTemplateStyle }) => { /***************************************/ const { addelivery, setAddelivery, clearData, setAccountCreateLogs, accountCreateLogs } = useContext(DispatchAddelivery)!; const { adgroups, dynamic: dynamicData } = addelivery; const { deliveryMode, creativeTemplateId, dynamicCreativeName, creativeComponents, configuredStatus } = dynamicData const { textLink, actionButton, showData, brand, mainJumpInfo } = creativeComponents || {} const [newVisible, setNewVisible] = useState(false); const [profileData, setprofileData] = useState() const getProfiles = useAjax((params) => getProfilesApi(params)) /***************************************/ useEffect(() => { if (['PAGE_TYPE_H5_PROFILE'].includes(brand?.[0]?.value?.jumpInfo?.pageType)) { getProfiles.run({}).then(res => { if (res) { setprofileData(res?.find((item: { id: any }) => item.id === brand?.[0]?.value?.profileId)) } }) } }, [brand]) return
创意信息
{dynamicData && Object.keys(dynamicData).length > 0 && <>

创意状态:{AD_STATUS_ENUM[configuredStatus as keyof typeof AD_STATUS_ENUM]}

创意名称:{dynamicCreativeName}

投放模式:{DELIVERY_MODE_ENUM[deliveryMode as keyof typeof DELIVERY_MODE_ENUM]}

{((creativeTemplateId && creativeTemplateAppellation) || creativeTemplateId) && `创意形式:${creativeTemplateAppellation || creativeTemplateId}`}

{brand?.length > 0 && <>

品牌形象跳转:{PAGE_TYPE_ENUM[brand?.[0]?.value?.jumpInfo?.pageType as keyof typeof PAGE_TYPE_ENUM]}

{['PAGE_TYPE_H5_PROFILE'].includes(brand?.[0]?.value?.jumpInfo?.pageType) ? <> {profileData ? <> {profileData?.profileName}

详细描述:{profileData?.description}

: {getProfiles.loading ? '' : '当前头像昵称跳转页被删除'} } : ['PAGE_TYPE_NOT_USED'].includes(brand?.[0]?.value?.jumpInfo?.pageType) && {brand?.[0]?.value?.brandName} } }

跳转类型:{mainJumpInfo?.map((item: any) => { let pageType = item.value.pageType return PAGE_TYPE_ENUM[pageType as keyof typeof PAGE_TYPE_ENUM] }).toString()}

{textLink?.length > 0 && <>

朋友圈文字链:开启

文字链文案:{TEXT_LINK_TYPE_ENUM[textLink?.[0]?.value?.linkNameType as keyof typeof TEXT_LINK_TYPE_ENUM]}

{textLink?.[0]?.value?.jumpInfo?.pageType &&

跳转落地页:{PAGE_TYPE_ENUM[textLink?.[0]?.value?.jumpInfo?.pageType as keyof typeof PAGE_TYPE_ENUM]}

} } {actionButton?.length > 0 && <>

行动按钮:开启

按钮文案:{actionButton?.[0]?.value?.buttonText}

{actionButton?.[0]?.value?.jumpInfo?.pageType &&

跳转落地页:{PAGE_TYPE_ENUM[actionButton?.[0]?.value?.jumpInfo?.pageType as keyof typeof PAGE_TYPE_ENUM]}

} } {showData?.length > 0 && <>

数据外显:开启

数据类型:{CONVERSION_DATA_ENUM[showData?.[0]?.value?.conversionDataType as keyof typeof CONVERSION_DATA_ENUM]}

转化行为:{CONVERSION_TARGET_ENUM[showData?.[0]?.value?.conversionTargetType as keyof typeof CONVERSION_TARGET_ENUM]}

} }
{newVisible && { setNewVisible(false) }} onChange={(dynamic) => { if ( dynamic.deliveryMode === deliveryMode && // 投放模式 dynamic?.creativeTemplateId === creativeTemplateId // 创意形式 ) { setAddelivery({ ...addelivery, dynamic }) } else { setAddelivery({ ...addelivery, dynamic, dynamicMaterialDTos: {}, dynamicCreativesTextDTOS: {} }) } let oldPageTypeList = mainJumpInfo?.map((item: { value: { pageType: any } }) => item.value) || [] let newPageTypeList = dynamic?.creativeComponents?.mainJumpInfo.map((item: { value: { pageType: any } }) => item.value) setNewVisible(false) clearData() if (!arraysHaveSameValues(oldPageTypeList || [], newPageTypeList || [])) { setAccountCreateLogs(accountCreateLogs.map(item => ({ ...item, pageList: [] }))) } }} />}
} export default React.memo(Dynamic)