import BaseAPI from '@/api/base_api'

const httpRequest = new BaseAPI(webConf)

const projectId = webConf.others.projectId
/**
 * 获取用户信息
 */
export function getUser() {
  return httpRequest.get('/passport/account/get-user-info')
}

/**
 * 修改用户信息
 */
export function updateUser(data) {
  return httpRequest.post('/usercenter/user/update-user', data)
}

/**
 * 修改密码
 */
export function updatePassword(data) {
  return httpRequest.post('/usercenter/user/update-pwd', data)
}

/**
 * 发送验证码
 */
export function sendCode(data) {
  return httpRequest.post('/usercenter/user/send-code', data)
}
/**
 * 检验验证码
 */
 export function checkCode(params) {
  return httpRequest.get('/usercenter/user/check-code' + params)
}
/**
 * 提交留咨信息
 */
 export function postNes(obj) {
  return httpRequest.post('/new-app/v1.0/applications', obj, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })
}

/**
 * 获取报名信息
 */
export function getApplication(params) {
  return httpRequest.get(`/enrollment/v1.0/application-materials/${projectId}`, params)
}
/**
 * 获取报名信息
 */
export function updateApplication(data) {
  return httpRequest.post(`/enrollment/v1.0/application-materials/${projectId}/put`, data, {
    headers: { 'Content-Type': 'application/json' }
  })
}

/**
 * 获取报名审核状态
 */
export function getApplicationStatus() {
  return httpRequest.get(`/enrollment/v1.0/application-materials/profile/${projectId}`)
}

/**
 * 获取支付二维码
 */
export function getOrder(params) {
  return httpRequest.get(
    `/enrollment/v1.0/application-materials/payment-records/request/${projectId}/APPLICATION_FEE`,
    params
  )
}

/**
 * 检查支付状态
 */
export function checkPay(id, params) {
  return httpRequest.get(
    `/enrollment/v1.0/application-materials/payment-records/check-status/${projectId}/APPLICATION_FEE/${id}`,
    params
  )
}

/**
 * 写推荐信
 */
export function addLetter(userId, letterId, data) {
  return httpRequest.post(
    `/enrollment/v1.0/application-materials/reco-letters/submit/${projectId}/${userId}/${letterId}/put`,
    data,
    {
      headers: { 'Content-Type': 'application/json' }
    }
  )
}

/**
 * 更换推荐人
 */
export function updateProvider(letterId, data) {
  return httpRequest.post(
    `/enrollment/v1.0/application-materials/reco-letters/change-provider/${projectId}/${letterId}/put`,
    data,
    {
      headers: { 'Content-Type': 'application/json' }
    }
  )
}
/**
 * 再次邀请
 */
export function sendToProvider(letterId) {
  return httpRequest.get(
    `/enrollment/v1.0/application-materials/reco-letters/send-invitation-to-provider/${projectId}/${letterId}`
  )
}
/**
 * 退出登录
 */
export function logout() {
  return httpRequest.get('/passport/rest/logout')
}

/**
 * 更改附件状态
 */
export function changeFileStatus(userId, recordId, status) {
  return httpRequest.get(
    `/enrollment/v1.0/application-materials/attachments/change-status/${projectId}/${userId}/${recordId}`,
    { status }
  )
}

/**
 * 修改用户信息
 */
export function getOpenId(data) {
  return httpRequest.post('/usercenter/v1/wechat/get-openid', data)
}
