import { http } from './request/request'
/**
 * 手机号授权
 * @param data 请求参数
 */
export const getBindPhoneTypeApi = async data => {
  return await http.post<any>('/xcx/login/getBindRelationList', data)
}
// /**
//  * 手机号获取用户身份
//  * @param data 请求参数
//  */
// export const getAdminTypeByPhoneApi = async (params: any) =>
//   await http.get<any>('/sysUser/getAdminTypeByPhone', params)

/**
 * 发送验证码
 * @param data 请求参数
 */
export const sendCodeMessageApi = async data =>
  await http.post<any>(`/sms/sendMessage?phoneNumbers=${data}`)

/**
 * 手机号验证码登录
 * @param data 请求参数
 */
export const smsLoginApi = async data =>
  await http.post<any>('/smsLogin', {
    ...data,
    clientType: 'PARENT',
  })

interface WxLoginApiResponse {
  accessToken: string
  wxUser: any
  account: string
  phone: string
}
/**
 * 微信登录
 * @param data 请求参数
 */
export const wxLoginApi = async data =>
  await http.post<WxLoginApiResponse>('/wxLogin', {
    ...data,
    clientType: 'PARENT',
  })

/**
 * 获取用户信息
 * @param data 请求参数
 */
export const getUserInfoApi = async () => await http.get<any>('/sysUser/selectUser')

/**
 * 更新用户信息
 * @param data 请求参数
 */
export const updateUserInfoApi = async (data: any) =>
  await http.post<any>('/sysUser/updateInfo', data)

/**
 * 授权用户绑定
 * @param data 请求参数
 */
export const bindAuthInfoApi = async data =>
  await http.post<any>('/wechatPublic/bindAuthInfo', data)

/**
 * 获取静默授权链接
 * @param data 请求参数
 */
export const getAuthUrlApi = async () => await http.get<any>('/wechatPublic/getAuthUrl')

// 退出登录
export const logoutApi = async () => await http.get<any>('/logout')
