import useFetch from '@/Hook/useFetch';
import { request } from 'umi';
import { api } from '../api'

interface LinkParams {
    // platformId: number,//平台ID
    // mpId: number,//公众号ID
    // linkType: number//链接类型
    pageNum: number,//
    pageSize: number,//
    platformName: string,//平台名称
}
interface Page {
    pageNum: number,
    pageSize: number
}
interface ExportExcleParams extends Page {
    linkType: number,//创建链接类型：1.推广链接 2.自定义活动 3.赠币活动 4常规活动链接 5 模板充值活动链接 6 模板直赠活动链接  7 模板消耗活动连接
    platformId: number,
}
//分页查询常用链接
export async function autoLink(params: LinkParams) {
    return request(`${api}/system/platform/generateLink/autoLink/list`, {
        method: 'POST',
        data: params
    })
}
//分页查询活动链接
export async function normalLink(params: LinkParams) {
    return request(`${api}/system/platform/generateLink/normalLink/list`, {
        method: 'POST',
        data: params
    })
}
//导出常用链接EXCEL
export async function exportLinkExcle(data: ExportExcleParams) {
    return request(`${api}/system/platform/generateLink/normalLink/export`, {
        method: 'POST',
        data: data,
        responseType: 'blob',
    })
}
//导出创建链接模板
export async function exportAutoLinkExcle(props: { platformName: string }) {
    return request(`${api}/system/static/${props.platformName}自动建链接导入模板.xlsx`, {
        method: 'GET',
        responseType: 'blob',
    })
    // return request(`${api}/system/static/${props.platformName}自动建链接导入模板.xlsx`)
    // return useFetch({url:`${api}/system/static/${props.platformName}自动建链接导入模板.xlsx`,params,method:'POST',excelName:'公众号付费趋势表'})
}
//导入创建链接EXCEL
export async function importLinkExcle(props: { data: FormDataEntryValue, platformName: string }) {
    return request(`${api}/system/platform/generateLink/autoLink/importExcel/${props.platformName}`, {
        method: 'POST',
        body: props.data
    })
}
//抓起常用链接
export async function creatNormalLink(params: { account: string, password: string, linkType: number, mpId: number, platformName: string, vip: boolean }) {
    return request(`${api}/system/platform/generateLink/normalLink`, {
        method: 'POST',
        data: params
    })
}
//导入创建自动化记录
export async function selectLinks(params: { platformName: number, pageSize: number, pageNum: number, createStatus: number }) {
    return request(`${api}/system/platform/generateLink/autoLink/importRecord/list`, {
        method: 'POST',
        data: params
    })
}