//url
const URL = "http://172.16.120.183:8080/";

//这里登陆用户名、密码 写活？
const LOGIN_NAME = "admin";
const LOGIN_PASSWORD = "e10adc3949ba59abbe56e057f20f883e";


const STATISTICS = "YtIoT/iot/analysis/view/getEfAnalysisList"; //数据统计查询

function ajaxRequest(path, method, data, success, error, type = 1) {

    let url = URL + path;

    let loginUser = {
        "V_LOGINNAME": LOGIN_NAME,
        "V_PASSWORD": LOGIN_PASSWORD,
    }

    if (type == 1) {
        data.queryJson = JSON.stringify(loginUser);
    } else {

        let paramJson = {};

        // for (key in loginUser) {
        //     paramJson[key] = loginUser[key];
        // }

        for (key in data) {
            paramJson[key] = data[key];
        }

        data = {}
        data.queryJson = JSON.stringify(paramJson);
    }


    $.ajax({
        async: false, //同步
        data: data,
        url: url,
        type: method, //请求方式 post get delete put
        dataType: "json",
        beforeSend: function(XMLHttpRequest) {
            // $("#loading").html("<img src='images/loading.gif' />")
            // handlePreloader();
            // $(".loadingdata").append('<div class="preloader"></div>');

        },
        success: success,
        error: error
    });

}