Browse Source

问题修复

yf_zd 5 years ago
parent
commit
f887197ad2

+ 175 - 2
templates/backstageNet/jk/equipmanage_jk.html

@@ -345,6 +345,25 @@
             margin-left: 5px;
             cursor: pointer;
         }
+        .jkedit {
+            background-image: url(../static/imgs/jkedit.png);
+            background-repeat: no-repeat;
+            background-size: 100% 100%;
+            width: 120px;
+            height: 30px;
+            margin: auto;
+            margin-top: 15px;
+            /* margin-bottom: 15px; */
+        }
+
+        .jkedit span {
+            width: 54px;
+            height: 32px;
+            display: inline-block;
+            float: left;
+            margin-left: 5px;
+            cursor: pointer;
+        }
         /* 监控列表 */
         .gardenListBtn{
             margin-top: 10px;
@@ -364,6 +383,19 @@
         .gardenListBtn button.layui-btn-primary:hover{
             box-shadow: 0 0 2px 0px #039c6b;
         }
+        /* 气象站定位弹框 */
+		#addLocation{
+			display: none;
+			padding: 20px;
+			height: 450px;
+		}
+		.mapbox{
+			height: 100%;
+		}
+		#allmap{
+			width: 100%;
+			height: 100%;
+		}
     </style>
 </head>
 <script>
@@ -470,6 +502,10 @@
                                             <span onmousedown="configCamera(this,'move',8)" onmouseup="configCamera(this,'stop')"></span>
                                             <span onmousedown="configCamera(this,'move',9)" onmouseup="configCamera(this,'stop')"></span>
                                         </div>
+                                        <div class="jkedit">
+                                            <span onclick="addMapPosition()" ></span>
+                                            <span onclick="ChangeName()" ></span>
+                                        </div>
                                     </div>
                                 </td>
                             </tr>
@@ -483,12 +519,22 @@
             </div>
         </div>
     </div>
-    <input type="text" name="" id="currid" value="{{equip_id|default:''}}">
-
+    <input type="hidden" name="" id="currid" value="{{equip_id|default:''}}">
+    <div id="addLocation">
+        <div class="">
+            经度:<input type="text" name="title" lay-verify="title" id="lng" placeholder="" class="layui-input" style="width: 200px;display: inline-block;">
+            纬度:<input type="text" name="title" lay-verify="title" id="lat"  placeholder="" class="layui-input" style="width: 200px;display: inline-block;">
+            <button type="button" id="shaixuan" onclick="sub_getMarker()" class="layui-btn layui-btn-normal">定位</button>			
+        </div>
+        <div class="mapbox">
+            <div id="allmap"></div>
+        </div>
+    </div>
 
     <script src="{% static '/lib/js/jquery-2.1.4.min.js'%}"></script>
     <script src="{% static '/lib/layui/layui.js'%}"></script>
     <script src="{% static '/js/backstageNet/common.js'%}"></script>
