/****   http.js   ****/
// 导入封装好的axios实例
import request from './request'

const http = {
    /**
     * methods: 请求
     * @param url 请求地址 
     * @param params 请求参数
     */
    get(url, params, ContentType) {
        const config = {
            method: 'get',
            url: url,
            headers: ContentType ? ContentType : { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }
        }
        if (params) {
            config.params = params
        }

        return request(config)
    },
    post(url, params, ContentType) {
        const config = {
            method: 'post',
            url: url,
            headers: ContentType ? ContentType : {
                'Content-Type': 'application/json; charset=utf-8'
            }
        }
        if (params) config.data = params
        return request(config)
    },
    put(url, params, ContentType) {
        const config = {
            method: 'put',
            url: url,
            headers: ContentType ? ContentType : {
                'Content-Type': 'application/json; charset=utf-8'
            }
        }
        if (params) {
            // config.params = params
            config.data = params
        }
        return request(config)
    },
    delete(url, params, ContentType) {
        const config = {
            method: 'delete',
            url: url,
            headers: ContentType ? ContentType : {
                'Content-Type': 'application/json; charset=utf-8'
            }
        }
        if (params) {
            // config.params = params
            config.data = params
        }
        return request(config)
    }
}
//导出
export default http
