import request from '@/utils/request'

export interface PagePopupItem {
    id: number
    name: string
    popup_type: number // 1=图片 2=文字 3=图文混合
    image: string
    title: string
    content: string
    link_type: number // 0=不跳转 1=站内 2=外部H5 3=电话
    link_url: string
    frequency: number // 1=每次 2=每会话一次 3=每天一次 4=仅一次
    delay_seconds: number
    auto_close_seconds: number
    is_closable: number // 1=可手动关闭 0=不可手动关闭
    sort: number
}

export function getPopupList(data: { page_path: string; platform: string }) {
    return request.get({ url: '/popup/list', data }, { withToken: false })
}

export function reportPopupAction(data: {
    popup_id: number
    action: 1 | 2 | 3 // 1=show 2=click 3=close
    page_path: string
    device_id?: string
    platform?: string
}) {
    return request.post({ url: '/popup/report', data }, { withToken: false })
}
