(function(doc, win) { var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', recalc = function() { var clientWidth = docEl.clientWidth; if(!clientWidth) return; docEl.style.fontSize = 20 * (clientWidth / 320) + 'px'; }; if(!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); doc.addEventListener('DOMContentLoaded', recalc, false); })(document, window); function initScroller(){ scroller1 = $("#wrapper1").initScroll( { pullDownAction: function(){ plus.nativeUI.showWaiting(); page.init(); },pullUpAction: function() { $(".pullUp").hide(); return false; } } ); } var mb; var docType, page, area, level, index,title,initArea,initLevel; var startDate, endDate, checked; //定义年份 var chooseYear; var now = new Date(); if(now.getMonth() >= 6){ chooseYear = now.getFullYear(); }else{ chooseYear = now.getFullYear() - 1; } mui.plusReady(function() { //plusReady调用完成后才可以调用plus的api window.addEventListener("loadData", function(e) { location.reload(); }); //下拉刷新初始化 initScroller(); plus.nativeUI.showWaiting(); /*管理员信息*/ var sDocInfo = plus.storage.getItem("docInfo"); var docInfo = JSON.parse(sDocInfo); var docSex = docInfo.sex; var docPhoto = docInfo.photo; /*传参接收*/ var self = plus.webview.currentWebview(); startDate = self.startDate;//开始时间 endDate = self.endDate;//结束时间 checked = self.checked;//时间控件选择值 area = self.area;//区域或机构代码 level = self.level;//级别(4:市 3:区 2:社区医院 1:团队) index = self.index;//查询指标代码 格式:(指标代码,指标代码,指标代码) title = self.title; initArea = self.area; initLevel = self.level; if(level==4){ title = title.substring(0,3); } $("#title").html(title); //显示年份 $(".choose-label").text(chooseYear+"年"); if(chooseYear == '2016'){ $("#onlineInfo").hide(); }else{ $("#onlineInfo").show(); } // //请求获取线上缴费数据 // getOnlineInfo(); // //设置时间选择器默认值 // var p = {from: startDate, to: endDate}; // if(checked!=-1) // p = {from: checked} // dataPicker.setValue(p.from, p.to); function tab(date1,date2){ var oDate1 = new Date(date1); var oDate2 = new Date(date2); var isYse=false if(oDate1.getTime() > oDate2.getTime()){ isYse=false } else { isYse=true } return isYse } function today(){ var c = new Date(); c.setDate(c.getDate() - 1); return formatDate(c); }//昨天 function getPreDate(pre){ var c = new Date(); c.setDate(c.getDate() - pre); return formatDate(c); }//前几天 function formatDate(d){ return d.getFullYear() + "-" + getMonth(d.getMonth()) + "-" + d.getDate(); } function getMonth(m){ m++; if(m<10) return "0" + m.toString(); return m.toString(); } 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'; } } page={ $juZheng:$(".juzheng"),//年龄分布 init:function(){ this.initJs(); this.initData(); //console.log(startDate+" "+endDate+" "+area+" "+level+" "+index) scroller1.refresh(); }, initData:function(){ var m=this; m.shujujiezhi(), m.jiaofeiList(startDate,endDate,area,level) m.healthList(startDate,endDate,area,level) m.groupList(startDate,endDate,area,level) m.sexList(startDate,endDate,area,level) m.agoList(startDate,endDate,area,level) //请求获取线上缴费数据 if(chooseYear == '2016'){ $("#onlineInfo").hide(); }else{ $("#onlineInfo").show(); getOnlineInfo(); } },//数据初始化 initJs:function(){ var m=this; }, shujujiezhi:function(){ var m=this; 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) } }) },//数据截止 jiaofeiList:function(startDate,endDate,area,level,index){ var m=this; sendGet("/statistics/leveltwo_increment",{ startDate:startDate, endDate:getEndDate(), //截止时间 area:area,// level:level, index:16 },function(res){ },function(res){ if(res.status=="200"){ var data=res.data.index_16; var arry=[]; // console.log("16:"+JSON.stringify(data)) if(data && data.length==1 && data[0].code==0){//未缴费率为100%的情况,后台没有返回已缴费的数据 $(".div-yijiaofei .y-amount").html("0"); $(".div-yijiaofei .y-rate").html("0.00%"); } $.each(data,function(i,v){ if(v.code == 0 || v.code == 1){ v.rate = parseFloat(v.rate).toFixed(2); if(v.code==1){ $(".div-yijiaofei .y-amount").html(v.amount); $(".div-yijiaofei .y-rate").html(v.rate+"%"); }else{ $(".div-weijiaofei .y-amount").html(v.amount); $(".div-weijiaofei .y-rate").html(v.rate+"%"); } arry.push({"value":v.rate, "name":v.name+" \n "+v.rate+"%"}) } }) m.echartsJFQKFun(arry) ; } }) }, //健康分布 healthList:function(startDate,endDate,area,level,index){ var m=this; var url = startDate==''? '/statistics/lowlevel_total' : "/statistics/leveltwo_increment"; sendGet("/statistics/leveltwo_increment",{ startDate:startDate, endDate:getEndDate(), //截止时间 area:area,// level:level, index:15 },function(res){ },function(res){ if(res.status=="200"){ var data=res.data.index_15; // console.log("15:"+JSON.stringify(data)) var arry=[]; $.each(data,function(i,v){ v.rate = parseFloat(v.rate).toFixed(2); arry.push({"value":v.rate, "name":v.name}); }); var colors = "#42C7FF,#FFC84C,#FB5DAB,#CD67FD,#795548,#607d8b,#ff5722,#cddc39,#9e9e9e,#3f51b5,#f44336,#9c27b0".split(','); var html = template('li_tmpl',{list: _.map(arry,function(v,i) { v.color = colors[i]; return v; })}); $('#jkCatalogs').html(html); m.echartsJKFBFun(arry,colors.slice(0,arry.length)) ; } }) }, //服务分布 groupList:function(startDate,endDate,area,level,index){ var m=this; var url = startDate==''? '/statistics/lowlevel_total' : "/statistics/leveltwo_increment"; var index = ((chooseYear==2016)?7:36); sendPost("/statistics/leveltwo_increment",{ startDate:startDate, endDate:getEndDate(), //截止时间 area:area, level:level, index:index },function(res){ },function(res){ if(res.status=="200"){ var data=res.data["index_"+index]; // console.log("777:"+JSON.stringify(data)) var total = 0; mb= {}; var arry=[]; if(chooseYear==2016) { $.each(data,function(i,v){ if(v.code == 1 || v.code == 2 || v.code == 3 || v.code == 7){ v.rate = parseFloat(v.rate).toFixed(2); arry.push({"value":v.rate, "name":v.name}); if(v.code=="1"){//普通人群 #42C7FF $(".div-ptrq").html(v.rate+"%"); }else if(v.code=="2"){//慢病人群65岁以下 #FFC84C $(".div-65xmbrq").html(v.rate+"%"); }else if(v.code=="3"){//65岁以上人群 #FB5DAB $(".div-65srq").html(v.rate+"%"); }else if(v.code=="7"){//慢病人群65岁以上 #CD67FD $(".div-65smbrq").html(v.rate+"%"); } } else{ mb[(v.code==100? "gat" : v.code==4? "gxy" : "tnb")] = v; total += v.amount; } }) var colors = "#42C7FF,#FFC84C,#FB5DAB,#CD67FD,#795548,#607d8b,#ff5722,#cddc39,#9e9e9e,#3f51b5,#f44336,#9c27b0".split(','); var html = template('li_tmpl',{list: _.map(arry,function(v,i) { v.color = colors[i]; return v; })}); $('#fwCatalogs').html(html); mb["total"] = total; jbfb(); m.echartsFun(arry,colors.slice(0,arry.length)) $('#ser2016').show(); $('#ser2017').hide(); }else{ $('#ser2017').show(); $('#ser2016').hide(); arry = _.chain(data).filter(function(v) { return !_.contains(["0","2","13"],v.code) }).map(function(v) { v.rate = parseFloat(v.rate).toFixed(2); return {"value":v.rate, "name":v.name} }).value(); plus.nativeUI.closeWaiting(); m.echartsFun2(arry) } } }) },//分组情况 sexList:function(startDate,endDate,area,level){ var m=this; var url = startDate==''? '/statistics/lowlevel_total' : "/statistics/leveltwo_increment"; sendGet("/statistics/leveltwo_increment",{ startDate:startDate, endDate:getEndDate(), //截止时间 area:area, level:level, index:6 },null,function(res){ if(res.status=="200"){ var data=res.data.index_6; var no = {"c-1": 1, "c-2": 2, "c-3": 3}; $.each(data, function(i,v){ delete no["c-"+ v.code]; m.rotateCyc($(".fzabout cite.a"+parseInt(v.code)), parseFloat(v.rate).toFixed(2), v.amount); }) for(var k in no){ m.rotateCyc($(".fzabout cite.a"+parseInt(no[k])), 0, 0); } } }) },//性别情况 agoList:function(startDate,endDate,area,level){ var m=this; var url = startDate==''? '/statistics/lowlevel_total' : "/statistics/leveltwo_increment"; var parmas={ startDate:startDate, endDate:getEndDate(), //截止时间 area:area,// level:level, index:8 } sendGet("/statistics/leveltwo_increment",parmas,function(res){ //console.log("1"+JSON.stringify(res)) },function(res){ //console.log("2"+JSON.stringify(res)) if(res.status=="200"){ var data=res.data.index_8; m.txingInit(data); } }) }, //健康分布 echartsJKFBFun:function(arry,colors){ var m=this; var myChart = echarts.init(document.getElementById('jkfb-main')); var option = { tooltip: { trigger: 'item', formatter: "{a}
{b}: {c} ({d}%)" }, // textStyle: { // color: '#fff', // fontStyle: 'normal', // fontSize: 16, // }, color:colors, series: [ { name:'访问来源', type:'pie', // center: ['50%', '50%'], radius : '65%', center:[70,'50%'], // selectedMode: 'single', // radius: [0, '100%'], // legendHoverLink:false, // hoverAnimation:false, // selectedOffset:0, label: { normal: { show: false, textStyle: { color: "#000" } // position: 'inner' } }, labelLine: { normal: { show: false } }, data:arry }, ] }; myChart.setOption(option); }, //健康分布扇形统计图 echartsJFQKFun:function(arry){ var m=this; var myChart = echarts.init(document.getElementById('jfqk-main')); var option = { tooltip: { trigger: 'item', formatter: "{a}
{b}: {c} ({d}%)" }, // textStyle: { // color: '#fff', // fontStyle: 'normal', // fontSize: 16, // }, color:['#909090', '#29C681'], series: [ { type:'pie', radius : ['70%', '90%'], // center:[70,55], itemStyle : { normal : { label : { show : false }, labelLine : { show : false } }, }, // selectedMode: 'single', // radius: [0, '100%'], // legendHoverLink:false, // hoverAnimation:false, // selectedOffset:0, // label: { // normal: { // textStyle: { // color: "#000" // } //// position: 'inner' // } // }, labelLine: { normal: { // show: false } }, data:arry }, ] }; myChart.setOption(option); }, //服务分布2017 echartsFun2:function(arry){ console.log("xx:"+JSON.stringify(arry)) var m=this; var myChart = echarts.init(document.getElementById('main2')); var name=[]; var rate =[]; $.map(arry,function(item,index){ name.push(item.name) rate.push(item.value) }) var option = { grid: {y: 25, y2:30, x:10, x2:10,width:$("#main2").width(),borderColor:'#ffffff'}, xAxis : [ { type : 'category', axisLine: {show:true,lineStyle:{color:'#dcdcdc',width:1}}, axisTick: {show:false}, axisLabel: { show:true, interval:0, textStyle: { color:'#333', fontSize: 14, }, formatter:function(val){ if(val.length>4){ return val.substring(0,4)+'…' }else{ return val } }, }, splitArea: {show:false}, splitLine: {show:false}, data : name } ], yAxis : [ { type : 'value', show:false, axisLine: {show:true,lineStyle:{color:'#dcdcdc',width:1}}, axisTick: {show:false}, axisLabel: {show:false}, splitArea: {show:false}, splitLine: {show:false}, axisLabel:{show:false} } ], dataZoom: [ { type: 'inside', orient:'horizontal', filterMode:'none', zoomLock:true, zoomOnMouseWheel:false, preventDefaultMouseMove:false, xAxisIndex:0, start: 0, end: 40 } ], series : [ { name:'', type:'bar', barWidth:20, barMinHeight:1, label:{ normal:{ show:true, position:'top', formatter: '{c}%', textStyle: { color: '#333', fontSize: 14, }, } }, itemStyle: {normal: {color:'#17B3EC'}}, data:rate } ] } myChart.setOption(option); }, //服务分布2016 echartsFun:function(arry,colors){ console.log("xx:"+JSON.stringify(arry)) var m=this; var myChart = echarts.init(document.getElementById('main')); var option = { tooltip: { trigger: 'item', formatter: "{a}
{b}: {c} ({d}%)" }, // textStyle: { // color: '#fff', // fontStyle: 'normal', // fontSize: 16, // }, color:colors, calculable : true, series: [ { name:'访问来源', type:'pie', // center: ['50%', '50%'], radius : '65%', center:[70,'50%'], // name:'访问来源', // type:'pie', // center: ['50%', '50%'], // radius : '65%', // roseType : 'radius', // radius : [20, 80], // center:[100,'50%'], // selectedMode: 'single', // radius: [0, '100%'], // legendHoverLink:false, // hoverAnimation:false, // selectedOffset:0, label: { normal: { show: false, textStyle: { color: "#000" } // position: 'inner' } }, labelLine: { normal: { show: false } }, data:arry }, ] }; myChart.setOption(option); },//服务分布扇形统计图 rotateCyc:function(obj,deg,size){ var deg1=360*(deg/100) if(deg<51){ obj.html('
'+deg+'%'+size+'
') }else{ obj.html('
'+deg+'%'+size+'
') } },//分组情况 txingInit:function(data){ var m=this; var data=data; // console.log(JSON.stringify(data)) /*条形图 变量*/ var dataLength=data.length; var dataWidth=20 if(dataLength!=0){ dataWidth=100/dataLength } var html=""; // var data=[{"amount":0,"code":"1","name":"0~6"},{"amount":0,"code":"2","name":"7~18"},{"amount":0,"code":"3","name":"18~30"},{"amount":0,"code":"4","name":"30~50"},{"amount":0,"code":"5","name":"50~65"},{"amount":0,"code":"1","name":">65"}] var count=0; $.each(data,function(i,v){ count+=parseInt(v.amount) html+='
  • '+ '

    '+v.amount+'

    '+ ''+ ''+ ''+ ''+v.name+''+ '
  • ' }) m.$juZheng.html(html) if(count!=0){//如果有数据 m.$juZheng.find("li").each(function(i,v){ var val=$(v).attr("data-value"); $(v).find("i").css("height",(parseInt(val)/count)*100+"%") }) } } } page.init() }); function asse(a, t){ return (a/t).toFixed(2) * 100; } function jbfb(){ var parmas={ startDate:startDate, endDate:endDate, //截止时间 area:area,// level:level, index:8 } sendPost("/statistics/sixfive_statistics", parmas, null, function(res){ if(res.status==200){ var total = 0; function setGlrq(t){ if(t != 0){ $.each(res.data, function(i, v) { if(v.amount != 0 ){ if(v.code==1) $('#glrq div.gxy').css('width', asse(v.amount, t) +'%').html(v.amount); else if(v.code==2) $('#glrq div.tnb').css('width', asse(v.amount, t) +'%').html(v.amount); else if(v.code==3) $('#glrq div.gat').css('width', asse(v.amount, t) +'%').html(v.amount); else if(v.code==4) $('#glrq div.jk').css('width', asse(v.amount, t) +'%').html(v.amount); } }); for(var k in mb){ if(mb[k].amount != 0 ) $('#mbrq div.'+ k).css('width', asse(mb[k].amount, t) +'%').html(mb[k].amount); } } } $.each(res.data, function(i, v) { if(v.code != 0){ total += v.amount; } }); if(total > mb.total){ setGlrq(total); } else{ setGlrq(mb.total); } } else mui.toast(res.msg); plus.nativeUI.closeWaiting(); // console.log("65sui"+ JSON.stringify(res)) }) } //获取线上缴费情况信息 function getOnlineInfo(){ var url = "/statistics/signPayOnline", params = { level:level, area:area, year: chooseYear }; sendGet(url, params, null, function(res){ if(res.status == 200){ $("#onlineV1").text(res.data.signPayOnlineNum); var total = parseInt(res.data.signPayOnlineNum) + parseInt(res.data.signPayUnderNum); $("#onlineV2").text(" / "+ total); }else{ mui.toast(res.msg); } }, true); } var dataPicker; $(function(){ dataPicker = $('#datePickDIV').lpicker({onCheck: function(){ var parent = plus.webview.getWebviewById("analysis1"); mui.fire(parent, "setDateVal", this.getValue()); var val = this.getValue(); page.groupList(val.from, val.to, area, level) page.sexList(val.from, val.to,area, level) page.agoList(val.from, val.to,area, level) }}); window.addEventListener("showMask", function() { dataPicker.toggle(); }); //添加信息删除按钮的点击事件 $("#closeBtn").on("tap", function(){ $(".information").hide(); scroller1.refresh(); }); //点击缴费情况跳转缴费情况详情页面 $("#onlineInfo").on("tap", function(){ if(chooseYear == '2016'){ return false; } mui.openWindow({ url:"pay-online-analysis.html", id: "pay-online-analysis", extras:{ level: level, code: area, title: $("#title").html(), year: chooseYear } }) }); window.addEventListener("showInformation", function(){ $(".information").show(); scroller1.refresh(); }); }) window.addEventListener("refresh", function(e) { area = e.detail.area || initArea; level = e.detail.level || initLevel; name = e.detail.name; chooseYear = e.detail.year; // console.log("area:"+area+" level:"+level+" name:"+name) $("#title").html(name); $(".choose-label").text(chooseYear+"年"); if(chooseYear == '2016'){ $("#onlineInfo").hide(); }else{ $("#onlineInfo").show(); } page.init(); }); document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);