import request from '@/utils/request'

/**
 * 登录接口
 * @param {string} user_name 用户名
 * @param {string} password 密码
 * @param {number} login_type 登录类型 0：帐号密码登录 1：短信登录 2：微信登录 3：QQ登录
 * @param {number} login_portal 登录入口 0：web 1：app
 * @param phone
 * @param valid_code
 * @returns {*}
 */
export function login(user_name, password, login_type, login_portal,phone,valid_code) {
  return request({
    url: '/api/user/login',
    method: 'post',
    data: {
      user_name,
      password,
      login_type,
      login_portal,
      phone,
      valid_code
    }
  })
}
/**
 * 获取用户信息接口
 * @returns {*}
 */
export function getInfo() {
  return request({
    url: '/api/user/base-account',
    method: 'post',
    params: {}
  })
}
/**
 * 登出接口
 * @returns {*}
 */
export function logout() {
  return request({
    url: '/api/user/logout',
    method: 'post',
    params: {}
  })
}
/**
 * 发送短信接口
 * @param phone
 * @param country_code
 * @returns {*}
 */
export function sendSmsCode(phone,country_code) {
  return request({
    url: '/api/user/get-phone-code',
    method: 'post',
    params: {
      phone,
      country_code
    }
  })
}
/**
 * 发送邮件验证阿门接口
 * @param email
 * @returns {*}
 */
export function sentEmailCode(email) {
  return request({
    url: '/api/user/get-reg-email-code',
    method: 'post',
    params: {
      email
    }
  })
}

/**
 * 注册接口
 * @param email
 * @param phone
 * @param valid_code
 * @param register_type
 * @param country_code
 * @returns {*}
 */
export function  register(email,phone,valid_code,register_type,country_code) {
  return request({
    url: '/api/user/register',
    method: 'post',
    data: {
      email,
      phone,
      valid_code,
      register_type,
      country_code
    }
  })
}
/**
 * 确认邮箱接口
 * @param pre_register_key
 * @param password
 * @param confirm_password
 * @returns {*}
 */
export function  confirmEmail(pre_register_key,password,confirm_password) {
  return request({
    url: '/api/user/confirm-register',
    method: 'post',
    data: {
      pre_register_key,
      password,
      confirm_password
    }
  })
}

/**
 * 获取微信登录二维码
 * @returns {*}
 */
export function getWechatLogin() {
  return request({
    url: '/api/wechat/mp-web-auth',
    method: 'get',
    params: {}
  })
}

/**
 * 获取微信登录状态
 * @param {String} wechatcode getWechatLogin获取的code
 * @returns {*}
 */
export function getWechatStatus(wechatcode) {
  return request({
    url: '/api/wechat/mp-web-auth-info',
    method: 'get',
    params: {
      wechatcode
    }
  })
}
/**
 * 获取谷歌登录url
 * @returns {*}
 */
export function getGoogleLogin() {
  return request({
    url: '/api/google/web-auth-url',
    method: 'get',
    params: {}
  })
}
/**
 * 获取谷歌登录状态
 * @param {String} state getGoogleLogin获取的state
 * @param {String} access_token getGoogleLogin获取的access_token
 * @returns {*}
 */
export function getGoogleStatus(state, access_token) {
  return request({
    url: '/api/google/web-auth-info',
    method: 'get',
    params: {
      state,
      access_token
    }
  })
}
/**
 * 获取linkedin登录url
 * @returns {*}
 */
export function getLinkedinLogin() {
  return request({
    url: '/api/linkedin/web-auth-url',
    method: 'get',
    params: {}
  })
}
/**
 * 获取linkedin登录状态
 * @param {String} state getLinkedinLogin获取的state
 * @param {String} code getLinkedinLogin获取的access_token
 * @returns {*}
 */
export function getLinkedinStatus(state, code) {
  return request({
    url: '/api/linkedin/web-auth-info',
    method: 'get',
    params: {
      state,
      code
    }
  })
}
/**
 * 绑定手机号接口
 * @param phone
 * @param valid_code
 * @param country_code
 * @param login_type
 * @param third_token
 * @returns {*}
 */
export function bindPhone(phone, valid_code, country_code, login_type, third_token){
  return request({
    url: '/api/wechat/user-bind',
    method: 'post',
    params: {
      phone,
      valid_code,
      country_code,
      login_type,
      third_token
    }
  })
}
