(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('