import {http} from "@/utils/http/axios";
import {RequestEnum} from "@/enums/httpEnum";


const baseUrl = '/api'

/**
 * @description: getLoansInfo
 */
export function getLoansInfo() {
  return http.request({
    url: `${baseUrl}/app/home/setting/loans`,
    method: 'GET'
  });
}

/**
 * @description: getHomeInfo
 */
export function getHomeInfo() {
  return http.request({
    url: `${baseUrl}/app/home/setting/home`,
    method: 'GET'
  });
}

/**
 * @description: getCalLoan
 */
export function getCalLoan(data) {
  return http.request({
    url: `${baseUrl}/app/home/loans/calLoan`,
    method: 'POST',
    data
  });
}
/**
 * @description: getLoansUser
 */
export function getLoansUser() {
  return http.request({
    url: `${baseUrl}/app/home/loans/loansUser`,
    method: 'GET'
  });
}
/**
 * @description: getUserInfo
 */
export function getUserInfo() {
  return http.request({
    url: `${baseUrl}/app/customer/card/info`,
    method: 'GET'
  });
}
/**
 * @description: getOssPolicyInfo
 */
export function getOssPolicyInfo() {
  return http.request({
    url: `${baseUrl}/v2/common/sts`,
    method: 'GET'
  });
}
/**
 * @description: uploadCommon
 */
export function uploadCommon(file, onUploadProgress?) {
  return http.uploadFile({
    url: `${baseUrl}/v2/common/upload`,
    method: 'POST',
    onUploadProgress: (progressEvent) => {
      onUploadProgress && onUploadProgress(progressEvent)
    }
  }, {
    file: file
  });
}

/**
 * updateCustomerCard
 * @param data
 */
export function updateCustomerCard(data) {
  return http.request({
    url: `${baseUrl}/app/customer/updateCustomerCard`,
    method: 'POST',
    data
  });
}

/**
 * getBankType
 */
export function getBankType() {
  return http.request({
    url: `${baseUrl}/app/home/setting/bankType`,
    method: RequestEnum.GET
  });
}

/**
 * getBankType
 */
export function getAgreement() {
  return http.request({
    url: `${baseUrl}/app/home/setting/agreement`,
    method: RequestEnum.GET
  });
}

/**
 * getCustomerInfo
 */
export function getCustomerInfo() {
  return http.request({
    url: `${baseUrl}/app/customer/info`,
    method: RequestEnum.GET
  });
}


/**
 * getCustomerInfo
 */
export function getStepBorrow() {
  return http.request({
    url: `${baseUrl}/app/borrow/getStepBorrow`,
    method: RequestEnum.GET
  });
}


/**
 * getBorrowPage
 */
export function getBorrowPage(params) {
  return http.request({
    url: `${baseUrl}/app/borrow/page`,
    method: RequestEnum.GET,
    params
  });
}


/**
 * getBorrowInfo
 */
export function getBorrowInfo(params) {
  return http.request({
    url: `${baseUrl}/app/borrow/info`,
    method: RequestEnum.GET,
    params
  });
}


/**
 * getBorrowWithdraw
 */
export function getBorrowWithdraw(params) {
  return http.request({
    url: `${baseUrl}/app/borrow/withdraw`,
    method: RequestEnum.GET,
    params
  });
}


/**
 * getSetting
 */
export function getSetting() {
  return http.request({
    url: `${baseUrl}/app/home/setting/home`,
    method: RequestEnum.GET
  });
}


/**
 * getSetting
 */
export function getContract(params?) {
  return http.request({
    url: `${baseUrl}/app/borrow/getContract`,
    method: RequestEnum.GET,
    params
  });
}


/**
 * startBorrow
 */
export function startBorrow(data) {
  return http.request({
    url: `${baseUrl}/app/borrow/start`,
    method: RequestEnum.POST,
    data
  });
}
