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 getConfig() {
    return request.get({ url: '/config' })
}

// 访问量
export const apiIndexVisit = (params: any) => request.get({ url: '/index/visit', data: params })

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

// 获取客服信息
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 }
        }
    })

// 获取城市信息-字母分组
export const apiCityInfo = (params: any) => request.get({ url: '/region/city', data: params })

// 微信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 })

// 绑定微信
export const apiBindwx = (params: any) => 
	request.post({url: '/user/bindWechat', data: params})

// 支付方式
export const apiPayPayWay = (params: any) =>
    request.get({ url: '/order/pay/way/list', data: params })

// 预支付
export const apiPayPrepay = (params: any) => request.post({ url: '/pay/wx/prePay', data: params })

// h5预支付
export const apiH5PayPrepay = (params: any) => request.post({ url: '/pay/h5/prePay', data: params })

// 充值支付接口
export const apiRechargeOrder = (params: any) =>
    request.post({ url: '/pay/wx/prePay', data: params })

// 查询订单
export const apiQueryOrder = (params: any) =>
    request.get({ url: '/order/pay/status', data: params })

// 查询充值记录
export const apiQueryRechargeList = (params: any) =>
    request.get({ url: '/recharge/record', data: params })

// 查询充值状态
export const apiQueryRecharge = (params: any) =>
    request.get({ url: '/recharge/payStatus', data: params })
