소스 검색

add default cityCenter and change the display of the onlinetime

git 5 년 전
부모
커밋
1bed89af5d
4개의 변경된 파일37개의 추가작업 그리고 23개의 파일을 삭제
  1. 8 3
      pages/amap/amap.css
  2. 19 17
      pages/amap/amap.js
  3. 5 2
      pages/amap/fence/fence.js
  4. 5 1
      pages/amap/route/route.js

+ 8 - 3
pages/amap/amap.css

@@ -253,15 +253,16 @@
     color: gray;
 }
 #route-play p{
-    font-size: 1.4rem;
+    font-size: 0.8em;
     color: #fdfdfd;
 }
 #electric-fence p{
-    font-size: 1.4rem;
+    font-size: 0.8em;
     color: #fdfdfd;
 }
 #car-lock p{
     color: #fdfdfd;
+    font-size: 1.1em;
 }
 .top-right-panel{
     /* display: flex; */
@@ -288,7 +289,7 @@
     display: flex;
     justify-content: center;
     align-items: center;
-    font-size: 2rem;
+    font-size: 1.2em;
 }
 hr{
     height: 1px;
@@ -352,12 +353,16 @@ hr{
 }
 .panel-right-content{
     width: 130px;
+    font-size: 1em;
 }
 .insurance-img{
     width: 25%;
     margin-left: 10px;
     z-index: 555;
 }
+#on-off-online{
+    font-size: 1em;
+}
 
 
 /* header */

+ 19 - 17
pages/amap/amap.js

@@ -3,11 +3,11 @@
     var lnglat;
     var mainMap;
     var getVehicleData;
-    var vehicleMarker;
-    var overlayData;
-    var vehicleMarker;
-    var circle;
-    var userInfo;
+    var overlayData;//
+    var vehicleMarker;//车辆marker
+    var circle;//主页显示围栏
+    var userInfo;//用户信息
+    var timeInterval = 10000;//定时刷新车辆数据间隔ms
     var page = {
         init: function ($page) {
             userInfo = renlian.storage.get('userinfo');
@@ -195,11 +195,14 @@
 
             get_mobile_gps_location();
             //车辆信息初始化
-            var timeInterval = 10000;
             //地图初始化
+            var defaultCity = renlian.storage.get('userinfo').baseinfo.defaultCity;
+            if(!defaultCity){
+                defaultCity = [109.84040,40.658168];
+            }
             if(!mainMap){
                 mainMap = new AMap.Map('amapcontainer', {
-                    center: [120.202222,30.184811],
+                    center: defaultCity,
                     zoom: 15
                 });
             }
@@ -254,6 +257,7 @@
                     if(!latlngSign){
                         first = false;
                         if(first){
+                            console.log('first');
                             t.map.setZoomAndCenter(15,startEnd.start);
                         }
                         t.vehicle.setPosition(null);
@@ -268,6 +272,7 @@
                     }
 
                     if(first){
+                        console.log('firstB');
                         t.map.setZoomAndCenter(15,vehiclePt);
                     }
 
@@ -290,25 +295,23 @@
 
                     //在线状态
                     if(mapData.onlineTime){
-                        var routeTime = new Date(mapData.onlineTime*1000);
-                        routePageData = {speed: mapData.speed == null ? 0 : mapData.speed, lastTime:routeTime.Format("yyyy-MM-dd hh:mm:ss")};
-                        var interval = parseInt(new Date().getTime()/1000) - mapData.onlineTime;
-                        if(interval < 24*3600){
+                        routePageData = {speed: mapData.speed == null ? 0 : mapData.speed, lastTime:mapData.lastLoactionTime ? mapData.lastLoactionTime : ''};
+                        if(mapData.onlineTime.online){
                             $('#on-off-online').text('在线中');
                             $('#on-off-online').css({color:"green"})
                         }else{
-                            var day = parseInt(interval/24/3600);
-                            $('#on-off-online').text('离线'+day+'天');
+                            var display = mapData.onlineTime.humenDisplay;
+                            $('#on-off-online').text('离线'+display);
                             $('#on-off-online').css({color:"gray"})
                         }
                     }else{
                         $('#on-off-online').text('未在线过');
                         $('#on-off-online').css({color:"gray"})
-                        var routeTime = new Date(0);
-                        routePageData = {speed: mapData.speed == null ? 0 : mapData.speed, lastTime:routeTime.Format("yyyy-MM-dd hh:mm:ss")};
+                        routePageData = {speed: mapData.speed == null ? 0 : mapData.speed, lastTime:''};
                     }
 
 
+
                     var fence = mapData.fenceShapeInfo;
                     if(fence){
                         fence = JSON.parse(fence);
@@ -473,7 +476,7 @@
 
             //轨迹页跳转
             $('#route-play').on('tap', function () {
-                renlian.nav.go({ path: 'amap/route', title: '轨迹回放', isBack: true, isHead: true, param: {textData:routePageData, defaultCenter: defaultCenter || startEnd.start} });
+                renlian.nav.go({ path: 'amap/route', title: '轨迹回放', isBack: true, isHead: true, param: {textData:routePageData, defaultCenter: defaultCenter || startEnd.start || null} });
                 if(infoWindow){infoWindow.close( );}
             });
 
@@ -502,7 +505,6 @@
 
 
         reload: function ($page, pageinfo) {
-
             if(userInfo.baseinfo.token != renlian.storage.get('userinfo').baseinfo.token){
                 vehicleMarker.setMap(null);
                 infoWindow = null;

+ 5 - 2
pages/amap/fence/fence.js

@@ -4,12 +4,15 @@
             
             $page.find('#fence-switch').rlswitch();
             var userinfo = renlian.storage.get('userinfo');
-
+            var defaultCity = renlian.storage.get('userinfo').baseinfo.defaultCity;
+            if(!defaultCity){
+                defaultCity = [109.84040,40.658168];
+            }
 
 
             // //地图初始化
             var map = new AMap.Map("fence-map", {
-                center: [120.210649,30.246071],//地图中心点
+                center: defaultCity,//地图中心点
                 zoom: 12 //地图显示的缩放级别
             });
             renlian.layer.loading(true, "加载数据中");

+ 5 - 1
pages/amap/route/route.js

@@ -5,6 +5,10 @@
 
            renlian.layer.loading(true, "加载数据中");
            var userinfo = renlian.storage.get('userinfo');
+           var defaultCity = renlian.storage.get('userinfo').baseinfo.defaultCity;
+            if(!defaultCity){
+                defaultCity = [109.84040,40.658168];
+            }
             $('#route-gpsNumber').text(userinfo.baseinfo.gpsNumber);
             $('#date-time').text('时间:'+param.textData.lastTime || '0000-00-00 00:00:00');
             $('#vehicle-speed').text('速度:'+param.textData.speed+' km/h')
@@ -20,7 +24,7 @@
 
             //地图初始化
             var routeMap = new AMap.Map('route-map', {
-                center: param.defaultCenter,
+                center: param.defaultCenter || defaultCity,
                 zoom: 15
             });