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

//本地测试
// const URL = "";
// const ELE_FIRE_DATA = "api/data1.json"; //电气火灾

//这里登陆用户名、密码 
const LOGIN_NAME = "sgec68";
const LOGIN_PASSWORD = "sgec68123";


const ELE_FIRE_DATA = "YtIoT/iot/analysis/view/getEfAnalysisList"; //电气火灾
const WATER_DATA = "YtIoT/iot/analysis/view/getWaterAnalysisList"; //水系统
const GET_NAME_LIST_DATA = "YtIoT/iot/company/view/getNameList"; //建筑下拉


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) { //不传用户名密码

        let paramJson = {};

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

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


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

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

}