|
@@ -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);
|
|
|
|
|
|
},
|
|
|
|