import myAxios from './axios'

/**
 * post方法，对应post请求
 * @param {String} url [请求的url地址]
 * @param {Object} params [请求时携带的参数]
 */

export function getFile(url, formData) {
  return myAxios({
    url: url,
    method: 'get',
    params: formData,
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function postFile(url, formData) {
  return myAxios({
    url: url,
    method: 'post',
    data: formData,
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function post(url, formData) {
  return myAxios({
    url: url,
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function getPost(url, formData) {
  return myAxios({
    url: url,
    method: 'post',
    params: formData,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function parmasPost(url, formData) {
  return myAxios({
    url: url,
    method: 'post',
    params: formData
  })
}

/**
 * get方法，对应get请求
 * @param {String} url [请求的url地址]
 * @param {Object} params [请求时携带的参数]
 */
export function get(url, parameter) {
  return myAxios({
    url: url,
    method: 'get',
    params: parameter
  })
}
export function upost(url, formData) {
  return myAxios({
    url: url + formData,
    method: 'post'
  })
}
export function uget(url, parameter) {
  return myAxios({
    url: url + parameter,
    method: 'get'
  })
}

/**
 * delete方法，对应delete
 * @param {String} url [请求的url地址]
 * @param {Object} params [请求时携带的参数]
 */
export function deletes(url, data) {
  return myAxios({
    url: url,
    method: 'delete',
    data: data
  })
}

/**
 * put方法，对应put请求
 * @param {String} url [请求的url地址]
 * @param {Object} data [请求时携带的参数]
 */
export function put(url, data) {
  return myAxios({
    url: url,
    method: 'put',
    data: data
  })
}
