| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830 | 
							- var self;
 
- var type, level, area, indexs, title,sort=1,banerIndex;
 
- var path = {};
 
- var roleLevel, userRole;
 
- var endDate;
 
- var startDate;
 
- var fromDate = "2016-08-01";
 
- var indexName = {'index_3': '咨询量:', 'index_4': '随访量:', 'index_5': '指导量:','index_27':'代预约量:','index_21': '绑定微信:','index_20': '绑定设备:'};
 
- var information = {
 
-     "3":"咨询量为签约年度(当年7月1日至次年6月30日)居民咨询的次数,点击右上角可切换查看不同年份数据",
 
-     "4":"随访量为签约年度(当年7月1日至次年6月30日)随访次数,点击右上角可切换查看不同年份数据",
 
-     "5":"指导量为签约年度(当年7月1日至次年6月30日)发送健康指导的次数,点击右上角可切换查看不同年份数据",
 
-     "27":"代预约量为签约年度(当年7月1日至次年6月30日)代居民预约挂号的次数,点击右上角可切换查看不同年份数据",
 
-     "21":"绑定微信量为签约年度签约居民(含未缴费)已关注微信号的数量统计,点击右上角可以切换查看不同年份数据",
 
-     "20":"绑定设备量为签约年度签约居民(含未缴费)已绑定的设备数量统计,点击右上角可以切换查看不同年份数据"
 
- };
 
- //初始化计算选择的年份
 
- var chooseYear;
 
- var now = new Date();
 
- if(now.getMonth() >= 6){
 
-     chooseYear = now.getFullYear();
 
- }else{
 
-     chooseYear = now.getFullYear() - 1;
 
- }
 
- //绑定按钮事件
 
- bindEvents();
 
- //页面初始化
 
- mui.plusReady(function() {
 
- 	self = plus.webview.currentWebview();
 
- 	type = self.type;
 
- //	userRole = JSON.parse(plus.storage.getItem("userRole"))[0] ;
 
- 	userRole = JSON.parse(plus.storage.getItem("selectedRole"));
 
- 	roleLevel = userRole.code == '350200'  ? 4 : userRole.code.length==6 ? 3 : 2;
 
- 	level = roleLevel;
 
- 	area = userRole.code;
 
- 	title = userRole.name; 
 
- 	
 
- 	//初始显示选中的年份
 
- 	$(".choose-label").text(chooseYear+"年");
 
- 	
 
- 	//初始化开始时间和结束时间
 
- 	startDate = getStartDate();
 
- 	endDate = getEndDate();
 
- 	
 
- 	//初始化
 
- 	load({type: type, level: level, area: area,title: title, year: chooseYear});
 
- 	//下拉刷新初始化
 
-    	initScroller();
 
-    	shaixuanInit(self);
 
- });
 
- function load(obj){
 
- 	var level = obj.level;
 
- 	var title = obj.title; 
 
- 	var date  = endDate;
 
- 	$('#tjTitle').html(level==4? "各区管理" : level==3? "各社区情况" : "各团队情况");
 
- 	$('#labLi2').toggle(level == 4);
 
- 	if($(".c-lab-mor .hit").attr("id")=="labLi2"){
 
- 		$('#list2').toggle(level == 4);
 
- 		$('#labLi2').removeClass("hit");
 
- 	}
 
- 	$('#list').show();
 
- 	$("#list2").hide();
 
- 	path[level] = {type: type, level: level, area: area, date: date}
 
- 	indexs = [3, 4, 5, 27, 21, 20];
 
- 	loadData(type, level, area, date);
 
- 	loadLineData(type, level, area, '', date, $('#l-legend li.l-over').attr('data-val'), $("#textTj .l-over").attr("data-index"));
 
- 	if(banerIndex){
 
- //		$("#index_"+banerIndex).closest("li").trigger("tap");
 
-         $("#textTj ul li").removeClass("l-over");
 
-         $("#index_"+banerIndex).closest("li").addClass("l-over");
 
- 	}
 
- 	if(!title){
 
- 		$('#labLi2').toggle(level == 4);
 
- 	}
 
- 	$(".c-lab-mor #labLi2").removeClass("hit");
 
- 	if(level==4){
 
- 		title = title.substring(0,3);
 
- 	}
 
- 	$("#title").html(title);
 
- 		
 
- 	//底部左边列表	(初始化时只执行一次)
 
- 	var params ={level: level, area: area, sort: 1, year: chooseYear}
 
- 	params.index = $("#textTj ul li.l-over").attr("data-index");
 
- 	//增量(咨询量、随访量、指导量),到达量(绑定微信、绑定设备)
 
- 	var url = params.index==3?"statistics/lowlevel_total_mesh":params.index==4 || params.index==5 || params.index==27 ?"statistics/lowlevel_total":"statistics/lowlevel_all";
 
- 	if(params.index==3) params.index="3,22";
 
- 	if(params.index == 21 || params.index == 20){
 
-         params.date = endDate;
 
-     }else{
 
-         params.endDate = endDate;
 
-     }
 
- 	sendPost(url, params,null,listHandle);
 
- }
 
