import { otherHttp, weatherHttp } from '/@/utils/http/axios'

const API_KEY = '4fb5c9e814994516b6522419651f2e9e'

// 查询实况天气
export function now(location: string) {
    return weatherHttp.get({
        url: `/v7/weather/now?key=${API_KEY}&location=${location}`,
    })
}

// 获取天气预报
export function forecast(location: string, day = 7) {
    return weatherHttp.get({
        url: `/v7/weather/${day}d?key=${API_KEY}&location=${location}`,
    })
}

// 获取气象预警信息
export function alarm(location: string) {
    return weatherHttp.get({
        url: `/weatheralert/v1/current/${location.replace(',', '/')}?key=${API_KEY}`,
    })
}

// 格点天气预报-日值（降雨、大风用）
export function gridForecastDaily(location: string, day = 3) {
    return weatherHttp.get({
        url: `/v7/weather/${day}d?key=${API_KEY}&location=${location}`,
    })
}

// 格点天气预报-小时值（温度用）
export function gridForecastHourly(location: string) {
    return weatherHttp.get({
        url: `/v7/weather/24h?key=${API_KEY}&location=${location}`,
    })
}

// 强对流预报（自建接口）
export function severeForecast(lon: string, lat: string) {
    return otherHttp.get({
        url: '/weather/forecast',
        params: { lon, lat },
    }, { isTransformResponse: false })
}
