diff --git a/api/commonRequest.js b/api/commonRequest.js index d44b516..2c830c2 100644 --- a/api/commonRequest.js +++ b/api/commonRequest.js @@ -1,16 +1,16 @@ -let aqEnnable = false // 参数加密开关 -const commonUrl = "http://10.40.92.33:18080/zhgd/"; +let aqEnnable = true;// 参数加密开关 +const commonUrl = "http://127.0.0.1:18080/zhgd/"; /* 登录相关 */ const login_url = commonUrl + "auth/login"; // 登录url const login_out = commonUrl + "auth/logout"; // 登出url const page_jump = commonUrl + "auth/pageJump"; // 登出url -const login_sg_page = "http://10.40.92.33:8100/sg_login.html" // 施工大屏登录页面 -const login_sc_page = "http://10.40.92.33:8101/sc_login.html" // 省侧大屏登录页面 -const login_sg_index = "http://10.40.92.33:8100/pages/home/navigation.html" // 施工大屏首页 -const login_sc_index = "http://10.40.92.33:8101/pages/web/index.html" // 省侧大屏首页 +const login_sg_page = "http://127.0.0.1:63342/ah_jjzhgd_webscreen/sg_login.html" // 施工大屏登录页面 +const login_sc_page = "http://10.40.92.33:8100/sc_login.html" // 省侧大屏登录页面 +const login_sg_index = "http://10.40.92.33:8101/pages/home/navigation.html" // 施工大屏首页 +const login_sc_index = "http://10.40.92.33:8100/pages/web/index.html" // 省侧大屏首页 /* POST 请求 */ -function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, contentType, isAes) { +function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, contentType,isAes) { $.ajax({ url: url, type: type, @@ -33,8 +33,7 @@ function ajaxRequest2(url, type, token, successFn, errorFn) { url: url, type: type, headers: { - "authorization": token, - "decrypt": 'decrypt' + "authorization": token }, success: successFn, error: errorFn @@ -50,26 +49,7 @@ function ajaxRequestGet(url, type, async, beforeFn, successFn, errorFn, isAes) { "authorization": sessionStorage.getItem("zhgd_token"), "decrypt": isAes ? '' : 'decrypt' }, - async: async, - beforeSend: beforeFn, - success: successFn, - error: errorFn - }); -} - - -/* GET请求 */ -function ajaxRequestGetExport(url, type, async, beforeFn, successFn, errorFn, isAes) { - $.ajax({ - url: url, - type: type, - headers: { - "authorization": sessionStorage.getItem("zhgd_token"), - "decrypt": isAes ? '' : 'decrypt' - }, - xhrFields: { - responseType: 'blob' // 告诉 xhr 我们期望返回的数据类型是 blob - }, + data: data, async: async, beforeSend: beforeFn, success: successFn, diff --git a/js/personnelControl/personnelControl.js b/js/personnelControl/personnelControl.js index 195f9c8..0cb9239 100644 --- a/js/personnelControl/personnelControl.js +++ b/js/personnelControl/personnelControl.js @@ -178,7 +178,6 @@ function wearGarList(){ } function mapInit(){ - debugger var lat,lon; // if (navigator.geolocation) { // navigator.geolocation.getCurrentPosition(function (position) { @@ -191,28 +190,8 @@ function wearGarList(){ map.centerAndZoom(new BMapGL.Point(lon,lat), 11); map.enableScrollWheelZoom(true); - // 创建点标记 - let marker = new BMapGL.Marker(new BMapGL.Point(lon,lat)); - map.addOverlay(marker); - // 创建信息窗口 - var opts = { - width: 200, - height: 100, - title: '人员信息' - }; - var content = createInfoWindowContent(); - var infoWindow = new BMapGL.InfoWindow(content, opts); - // 点标记添加点击事件 - marker.addEventListener('click', function () { - map.openInfoWindow(infoWindow, new BMapGL.Point(lon,lat)); // 开启信息窗口 - }); - // 创建信息窗口内容 - function createInfoWindowContent() { - return '
张三 男 xx岁
' + - '
17681010134
' + - '
查看轨迹
'; - } - + // 人员定位 + personnelPositioning(); // 绘制镂空面 RecreateFence(); @@ -225,6 +204,92 @@ function wearGarList(){ } + //人员定位 + function personnelPositioning(){ + const url = commonUrl + "screen/largeScreen/personnelControl/personnelCoordinatePoint"; + const params = { + "roleCode": roleCode, + "orgId": orgId, + "userId": userId, + "bidCode": bidCode + } + let encryptStr = encryptCBC(JSON.stringify(params)); + ajaxRequest(url, "POST", encryptStr, true, function () { + }, function (result) { + console.log(result); + if (result.code === 200) { + + let data = result.data; + data.forEach(function(item) { + debugger + let arrName = item.modeName.split(','); + let arr = item.val.split(',') + for (let i = 0; i < arrName.length; i++) { + item[arrName[i]] = arr[i]; + } + // 解析经纬度和绑定人 + var latitude = parseFloat(item.维度); // 维度 + var longitude = parseFloat(item.经度); // 经度 + var bindUser = item.绑定人; // 绑定人 + + 创建标记点 + var point = new BMapGL.Point(longitude, latitude); + var marker = new BMapGL.Marker(point); + map.addOverlay(marker); + + // 创建信息窗口 + var opts = { + width: 200, + height: 100, + title: '人员信息' + }; + var content = createInfoWindowContent(item.userName, bindUser, item.phone); // 使用解析后的数据创建信息窗口内容 + var infoWindow = new BMapGL.InfoWindow(content, opts); + + // 点标记添加点击事件 + marker.addEventListener('click', function () { + map.openInfoWindow(infoWindow, point); // 开启信息窗口 + }); + }); + console.log(data); + // 创建信息窗口内容 + function createInfoWindowContent(userName, bindUser, phone) { + return '
' + userName + ' ' + bindUser + '
' + + '
' + phone + '
' + + '
查看轨迹
'; + } + // // 创建点标记 + // let marker = new BMapGL.Marker(new BMapGL.Point(lon,lat)); + // map.addOverlay(marker); + // // 创建信息窗口 + // var opts = { + // width: 200, + // height: 100, + // title: '人员信息' + // }; + // var content = createInfoWindowContent(); + // var infoWindow = new BMapGL.InfoWindow(content, opts); + // // 点标记添加点击事件 + // marker.addEventListener('click', function () { + // map.openInfoWindow(infoWindow, new BMapGL.Point(lon,lat)); // 开启信息窗口 + // }); + // // 创建信息窗口内容 + // function createInfoWindowContent() { + // return '
张三 男 xx岁
' + + // '
17681010134
' + + // '
查看轨迹
'; + // } + + } else if (result.code === 500) { + layer.msg(result.msg, { icon: 2 }); + }else if(result.code === 401){ + loginout(1) + } + }, function (xhr) { + // error(xhr) + } , "application/json",aqEnnable); + } + // 重新绘制围栏 function RecreateFence(){ const url = commonUrl + "screen/largeScreen/personnelControl/getReplicaFence"; @@ -282,7 +347,7 @@ function wearGarList(){ // error(xhr) } , "application/json",aqEnnable); } -function test(){ +function test(bindUser){ // 查看轨迹函数 layer.open({ type: 2, diff --git a/js/personnelControl/personnelControlList.js b/js/personnelControl/personnelControlList.js index 0c0cea8..f20e4e9 100644 --- a/js/personnelControl/personnelControlList.js +++ b/js/personnelControl/personnelControlList.js @@ -197,10 +197,12 @@ function wearGarList(){ function mapInit(module){ // 获取经纬度 var lat,lon; - if (navigator.geolocation) { - navigator.geolocation.getCurrentPosition(function (position) { - lat = position.coords.latitude; - lon = position.coords.longitude; + // if (navigator.geolocation) { + // navigator.geolocation.getCurrentPosition(function (position) { + // lat = position.coords.latitude; + // lon = position.coords.longitude; + lat = '31.93566198931321'; + lon = '117.16010067578883'; console.log(lon,lat) map= new BMap.Map("map"); map.centerAndZoom(new BMap.Point(lon,lat), 15); @@ -217,10 +219,10 @@ function mapInit(module){ - }); - } else { - console.log("浏览器不支持 Geolocation API"); - } + // }); + // } else { + // console.log("浏览器不支持 Geolocation API"); + // } }