index.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. {extend name="common/common2" /}
  2. {block name="main"}
  3. <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
  4. <script type="text/javascript"
  5. src="https://webapi.amap.com/maps?v=1.4.15&key={$gdKey}"></script>
  6. <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
  7. <style>
  8. #ydw ul {list-style:none;margin:0px;}
  9. #ydw ul li {float:left;width: 235px}
  10. #wdw ul {list-style:none;margin:0px;}
  11. #wdw ul li {float:left;width: 235px}
  12. #ydw {margin-left:-25px;}
  13. #wdw {margin-left:-25px;}
  14. </style>
  15. <div class="ibox">
  16. <div class="ibox-content">
  17. <div class="row">
  18. <div class="col-xs-12" style="display: flex">
  19. <div class="input-group" id="online_number">
  20. 在线设备数量:0
  21. </div>
  22. &nbsp;&nbsp;
  23. <div class="input-group" id="cpage">
  24. <a href="">上一页&nbsp;&nbsp;|</a>
  25. <a style="color:black;">&nbsp;&nbsp;当前第1页&nbsp;&nbsp;</a>
  26. <a>|&nbsp;&nbsp;下一页&nbsp;&nbsp;|</a>
  27. <a style="color:black;">&nbsp;&nbsp;共0条</a>
  28. </div>
  29. &nbsp;&nbsp;
  30. <div class="input-group" onclick="layerOpenReload(this)" url="{:url('getSosList')}" data-title="紧急呼叫列表" data-table="1" id="sos_num" style="display: none;color: red;cursor: pointer">
  31. 紧急呼叫数量:0
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="jqGrid_wrapper" style="background: #ffffff">
  37. <div id="container" style="border-collapse: collapse;margin-left: 10px;margin-top:82px;width: 820px;height: 435px;"></div>
  38. </div>
  39. <div class="ibox-content" style="height: 450px;width: 295px;position: relative;float: right;overflow-x: hidden;overflow-y: scroll;">
  40. <fieldset>
  41. <div class="col-xs-12">
  42. <label class="cr-inline" onclick="a_tap(1)">
  43. <input type="radio" checked name="type" value="1" >有定位设备&nbsp;&nbsp;
  44. </label>
  45. <label class="cr-inline" onclick="a_tap(0)">
  46. <input type="radio" name="type" value="0" >无定位设备
  47. </label>
  48. </div>
  49. <div id="ydw">
  50. <ul id="ydwul">
  51. </ul>
  52. </div>
  53. <div id="wdw" style="display: none">
  54. <ul id="wdwul">
  55. </ul>
  56. </div>
  57. </fieldset>
  58. </div>
  59. </div>
  60. {/block}
  61. {block name="script"}
  62. <script type="text/javascript">
  63. getSosNum();
  64. function getSosNum() {
  65. $.ajax({
  66. type: "post",
  67. url: '/admin/Location/getSosNum.html',
  68. async: false,
  69. dataType: 'json',
  70. success: function (res) {
  71. if (res.code == 1) {
  72. if(res.data > 0){
  73. $('#sos_num').attr('style','display:block;color:red;cursor:pointer');
  74. $('#sos_num').html('紧急呼叫数量:'+res.data);
  75. }else {
  76. $('#sos_num').attr('style','display:none');
  77. }
  78. } else {
  79. layer.msg(res.msg, {icon: 2})
  80. }
  81. },
  82. });
  83. }
  84. window.setInterval(getSosNum,10000);
  85. function a_tap(val) {
  86. if(val==1){
  87. $("#ydw").attr('style','display:block');
  88. $("#wdw").attr('style','display:none');
  89. }else {
  90. $("#wdw").attr('style','display:block');
  91. $("#ydw").attr('style','display:none');
  92. }
  93. }
  94. //初始化地图对象,加载地图
  95. var data = [];
  96. var page = 1;
  97. get_data(page)
  98. function setPage(page) {
  99. get_data(page);
  100. }
  101. function get_data(page) {
  102. $.ajax({
  103. type: "post",
  104. url: '/admin/Location/index.html',
  105. async: false,
  106. dataType: 'json',
  107. data: {
  108. page: page,
  109. },
  110. success: function (res) {
  111. if (res.code == 1) {
  112. console.log(res)
  113. data = res.data.data;
  114. $('#online_number').html('在线设备数量:'+res.data.online_numbers);
  115. $('#cpage').html(res.data.page);
  116. $('#ydwul').html(res.data.ydw);
  117. $('#wdwul').html(res.data.wdw);
  118. } else {
  119. layer.msg(res.msg, {icon: 2})
  120. }
  121. },
  122. });
  123. }
  124. var map = new AMap.Map("container", {resizeEnable: true});
  125. var lnglats = data;
  126. var infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(0, -30)});
  127. for (var i = 0, marker; i < lnglats.length; i++) {
  128. var marker = new AMap.Marker({
  129. position: lnglats[i]['lonLat'],
  130. map: map,
  131. icon: lnglats[i]['icon'],
  132. });
  133. marker.content = '设备:' + lnglats[i]['imeI'] + '</br>昵称:' + lnglats[i]['name']
  134. + '</br>时间:' + lnglats[i]['updated_at']
  135. + '</br>地址:' + lnglats[i]['address']
  136. + '</br>经度:' + lnglats[i]['lon'] + ',纬度:' + lnglats[i]['lat']
  137. ;
  138. marker.on('click', markerClick);
  139. }
  140. function markerClick(e) {
  141. infoWindow.setContent(e.target.content);
  142. infoWindow.open(map, e.target.getPosition());
  143. }
  144. map.setFitView();
  145. </script>
  146. {/block}