123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- import { reactive } from 'vue'
- import { getAdPresets } from '../basicInfo/ts/basicApi'
- import { FillBackData } from '../basicInfo/ts/fillBack'
- import _ from 'lodash'
- export interface IOuterConfigRule {
- type: string,
- val: any,
- other: any,
- }
- export function basicInfoDeclare() {
- //广告基本信息
- const basicInfoData = reactive<any>({
- visible: false,
- copywriting: [],
- fillBack: {},
- outerConfig: { //外层配置
- attributionOuter: {
- enabled: false,
- visible: false,
- optional: false,
- isComplete: false, // 是否完成填写
- name: '精准匹配归因',
- value: {},
- other: {}
- },
- unionPosition: {
- enabled: false,
- visible: false,
- optional: false,
- isComplete: false, // 是否完成填写
- infoSelect: [],//流量包type
- name: '优量汇流量包',
- value: {},
- other: {}
- },
- weChatVideoAccount: {
- enabled: false,
- visible: false,
- optional: false,
- isComplete: false, // 是否完成填写
- name: '配置视频号',
- value: {},
- other: {}
- },
- expandPopulation: { //已下线
- enabled: false, //是否需要配置
- visible: false, //对应弹框显隐
- optional: true, //选填
- isComplete: false, // 是否完成填写
- name: '扩量种子人群(选填)',
- value: {},
- other: {}
- },
- targetingPartyData: {
- enabled: false, //是否需要配置
- visible: false,
- optional: true,
- isComplete: false, // 是否完成填写
- name: '一方数据助攻(选填)',
- value: {},
- other: {}
- },
- }
- })
- return {
- basicInfoData
- }
- }
- interface IHandleAdBasic {
- updateHaveContent: (...args: any[]) => void,
- judgeEvent: (...args: any[]) => boolean,
- clearOriginalityInfo: (...args: any[]) => void,
- [propName: string]: any
- }
- //广告基本信息 - 广告外层配置
- export function handleAdBasic({
- clearOriginalityInfo,
- updateHaveContent,
- judgeEvent,
- basicInfoData,
- CreativeMaterialRef,
- CopywriterRef,
- LandPageRef,
- targetRef,
- pageInfo,CreativeMaterial_clear
- }: IHandleAdBasic) {
- /**广告基础信息回调 */
- const basicInfoClose = (obj) => {
- console.log('obj',obj);
- if (obj?.type == 'update') {
- //判断版位是否变化,版位变化则创意基本信息、创意文案、落地页 、素材 清空
- if (obj.params.automatic_site != basicInfoData.fillBack?.automatic_site || obj.params.site_ids != basicInfoData.fillBack?.site_ids) {
- clearOriginalityInfo()
- updateHaveContent(5, 0, false, true)
- CreativeMaterial_clear()
- if (CopywriterRef.value) {
- CopywriterRef.value[0]?.clearEvent()
- }
- updateHaveContent(7, 0, false, true)
- if (LandPageRef.value) {
- LandPageRef.value[0]?.clearEvent()
- }
- updateHaveContent(8, 0, false, true)
- }
- basicInfoData.copywriting = obj.copywriting
- basicInfoData.fillBack = obj.params
- updateHaveContent(2, -1, false)
- getButtonBasicOuter(obj.params)
- }
- basicInfoData.visible = false
- }
- /**广告预存信息获取 */
- const getAdPresetsInfo = (type?, info?) => {
- if(type == 'strategyGroups'){
- getAdBasicInfo(info)
- }else{
- getAdPresets({ 'promoted_object_type': targetRef.value?.value }).then((res) => {
- getAdBasicInfo(res)
- })
- }
- }
- const getAdBasicInfo = (res) => {
- getButtonBasicOuter(res)
- FillBackData({
- data: res,
- type: 'api',
- cb: (data: { params: any, copywriting: [] }) => {
- if (data.copywriting && Array.isArray(data.copywriting) && data.copywriting.length > 0) {
- basicInfoData.copywriting = data.copywriting
- for(let key in data.params) {
- if(data.params[key] === null) {
- data.params[key] = ''
- }
- }
- basicInfoData.fillBack = data.params
- updateHaveContent(2, -1, false)
- }
- }
- })
- }
- /**广告信息外部配置获取 */
- const getButtonBasicOuter = (res) => {
- for (let i in basicInfoData.outerConfig) {
- basicInfoData.outerConfig[i].enabled = false
- }
- // if (res?.expand_enabled == 1) { // 扩量种子人群
- // basicInfoData.outerConfig.expandPopulation.enabled = true;
- // }
- if (res?.smart_targeting_switch == 1) { // 智能定向外层配置
- basicInfoData.outerConfig.targetingPartyData.enabled = true;
- }
- if (res?.attribution_type == 2) { // 精准匹配归因
- basicInfoData.outerConfig.attributionOuter.enabled = true;
- }
- if(res?.site_ids?.indexOf('SITE_SET_CHANNELS') != -1){ //微信视频号
- basicInfoData.outerConfig.weChatVideoAccount.enabled = true;
- }
- if (res?.union_position_enabled == 1 || res?.exclude_union_position_enabled == 1) { //优量汇流量包 -- 需要定向包完成填写
- basicInfoData.outerConfig.unionPosition.enabled = true;
- basicInfoData.outerConfig.unionPosition.infoSelect = []
- res?.union_position_enabled == 1 && basicInfoData.outerConfig.unionPosition.infoSelect.push({ name: '定投流量包', id: 1 })
- res?.exclude_union_position_enabled == 1 && basicInfoData.outerConfig.unionPosition.infoSelect.push({ name: '屏蔽流量包', id: 2 })
- }
- }
- /**点击基础信息外层配置 */
- const basicOuterClick = (key) => {
- if (key == 'unionPosition') { //优量汇流量包 - 需要定向包完成填写
- if (!judgeEvent(-2)) return
- }
- if (key == 'weChatVideoAccount'){ // 微信视频号 - 完成创意文案之前的配置
- if (!judgeEvent(7)) return
- }
- basicInfoData.outerConfig[key].visible = true;
- }
- /** 外部配置回调 */
- interface IBasicOuterClose {
- 'type': string,
- 'key': string,
- 'val'?: string,
- 'other'?: string
- }
- const basicOuterClose = ({ key, val, type, other }: IBasicOuterClose) => {
- basicInfoData.outerConfig[key].visible = false;
- if (type == 'submit') {
- basicInfoData.outerConfig[key].value = val ? val : {};
- basicInfoData.outerConfig[key].isComplete = isCompleteEvent(basicInfoData.outerConfig[key]);
- if(other){
- basicInfoData.outerConfig[key].other = other
- }
- }
- }
- const isCompleteEvent = (data) => {
- for (let i = 0; i < pageInfo.accIdsList.length; i++) {
- let info = data.value[pageInfo.accIdsList[i].id]
- if (Array.isArray(info) && info.length == 0) {
- return false
- } else if (Object.prototype.toString.call(info) == '[object Object]' && Object.keys(info).length == 0) {
- return false
- } else if (!info || info == '') {
- return false
- }
- }
- return true
- }
- /**基础外部配置 - 获取对象公共数据 */
- const getCommonValue = (data) => {
- let obj = {}
- pageInfo.accIdsList.forEach((item) => {
- if (data[item.id] && data[item.id] != '') {
- obj[item.id] = data[item.id]
- }
- });
- return obj
- }
- return {
- basicInfoClose,
- getAdPresetsInfo,
- basicOuterClick,
- basicOuterClose,
- getCommonValue,
- isCompleteEvent
- }
- }
|