git 6 년 전
부모
커밋
0b090e385a
4개의 변경된 파일64개의 추가작업 그리고 71개의 파일을 삭제
  1. 1 1
      pages/amap/amap.js
  2. 2 2
      pages/amap/fence/fence.html
  3. 60 67
      pages/amap/fence/fence.js
  4. 1 1
      scripts/lrmui.js

+ 1 - 1
pages/amap/amap.js

@@ -188,7 +188,7 @@
                         $page.find('#lockStatus').addClass('icon-suo');
                     }
                     
-                    fencePageData = {fenceInfo: fence, defaultLocation: vehiclePt};
+                    fencePageData = {fenceInfo: fence, defaultLocation: vehiclePt, fenceStatus:mapData.fenceAlarmStatus};
                 });
          
             };

+ 2 - 2
pages/amap/fence/fence.html

@@ -5,7 +5,7 @@
             <div class="mui-input-row mui-input-range">
                 <div class="part-layout">
                     <span style="min-width:40px">半径</span>
-                    <input type="range" min="0" max="1000" value="100" id="fence-radius" data-input-slider="1">
+                    <input type="range" min="0" max="500" value="100" id="fence-radius" data-input-slider="1">
                     <span id="display-radius"></span>
                 </div>
             </div>
@@ -15,7 +15,7 @@
     <div class="fence-isable lr-form-container">
             <div class="lr-form-row">
                     <label>启用围栏</label>
-                    <div id="switch1"></div>
+                    <div id="fence-switch"></div>
                 </div>
     </div>
 

+ 60 - 67
pages/amap/fence/fence.js

@@ -23,6 +23,11 @@
 
             var fenceInfo = param.fenceInfo;
             var defaultPt = param.defaultLocation;
+            var ableStatus = parm.fenceAlarmStatus;
+
+            if(ableStatus){
+                $('#fence-switch').addClass('f-active');
+            }
             console.log(param);
 
 
@@ -45,7 +50,7 @@
             // displayFence(fenceInfo);
 
 
-            $page.find('#switch1').lrswitch();
+            $page.find('#fence-switch').lrswitch();
 
             var rangeObj = $('#fence-radius');
             $('#display-radius')[0].innerHTML = rangeObj[0].value;
@@ -58,32 +63,74 @@
                 $('#display-radius')[0].innerHTML = this.value;
                 var radius = getSetRadius();
                 circleFence.setRadius(radius);
-                console.log(circleFence.getRadius( ));
-                setFenceView(circleFence);
+                // setFenceView(circleFence);
+                map.setFitView([ circleFence ]);
                 
             });
 
-
-
             map.on('moveend', function(){
                 var center = map.getCenter();
                 circleFence.setCenter(center);
             });
 
-            function setFenceCenter(center){
-                circleFence.setCenter(center); 
+            //保存
+            $page.find('#save-fence').on('tap', function(){
+                
+                learun.layer.confirm('保存将会覆盖原围栏', function (_index) { 
+                    if(_index === '1'){
+                        var data = getPostData();
+                        if(!data){
+                            learun.layer.toast('围栏信息有误或者为空');
+                            return;
+                        }
+                        postFence(data);
+                    }else{
+                        return;
+                    }
+                }, '保存围栏', ['否', '是']);
+            });
+
+            //获取提交数据
+            function getPostData(){
+                var fenceEnable = getAbleStatus();
+                var radius = circleFence.getRadius();
+                var circleCenter = circleFence.getCenter();
+                var center = {lng: circleCenter.lng, lat:circleCenter.lat}
+                var data = {
+                    type: 'circle',
+                    data: {radius: radius, center: center},
+                    fenceAlarmEnable: fenceEnable
+                };
+
+                return data;
             }
 
-            function getPresentCenter(map){
-                return map.getCenter();
+            //获取启用状态
+            function getAbleStatus(){
+                var status = $('#fence-switch').hasClass('f-active');
+                if(status){
+                    return true;
+                }else{
+                    return false;
+                }
+            }
+
+
+
+            //post围栏信息
+            function postFence(data){
+                learun.httppost(config.webapi+'?s=api/save_fence_info',data,function(res){
+                    if(!res.success){
+                        learun.layer.toast(res.message);
+                        return;
+                    }
+                    learun.layer.toast('保存成功');
+                });
             }
 
-            //围栏自适应地图等级
-            function setFenceView(fence){
-                map.setFitView([ fence ]);
-            };
 
             
+            
             //显示围栏(初始)
             // function displayFence(fenceInfo){
             //     if(!fenceInfo){
@@ -121,60 +168,6 @@
             // }
 
 
-            
-
-
-
-            // //post围栏信息
-            // function postFence(data){
-            //     var post_data = data;
-
-            //     learun.httppost(config.webapi+'?s=api/save_fence_info',post_data,function(res){
-            //         if(!res.success){
-            //             learun.layer.toast(res.message);
-            //             return;
-            //         }
-            //         learun.layer.toast('保存成功');
-            //     });
-            // }
-
-
-
-
-            // var circle = new AMap.Circle({
-            //     center: [116.433322, 39.900255],
-            //     radius: 1000, //半径
-            //     borderWeight: 3,
-            //     strokeColor: "#FF33FF", 
-            //     strokeOpacity: 1,
-            //     strokeWeight: 6,
-            //     strokeOpacity: 0.2,
-            //     fillOpacity: 0.4,
-            //     strokeStyle: 'dashed',
-            //     strokeDasharray: [10, 10], 
-            //     // 线样式还支持 'dashed'
-            //     fillColor: '#1791fc',
-            //     zIndex: 50,
-            // })
-        
-            // circle.setMap(map)
-            // // 缩放地图到合适的视野级别
-
-            
-
-            // map.setFitView([ circle ])
-            //     map.on('moveend', function(){
-            //     var center = map.getCenter();
-            //     circle.setCenter(center);
-            // });
-
-            // $('#fence-radius').on('input',function(){
-            //     $('#display-radius')[0].innerHTML = this.value;
-            //     circle.setRadius(this.value);
-            //     map.setFitView([circle]);
-                
-            // });
-
 
 
 

+ 1 - 1
scripts/lrmui.js

@@ -731,7 +731,7 @@ u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(
         };
         $.extend(dfop, op || {});
         dfop.callback = function () {
-            learun.formblur();
+            //learun.formblur();
         };
 
         setTimeout(function () {