request.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //动态获取url
  2. //const URL = getUrl();
  3. //console.log('动态获取URL' + URL)
  4. // function getUrl(){
  5. // return window.location.protocol+'//'+window.location.host
  6. // }
  7. //本地调试url
  8. const URL = "https://iot.usky.cn/";
  9. // const URL = "http://172.16.120.213:8080/";
  10. // const URL = "http://127.0.0.1:8080/";
  11. //这里登陆用户名、密码 写活?
  12. const LOGIN_NAME = "admin";
  13. const LOGIN_PASSWORD = "e10adc3949ba59abbe56e057f20f883e";
  14. const STATISTICS = "YtIoT/iot/alarm/view/getWjDataStatisticsList"; //数据统计查询
  15. //const STATISTICS = "data/statistics.json"; //数据统计查询
  16. const DEVICE_LIST = "YtIoT/iot/alarm/view/getWjDeviceList"; //设备列表查询
  17. //const DEVICE_LIST = "../data/deviceList.json";//设备列表查询
  18. const DEVICE_INFO_LIST = "YtIoT/iot/alarm/view/getWjDeviceInfoList" //设备详情查询
  19. const ALARM_LIST = "YtIoT/iot/alarm/view/getWjAlarmList"; //告警列表查询
  20. //const ALARM_LIST = "../data/alarmList.json";//告警列表查询
  21. const ALARM_HANDLE = "YtIoT/iot/alarm/view/updateWjAlarm";
  22. function ajaxRequest(path, method, data, success, error, type = 1) {
  23. let url = URL + path;
  24. let loginUser = {
  25. "V_LOGINNAME": LOGIN_NAME,
  26. "V_PASSWORD": LOGIN_PASSWORD,
  27. }
  28. if (type == 1) {
  29. data.queryJson = JSON.stringify(loginUser);
  30. } else {
  31. let paramJson = {};
  32. for (key in loginUser) {
  33. paramJson[key] = loginUser[key];
  34. }
  35. for (key in data) {
  36. paramJson[key] = data[key];
  37. }
  38. data = {}
  39. data.queryJson = JSON.stringify(paramJson);
  40. }
  41. $.ajax({
  42. async: false, //同步
  43. data: data,
  44. url: url,
  45. type: method, //请求方式 post get delete put
  46. dataType: "json",
  47. beforeSend: function(XMLHttpRequest) {
  48. // $("#loading").html("<img src='images/loading.gif' />")
  49. // handlePreloader();
  50. // $(".loadingdata").append('<div class="preloader"></div>');
  51. },
  52. success: success,
  53. error: error
  54. });
  55. }