|
@@ -106,17 +106,15 @@
|
|
|
if (data.length == 0) {
|
|
|
var t1 = window.setTimeout(getRegistrationID, 1000);
|
|
|
}else{
|
|
|
- console.log("JPushPlugin:registrationID is " + data);
|
|
|
var post_data = {
|
|
|
"regid":data,
|
|
|
"uid":userinfo.baseinfo.userId
|
|
|
};
|
|
|
learun.httppost(config.webapi+'?s=api/update_jg_registrationid',post_data,function(res){
|
|
|
- console.log(res.message);
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
} catch (exception) {
|
|
|
- console.log(exception);
|
|
|
}
|
|
|
};
|
|
|
var getRegistrationID = function() {
|
|
@@ -135,19 +133,17 @@
|
|
|
}
|
|
|
init_nav();
|
|
|
|
|
|
-
|
|
|
- console.log(userinfo);
|
|
|
-
|
|
|
-
|
|
|
+ //地图
|
|
|
var startEnd = {start:new AMap.LngLat(113.951104,22.542902), end:new AMap.LngLat(113.955439,22.532956)};
|
|
|
|
|
|
var fencePageData = null;
|
|
|
+ var routePageData = null;
|
|
|
|
|
|
// var userIcon = new AMap.Icon({size: new AMap.Size(50,50), image:'./images/gelocation.png'})
|
|
|
- var userMarker = new AMap.Marker({icon: "./images/gelocation-2.png", offset:new AMap.Pixel(16, -16)});
|
|
|
+ var userMarker = new AMap.Marker({icon: "./images/gelocation-2.png", offset:new AMap.Pixel(-16, -28)});
|
|
|
|
|
|
//车辆信息初始化
|
|
|
- var timeInterval = 5000;
|
|
|
+ var timeInterval = 10000;
|
|
|
//地图初始化
|
|
|
var mainMap = new AMap.Map('amapcontainer');
|
|
|
mainMap.on('complete', function(){
|
|
@@ -172,16 +168,10 @@
|
|
|
|
|
|
circle.setMap(mainMap);
|
|
|
|
|
|
- // learun.vehicleInfoWin = new AMap.InfoWindow({
|
|
|
- // isCustom: true,
|
|
|
- // offset: new AMap.Pixel(60, -40),
|
|
|
- // content: '<div class="ract LeftBubble"><span>位置导航XX小区...</span></div>'
|
|
|
- // });
|
|
|
-
|
|
|
- var overlayData = {map:mainMap, vehicle:vehicleMarker, circle:circle, infoWin:learun.vehicleInfoWin};
|
|
|
+ var overlayData = {map:mainMap, vehicle:vehicleMarker, circle:circle};
|
|
|
|
|
|
var getVehicleData = function(t, first=false){
|
|
|
- var deviceNumber = 'AAAAAA000003';
|
|
|
+ var deviceNumber = userinfo.baseinfo['deviceNumber'];
|
|
|
var mapData = null;
|
|
|
learun.httpget(config.webapi+"/?s=api/get_map_index_data", {deviceNumber:deviceNumber}, function (_res) {
|
|
|
mapData = _res.data;
|
|
@@ -199,10 +189,18 @@
|
|
|
|
|
|
t.vehicle.setPosition(vehiclePt);
|
|
|
t.vehicle.setMap(t.map);
|
|
|
- // t.infoWin.setPosition(vehiclePt)
|
|
|
- // t.infoWin.setMap(t.map);
|
|
|
-
|
|
|
- // console.log(mapData);
|
|
|
+ //在线状态
|
|
|
+ if(mapData.onlineTime){
|
|
|
+ var interval = new Date() - mapData.onlineTime;;
|
|
|
+ if(interval < 24*3600){
|
|
|
+ $('#on-off-online').text('在线中');
|
|
|
+ $('#on-off-online').css({color:"green"})
|
|
|
+ }else{
|
|
|
+ var day = parseInt(interval/24/3600);
|
|
|
+ $('#on-off-online').text('离线'+day+'天');
|
|
|
+ $('#on-off-online').css({color:"gray"})
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
var fence = JSON.parse(mapData.fenceShapeInfo);
|
|
|
if(fence.type == 'circle'){
|
|
@@ -218,14 +216,14 @@
|
|
|
}
|
|
|
|
|
|
fencePageData = {fenceInfo: fence, defaultLocation: vehiclePt, fenceStatus:mapData.fenceAlarmStatus};
|
|
|
+ var routeTime = new Date(mapData.onlineTime);
|
|
|
+
|
|
|
+ routePageData = {speed:mapData.speed, lastTime:routeTime.Format("yyyy-MM-dd hh:mm:ss")}
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//定位
|
|
|
$page.find('#user-location').on('tap', function(){
|
|
|
get_mobile_gps_location(function(position){
|
|
@@ -237,16 +235,28 @@
|
|
|
//锁车
|
|
|
$page.find('#car-lock').on('tap', function(){
|
|
|
var lockStatus = $page.find('#lockStatus');
|
|
|
- console.log(lockStatus.hasClass('icon-jiesuo'));
|
|
|
- if(lockStatus.hasClass('icon-jiesuo')){
|
|
|
- lockStatus.removeClass('icon-jiesuo');
|
|
|
- lockStatus.addClass('icon-suo');
|
|
|
- learun.layer.toast('车辆已锁定');
|
|
|
- }else{
|
|
|
- lockStatus.removeClass('icon-suo');
|
|
|
- lockStatus.addClass('icon-jiesuo');
|
|
|
- learun.layer.toast('车辆已解锁');
|
|
|
+
|
|
|
+ var postData = {
|
|
|
+ deviceNumber:'AAAAAA000003',
|
|
|
+ lockStatus: lockStatus.hasClass('icon-jiesuo') ? 1 : 0
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ learun.httppost(config.webapi+'?s=api/change_lock_status',postData,function(res){
|
|
|
+ if(!res.success){
|
|
|
+ learun.layer.toast('锁车失败');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(lockStatus.hasClass('icon-jiesuo')){
|
|
|
+ lockStatus.removeClass('icon-jiesuo');
|
|
|
+ lockStatus.addClass('icon-suo');
|
|
|
+ learun.layer.toast('车辆已锁定');
|
|
|
+ }else{
|
|
|
+ lockStatus.removeClass('icon-suo');
|
|
|
+ lockStatus.addClass('icon-jiesuo');
|
|
|
+ learun.layer.toast('车辆已解锁');
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
|
|
@@ -255,12 +265,6 @@
|
|
|
getVehicleData(overlayData, true);
|
|
|
|
|
|
|
|
|
- //导航页面跳转
|
|
|
- // $page.find('.ract').on('tap', function(){
|
|
|
- // console.log('re');
|
|
|
- // learun.nav.go({ path: 'demo/amap/navigation', title: '导航', isBack: true, isHead: true, param: '我是一个参数' });
|
|
|
-
|
|
|
- // });
|
|
|
var geocoder;
|
|
|
AMapUI.defineTpl("ui/overlay/SimpleInfoWindow/tpl/container.html", [], function() {
|
|
|
return document.getElementById('my-infowin-tpl').innerHTML;
|
|
@@ -268,6 +272,7 @@
|
|
|
|
|
|
AMapUI.loadUI(['overlay/SimpleInfoWindow'], function(SimpleInfoWindow) {
|
|
|
var lnglat = vehicleMarker.getPosition();
|
|
|
+ var address = '坐标未解析成功';
|
|
|
|
|
|
|
|
|
|
|
@@ -278,30 +283,25 @@
|
|
|
radius: 500 //范围,默认:500
|
|
|
});
|
|
|
}
|
|
|
- var address = '坐标未解析成功'
|
|
|
+
|
|
|
geocoder.getAddress(lnglat, function(status, result) {
|
|
|
if (status === 'complete' && result.regeocode) {
|
|
|
address = result.regeocode.formattedAddress;
|
|
|
|
|
|
if(!infoWindow){
|
|
|
var infoWindow = new SimpleInfoWindow({
|
|
|
- myCustomContent: '<span style="max-width:100%">'+address+'</span>',
|
|
|
+ infoBody: '<span>'+address+'</span>',
|
|
|
//基点指向marker的头部位置
|
|
|
- offset: new AMap.Pixel(54, -47)
|
|
|
+ offset: new AMap.Pixel(50, -64)
|
|
|
});
|
|
|
}
|
|
|
infoWindow.open(mainMap, lnglat);
|
|
|
- }else{alert(JSON.stringify(result))}
|
|
|
- });
|
|
|
+ infoWindow.get$Container().on('click', function(){
|
|
|
+ learun.nav.go({ path: 'amap/navigation', title: '导航', isBack: true, isHead: true, param: startEnd });
|
|
|
+ });
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //marker 点击时打开
|
|
|
- infoWindow.get$Container().on('click', function(){
|
|
|
- learun.nav.go({ path: 'amap/navigation', title: '导航', isBack: true, isHead: true, param: startEnd });
|
|
|
+ }else{learun.layer.toast(JSON.stringify(result))}
|
|
|
});
|
|
|
-
|
|
|
|
|
|
});
|
|
|
|
|
@@ -355,7 +355,7 @@
|
|
|
|
|
|
//轨迹页跳转
|
|
|
$page.find('#route-play').on('tap', function () {
|
|
|
- learun.nav.go({ path: 'amap/route', title: '轨迹回放', isBack: true, isHead: true, param: '我是一个参数' });
|
|
|
+ learun.nav.go({ path: 'amap/route', title: '轨迹回放', isBack: true, isHead: true, param: routePageData });
|
|
|
});
|
|
|
|
|
|
//围栏页跳转
|
|
@@ -363,12 +363,19 @@
|
|
|
learun.nav.go({ path: 'amap/fence', title: '围栏设置', isBack: true, isHead: true, param: fencePageData });
|
|
|
});
|
|
|
|
|
|
-
|
|
|
+ //保险页跳转
|
|
|
+ $page.find('.insurance-img').on('tap', function () {
|
|
|
+ learun.nav.go({ path: 'insure', title: '保险理赔', isBack: true, isHead: true, param: 'test' });
|
|
|
+ });
|
|
|
//定时刷新数据
|
|
|
|
|
|
- // setInterval(function(){
|
|
|
- // getVehicleData(overlayData);
|
|
|
- // }, timeInterval);
|
|
|
+ var mainPageInterval = setInterval(function(){
|
|
|
+ if($('.f-page').length > 1){
|
|
|
+ clearTimeout(mainPageInterval);
|
|
|
+ }
|
|
|
+ console.log('dd');
|
|
|
+ getVehicleData(overlayData);
|
|
|
+ }, timeInterval);
|
|
|
|
|
|
}
|
|
|
};
|