- //返回事件
 
- mui.back = function(){
 
- 	if(level==4 || level==roleLevel){
 
- 		var mainPage =plus.webview.getWebviewById("admin.html");
 
- 		mui.fire(mainPage, "refreshData");
 
- 		//关闭筛选页面
 
- 		var shaixuan =  plus.webview.getWebviewById("shaixuan2.html");
 
-         if(shaixuan){
 
-             shaixuan.close();
 
-         }
 
- 		self.close();
 
- 	} 
 
- 	else{
 
- 		level++;
 
- 		var params = path[level];
 
- 		if(!params){
 
- 			level++;
 
- 			params = path[level];
 
- 		}
 
- 		type = params.type;
 
- 		area = params.area;
 
- 		title = params.title || userRole.name;
 
- 		load({type: type, level: level, area: area, fromDate: fromDate, endDate: endDate,title: title});
 
- 		
 
- 		if(level==4){
 
- 			title = title.substring(0,3);
 
- 		}
 
- 		$("#title").html(title);
 
- 		$('#tjTitle').html(level==4? "各区管理" : level==3? "各社区情况" : "各团队情况");
 
- 		$(".c-lab-mor #labLi1").addClass("hit")
 
- 	}
 
- }
 
- /**
 
-  * 初始化筛选事件
 
-  */
 
- function shaixuanInit(main){
 
-     var shaixuan = plus.webview.getWebviewById('shaixuan2.html');
 
-     if(!shaixuan){
 
-         shaixuan = mui.createWindow({
 
-                 id: 'shaixuan2.html',
 
-                 url: 'shaixuan2.html',
 
-                 styles: {
 
-                     top: 0,
 
-                     bottom: 0,
 
-                     left: '20%',
 
-                     width: '80%',
 
-                     scorllIndicator: "none"
 
-                 },
 
-                 show:{
 
-                   aniShow: "slide-in-right",
 
-                   duration: "400"
 
-                 }
 
-            });
 
-         
 
-     }
 
-     window.addEventListener("hideShaiXuan",function(){
 
-         main.setStyle({mask:"none"});
 
-         shaixuan.hide();
 
-     }, false);
 
-      
 
-     window.addEventListener("showShaiXuan", function() {
 
-         shaixuan.show();
 
-         main.setStyle({mask:"rgba(0,0,0,0.5)"});
 
-         main.addEventListener("maskClick",function(){
 
-             main.setStyle({mask:"none"});
 
-             shaixuan.hide();
 
-         }, false);
 
-     });
 
- }
 
- /*****************************************************************************/
 
- /*****                              点击事件                                                        	**********/
 
- /*****************************************************************************/
 
