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

/**
 * 更改附件状态
 */
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)
}

/**
 * 签名
 */
export function createSign(data) {
  return httpRequest.post('/usercenter/v1/sign/sign', data)
}

/**
 * 获取签名文档
 */
export function getSignDocument(data) {
  return httpRequest.get('/usercenter/v1/sign/document', data)
}

/**
 * 提交留资
 */
export function submitApply(data) {
  return httpRequest.post(`/enrollment/v1.0/applications/${projectId}/apply`, data, {
    headers: { 'Content-Type': 'application/json' }
  })
}

/**
 * 查询留资
 */
export function getApply(params) {
  return httpRequest.get(`/enrollment/v1.0/applications/${projectId}/apply`, params, {
    headers: { 'Content-Type': 'application/json' }
  })
}

/**
 * 申请支付
 */
export function getPayment(params) {
  return httpRequest.get(`/enrollment/v1.0/applications/${projectId}/request-payment/APPLICATION_FEE`, params)
}

/**
 * 获取支付订单列表
 */
export function getPaymentList() {
  return httpRequest.get(`/enrollment/v1.0/applications/${projectId}/get-payment-info/APPLICATION_FEE`)
}
