import request from '@/utils/request'

const BASE_API = process.env.VUE_APP_BASIC_API

/**
 * 验证码登录
 * @yapi http://yapi.cusc.com:3000/project/28/interface/api/7256
 */
export function login(data) {
  return request({
    url: `${BASE_API}userEnterprise/auth/login`,
    data
  })
}

/**
 * 用户名密码登录
 * @yapi http://yapi.cusc.com:3000/project/28/interface/api/7256
 */
export function loginUserName(data) {
  return request({
    url: `${BASE_API}userEnterprise/auth/login/userName`,
    data
  })
}

/**
 * 退出登录
 * @yapi http://10.166.2.23:3000/project/28/interface/api/8664
 */
export function logout(data) {
  return request({
    url: `${BASE_API}userEnterprise/auth/logout`,
    data
  })
}

/**
 * 发送短信验证码
 * @yapi http://yapi.cusc.com:3000/project/28/interface/api/7252
 */
export function sendSmsCaptcha(data) {
  return request({
    url: `${BASE_API}userEnterprise/auth/getSms`,
    data
  })
}

/**
 * 获取短信验证码
 * @yapi http://yapi.cusc.com:3000/project/28/interface/api/7248
 */
export function getGraphic(data) {
  return request({
    url: `${BASE_API}userEnterprise/auth/getGraphic?platformSource=Web`,
    method: 'get',
    data
  })
}

export function queryMenus() {
  return request({
    url: `${BASE_API}resource/queryCurrUserResourceList`,
    data: {}
  })
}

/**
 * 账号密码登录-获取随机请求id-登录密码加密
 * @yapi http://yapi.cusc.com:3000/project/28/interface/api/7256
 */
export function getLoginSecretKey(data) {
  return request({
    url: `${BASE_API}userEnterprise/auth/getLoginSecretKey?platformSource=Web`,
    method: 'get',
    data
  })
}

/**
 * 忘记密码
 * @yapi http://yapi.cusc.com:3000/project/28/interface/api/7256
 */
export function forgetPassword(data) {
  return request({
    url: `${BASE_API}password/forget`,
    data,
    hideToast: true
  })
}

/**
 * 修改密码
 * @yapi http://yapi.cusc.com:3000/project/28/interface/api/7256
 */
export function changePassword(data) {
  return request({
    url: `${BASE_API}password/change`,
    data
  })
}

/**
 * OCR读取身份证照片信息
 */
export const ocrIdcard = data => {
  return request({
    url: `${BASE_API}ocr/idCard`,
    data
  })
}