- function bindEvents(){
 
- 	//index类别切换
 
- 	var barImg= $("#textTj li");
 
- 	barImg.on("tap", function(){
 
- 		$("#textTj").css("pointer-events","none");
 
- 		$('#textTj li').removeClass("l-over");
 
- 		$(this).addClass("l-over");
 
- 		
 
- 		var index = "index_" + $(this).attr("data-index");
 
- 		//获取到index值,然后替换information里面的数据
 
- 		$("#infoText").text(information[$(this).attr("data-index")]);
 
- 		$("#list ul").hide();
 
- 		$("#list2 ul").hide();
 
- 		if($(".c-lab-mor li.hit").attr("id")=="labLi2"){
 
- 			$("#s_"+ index).show();
 
- 		}else{
 
- 			$("#l_"+ index).show();
 
- 		}
 
- 		banerIndex = $(".l-qytj-barner .l-over").attr("data-index");
 
- 		
 
- 		loadLineData(type, level, area, fromDate, endDate, 
 
- 			$('#l-legend li.l-over').attr('data-val'),
 
- 			$(this).attr("data-index"));
 
- 			
 
- 		//tab初始化
 
- 		$(".c-lab-mor li").eq(0).trigger("tap");
 
- 		$(".c-lab-mor li").eq(1).attr("data-visited","false");
 
- 		
 
- 		//底部左边列表	
 
- 		var params ={level: level, area: area, sort: 1, year: chooseYear}
 
- 		params.index = $("#textTj li.l-over").attr("data-index");
 
- 		//增量(咨询量、随访量、指导量),到达量(绑定微信、绑定设备)
 
- 		var url = params.index==3?"statistics/lowlevel_total_mesh":params.index==4 || params.index==5 || params.index==27 ?"statistics/lowlevel_total":"statistics/lowlevel_all";
 
- 		if(params.index==3) params.index="3,22";
 
- 		if(params.index == 21 || params.index == 20){
 
- 			params.date = endDate;
 
- 		}else{
 
- 			params.endDate = endDate;
 
- 		}
 
- 		sendPost(url, params,null,listHandle);
 
- 	
 
- 	})
 
- 	//tab切换
 
-    $(".c-lab-mor li").on("tap",function(){
 
- 		var tabid = $(this).attr("id");
 
- 		var top = $(this).offset().top;
 
- 		$(".c-lab-mor li").removeClass("hit");
 
- 		$(this).addClass("hit");
 
- 		$("#list ul").hide();
 
- 		$("#list2 ul").hide();
 
- 		var index = "index_" + $(".l-qytj-barner").find("li.l-over").attr("data-index");
 
- 		if(tabid=="labLi1"){
 
- 			$("#list").show();
 
- 			$("#list2").hide();
 
- 			$("#l_"+ index).show();
 
- 		}else{
 
- 			var visited = $(this).attr("data-visited");
 
- //	    	if(visited == "false"){
 
- 	    		var params = {level: level, area: area, sort: 1, year: chooseYear};
 
- 		    	params.index = $("#textTj li.l-over").attr("data-index");
 
- 		    	var url = params.index==3?"statistics/lowlevel_total_mesh":params.index==4 || params.index==5 || params.index==27?"statistics/lowlevel_total":"statistics/lowlevel_all";
 
- 		    	if(params.index==3) params.index="3,22";
 
- 		    	if(params.index == 21 || params.index == 20){
 
- 					params.date = endDate;
 
- 				}else{
 
- 					params.endDate = endDate;
 
- 				}
 
- 		    	if(roleLevel==4){//市级管理员才可以查看市下面的所有社区数据
 
- 					params.lowLevel = 2;
 
- 					params.level = level;
 
- 					plus.nativeUI.showWaiting();
 
- 					sendPost(url, params,null, list2Handle);
 
- 					delete params.lowLevel;
 
- 				}
 
- //		    	$(this).attr("data-visited","true");
 
- //	    	}
 
- 			$("#list").hide();
 
- 			$("#list2").show();
 
- 			$("#s_"+ index).removeClass("c-hide").show();
 
- 		}
 
- 		scroller1.refresh();
 
-         window.onscroll = function () {
 
-             var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
 
-             if(top!=-1 && top>0){
 
-             	 window.scrollTo(0,top);
 
-             	 top = -1;
 
-             }
 
-         }    
 
- 	});	
 
- 	
 
- 	//底部列表的点击事件
 
- 	$(".list-panel").on('tap', 'li', function(){
 
- 	    var $this = $(this);
 
- 	    if($this.data('next') == 1){
 
- 	        var divId = $this.parent().parent().attr("id");
 
- 	        if(divId == "list"){
 
-     	        level--;
 
-                 area = $(this).attr("data-code");
 
-                 var name = $(this).attr("data-name");
 
-                 title = name;
 
-                 load({type: type, level: level, area: area, from: fromDate, to: endDate, title: name,index: $("#textTj .l-over").attr("data-index")});
 
-     //          var name = $(this).attr("data-name");
 
-     //          title = name;
 
-                 $("#title").html(title);
 
-                 $('#tjTitle').html(level==4? "各区管理" : level==3? "各社区情况" : "各团队情况");
 
-                 path[level] = {type: type, level: level, area: area, from: fromDate, to: endDate, title: name}
 
-             }else if(divId == "list2"){
 
-                 level = 2;
 
-                 area = $(this).attr("data-code");
 
-                 load({type: type, level: level, area: area, from: fromDate, to: endDate, title: name});
 
-                 var name = $(this).attr("data-name");
 
-                 title = name;
 
-                 $("#title").html(title);
 
-                 $('#tjTitle').html("各团队情况");
 
-                 path[level] = {type: type, level: level, area: area, from: fromDate, to: endDate, title: name}
 
-             }
 
- 	    }
 
- 	})
 
- 	//日、周、月按钮切换
 
-     $(".div-btn-group").on("tap",".div-btn",function(){
 
-     	var dataId = $(this).attr("data-id");
 
-     	$(".div-btn-group .div-btn").removeClass("active");
 
-     	$(this).addClass("active");
 
- 		loadLineData(type, level, area, fromDate, endDate, dataId,$("#textTj").find('.l-over').attr("data-index"));
 
-     });	
 
-     
 
-     //左滑筛选区域的数据
 
-     $('.header-link').on("tap", function(){
 
-         var self = plus.webview.currentWebview();
 
-         mui.fire(self, "showShaiXuan");
 
-     });
 
-     
 
-     window.addEventListener("refresh", function(e){
 
-         chooseYear = e.detail.year;
 
-         startDate = getStartDate();
 
-         endDate = getEndDate();
 
-         //初始显示选中的年份
 
-         $(".choose-label").text(chooseYear+"年");
 
-         load({type: type, level: level, area: area,title: title, year: chooseYear});
 
-     });
 
-     
 
-     //说明信息相关事件
 
-     $("#closeBtn").on("tap", function(){
 
-         $(".information").hide();
 
-         scroller1.refresh();
 
-     });
 
-     
 
-     $(".info-icon").on("tap", function(){
 
-         $(".information").show();
 
-         scroller1.refresh();
 
-     });
 
- }
 
