$(document).ready(function () {
	var lineIndex=$("#lineIndex").val();
	lineIndex=filterXSS(lineIndex);
	$.ajax({
		method:"post",
		url:"/pqs9200/device/deviceInfo",
		data:{
		lineIndex:lineIndex
		},
		success: function (data) {
			if(data == null){
	    		layer.msg('详细信息加载失败',{icon:2,time:1000});
			}else{
				$("#jcdxx").text(data.name);
				$("#jcxl").text(data.subv_name);
				$("#tyrq").text(data.time);
				$("#cj").text(data.manufacturer);
				$("#xh").text(data.devType);
				$("#loadtype").text(data.loadType);
				$("#lineOnject").text(data.objName == null ? '/':data.objName);
				$("#wlcs").text(data.ip);
				$("#txzt").text(data.txzt);
				$("#dydj").text(data.scale);
				$("#pt").text(data.pt);
				$("#ct").text(data.ct);
				$("#jzdl").text(data.jzcmp);
				$("#mxdl").text(data.dlcmp);
				$("#ydrl").text(data.xycmp);
				$("#gdrl").text(data.devcmp);
			    if(data.devType.indexOf("CLD")>0){
			    	$("#onlycld").removeAttr("hidden");
			    	$("#baseFlow").text(data.baseFlow);
			    	$("#extendFlow").text(data.extendFlow);
			    	$("#useFlow").text(data.useFlow);
			    }else{
			        $("#onlycld").attr("hidden","true");
			    }
			}
		}
	});

    initMap();
});


var longitude=$("#longitude").val();
var latitude=$("#latitude").val();
var image=$("#image").val();
longitude=filterXSS(longitude);
latitude=filterXSS(latitude);
image=filterXSS(image);

/************************************
获取监测点经纬度信息加载到地图
************************************/
//创建图标
var redIcon = new BMap.Icon("../images/img/pred.png", new BMap.Size(25, 25));
var greenIcon = new BMap.Icon("../images/img/pgreen.png", new BMap.Size(25, 25));
var yellowIcon = new BMap.Icon("../images/img/pyellow.png", new BMap.Size(25, 25));
var grayIcon = new BMap.Icon("../images/img/pgray.png", new BMap.Size(25, 25));
var winIcon = new BMap.Icon("../images/img/warning.gif", new BMap.Size(40, 40));
//终端状态（0：投运；1：中断；2：退运）
var redMarkerOptions = {
   icon: redIcon,
   enableDragging: false
}
var greenMarkerOptions = {
   icon: greenIcon,
   enableDragging: false
}
var yellowMarkerOptions = {
   icon: yellowIcon,
   enableDragging: false
}
var grayMarkerOptions = {
   icon: grayIcon,
   enableDragging: false
}

var winMarkerOptions = {
   icon: winIcon,
   enableDragging: false
}


/********************************************
 JS初始化百度地图
 *******************************************/
var pointmap;
var blfirstload = true;//首次登录界面
function initMap() {
	pointmap = new BMap.Map("pointmap", {minZoom:5,maxZoom: 15, enableMapClick: false});
    pointmap.enableScrollWheelZoom(true);//开启鼠标滚轮缩放
    pointmap.addControl(new BMap.NavigationControl());  //添加移图，放大缩小控件
    //地图加载完毕事件
    var point = new BMap.Point(longitude,latitude);
	pointmap.centerAndZoom(point, 15);  //设初始化地图
	pointmap.panTo(point, false);

	if(image=="green"){
		var  marker = new BMap.Marker(point, greenMarkerOptions);
	}else if(image == "yellow"){
		var  marker = new BMap.Marker(point, yellowMarkerOptions);
	}else if(image == "gray"){
		var  marker = new BMap.Marker(point, grayMarkerOptions);
	}else{
		var  marker = new BMap.Marker(point, redMarkerOptions);
	}

	pointmap.addOverlay(marker);
    pointmap.disableDragging(); //禁止拖拽地图
}
