
// 图片路径转换
			var proName = top.window.location.pathname.split("/")[1];
			var sysUrl = "http://"+window.location.host+"/"+proName;
			var picProxyGetUrl = sysUrl+"/sourceProxy?fileType=picUrlProxy&picUrl=";
		    //页面全局搜索条件
			var params = {}; 
			var num;
			params.occurTime = '1';	  //默认时间今天
			params.accidentState = '99'; //默认状态全部
			//params.page = num ;
			params.page = num ===undefined?0:(num-1)*limit ;
			params.rows = 10;
			//初始化数据data对象
			var pageData;
			var startDate = laydate.render({ 
				elem: '#startTime' ,
				type: 'date',
				max: "2099-12-31",
				done: function(value, dates) {
					endDate.config.min = {
						year: dates.year,
						month: dates.month - 1, 
						date: dates.date,
						hours: 0,
						minutes: 0,
						seconds: 0
					};
				}
			});
			var endDate = laydate.render({ 
				elem: '#endTime', 
				type: 'date',
				min: "1970-1-1", 
				done: function(value, dates) {
					startDate.config.max = {
						year: dates.year,
						month: dates.month - 1, 
						date: dates.date,
						hours: 0,
						minutes: 0,
						seconds: 0
					}
				}
			});
			$("#timeTab").on('click', 'li', function() {
				$(this).addClass('active').siblings('li').removeClass('active')
				if($(this).attr('data-c')=="4"){
					$('#timeDiv').slideDown('slow')
				}else{
					$('#timeDiv').slideUp('slow')
				}
			})
			$("#ulState").on('click', 'li', function() {
				$(this).addClass('active').siblings('li').removeClass('active')
			})
			var innerText = doT.template($("#pttab").text());
			//iframe页面填充数据
			function childFillData(datas) {
				if(typeof datas == "string") {
					datas = JSON.parse(datas);
				}
				datas.forEach(function(item){
					var str = JSON.stringify(item);
					item.str = str;
				})
				//将当前数据赋值给全局页面数据pagedata
				pageData = datas;
				console.log('5555555',pageData);
				changeUrl(datas); //修改图片链接
				$('#tab-list').html(innerText(datas));
			}
			//pushlet填充数据
			function pushletFillData(datas) {
				resetSearchQuery();  //重新执行一次查询操作
			}
			//图片url转换
			function changeUrl(data) {
				data.forEach(function(item) {
					if(item.eventSmallUrl != null) {
						var proName = top.window.location.pathname.split("/")[1];
						var sysUrl = "http://" + window.location.host + "/" + proName;
						item.eventSmallUrl = sysUrl + "/sourceProxy?fileType=picUrlProxy&picUrl=" + item.eventSmallUrl;
					}
				})
			}
			$('#tab-list').on('click', '.tab-look', function() {
				var data_val = $(this).attr('data-val');
				if(typeof data_val == "string") {
					data_val = JSON.parse(data_val);
				}
				//获取图片路径
				var imgPath = data_val.eventSmallUrl; 
				var sz_imgPath=new Array(); 
				var firstImg = '';
				var allImg = '';
				if(imgPath != null){
					sz_imgPath = imgPath.split('$');
					firstImg = sz_imgPath[0];
					//循环显示小图
					for(var k=0;k<sz_imgPath.length;k++){
						allImg+='<img src="'+picProxyGetUrl+sz_imgPath[k]+'" alt=""  width="130" height="100" onerror="$.loadErrorPic(this);">';
					}
				}
				parent.$("#dd").find('.info-ul').html('<li>相机名称：'+data_val.tdmc+'</li><li>报警时间：'+data_val.occurTime+'</li>'+
													  '<li>事件类型：'+data_val.eventName+'</li><li>警情等级：'+data_val.alarmLevelName+'</li>'+
													  '<li>道路名称：'+data_val.roadName+'</li><li>隧道名称：'+data_val.tunnelName+'</li>'+
													  '<li>起止桩号：'+data_val.startPile+'</li>'+
													  '<li>处理状态：'+data_val.accidentName+'</li>');
				//大图
				parent.$("#dd").find('div.pc-img-topimg img').eq(0).attr('src',picProxyGetUrl+firstImg);
				parent.$("#dd").find('div.pc-img-btm').html(allImg);
				//将本页面搜索条件放到弹窗中，执行关闭时重新查询一次。
				var v_param = JSON.stringify(params); 
				parent.$('#dd').find('div .div-img>ul').eq(0).attr('data-query',v_param)
				//判断确认报警、忽略报警按钮是否显示
				if(data_val.accidentName != '未处理'){
					parent.$("#dd").find('div #btn_qrbj').hide();
					parent.$("#dd").find('div #btn_hlbj').hide();
				}else{
					parent.$("#dd").find('div #btn_qrbj').show();
					parent.$("#dd").find('div #btn_hlbj').show();
				}
				//将摄像头设备编号、通道编号、通道名称信息填充至按钮
				var data_channel = data_val.vdId+'$'+data_val.channelId+'$'+data_val.tdmc;
				parent.$("#dd").find('div .div-img-title li').attr('data-channel',data_channel);
				parent.$("#dd").find('div .div-img-title li').attr('data-time',data_val.occurTime);
				//确认报警、忽略报警按钮中，把当前记录id放在data-id标签中
				parent.$("#dd").find('div .div-info input').attr('data-id',data_val.accidentId);
				parent.$("#dd").dialog({
					title: '事件详情',
					width: 710,
					top: 60,
					left: 350,
					closed: false,
					cache: false,
					//  href: 'get_content.php',
					modal: true,
					onClose:function(){    //关闭窗口事件
		                resetSearchQuery();
		            }  
				});
			}).on("click", '.tab-confim', function() {  //确认报警
				var params = {};
				params.accidentState = 3;
				params.accidentId = $(this).attr("data-c");
				$.ajax({
					type: "post",
					url: "trafficaccidentinfoAction!update_Trafficaccidentinfo.do",
					dataType: "json",
					data: params,
				}).done(function(res) {
					console.log(res);
					top.$.showMsg("状态已变更为【确认报警】");
					resetSearchQuery();
				});
			}).on("click", '.tab-ignore', function() {  //忽略报警
				var params = {};
				params.accidentState = 4;
				params.accidentId = $(this).attr("data-c");
				$.ajax({
					type: "post",
					url: "trafficaccidentinfoAction!update_Trafficaccidentinfo.do",
					dataType: "json",
					data: params,
				}).done(function(res) {
					console.log(res);
					top.$.showMsg("状态已变更为【忽略报警】");
					resetSearchQuery();
				});
			})
			//点击关闭按钮后操作事件，点击确认、忽略后操作事件
			function resetSearchQuery(){
				console.log("点击关闭按钮后重新查询条件======", params)
				var page_num = params.page;
				console.log('page_num = ' ,page_num);
				$.ajax({
					type: "post",
					url: "trafficaccidentinfoAction!query_TrafficHomePageinfo.do",
					dataType: "json",
					data: params,
				}).done(function(res) {
					//console.log('搜索返回数据===',res)
					if(res.total) {
						childFillData(res.rows)
						//console.log('重新搜索返回====',num);
						//console.log('重新搜索返回====',res.total);
						if (page_num === undefined) {
		                    $("#page").initPage(res.total, 1, function (index) {
		                    	//searchXjRequest(box, page, index)
		                    	searchRequest(page, index);
		        			});
		                }else{
		                	$("#page").initPage(res.total, page_num, function (index) {
		                    	searchRequest(page, index);
		        			});
		                }
					}
				});
			}
			
			//全局搜索
			function searchRequest(page, num){
				//page {maxshowpageitem:"5",pagelistcount:"10",pageId:"page"}  maxshowpageitem 最大显示页数，
				console.log('全局搜索分页---page--',page);
				console.log('全局搜索分页---num---',num);
				params = {};
				var timeLi = $("#timeTab").children('.active').attr('data-c');
				var stateLi = $("#ulState").children('.active').attr('data-c');
				if(timeLi == 4){
					params.occurTime = $("#startTime").val()+'/'+$("#endTime").val()
				}else{
					params.occurTime = timeLi;	
				}
				params.accidentState = stateLi;
				//params.page = num===undefined?0:(num-1)*10 ;
				var usersearch = $("#tab-search").val(); //搜索框
				params.search = $.trim(usersearch);
				params.page = num;
				params.rows = 10;
				console.log("全局参数======", params)
				$.ajax({
					type: "post",
					url: "trafficaccidentinfoAction!query_TrafficHomePageinfo.do",
					dataType: "json",
					data: params,
				}).done(function(res) {
					console.log(res)
					if(res.total) {
						childFillData(res.rows)
						if (num === undefined) {
		                    $("#page").initPage(res.total, 1, function (index) {
		                    	//searchXjRequest(box, page, index)
		                    	searchRequest(page, index);
		        			});
		                }
					}
				});
			
			}
			//进入页面后先执行一次查询操作。
			$('#tab-btn-search').on('click',searchHandler).trigger('click');
			function searchHandler(){
				params = {};  //页面搜索条件
				var timeLi = $("#timeTab").children('.active').attr('data-c');
				var stateLi = $("#ulState").children('.active').attr('data-c');
				if(timeLi == 4){
					params.occurTime = $("#startTime").val()+'/'+$("#endTime").val()
				}else{
					params.occurTime = timeLi;	
				}
				params.accidentState = stateLi;
				var usersearch = $("#tab-search").val(); //搜索框
				params.search = $.trim(usersearch);
				params.page = num ===undefined?0:(num-1)*limit ;
				params.rows = 10;
				console.log("全局参数======", params)
				$.ajax({
					type: "post",
					url: "trafficaccidentinfoAction!query_TrafficHomePageinfo.do",
					dataType: "json",
					data: params,
				}).done(function(res) {
					console.log('搜索返回数据===',res)
					if(res.total) {
						childFillData(res.rows)
						if (num === undefined) {
							console.log(res.total)
		                    $("#page").initPage(res.total, 1, function (index) {
		                    	//searchXjRequest(box, page, index)
		                    	searchRequest(page, index);
		        			});
		                }
					}
				});
			}
			
			/*
			$("#tab-btn-search").click(function() {
				params = {};  //页面搜索条件
				var timeLi = $("#timeTab").children('.active').attr('data-c');
				var stateLi = $("#ulState").children('.active').attr('data-c');
				if(timeLi == 4){
					params.occurTime = $("#startTime").val()+'/'+$("#endTime").val()
				}else{
					params.occurTime = timeLi;	
				}
				params.accidentState = stateLi;
				params.page = num ===undefined?0:(num-1)*limit ;
				params.rows = 10;
				console.log("全局参数======", params)
				$.ajax({
					type: "post",
					url: "trafficaccidentinfoAction!query_TrafficHomePageinfo.do",
					dataType: "json",
					data: params,
				}).done(function(res) {
					console.log('搜索返回数据===',res)
					if(res.total) {
						childFillData(res.rows)
						if (num === undefined) {
							console.log(res.total)
		                    $("#page").initPage(res.total, 1, function (index) {
		                    	//searchXjRequest(box, page, index)
		                    	searchRequest(page, index);
		        			});
		                }
					}
				});
			
			})
			*/
			//轮播图
			var a = parent.$(".view").closest('.swiper-container');
			console.log(Swiper)
			var viewSwiper = new Swiper('.view .swiper-container', {
				onSlideChangeStart: function() {
					updateNavPosition()
				}
			})
			console.log(viewSwiper)
			$('.view .arrow-left,.preview .arrow-left').on('click', function(e) {
				e.preventDefault()
				if(viewSwiper.activeIndex == 0) {
					viewSwiper.swipeTo(viewSwiper.slides.length - 1, 1000);
					return
				}
				viewSwiper.swipePrev()
			})
			$('.view .arrow-right,.preview .arrow-right').on('click', function(e) {
				e.preventDefault()
				if(viewSwiper.activeIndex == viewSwiper.slides.length - 1) {
					viewSwiper.swipeTo(0, 1000);
					return
				}
				viewSwiper.swipeNext()
			})

			var previewSwiper = new Swiper('.preview .swiper-container', {
				visibilityFullFit: true,
				slidesPerView: 'auto',
				onlyExternal: true,
				onSlideClick: function() {
					viewSwiper.swipeTo(previewSwiper.clickedSlideIndex)
				}
			})

			function updateNavPosition() {
				$('.preview .active-nav').removeClass('active-nav')
				var activeNav = $('.preview .swiper-slide').eq(viewSwiper.activeIndex).addClass('active-nav')
				if(!activeNav.hasClass('swiper-slide-visible')) {
					if(activeNav.index() > previewSwiper.activeIndex) {
						var thumbsPerNav = Math.floor(previewSwiper.width / activeNav.width()) - 1
						previewSwiper.swipeTo(activeNav.index() - thumbsPerNav)
					} else {
						previewSwiper.swipeTo(activeNav.index())
					}
				}
			}
			
			