- /*****************************************************************************/
 
- /*****                           统计数据刷新                                                        	**********/
 
- /*****************************************************************************/
 
- function initScroller(){	
 
- 		scroller1 =  $("#wrapper1").initScroll(
 
- 			{
 
- 				pullDownAction: function(){	
 
- 					plus.nativeUI.showWaiting();
 
- 					$(".pullUp").hide();
 
- 					type = type;
 
- 					level = level;
 
- 					area = area;
 
- 					load({type: type, level: level, area: area,title: title});
 
- 					$(".c-lab-mor #labLi1").addClass("hit");
 
- 					$(".c-lab-mor #labLi2").removeClass("hit");
 
- 					$(".div-list").show();
 
- 					$(".div-list2").hide();
 
- 				},pullUpAction: function() {
 
- 					$(".pullUp").hide();
 
- 					return false;
 
- 				}
 
- 			}
 
- 		);
 
- }
 
- $('.l-refresh').on("tap", function(){
 
- 	self = plus.webview.currentWebview();
 
- 	type = self.type;
 
- 	level = self.level;
 
- 	area = self.area;
 
- 	load({type: type, level: level, area: area,title: title});
 
- 	$(".c-lab-mor #labLi1").addClass("hit");
 
- })
 
- /*****************************************************************************/
 
- /*****                          统计数据初始化                                                      	**********/
 
- /*****************************************************************************/
 
- //加载数据
 
- function loadData(type, level, area, date){
 
- 	clearData(type);
 
- 	var params = {level: level, area: area, endDate: date, year: chooseYear}
 
- 	for(var k in indexs){
 
- 		params.index = indexs[k];
 
- 		loadAmount(params);
 
- 	}	
 
- 	if(level==4){//市级管理员才可以查看市下面的所有社区数据
 
- 		$(".c-lab-mor #labLi2").removeClass("c-hide");
 
- 	} 
 
- 	if(type==1){//从签约分析跳转过来
 
- 		$(".div-lv").removeClass("c-hide");
 
- 	} 
 
- }
 
- /*****************************************************************************/
 
- /*****                  折线图初始化                                                                	**********/
 
- /*****************************************************************************/
 
- var dateData = {};
 
- function loadLineData(type, level, area, from, to, interval, index){
 
- 	var level =level;
 
- 	plus.nativeUI.showWaiting();
 
- 	//增量(咨询量、随访量、指导量),到达量(绑定微信、绑定设备)
 
- 	var activeIndexss = banerIndex || $(".l-qytj-barner li.l-over").attr('data-index');
 
- 	var url = (activeIndexss==3 || activeIndexss==4 || activeIndexss==5 || activeIndexss==27)? "statistics/interval" : "/statistics/interval_total";
 
- //	if(from=='')
 
- //		from = '2016-08-01';
 
-     var fromDate = startDate;
 
- //  if(activeIndexss == 21 || activeIndexss == 20){
 
- //      fromDate = "2016-08-01"; 
 
- //  }
 
- 	var params = {level: level, area: area, startDate: fromDate, endDate: endDate, 
 
- 		interval: $(".div-btn-group .div-btn.active").attr("data-id")}
 
- 	params.index = banerIndex || $(".l-qytj-barner li.l-over").attr('data-index');
 
- 	sendPost(url, params, null, dateLineHandle); 
 
- }
 
- /**
 
-    * 获取多少天前的日期
 
-    */
 
