git vor 6 Jahren
Ursprung
Commit
20ce343325
3 geänderte Dateien mit 64 neuen und 47 gelöschten Zeilen
  1. 58 41
      pages/amap/amap.js
  2. 3 3
      pages/amap/route/route.js
  3. 3 3
      pages/baojinginfo/baojinginfo.js

+ 58 - 41
pages/amap/amap.js

@@ -7,8 +7,10 @@
     var overlayData;
     var vehicleMarker;
     var circle;
+    var userInfo;
     var page = {
         init: function ($page) {
+            userInfo = learun.storage.get('userinfo');
 			//初始化顶部导航栏
             function init_nav(){
 				var _html = '';
@@ -146,7 +148,6 @@
 				navigator.geolocation.getCurrentPosition(onSuccess, onError);
 			}
 			
-			var userinfo = learun.storage.get('userinfo');
 			//上报客户端极光注册信息
 			function update_jg_registrationid(){
 				var onGetRegistrationID = function(data) {
@@ -157,7 +158,7 @@
 					}else{
 						var post_data = {
 							"regid":data,
-							"uid":userinfo.baseinfo.userId
+							"uid":learun.storage.get('userinfo').baseinfo.userId
 						};
 						learun.httppost(config.webapi+'?s=api/update_jg_registrationid',post_data,function(res){
 
@@ -197,7 +198,7 @@
             //地图初始化
             if(!mainMap){
                 mainMap = new AMap.Map('amapcontainer', {
-                    center: [120.210649,30.246071],
+                    center: [120.202222,30.184811],
                     zoom: 15
                 });
             }
@@ -238,6 +239,7 @@
                 var mapData = null;
                 learun.httpget(config.webapi+"/?s=api/get_map_index_data", {deviceNumber:deviceNumber}, function (_res) {
                     mapData = _res.data;
+                    console.log(mapData);
                     if(!mapData){
                         learun.layer.warning('无地图数据,请检测网络或联系管理员!', function () { }, '提示', '关闭');
                         return;
@@ -245,6 +247,9 @@
                     latlngSign = mapData.vehicleLocation.longitude;
                     if(!latlngSign){
                         first = false;    
+                        t.map.setZoomAndCenter(15,[120.202222,30.184811]);
+                        t.vehicle.setPosition(null);
+                        t.vehicle.setMap(null);
                     }else{
                         var vehiclePt = new AMap.LngLat(+mapData.vehicleLocation.longitude, +mapData.vehicleLocation.latitude);
                         startEnd.end = vehiclePt;
@@ -256,6 +261,8 @@
                         t.map.setZoomAndCenter(15,vehiclePt);
                     }
                     $('#battery').html(mapData.battery+'%');
+
+                    vehicleInfoWin();
                     
 
                     //在线状态
@@ -286,8 +293,7 @@
                         fence = JSON.parse(fence);
                         if(fence.type == 'circle'){
                             t.circle.setCenter(new AMap.LngLat(fence.data.center.lng, fence.data.center.lat));
-                            t.circle.setRadius(fence.data.radius);
-                        
+                            t.circle.setRadius(parseInt(fence.data.radius));
                             t.circle.setMap(t.map);
                         }                 
                     }
@@ -316,7 +322,7 @@
                 var lockStatus = $('#lockStatus');
 
                 var postData = {
-                    deviceNumber: userinfo.baseinfo.deviceNumber,
+                    deviceNumber: learun.storage.get('userinfo').baseinfo.deviceNumber,
                     lockStatus: lockStatus.hasClass('icon-jiesuo') ? 1 : 0
                 }
 
@@ -350,44 +356,50 @@
             AMapUI.defineTpl("ui/overlay/SimpleInfoWindow/tpl/container.html", [], function() {
                 return document.getElementById('my-infowin-tpl').innerHTML;
             });
-            AMapUI.loadUI(['overlay/SimpleInfoWindow'], function(SimpleInfoWindow) {
-                
-                lnglat = vehicleMarker.getPosition();
-                var address = '坐标未解析成功';
 
+            function vehicleInfoWin(){
+                AMapUI.loadUI(['overlay/SimpleInfoWindow'], function(SimpleInfoWindow) {
+                    
+                    lnglat = vehicleMarker.getPosition();
+                    console.log(lnglat)
+                    var address = '坐标未解析成功';
 
 
 
-                if(!geocoder){
-                    geocoder = new AMap.Geocoder({
-                        city: "0571", //城市设为北京,默认:“全国”
-                        radius: 500 //范围,默认:500
-                    });
-                }
-                
-                geocoder.getAddress(lnglat, function(status, result) {
-                    if (status === 'complete' && result.regeocode) {
-                        address = result.regeocode.formattedAddress;
-
-                        if(!infoWindow){
-                                infoWindow = new SimpleInfoWindow({
-                                infoBody: '<span>'+address+'</span>',
-                                //基点指向marker的头部位置
-                                offset: new AMap.Pixel(50, -64)
-                            });
-                        }
-                        infoWindow.open(mainMap, lnglat);
-                        infoWindow.get$Container().on('click', function(){
-                            learun.nav.go({ path: 'amap/navigation', title: '导航', isBack: true, isHead: true, param: startEnd });
-                            if(infoWindow){infoWindow.close( );}
-                        });
 
-                    }else{
-                        // learun.layer.toast(JSON.stringify(result));
+                    if(!geocoder){
+                        geocoder = new AMap.Geocoder({
+                            city: "0571", //城市设为北京,默认:“全国”
+                            radius: 500 //范围,默认:500
+                        });
                     }
+                    
+                    geocoder.getAddress(lnglat, function(status, result) {
+                        if (status === 'complete' && result.regeocode) {
+                            address = result.regeocode.formattedAddress;
+
+                            if(!infoWindow || userInfo.baseinfo.token != learun.storage.get('userinfo').baseinfo.token){
+                                    infoWindow = new SimpleInfoWindow({
+                                    infoBody: '<span>'+address+'</span>',
+                                    //基点指向marker的头部位置
+                                    offset: new AMap.Pixel(50, -64)
+                                });
+                            }
+                            infoWindow.open(mainMap, lnglat);
+                            infoWindow.get$Container().on('click', function(){
+                                learun.nav.go({ path: 'amap/navigation', title: '导航', isBack: true, isHead: true, param: startEnd });
+                                if(infoWindow){
+                                    infoWindow.close( );
+                                }
+                            });
+
+                        }else{
+                            // learun.layer.toast(JSON.stringify(result));
+                        }
+                    });
+                    
                 });
-                
-            });
+        }
 
 
 
@@ -468,13 +480,18 @@
 
 
         reload: function ($page, pageinfo) {
+
+            if(userInfo.baseinfo.token != learun.storage.get('userinfo').baseinfo.token){
+                vehicleMarker.setMap(null);
+                infoWindow = null;
+                getVehicleData(overlayData, true);
+            }else{
+                getVehicleData(overlayData);
+            }
+
             if(infoWindow){
                 infoWindow.open(mainMap, lnglat);
             }
-            getVehicleData(overlayData);
-
-            console.log($page);
-            console.log(pageinfo);
             
         },
 

+ 3 - 3
pages/amap/route/route.js

@@ -5,7 +5,7 @@
 
            learun.layer.loading(true, "加载数据中");
            var userinfo = learun.storage.get('userinfo');
-            $('#route-devicenumber').text(userinfo.baseinfo.deviceNumber);
+            $('#route-gpsNumber').text(userinfo.baseinfo.gpsNumber);
             $('#date-time').text('时间:'+param.lastTime || '0000-00-00 00:00:00');
             $('#vehicle-speed').text('速度:'+param.speed+' km/h')
 			
@@ -232,7 +232,7 @@
 
                     var post_data = {
                         "date":date,
-                        "deviceNumber": userinfo.baseinfo.deviceNumber
+                        "gpsNumber": userinfo.baseinfo.gpsNumber
                     }
                     var geocoder = null;
                     learun.httppost(config.webapi+'?s=api/get_gps_route',post_data,function(res){
@@ -268,7 +268,7 @@
                 var nowDate = new Date().Format("yyyy-MM-dd");
                 var post_data = {
                     "date": nowDate,
-                    "deviceNumber": userinfo.baseinfo.deviceNumber
+                    "gpsNumber": userinfo.baseinfo.gpsNumber
                 }
                 learun.httppost(config.webapi+'?s=api/get_gps_route',post_data,function(res){
                     if(!res.success){

+ 3 - 3
pages/baojinginfo/baojinginfo.js

@@ -48,7 +48,7 @@
 												<div class="lr-list-item lr-list-item-multi" style="line-height: 25px;">\
 													<h4 id="time">'+ _item.AddTime +'</h4>\
 													<p class="lr-ellipsis">'+ _item.LicensePlate +'<span class="" style="right: 15px;position: absolute;top: 50%;transform: translateY(-50%);">'+ _item.DeviceNumber +'</span></p>\
-													<a class="lr-nav-right gaojingdetail">'+ _item.Type +'<span class="lr-badge lr-badge-primary lr-badge-inverted">详情</span></a>\
+													<a class="lr-nav-right gaojingdetail">告警<span class="lr-badge lr-badge-primary lr-badge-inverted">详情</span></a>\
 												</div>';
 									$page.find('.gaojinginfo').html(msg_html_list);
 									var addtime = $('#time').text();
@@ -90,12 +90,12 @@
 												<div class="lr-list-item lr-list-item-multi" style="line-height: 25px;">\
 													<h4 id="time">'+ _item.AddTime +'</h4>\
 													<p class="lr-ellipsis">'+ _item.LicensePlate +'<span class="" style="right: 15px;position: absolute;top: 50%;transform: translateY(-50%);">'+ _item.DeviceNumber +'</span></p>\
-													<a class="lr-nav-right gonggaodetail">'+ _item.Type +'<span class="lr-badge lr-badge-primary lr-badge-inverted">详情</span></a>\
+													<a class="lr-nav-right gonggaodetail">公告<span class="lr-badge lr-badge-primary lr-badge-inverted">详情</span></a>\
 												</div>';
 									$page.find('.gonggaoinfo').html(msg_html_list);
 									$('.gonggaodetail').on('tap', function () {
 										var addtime = $('#time').text();
-										learun.nav.go({ path: 'noticedetail', title: '告详情', type: 'right', param:'{"addtime":"'+addtime+'"}'});
+										learun.nav.go({ path: 'noticedetail', title: '告详情', type: 'right', param:'{"addtime":"'+addtime+'"}'});
 									});
 								});