import request from '@/utils/request'
// #ifdef H5
import { getSignLink } from '@/hooks/wechat'
// #endif

//发送短信
export function smsSend(data: any) {
    return request.post({ url: '/sms/send', data: data })
}

// 获取系统配置
export function apiConfig() {
    return request.get({ url: '/configuration/detail' })
}

// 获取政策协议
export function getPolicy(data: any) {
    return request.get({ url: '/policy', data: data })
}

// 问题管理
export function apiFault(data: any) {
    return request.get(
        {
            url: '/fault/list',
            data: {
                ...data,
                pageSize: 60
            }
        },
        {
            ignoreCancel: true
        }
    )
}

// 获取客服信息
export function apiContactService(data: any) {
    return request.get({ url: '/decorate/pages/service', data: data })
}

// 公众号登录
export const apiOALogin = (params: any) => request.post({ url: '/login/oaLogin', data: params })

// 公众号-获取授权url
export const apiCodeUrlGet = () =>
    request.get({
        url: '/login/codeUrl',
        data: {
            url: location.href,
            headers: { 1: 1 }
        }
    })

// 微信sdk配置
export const apiJsConfig = (data: any) =>
    request.get({ url: '/wechat/jsConfig', data: { url: getSignLink() } })

/**
 * @param { Object } params { address: 广州市番禺区xxx }
 * @return { Promise }
 * @description 地址逆解析
 */
export const getGeocoder = (params: any) =>
    request.get({ url: '/region/keyWordAddress', data: params })

/**
 * @param { Object } params { location: xxx,xxx }
 * @return { Promise }
 * @description 地址逆解析
 */
export const getGeocoderCoordinate = (params: any) =>
    request.post({ url: '/region/genCoder', data: params })