- function getDateBefore(days) {
 
- 	var now = new Date();
 
- 	var date = new Date(now.getTime() - days * 24 * 3600 * 1000);
 
- 	var year = date.getFullYear();
 
- 	var month = date.getMonth() + 1;
 
- 	var day = date.getDate();
 
- 	var hour = date.getHours();
 
- 	var minute = date.getMinutes();
 
- 	var second = date.getSeconds();
 
- 	return year + '/' + (month < 10 ? '0' + month : month) + '/' + (day < 10 ? '0' + day : day);
 
- }
 
- //获取数据最大值
 
- function maxData(data){
 
- 	var maxData = Math.max.apply(Math,data);
 
- 	var yAxis = maxData<10?10:maxData;
 
- 	return yAxis;
 
- }
 
- //初始化折线图
 
- function drawChart(dateData){
 
- 	var recordCount = 10;//一页显示几条数据
 
- 	var allRecordData = dateData.amountArr.reverse();
 
- 	var dateArr = dateData.dateArr.reverse();
 
- 	var resultData = _.groupBy(allRecordData,function(item,i){return Math.floor(i/recordCount)});
 
- 	var dateArrData = _.groupBy(dateArr,function(item,i){return Math.floor(i/recordCount)});
 
- 	//以下为折线图处理
 
- 	var gnum = Math.ceil(allRecordData.length / recordCount);
 
- 	var HandStartX,HandStartY,HandEndX,HandEndY,CountX,CountY,startPos,isScrolling,number=allRecordData.length,times=allRecordData.length%recordCount;
 
- 	var canvasStr = '<div class="div-layer"></div>';
 
- 	for(var x in resultData){
 
- 		canvasStr = '<canvas id="wcMotion'+x+'" class="canvas-wc animated" style="display:block"></canvas>'+canvasStr;
 
- 	}
 
- 	$(".l-zxt-inner").html(canvasStr);
 
- 	var dateType = $(".div-btn-group .div-btn.active").attr("data-id");
 
- 	window.setTimeout(function() {
 
- 		for(var x in resultData){
 
- 			var startDay = new Date(getDateBefore(times-1));
 
- 			var resultDateArr = dateArrData[x].reverse();
 
- 			var yAxis = maxData(resultData[x]);//求数据的最大值
 
- 			$('#wcMotion'+x).wcChart({
 
- 				height: 200,	// width and height must be set if change
 
- 				yAxis:yAxis,
 
- 				day: startDay,
 
- 				points: [],
 
- 				dateType:dateType,
 
- 				dateArr:resultDateArr,
 
- 				data: resultData[x].reverse(),
 
- 				fill: {gradient: [["#17B3EC",.1], ["#17B3EC",.5]], gradientAngle: Math.PI * -45/180},
 
- 				animation: null // 修复bug#3298 【医生端】总体分析排版优化。(vivo手机)
 
- 			});
 
- 			if(x==0){
 
- 				$('#wcMotion'+x).show();
 
- 			} 
 
- 			times+=recordCount;
 
- 			
 
- 			//折线图画布添加左滑和右滑效果
 
- 			var wcMotion = document.getElementById('wcMotion'+x);
 
- 			wcMotion.addEventListener('touchstart', function(event) {
 
- 				HandStartX=event.touches[0].clientX;
 
- 				HandStartY=event.touches[0].clientY;
 
- 				//touches数组对象获得屏幕上所有的touch,取第一个touch
 
- 			   var touch = event.targetTouches[0];
 
- 			   //取第一个touch的坐标值
 
- 			   startPos = {x:touch.pageX,y:touch.pageY,time:+new Date};
 
- 			   //这个参数判断是垂直滚动还是水平滚动
 
- 			   isScrolling = 0;
 
- 			  }, false);
 
- 			  
 
- 			  wcMotion.addEventListener('touchend', function(event) {
 
- 					HandEndX=event.changedTouches[0].clientX;
 
- 					HandEndY=event.changedTouches[0].clientY;
 
- 					CountX=HandEndX-HandStartX;
 
- 					CountY=HandEndY-HandStartY;
 
- 					if((Math.abs(CountX)>Math.abs(CountY))&& Math.abs(CountX)>50){
 
- 						var targetMotion = $(event.target);
 
- 				   		if(CountX<0){
 
- 				   			if(targetMotion.next().length>0 && !targetMotion.next().hasClass("div-layer")){
 
- 				   				targetMotion.siblings().hide();
 
- 				   				targetMotion.addClass("fadeOutLeft");
 
- 				   				targetMotion.next().removeClass("fadeOutRight").removeClass("fadeOutLeft").removeClass("fadeInLeft").addClass("fadeInRight").show();
 
- 				   			}
 
- 							console.log("左滑");
 
- 				   		}else{
 
- 				   			if(targetMotion.prev().length>0 && !targetMotion.prev().hasClass("div-layer")){
 
- 				   				targetMotion.siblings().hide();
 
- 				   				targetMotion.addClass("fadeOutRight");
 
- 				   				targetMotion.prev().removeClass("fadeOutRight").removeClass("fadeOutLeft").removeClass("fadeInRight").addClass("fadeInLeft").show();
 
- 				   			}
 
- 				   			console.log("右滑");
 
- 				   		}
 
- 				   	}
 
- 		
 
- 			  }, false);
 
- 			  
 
- 			   wcMotion.addEventListener('touchmove', function(event) {
 
- 				 //当屏幕有多个touch或者页面被缩放过,就不执行move操作
 
- 				   if(event.targetTouches.length > 1 || event.scale && event.scale !== 1) return;
 
- 				   var touch = event.targetTouches[0];
 
- 				   endPos = {x:touch.pageX - startPos.x,y:touch.pageY - startPos.y};
 
- 				   //isScrolling为1时,表示纵向滑动,0为横向滑动
 
- 				   isScrolling = Math.abs(endPos.x) < Math.abs(endPos.y) ? 1:0;
 
- 				   if(isScrolling === 0){
 
- 				    //阻止触摸事件的默认行为,即阻止滚屏
 
- 				    event.preventDefault();
 
- 				   }
 
- 			  }, false);
 
- 	  
 
- 		}
 
- 	}, 500);	
 
- 	
 
- }
 