+	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=TcRPmrsiZUqdUBWoELrUArRkCRC36KMx"></script>
 
     <script>
         $.ajaxSetup({
@@ -541,7 +587,134 @@
 
             $("#span_V" + n).addClass("active");
         }
+        // 百度地图API功能
+        var map = new BMap.Map("allmap");
+        map.centerAndZoom(new BMap.Point(113.64964385, 34.75661006), 13);// 创建点坐标
+        map.enableScrollWheelZoom();   //启用滚轮放大缩小,默认禁用
+        map.enableContinuousZoom();    //启用地图惯性拖拽,默认禁用
+        map.addControl(new BMap.NavigationControl());               // 添加平移缩放控件
+        map.addControl(new BMap.ScaleControl());                    // 添加比例尺控件
+        map.addControl(new BMap.OverviewMapControl());              //添加缩略地图控件
+        map.enableScrollWheelZoom();                            //启用滚轮放大缩小
+        map.addControl(new BMap.MapTypeControl());
+        //单击获取点击的经纬度
+        map.addEventListener("click", function (e) {
+            map.clearOverlays();
+            $('#lng').val(e.point.lng);
+            $('#lat').val(e.point.lat);
+            var point = new BMap.Point(e.point.lng, e.point.lat);
+            var marker = new BMap.Marker(point);
+            map.addOverlay(marker);
+            // alert(e.point.lng + "," + e.point.lat);
+        });
 
+        function sub_getMarker() {
+            map.clearOverlays();
+            var points = []
+            var point = new BMap.Point($('#lng').val(), $('#lat').val());
+            var marker = new BMap.Marker(point);
+            map.addOverlay(marker);
+            points.push(point)
+            console.log(points)
+            map.setViewport(points);
+        }
+        // 添加地图定位
+        function addMapPosition(obj) {
+            id = $('#divMain a.aSelected').find('.equipname').html().trim();
+            layui.use('layer', function () { //独立版的layer无需执行这一句
+                var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
+                layer.open({
+                    title: '手动添加位置',
+                    type: 1,
+                    area: ['900px', '600px'],
+                    btn: ['确定', '取消'],
+                    yes: function (index, layero) {
+                        //按钮【按钮一】的回调
+                        if($('#lng').val() && $('#lat').val()){
+                            $.ajax({
+                                url:'equip_location',
+                                type:'post',
+                                data:{
+                                    e_id:id,
+                                    lng:$('#lng').val(),
+                                    lat:$('#lat').val(),
+                                },
+                                success:function(data){
+                                    console.log(data)
+                                    if(data == 0){
+                                        layer.closeAll();
+                                    }else{
+                                        layer.msg('添加失败', {icon: 2}); 
+                                    }
+                                },
+                                error:function(type){
+                                    console.log(type)
+                                }
+                            })
+                        }else{
+                            layer.msg('请先定位', {icon: 2}); 
+                        }
+                    
+                        return false;  
+                    }
+                    , btn2: function (index, layero) {
+                        //按钮【按钮二】的回调
+                        //return false 开启该代码可禁止点击该按钮关闭
+                    },
+                    content: $('#addLocation')
+                });
+            });
+        }
+
+        //点击修改名称,跳出弹框并显示所选设备的设备名称;
+        function ChangeName() {
+            id = $('#divMain a.aSelected').find('.equipname').html().trim();
+            layui.use('layer', function () { //独立版的layer无需执行这一句
+                var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
+                layer.prompt({ title: '修改名称', value: '', area: 400 }, function (val, index) {
+                    layer.close(index);
+                    ChangeNameSub(id, val);
+                });
+            });
+        }
+        function ChangeNameSub(deviceId, name, address) {
+                data = {
+                    ename: name,
+                    eid: deviceId
+                }
+            //校验重复校验重复
+            $.ajax({
+                type: "post",
+                url: "equip_location",
+                data: data,
+                dataType: "json",
+                success: function (data) {
+                    if (data == 1) {
+                        // layer.tips("设备名已存在!", '#ename');
+                        layui.use('layer', function () {
+                            var layer = layui.layer;
+                            layer.msg('设备名已存在!');
+                        })
+                        return false;
+                    }
+                    else if (data == 2) {
+                        layui.use('layer', function () {
+                            var layer = layui.layer;
+                            layer.msg('设备位置添加成功!');
+                            // window.location.href = window.location.href;
+                        })
+                    }
+
+                    else if (data == 0) {
+                        layui.use('layer', function () {
+                            var layer = layui.layer;
+                            layer.msg('设备名称修改成功!');
+                            // window.location.href = window.location.href;
+                        })
+                    } 
+                }
+            });
+        }
         function setMouseOut(idx) {
             if (curIndex != idx && $("#a_" + idx).length > 0)
                 $("#a_" + idx).removeClass("aSelected");

+ 69 - 23
templates/backstageNet/map/map.html

@@ -21,6 +21,10 @@
             width: 100%;
             height: 100vh;
         }
+        .BMapLib_SearchInfoWindow .BMapLib_bubble_content p{
+            line-height: 24px;
+            font-size: 14px;
+        }
     </style>
 </head>
 
@@ -125,6 +129,7 @@
     $("#mapControl_type").html("卫星");
     map.centerAndZoom(new BMap.Point(map_center[0], map_center[1]), 15);
     map.enableScrollWheelZoom(true);
+    geoc = new BMap.Geocoder();
 
     //气象站标识
     var qxzIcon = new BMap.Icon("{% static 'imgs/qxz.png'%}", new BMap.Size(30, 40), { imageSize: new BMap.Size(30, 40),anchor: new BMap.Size(0, 0) });
@@ -137,12 +142,17 @@
     //摄像头标识——加密
     var sxtEncryptIcon = new BMap.Icon("{% static 'imgs/sxt-Encrypt.png'%}", new BMap.Size(30, 40), { imageSize: new BMap.Size(30, 40) });
     
-    function openInfo(title, content, e) {
+    function openInfo(title, id, e) {
         var p = e.target;
-        var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
+        var point = new BMap.Point(p.getPosition().lng-.0004, p.getPosition().lat-.001);
+        geoc.getLocation(point, function (rs) {
+            var addComp = rs.addressComponents;
+            $('.area').html('位置:' + addComp.province + ", " + addComp.city + ", " + addComp.district)
+        });
         //var infoWindow = new BMap.InfoWindow(content);  // 创建信息窗口对象
         //map.openInfoWindow(infoWindow, point); //开启信息窗口
 
+        var content = '<p>IMEI:' + id + '</p><p class="area">位置:' + e.point.equip_location + '</p></br>';
         var searchInfoWindow = new BMapLib.SearchInfoWindow(map, content, {
             title: title, //标题 
             panel: "panel", //检索结果面板  
@@ -180,22 +190,27 @@
     var WeatherstationMarker = [];//气象站
     var CameraMarker = [];//摄像头
 
-    GetMonitorMark(1);
+    // GetMonitorMark(1);
+    getData()
     function getData(){
         $.ajax({
-            url:'',
+            url:'equip_addr',
             type:'post',
             data:'',
             dataType:'json',
             success:function(data){
-                
+                var dat = {
+                    "Status": true,
+                    "list":data
+                }
+                GetMonitorMark(dat)
             }
         })
     }
 
     //监测数据
-    function GetMonitorMark(ShowStatus) {
-        var data = {
+    function GetMonitorMark(data) {
+        var data1 = {
             "Status": true,
             "list": [{
                 "id": "D08652664",
@@ -239,8 +254,8 @@
                 for (var i = 0; i < jsonObj.list.length; i++) {
                     var markObj = jsonObj.list[i];
 
-                    var id = markObj.id;
-                    var markType = markObj.markType;
+                    var id = markObj.equip_id;
+                    var markType = markObj.equip_type;
                     var title = markObj.title;
                     var theName = markObj.EquipmentName;
                     var lng = markObj.lng;
@@ -256,9 +271,9 @@
                         var CameraNo = markObj.CameraNo;
                         marker = createCameraMarker(lng, lat, icon, title, id, CameraNo);
                     }
-                    else //气象站
-                        marker = createMarker(lng, lat, icon, title, content);
-
+                    else if (markType == "5") { //气象站
+                        marker = createMarker(lng, lat, icon, '气象站', id);
+                    }
                     map.addOverlay(marker);
 
                     switch (markType) {
@@ -287,31 +302,25 @@
             $("#" + objId).html("");
     }
     function GetMarkerIcon(markType, isRun) {
-        var icon = qxzIcon;
+        var icon = '';
 
         switch (markType) {
             case 5:
-                if (isRun)
-                    icon = qxzIcon;
-                else
-                    icon = qxzOffIcon;
+                icon = qxzIcon;
                 break;
             case 6:
-                if (isRun)
-                    icon = sxtIcon;
-                else
-                    icon = sxtOffIcon;
+                icon = sxtIcon;
                 break;
         }
 
         return icon;
     }
     //将创建marker的方法抽出来,否则的话总是打开最后一个InfoWindow
-    function createMarker(lng, lat, icon, title, content) {
+    function createMarker(lng, lat, icon, title, id) {
 
         var markerx = new BMap.Marker(new BMap.Point(lng, lat), { icon: icon });
         markerx.addEventListener("click", function (e) {
-            openInfo(title, content, e);
+            openInfo(title, id, e);
         });
         return markerx;
     }
@@ -358,6 +367,43 @@
         $("#mapControl_typeChange").hide();
 
     }
+    function toggleIcon(obj, markType) {
+        var IconShow = false;
+
+        if ($(obj).hasClass("IconHide")) {
+            IconShow = true;
+            $(obj).removeClass("IconHide");
+        }
+        else {
+            IconShow = false;
+            $(obj).addClass("IconHide");
+        }
+
+        var pointArray;
+
+        switch (markType) {
+            case 5:
+                pointArray = WeatherstationMarker;
+                break;
+            case 6:
+                pointArray = CameraMarker;
+                break;
+        }
+
+        for (var i = 0; i < pointArray.length; i++) {
+            var marker = pointArray[i];
+            if (IconShow) {
+                var marker = pointArray[i];
+                //map.addOverlay(marker); 
+                marker.show();
+            }
+            else {
+                var marker = pointArray[i];
+                // map.removeOverlay(marker); 
+                marker.hide();
+            }
+        }
+    }
     // 图例悬浮
     function SetAnimation(opFlag, markType) {
 

+ 157 - 2
templates/backstageNet/qxzctrl/qxzctrl.html

@@ -292,6 +292,19 @@
         .fr {
             float: right;
         }
+        /* 气象站定位弹框 */
+		#addLocation{
+			display: none;
+			padding: 20px;
+			height: 450px;
+		}
+		.mapbox{
+			height: 100%;
+		}
+		#allmap{
+			width: 100%;
+			height: 100%;
+		}
     </style>
 </head>
 
@@ -336,7 +349,11 @@
                 <div class="ctrlDiv">
                     <div class="title">
                         <div class="widget-title">
-                            <button type="button" class="layui-btn  layui-btn-normal layui-btn-sm fr" onclick="qxzDownCtrlFun()">刷新</button>
+                            <div class="fr">
+                                <button type="button" class="layui-btn  layui-btn-normal layui-btn-sm" onclick="addMapPosition()">定位</button>
+                                <button type="button" class="layui-btn  layui-btn-normal layui-btn-sm" onclick="ChangeName()">重命名</button>
+                                <button type="button" class="layui-btn  layui-btn-normal layui-btn-sm" onclick="qxzDownCtrlFun()">刷新</button>
+                            </div>
                             <h2>控制开关
                                 <span id="Uptime"></span>
                             </h2>
@@ -352,10 +369,20 @@
         </div>
     </div>
     <input type="hidden" id="qxzPhotoId">
-
+    <div id="addLocation">
+        <div class="">
+            经度:<input type="text" name="title" lay-verify="title" id="lng" placeholder="" class="layui-input" style="width: 200px;display: inline-block;">
+            纬度:<input type="text" name="title" lay-verify="title" id="lat"  placeholder="" class="layui-input" style="width: 200px;display: inline-block;">
+            <button type="button" id="shaixuan" onclick="sub_getMarker()" class="layui-btn layui-btn-normal">定位</button>			
+        </div>
+        <div class="mapbox">
+            <div id="allmap"></div>
+        </div>
+    </div>
     <script src="{% static '/lib/js/jquery-2.1.4.min.js'%}"></script>
     <script src="{% static '/lib/layui/layui.js'%}"></script>
     <script src="{% static '/js/backstageNet/common.js'%}"></script>
+	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=TcRPmrsiZUqdUBWoELrUArRkCRC36KMx"></script>
     <script>
         var currpage = 1;
         var layer, element, form;
@@ -376,6 +403,134 @@
             })
 
         })
+         // 百度地图API功能
+         var map = new BMap.Map("allmap");
+        map.centerAndZoom(new BMap.Point(113.64964385, 34.75661006), 13);// 创建点坐标
+        map.enableScrollWheelZoom();   //启用滚轮放大缩小,默认禁用
+        map.enableContinuousZoom();    //启用地图惯性拖拽,默认禁用
+        map.addControl(new BMap.NavigationControl());               // 添加平移缩放控件
+        map.addControl(new BMap.ScaleControl());                    // 添加比例尺控件
+        map.addControl(new BMap.OverviewMapControl());              //添加缩略地图控件
+        map.enableScrollWheelZoom();                            //启用滚轮放大缩小
+        map.addControl(new BMap.MapTypeControl());
+        //单击获取点击的经纬度
+        map.addEventListener("click", function (e) {
+            map.clearOverlays();
+            $('#lng').val(e.point.lng);
+            $('#lat').val(e.point.lat);
+            var point = new BMap.Point(e.point.lng, e.point.lat);
+            var marker = new BMap.Marker(point);
+            map.addOverlay(marker);
+            // alert(e.point.lng + "," + e.point.lat);
+        });
+
+        function sub_getMarker() {
+            map.clearOverlays();
+            var points = []
+            var point = new BMap.Point($('#lng').val(), $('#lat').val());
+            var marker = new BMap.Marker(point);
+            map.addOverlay(marker);
+            points.push(point)
+            console.log(points)
+            map.setViewport(points);
+        }
+        // 添加地图定位
+        function addMapPosition(obj) {
+            id = $('.equipListUl li.active').attr('id');
+            layui.use('layer', function () { //独立版的layer无需执行这一句
+                var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
+                layer.open({
+                    title: '手动添加位置',
+                    type: 1,
+                    area: ['900px', '600px'],
+                    btn: ['确定', '取消'],
+                    yes: function (index, layero) {
+                        //按钮【按钮一】的回调
+                        if($('#lng').val() && $('#lat').val()){
+                            $.ajax({
+                                url:'equip_location',
+                                type:'post',
+                                data:{
+                                    e_id:id,
+                                    lng:$('#lng').val(),
+                                    lat:$('#lat').val(),
+                                },
+                                success:function(data){
+                                    console.log(data)
+                                    if(data == 0){
+                                        layer.closeAll();
+                                    }else{
+                                        layer.msg('添加失败', {icon: 2}); 
+                                    }
+                                },
+                                error:function(type){
+                                    console.log(type)
+                                }
+                            })
+                        }else{
+                            layer.msg('请先定位', {icon: 2}); 
+                        }
+                    
+                        return false;  
+                    }
+                    , btn2: function (index, layero) {
+                        //按钮【按钮二】的回调
+                        //return false 开启该代码可禁止点击该按钮关闭
+                    },
+                    content: $('#addLocation')
+                });
+            });
+        }
+
+        //点击修改名称,跳出弹框并显示所选设备的设备名称;
+        function ChangeName() {
+            id = $('.equipListUl li.active').attr('id');
+            layui.use('layer', function () { //独立版的layer无需执行这一句
+                var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
+                layer.prompt({ title: '修改名称', value: '', area: 400 }, function (val, index) {
+                    layer.close(index);
+                    ChangeNameSub(id, val);
+                });
+            });
+        }
+        function ChangeNameSub(deviceId, name, address) {
+                data = {
+                    ename: name,
+                    eid: deviceId
+                }
+            //校验重复校验重复
+            $.ajax({
+                type: "post",
+                url: "equip_location",
+                data: data,
+                dataType: "json",
+                success: function (data) {
+                    if (data == 1) {
+                        // layer.tips("设备名已存在!", '#ename');
+                        layui.use('layer', function () {
+                            var layer = layui.layer;
+                            layer.msg('设备名已存在!');
+                        })
+                        return false;
+                    }
+                    else if (data == 2) {
+                        layui.use('layer', function () {
+                            var layer = layui.layer;
+                            layer.msg('设备位置添加成功!');
+                            // window.location.href = window.location.href;
+                        })
+                    }
+
+                    else if (data == 0) {
+                        layui.use('layer', function () {
+                            var layer = layui.layer;
+                            layer.msg('设备名称修改成功!');
+                            // window.location.href = window.location.href;
+                        })
+                    } 
+                }
+            });
+        }
         // 首页
         function gotofirstpage() {
             currpage = 1;

+ 13 - 0
templates/outerNet/index2.html

@@ -251,7 +251,20 @@
                             <ul class="news-txt-list">
                                 {% for news in article %}
                                 <li class="news-txt-item">
+                                    {% if news.art_type == '5' %}
                                     <a href="news_view?id={{news.id}}" target="_blank">{{news.title}}</a>
+                                    {% elif news.art_type == '6' %}
+                                    <a href="video_detail?name={{news.title}}" target="_blank">{{news.title}}</a>
+                                    {% elif news.art_type == '7' %}
+                                    <a href="equip_show_detail?name={{news.title}}" target="_blank">{{news.title}}</a>
+                                    {% elif news.art_type == '8' %}
+                                    <a href="garden_intro?name={{news.title}}" target="_blank">{{news.title}}</a>
+                                    {% elif news.art_type == '9' %}
+                                    <a href="dorm_detail?name={{news.title}}" target="_blank">{{news.title}}</a>
+                                    {% elif news.art_type == '10' %}
+                                    <a href="tourist?name={{news.title}}" target="_blank">{{news.title}}</a>
+                                    {% else %}
+                                    {% endif %} 
                                 </li>
                                 {% endfor %}
                             </ul>

+ 1 - 0
templates/static/css/index2.css

@@ -450,6 +450,7 @@ span.swiper-pagination-bullet-active{
 .travelList .travelItem .travelTitle div{
     height: 40px;
     overflow: hidden;
+    font-size: 14px;
 }
 .travelCover .travelRight{
     width: 280px;