import useFetch from '@/Hook/useFetch'
import { launchApi, api } from '../api'

import { request } from 'umi';

/**查询号 */
export async function getAccApi() {
    return request(`${api}/adlaunch/wechatInfo/listAllWechatInfo`, {
        method: 'GET'
    })
}

/**获取定向包 */
export interface OrientProps {
    pageNum: number,
    pageSize: number,
    serviceName: string,       // 服务商
    wechatName: string,        // 公众号
    humanPackageName?: string  // 人群包名称
}
export async function getOrientApi(params: OrientProps) {
    return request(`${api}/adlaunch/humanInfo/list`, {
        method: 'POST',
        data: params
    })
}

/** 推广页 */
export async function setPromotionPageAjax(params: { userId: string | number, name: string, typesetting: string }) {
    return request(`${api}/adlaunch/layoutTypesetting`, {
        method: 'POST',
        data: params
    })
}

/**查询落地页 */
export async function getLayoutLocalApi(params: { pageNum: number, pageSize: number, name?: string | undefined, updateStartDate?: string | undefined, updateEndDate?: string | undefined }) {
    return request(`${api}/adlaunch/layoutTypesetting/list`, {
        method: 'POST',
        data: params
    })
}

/** 删除落地页 */
export async function delLayoutLocalApi(params: { userId: string | number, name: string }) {
    return request(`${api}/adlaunch/layoutTypesetting/remove`, {
        method: 'POST',
        data: params
    })
}


/** 删除计划 */
export async function delAdPlanLocalApi(params: { objectName: string, serviceName: string, wechatName: string }) {
    return request(`${api}/adlaunch/actionRecord/remove`, {
        method: 'POST',
        data: params
    })
}

/** 获取计划列表 */
export interface PlanProps {
    pageNum: number,
    pageSize: number,
    serviceName?: string | undefined, // 服务商
    status?: string | undefined,      // 状态
    planName?: string | undefined,    // 计划名称
    wechatName?: string | undefined,  // 广告主名称
    taskName?: string | undefined,    // 任务名称
    startData?: string | undefined,   // 创建开始时间
    endData?: string | undefined      // 创建截止时间
}
export async function getPlanActionRecordApi(params: PlanProps) {
    return request(`${api}/adlaunch/actionRecord/listPlan`, {
        method: 'POST',
        data: params
    })
}
/**创建计划*/
export async function createAd(params: { planList: any[], userId: string }) {
    return request(`${api}/adlaunch/actionRecord/createAdPlan`, {
        method: 'POST',
        data: params
    })
}

/** 获取服务商 */
export async function getAdWechatServiceNameApi() {
    return request(`${api}/adlaunch/wechatInfo/getAllServiceName`, {
        method: 'GET'
    })
}

/** 获取广告主名称 */
export async function getAdWechatWechatNameApi(params: { serviceName: string }) {
    return request(`${api}/adlaunch/wechatInfo/getAllWechat/${params?.serviceName}`, {
        method: 'GET'
    })
}

/** 获取任务列表 */
export interface TaskProps {
    serviceName?: string | undefined,
    // status?: string | undefined,
    createTime?: string | undefined,
    taskName?: string | undefined,
    wechatName?: string | undefined,
    objectName?: string | undefined,
    local?: string | undefined,
    channel?: string | undefined,
    pageNum: number,
    pageSize: number
}
export async function getTaskListApi(params: TaskProps) {
    return request(`${api}/adlaunch/actionRecord/list`, {
        method: 'POST',
        data: params
    })
}
/** 刷新 */
export async function refreshDataApi(params: { userId: number, is_refresh: string }) {
    return request(`${api}/adlaunch/wechatInfo/refresh/${params?.userId}/${params?.is_refresh}`, {
        method: 'GET'
    })
}

/** 扫码回调 */
export async function getScanStatusApi() {
    return request(`${api}/adlaunch/wechatCookie/getScanStatus`, {
        method: 'GET'
    })
}

/**个人概览 */
// export async function overview(params: Params) {
//     return useFetch({ url: '/data/pitcher_panel/overview', params, method: 'POST' })
// }
/**MP收藏*/
export async function adqCollect(parmas: { accountId: any, collect: any }) {
    return request(`${api}/ads/adsChannelAccount/collect/adq/${parmas.accountId}/${parmas.collect}`, {
        method: 'POST'
    })
}
/**ADQ收藏*/
export async function mpCollect(parmas: { accountId: any, collect: any }) {
    return request(`${api}/ads/adsChannelAccount/collect/mp/${parmas.accountId}/${parmas.collect}`, {
        method: 'POST'
    })
}