- function dateLineHandle(res){
 
- 	var activeIndexss = banerIndex || $(".l-qytj-barner li.l-over").attr('data-index');
 
- 	if(res.status==200){
 
- 		for(var p in res.data){
 
- 			dateData[p] = activeIndexss=="20" || activeIndexss=="21"?formatDateData(res.data[p].data):formatDateData(res.data[p]);
 
- 			if(dateData[p].amountArr && dateData[p].amountArr.length>0){
 
- //				$('#l-jmfx').toggle(p == "index_1" );
 
- 				$('#l-jmfx').show();
 
- 				$(".l-zxt-con").hide();
 
- 				mui.later(function(){
 
- 					$(".l-zxt-con").show();
 
- 				}, 100);
 
- 				$('#l-legend').hide();
 
- 				$("#echarts_wushuju").hide();
 
- 				$('#l-times').html(type==1? '(人)' : '(次)').hide();
 
- 			} else{
 
- 				$(".l-zxt-con").hide();
 
- 				$("#echarts_wushuju").show();
 
- 				$('#l-legend').hide();
 
- 			}
 
- 			drawChart(dateData[p]);//初始化折线图
 
- 			setTimeout(function(){
 
- 				$("#textTj").css("pointer-events","");
 
- 				plus.nativeUI.closeWaiting();
 
- 			},1000)
 
- 		}
 
- 	} else {
 
- 		mui.toast(res.msg);
 
- 	}
 
- }
 
-  
 
- //折线图数据格式转化
 
- function formatDateData(data){
 
- 	var dateArr = [];
 
- 	var amountArr = [];
 
- 	for(var k in data){
 
- 		dateArr.push(data[k].range.substring(5));
 
- 		amountArr.push(data[k].amount);
 
- 	}
 
- 	return {dateArr: dateArr, amountArr: amountArr};
 
- }
 
- //获取当前时间
 
- endDate = getNowDate();
 
- function getNowDate() {
 
-     var date = new Date();
 
-     var month = date.getMonth() + 1;
 
-     var strDate = date.getDate();
 
-     if (month >= 1 && month <= 9) {
 
-         month = "0" + month;
 
-     }
 
-     if (strDate >= 0 && strDate <= 9) {
 
-         strDate = "0" + strDate;
 
-     }
 
-     var currentdate = date.getFullYear() + "-" + month + "-" + strDate;
 
-     return currentdate;
 
- }
 
- function clearData(type){
 
- 	$("#textTj li").removeClass("l-over");
 
- 	if(!banerIndex){
 
- 		$("#textTj li").eq(0).addClass("l-over");
 
- 	}
 
- 	$('#l-jmfx').hide();
 
- 	$("#list").empty();
 
- 	$("#list2").empty();
 
- 	$(".l-data").html("0");
 
- }
 
- //后台接收数据
 
