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 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')
}