- function loadAmount(params){
 
- 	//数据截止时间
 
- 	sendPost("/statistics/time",null,function(res){
 
- 		
 
- 	},function(res){
 
- 		if(res.status=="200"){
 
- 			var date = (res.data && res.data.substring(11,16)) || "";
 
- 			$(".jiezhi-time").html(date);
 
- 		}
 
- 	})
 
- 	
 
- 	//增量(咨询量、随访量、指导量),到达量(绑定微信、绑定设备)
 
- 	var url = "statistics/total";
 
- 	if(params.index == 20 || params.index == 21){
 
- 	    url = "statistics/index_all";
 
- 	}else{
 
- 	    params.startDate = startDate; //增量需要开始时间和结束时间
 
- 	}
 
- 	sendPost(url, params, null, countHandle);	
 
- }
 
- //获取左下列表
 
- function listHandle(res){
 
- 	if(res.status == 200) {
 
- 		template.helper("setRate", function(all,  amount){
 
- 			if(all == 0)
 
- 				return 0;
 
- 			return (amount / all * 100).toFixed(2);
 
- 		});
 
- 		
 
- 		res = res.data;
 
- 		var $div;
 
- 		for(var k in res){
 
- 			var curIndex = k.split("index_")[1];
 
- 			var list = res[k];
 
- 			if(curIndex=="3"){//咨询量
 
- 				for(var i=0;i<list.length;i++){
 
- 					var amount = list[i].amount.split(",");
 
- 					list[i].amount = amount[0];//咨询量
 
- 					list[i].noAmount = amount[1];//未回复咨询量
 
- 				}
 
- 			}
 
- 			var topArr = [];
 
- 			if(curIndex == "21"){
 
- 			    topArr = soreRank(bindRateArr(list));
 
- //              topArr = soreRank(amountArr(list));
 
- 			}else{
 
- 			    topArr = soreRank(amountArr(list));
 
- 			}
 
- 			
 
- 			for(var j in list){
 
- 				list[j].top = topArr[j];
 
- 			}
 
- 			if(curIndex=="1" && level!=2){
 
- 				res.rateName = "签约率";
 
- 				for(var j in list){
 
- 					if(list[j].rate){
 
- 						list[j].rate = list[j].rate.substring(0,4);
 
- 					}
 
- 				}
 
- 			}
 
- 			res.all = assAmount(list);
 
- 			res.amountName = indexName[k];
 
- 			res.list = list;
 
- 			res.level = level;
 
- 			res.index = curIndex;
 
- 			var indexF = banerIndex!=undefined?"index_"+banerIndex:'index_3'
 
- 			$div = $('<ul id="l_'+k+'" class="l-gq-list '+  (k!=indexF? 'c-hide': '') +'"></ul>');
 
- 			$('#l_'+k).remove();
 
- 		}
 
- 		//查看下一级详情
 
- 		if($div){
 
- 		    //如果是微信绑定或设备绑定,则增加置顶展示当面层级的总绑定率及已缴费 未缴费居民数
 
- 		    if(curIndex == '21'){
 
- 		        var url = "/statistics/getLevelTotalSingle",
 
- 		            params = {date: endDate, level: level, area: area};
 
- 		        sendPost(url, params, null, function(res2){
 
- 		            if(res2.status == 200){
 
-                         var html = template('top_li', res2.data);
 
-                         $div.append(html);
 
-                         $div.append(template("list_tmpl", res));
 
-                         $("#list").append($div);
 
-                         scroller1.refresh();
 
-                         plus.nativeUI.closeWaiting();
 
- 		            }else{
 
- 		                mui.toast(res2.msg);
 
- 		            }
 
- 		        }, 'post', '', true);
 
- 		        return ;
 
- 		    }else{
 
- 		        $div.append(template("list_tmpl", res));
 
-                 $("#list").append($div);
 
-                 scroller1.refresh();
 
-                 plus.nativeUI.closeWaiting();
 
- 		    }
 
- 			
 
- //		    var width = $(".l-qytj-barner li[data-index=3]").width();
 
- //		    $(".band-weixin").width(width).css("display","inline-block");
 
- //		    $(".band-dervice").width(width).css("display","inline-block");
 
- 		}
 
- 			
 
- 	} else {
 
- 		mui.toast(res.msg);
 
- 	}
 
- }
 
- //右下列表
 
- function list2Handle(res){
 
- 	if(res.status == 200) {
 
- 		template.helper("setRate", function(all,  amount){
 
- 			if(all == 0)
 
- 				return 0;
 
- 			return (amount / all * 100).toFixed(2);
 
- 		});
 
- 		
 
- 		res = res.data;
 
- 		var $div;
 
- 		for(var k in res){
 
- 			var curIndex = k.split("index_")[1];
 
- 			var list = res[k];
 
- 			if(curIndex=="3"){//咨询量
 
- 				for(var i=0;i<list.length;i++){
 
- 					var amount = list[i].amount.split(",");
 
- 					list[i].amount = amount[0];//咨询量
 
- 					list[i].noAmount = amount[1];//未回复咨询量
 
- 				}
 
- 			}
 
- 			var topArr = [];
 
-             if(curIndex == "21"){
 
-                 topArr = soreRank(bindRateArr(list));
 
- //              topArr = soreRank(amountArr(list));
 
-             }else{
 
-                 topArr = soreRank(amountArr(list));
 
-             }
 
- 			for(var j in list){
 
- 				list[j].top = topArr[j];
 
- 			}
 
- 			if(curIndex=="1" && level!=2){
 
- 				res.rateName = "签约率";
 
- 				for(var j in list){
 
- 					if(list[j].rate){
 
- 						list[j].rate = list[j].rate.substring(0,4);
 
- 					}
 
- 				}
 
- 			}
 
- 			res.all = assAmount(list);
 
- 			res.amountName = indexName[k];
 
- 			res.list = list;
 
- 			res.level = level;
 
- 			res.index = curIndex;
 
- 			$div = $('<ul id="s_'+k+'" class="l-gq-list '+ (k!='index_1' && k!='index_3'? '': '') +'"></ul>');
 
- 			$('#s_'+k).remove();
 
- 		}
 
- 		
 
- 		if($div){
 
- 			$div.append(template("list_tmpl", res));
 
- 			$("#list2").append($div);
 
- 			setTimeout(function(){
 
- 				if(banerIndex==curIndex){
 
- 					$("#list ul").hide();
 
- 					$("#l_index_"+ banerIndex).show();
 
- 					$('#l-jmfx').toggle($(".l-qytj-barner .l-over").attr("data-index")=="1");
 
- 				}
 
- 			},300)
 
- 			scroller1.refresh();
 
- 		    plus.nativeUI.closeWaiting();
 
- 		}
 
- 			
 
- 	} else {
 
- 		mui.toast(res.msg);
 
- 	}
 
- }
 
- function countHandle(res){
 
- 	if(res.status == 200) {
 
- 		res = res.data;
 
- 		for(var k in res){
 
- 			$('#'+ k).html(res[k]);
 
- 		}
 
- 	} else {
 
- 		mui.toast(res.msg);
 
- 	}
 
- }
 
- //数量数组
 
- function amountArr(list){
 
- 	var amountArr = [];
 
- 	for(var k in list){
 
- 		amountArr.push(list[k].amount);
 
- 	}
 
- 	return amountArr;
 
- }
 
- //绑定率数组
 
- function bindRateArr(list){
 
-     var arr = [];
 
-     for(var k in list){
 
-         arr.push(list[k].bindRate);
 
-     }
 
-     return arr;
 
- }
 
- //格式化数量
 
- function assAmount(list){
 
- 	var all = 0;
 
- 	for(var k in list){
 
- 		all += parseInt(list[k].amount);
 
- 	}
 
- 	return all;
 
- }
 
- //排序
 
- function soreRank(arr) {
 
- 	var temp = [];
 
- 	var lis = [];
 
- 	for(var i=0;i<arr.length;i++)
 
- 		lis.push(arr[i])
 
- 	lis = _.uniq(lis);
 
- 	for(var i=0;i<arr.length;i++)
 
- 		temp[i] = lis.indexOf(arr[i])+1;
 
- 	
 
- 	return temp;
 
- }
 
- function getStartDate(){
 
-     // 按年度来计算的时候,开始时间是该年度7月1号还是到下一个年的6月30号结束
 
-     if(chooseYear == 2016){
 
-         return chooseYear + "-08-01";
 
-     }else{
 
-         return chooseYear+'-07-01';
 
-     }
 
- }
 
- //获取结束时间
 
- function getEndDate(){
 
-     chooseYear = parseInt(chooseYear);
 
-     var endDate = new Date((chooseYear+1) + '-06-30'),
 
-         now = new Date();
 
-     if(now <= endDate){
 
-         var month = now.getMonth()+1,
 
-             date1 = now.getDate();
 
-         if(month < 10){
 
-             month = "0"+month;
 
-         }
 
-         if(date1 < 10){
 
-             date1 = "0"+date1;
 
-         }
 
-         return now.getFullYear()+"-"+month+"-"+date1;
 
-     }else{
 
-         return (chooseYear+1) + '-06-30';
 
-     }
 
- }
 
- document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
 
 
  |