123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951 |
- mui.init();
- var selfwv,
- userRole,
- initLevel,
- initAreaCode,
- initTitle,
- level,
- areaCode,
- areaTitle,
- index = "2", // 顶部tab对应的指标的index
- selectedDateType = 1, //折线图中选择的时间类型。 1-日,2-周, 3-月
- indexs = ['2','3', '5', '6'], //对应顶部tab的index值
- endDate,
- startDate,
- nowYear = new Date().getYear(),
- quShiStartDate,
- quShiEndDate,
- lowLevel,
- indexName = {'index_2': '活跃居民','index_3': '居民咨询量', 'index_5': '健康指导','index_6':'关注人次','index_1':'有效关注', 'index_4': '注册居民','index_83': "健康文章"};
- var initTabOffsetTop = 0; //初始化时,底部tab距离顶部的位置
- var index_5, index_83; //标记健康教育中健康文章和健康指导的值
- var reqParam = []; //请求参数
- var reqList = []; //请求的链接数据,根据这些信息后退的时候使用
- //初始化计算选择的年份
- var chooseYear;
- var now = new Date();
- if(now.getMonth() >= 6){
- chooseYear = now.getFullYear();
- }else{
- chooseYear = now.getFullYear() - 1;
- }
- var information = {
- "2":"注册居民人数为当前(截止最新时间)累计注册城市爱健康的居民人数总和。",
- "3":"居民咨询量为当前(截止最新时间)累计发起咨询的次数总和。",
- "5":"健康教育量为当前(截止最新时间)累计发送健康指导和健康文章的数量总和。",
- "6":"居民关注数量为当前(截止最新时间)累计关注医生的有效居民人数总和。"
- };
- mui.plusReady(function(){
- selfwv = plus.webview.currentWebview();
- userRole = JSON.parse(plus.storage.getItem("selectedRole"));
- initLevel = level = 3;//因为总体分析只能看到科室和医生,所以3代表科室级别,2代表医生级别
- initAreaCode = areaCode = srOrgCode;//默认是上饶机构code,值在common_http.js文件中
- initTitle = areaTitle = userRole.name;
- //处理点击首页的tap默认触发本页面的顶部tap
- if(selfwv.index){
- $(".l-banner li").removeClass("active");
- selfwv.index==0?index='2':selfwv.index==1?index='3':selfwv.index==2?index=5:selfwv.index==3?index=6:index=2;
- $(".l-banner li").eq(selfwv.index).addClass("active");
- }
- $("#areaTitle").text(areaTitle);
- $("#infoText").text(information[index]);
- $(".choose-label").text(chooseYear + '年');
- //初始化趋势图时间
- nowYear = new Date().getYear()
- nowYear += (nowYear < 2000) ? 1900 : 0;
- initReqParams(); //初始请求参数信息
- loadData([0,1,2]);
-
- //记录返回链接信息
- reqList.push({
- level: level,
- lowLevel: lowLevel,
- areaCode: areaCode,
- areaTitle: areaTitle,
- index: index,
- req: reqParam
- });
-
- initTabOffsetTop = $(".area-tab-panel").offset().top;
-
- showBottomTab();
- bindEvents();
- });
- initScroller();
- function getTopReqParams(){
- var url = "/statistics/getIndexTotal",
- data = {endDate:getDateFromNow(),area:areaCode,level:3};
- return {
- url: url,
- reqType: 'GET',
- data: data
- };
- }
- function initReqParams(){
- //初始化开始时间和结束时间
- startDate = getStartDate();
- endDate = getEndDate();
- quShiStartDate = formatDate(new Date(nowYear,0,1));
- quShiEndDate = formatDate(new Date(nowYear,11,31));
- $(".add-qushi-date-text").html(nowYear.toString())
-
- //增量(注册居民2、居民咨询量3、健康教育5、)到达量(居民关注6)
- var url2 = "/statistics/interval",//默认注册居民
- url3 = '/statistics/registerRange';;//默认注册居民
- if(index=='3' || index == '6'){
- url3 = "/statistics/lowlevel_total_mesh"
- }else if(index == '5'){
- url3 = '/statistics/article_lowlevel_total';
- }else if(index=='6'){
- url2 = "/statistics/interval_total";
- }
- if(index==2){//注册居民
- reqParam = [{//请求中间部分
- url: url2,
- reqType: 'POST',
- data:{
- index: '2,4',
- level: level, //等级(1 团队,2 科室,3 机构,4 区)
- area: areaCode, //默认是49229004X
- startDate: quShiStartDate,
- endDate: quShiEndDate,
- interval: selectedDateType
- }
- },{ //如果是注册居民,则增加置顶展示当面层级的注册率及关注平台人数、 注册人数.只针对注册居民时使用
- url: url3,
- reqType: 'POST',
- data: {}
- }];
- }else{//居民咨询量3、健康教育5、居民关注6
- reqParam = [{//请求中间部分
- url: url2,
- reqType: 'POST',
- data:{
- index: index == 5 ? '5,83' : (index==6)?"1,6":index,
- level: level, //等级(1 团队,2 科室,3 机构,4 区)
- area: areaCode, //默认是49229004X
- startDate: quShiStartDate,
- endDate: quShiEndDate,
- interval: selectedDateType
- }
- },{//请求底部部分
- url: url3,
- reqType: 'POST',
- data: {
- index: (index == 3) ? "3,22" : (index==6)?"1,6":index,
- endDate: endDate,
- level: level,
- area: areaCode,
- sort: 1
- }
- }];
- if(lowLevel){
- reqParam[1].data.lowLevel = lowLevel;
- }
- }
-
- }
- /*
- * 加载页面数据
- * @param loadArr array 记录需要请求的区域0-顶部,1-中间,2-底部
- */
- function loadData(loadArr){
- plus.nativeUI.showWaiting();
- getJieZhiTime();
- var reqPromise = [],
- newArr = []; //记录非顶部请求的请求数组
- if(loadArr.indexOf(0) > -1){
- //请求加载了头部的内容
- var url = "/statistics/getIndexTotal",
- data = {endDate:getDateFromNow(),area:areaCode,level:level};
- var reqs = [{url: url,reqType: 'GET',data: data}];
- getReqPromises(reqs, true).then(function(ress){
- handleTopPanelData(ress);
- }).then(function(){
- //如果饼图已经显示了,则这边需要重新绘制新的数据
- if($("#pieChartsPanel").hasClass("show")){
- $("#pieChartsPanel").show();
- $("#pieChartsPanel").addClass("show");
- $(".wz-num").text(index_83);
- $(".zd-num").text(index_5);
- var allindex=(index_83+index_5)*0.01;
- console.log(allindex+" "+index_83/allindex +" "+index_5/allindex)
- var wzNumP = allindex==0?"0%":(index_83/allindex).toFixed(2)+"%";
- var zdNumP = allindex==0?"0%":(index_5/allindex).toFixed(2)+"%";
- $(".wz-num-p").text(wzNumP);
- $(".zd-num-p").text(zdNumP);
- var arr = [{
- name: '健康文章',
- value: index_83
- },{
- name: '健康指导',
- value: index_5
- }];
-
- drawPie('pieChart', arr, ['#ffc800', '#17b3ec']);
- }else{
- $("#pieChartsPanel").hide();
- $("#pieChartsPanel").removeClass("show");
- }
- });
- }
- for(var i=0; i<loadArr.length; i++){
- if(loadArr[i] == 0){
- // do nothing
- }else{
- var j = loadArr[i] - 1;
- reqPromise.push(reqParam[j]);
- newArr.push(loadArr[i]);
- }
- }
- if(index == '2'){//注册居民
- $("#pieChartsPanel2").show();
- $(".area-panel").addClass("bgc-fff").hide();
- }else{
- $("#pieChartsPanel2").hide();
- $(".area-panel").removeClass("bgc-fff").show();
- }
-
- if(index == '5' ){
- //如果饼图还没有显示了,说明当前操作是点击了”健康教育“tab,此时需要绘制饼图,这样才会有动画效果
- if(!$("#pieChartsPanel").hasClass("show")){
- $("#pieChartsPanel").show();
- $("#pieChartsPanel").addClass("show");
- $(".wz-num").text(index_83);
- $(".zd-num").text(index_5);
- var allindex=(index_83+index_5)*0.01;
- console.log(allindex+" "+index_83/allindex +" "+index_5/allindex)
- var wzNumP = allindex==0?"0%":(index_83/allindex).toFixed(2)+"%";
- var zdNumP = allindex==0?"0%":(index_5/allindex).toFixed(2)+"%";
- $(".wz-num-p").text(wzNumP);
- $(".zd-num-p").text(zdNumP);
-
- var arr = [{
- name: '健康文章',
- value: index_83
- },{
- name: '健康指导',
- value: index_5
- }];
-
- drawPie('pieChart', arr, ['#ffc800', '#17b3ec']);
- }
- }else{
- $("#pieChartsPanel").hide();
- $("#pieChartsPanel").removeClass("show");
- }
-
- if(reqPromise.length > 0){
- getReqPromises(reqPromise, true).then(function(ress){
- var res2, res3;
-
- for(var i=0; i<newArr.length; i++){
- var j = newArr[i] + 1;
- if(j == 2){
- res2 = ress[i];
- }
- if(j == 3){
- res3 = ress[i];
- }
- }
- if(res2){
- if(res2.status == 200){
- handleSecondPanelData(res2.data);
- }else{
- mui.toast(res2.msg);
- }
-
- }
- if(res3){
- if(index=='2'){//注册居民
- if(res3.status == 200){
- $("#pieChartsPanel2").show();
- handleZCGKData(res3.data);
- }else{
- $("#pieChartsPanel2").hide();
- mui.toast(res3.msg);
- }
- }else{
- if(res3.status == 200){
- listHandle(res3.data);
- }else{
- $("#listTable").empty();
- mui.toast(res3.msg);
- }
- }
- }
- plus.nativeUI.closeWaiting();
- }).catch(function(e){
- console.log(e);
- plus.nativeUI.closeWaiting();
- });
- }
- }
- /*
- * 加载数据截止时间
- */
- function getJieZhiTime(){
- 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+")");
- }
- });
- }
- /*
- * 处理顶部各tab的值
- */
- function handleTopPanelData(ress){
- if(ress[0].status==200){
- var data = ress[0].data;
- $("#index_2 .span-account").html(data.reginNum);
- $("#index_3 .span-account").html(data.consultNum);
- $("#index_5 .span-account").html(parseInt(data.educateNum)+parseInt(data.guideNum));
- $("#index_6 .span-account").html(data.concernNum);
- index_83 = data.educateNum;
- index_5 = data.guideNum;
- }else{
- mui.toast(ress[0].msg);
- }
-
- }
- /*
- * 处理中间折线图区域的数据
- */
- function handleSecondPanelData(data){
- var dataZoom_end,
- xDatas = [],
- yDatas = [],
- names = [],
- colors = ['#12b7f5', '#cd67fd'];
- for(var p in data){
- if(selectedDateType=="3"){
- _.each(data[p], function(o){
- o.range=o.range.substr(0,7)
- });
- }
- names.push(indexName[p]);
- var xData = _.map(data[p], function(o){
- return o.range;
- });
- var yData = _.map(data[p], function(o){
- return o.amount;
- });
-
- xDatas.push(xData);
- yDatas.push(yData);
- var lastIndex = yData.length % 10;
- if(yData.length >10 ){
- dataZoom_end = 100-(9/yData.length)*100;
- }else{
- dataZoom_end = 0;
- }
- //初始给定第一版页面中时间区间
- if(selectedDateType == 3){
- var d1 = lastIndex > 0 ? xData[yData.length - lastIndex] : xData[yData.length - 10],
- d2 = xData[yData.length -1];
- if(d1){
- $("#startValue").text(d1.substr(0,4)+"年"+d1.substr(5,2)+"月");
- $("#endValue").text(d2.substr(0,4)+"年"+d2.substr(5,2)+"月");
- }else{
- $("#startValue").text(d1);
- $("#endValue").text(d2);
- }
- }else{
- $("#startValue").text(lastIndex > 0 ? xData[yData.length - lastIndex] : xData[yData.length - 10]);
- $("#endValue").text(xData[yData.length -1]);
- }
- }
- drawLine(names, dataZoom_end, xDatas[0], yDatas, colors);
- }
- /*
- * 处理底部科室、医生的数据
- */
- function listHandle(data){
- for(var k in data){
- var list = data[k];
- if(index=="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];//未回复咨询量
- }
- }
-
- if(index=="6"){//关注居民
- 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 = [];
- topArr = soreRank(amountArr(list, 'amount'));
-
- for(var j in list){
- list[j].top = topArr[j];
- }
-
- var html = template("data-list", {
- list: list,
- level: level,
- index: index,
- lowLevel: lowLevel
- });
- $("#listTable").empty().append(html);
- }
- }
- /*
- * 处理注册居民-注册率概况的数据
- */
- function handleZCGKData(data){
- $("#pieChartsPanel2 .title").text("注册率概况");
- $(".jf-num").text(data.wxUser);
- $(".wjf-num").text(data.reginNum);
- $(".num").text(data.registeRange || 0);
- var arr = [{
- name: '关注平台人数',
- value: data.wxUser
- },{
- name: '注册人数',
- value: data.reginNum
- }];
- drawPie('pieChart2', arr, ['#17b3ec', '#909090']);
- }
- /*
- * 获得团队信息
- */
- function showTeamInfo(teamId){
- var url = "/doctor/admin-teams/teams/info",
- params = {
- teamId: teamId
- };
- plus.nativeUI.showWaiting();
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- var data = res.data;
- data.memberLength = data.members.length;
- var html = template("teamInfo", data);
- $("#teamInfoBox").empty().append(html);
- $(".modal-overlay").addClass("modal-overlay-visible");
- setTimeout(function(){
- $(".modal-content").show();
- },50)
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
- }
- /*
- * 控件事件绑定
- */
- function bindEvents(){
- //说明信息相关事件
- $("#closeBtn").on("tap", function(){
- $(".information").hide();
- });
-
- $(".info-icon").on("tap", function(){
- $(".information").show();
- });
-
- //点击顶部tab切换
- $(".l-banner").on('tap', 'li', function(){
- var $this = $(this),
- val = $this.attr("data-index");
- if($this.hasClass("active")){
- return false;
- }
- $(".l-banner li.active").removeClass("active");
- $this.addClass("active");
-
- index = val;
-
- $("#infoText").text(information[index]);
- var tagName = index == '5' ? '推送量' : indexName['index_'+index];
- if(index=='6'){//居民关注
- $(".qushi-span").text("居民关注趋势");
- }else{
- $(".qushi-span").text(tagName+"新增趋势");
- }
- //加载数据
- initReqParams();
- loadData([1,2]);
- //记录返回链接信息
-
- reqList=[];
- reqList.push({
- level: level,
- lowLevel: lowLevel,
- areaCode: areaCode,
- areaTitle: areaTitle,
- index: index,
- req: reqParam
- });
- });
-
- //日月周切换
- $(".date-tag").on('tap', function(){
- var $this = $(this),
- val = $this.attr("data-type");
- if($this.hasClass("active")){
- return false;
- }
- $(".date-tag").removeClass("active");
- $this.addClass("active");
-
- selectedDateType = val;
- initReqParams();
- loadData([1]);
- });
-
- //底部各区,社区,团队tab切换
- $(".area-tab").on('tap', function(){
- var $this = $(this),
- type = $this.attr("data-val"); //4 - 各区, 3 - 社区, 2 - 团队
-
- if($this.hasClass("active")){
- return false;
- }
- $(".area-tab").removeClass("active");
- $this.addClass("active");
-
- if(type == "3"){
- lowLevel = 2;
- }else{
- lowLevel = 1;
- }
-
- initReqParams();
- loadData([2]);
- });
-
- //点击列表查看下一级数据
- $("#listTable").on('tap', '.data-row', function(){
- var $this = $(this),
- code = $this.attr("data-code"),
- name = $this.attr("data-name");
-
- if($this.find(".fa-angle-right").length == 0){
- //团队内容
- showTeamInfo(code);
- return false;
- }
-
- areaTitle = name;
- areaCode = code;
- var newlevel = level - 1;
- //如果是市级管理员,先点击“社区”tab后再往下看下一级的数据,需要将level再-1
- if(newlevel == 3 && lowLevel == 2){
- newlevel -- ;
- }
- lowLevel = '';
- level = newlevel;
- $("#areaTitle").text(areaTitle);
-
- //判断当前tab的位置
- var top = $(".area-tab-panel").offset().top;
- if(top < 0){
- mui(".mui-scroll-wrapper").scroll().scrollTo(0, -(parseInt(initTabOffsetTop)/2), 500);
- }
-
- showBottomTab();
- initReqParams();
- loadData([0,1,2]);
- //记录返回链接信息
- reqList.push({
- level: level,
- lowLevel: lowLevel,
- areaCode: areaCode,
- areaTitle: areaTitle,
- index: index,
- req: reqParam
- });
- });
-
- //弹出遮罩
- $(".icon-remark").on("click", function(e) {
- $(".modal-overlay").addClass("modal-overlay-visible");
- setTimeout(function(){
- $(".modal-content").show();
- },50)
- });
-
- $(".div-close,.modal-overlay").on("click",function(){
- $(".modal-overlay").removeClass("modal-overlay-visible");
- $(".modal-content").hide();
- });
-
- //左滑筛选区域的数据
- $('.header-link').on("tap", function(){
- var self = plus.webview.currentWebview();
- mui.fire(self, "showShaiXuan");
- });
-
- //添加页面监听
- window.addEventListener("refresh", function(e){
- var year = e.detail.year;
- //重置变量值
- chooseYear = year;
- level = initLevel;
- areaCode = initAreaCode
- areaTitle = initTitle;
- lowLevel = "";
- startDate = getStartDate();
- endDate = getEndDate();
-
- $("#areaTitle").text(areaTitle);
- $(".choose-label").text(chooseYear+"年");
-
- showBottomTab();
- initReqParams();
-
- //清空请求数组
- reqList.splice(0, reqList.length);
- //记录返回链接信息
- reqList.push({
- level: level,
- lowLevel: lowLevel,
- areaCode: areaCode,
- areaTitle: areaTitle,
- index: index,
- req: reqParam
- });
- loadData([0,1,2]);
- })
-
- //中间趋势图左箭头事件
- $(".zuoJiao-img").on("tap",function(){
- nowYear = nowYear - 1;
- quShiStartDate = formatDate(new Date(nowYear,0,1));
- quShiEndDate = formatDate(new Date(nowYear,11,31));
- $(".add-qushi-date-text").html(nowYear.toString());
- initReqParams();
- loadData([1]);
- })
- //中间趋势图又箭头事件
- $(".youJiao-img").on("tap",function(){
- nowYear = nowYear + 1;
- quShiStartDate = formatDate(new Date(nowYear,0,1));
- quShiEndDate = formatDate(new Date(nowYear,11,31));
- $(".add-qushi-date-text").html(nowYear.toString());
- initReqParams();
- loadData([1]);
- })
- }
- /*
- * 控制底部科室,医生
- */
- function showBottomTab(){
- $(".area-tab").removeClass("active");
- switch(level){
- case 3:
- $(".area-tab").eq(0).addClass("active").show();
- $(".area-tab").eq(1).show();
- break;
- case 2:
- $(".area-tab").eq(0).hide();
- $(".area-tab").eq(1).addClass("active").show();
- break;
- }
- }
- /*
- * 初始化scroller
- */
- function initScroller(){
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
- mui('.mui-scroll-wrapper').pullRefresh({
- down: {
- callback: function() {
- var self = this;
- setTimeout(function() {
- initReqParams();
- loadData([0,1,2]);
- self.endPulldownToRefresh();
- }, 1000);
- }
- }
- });
- }
- /*
- * 绘制折线图
- */
- function drawLine(name, dataZoom_end, xData, yDatas, colors){
- var lineCharts = echarts.init(document.getElementById('lineChart'));
- var options = {
- tooltip: {
- trigger: 'axis'
- },
- color: colors,
- legend: {
- bottom: '0px',
- data: name,
- borderColor: "#f1f1f1"
- },
- grid: {
- show: false,
- left: '10px',
- right: '10px',
- bottom: '30px',
- top: '10px',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- data: xData,
- axisLabel: {
- interval:0,//横轴信息全部显示
- formatter: function (value, index) {
- if(selectedDateType == 1 || selectedDateType == 2){
- if(index == 0){
- $("#startValue").text(value);
- return value.substr(5,2)+"月"+value.substr(8,2);
- }else{
- if(index == 10){
- $("#endValue").text(value);
- }
- return value.substr(8,2);
- }
- }else if(selectedDateType == 3){
- var val = value.substr(5,2)+"月"
- if(index == 0){
- $("#startValue").text(value.substr(0,4)+"年"+val);
- }else{
- if(index == 9){
- $("#endValue").text(value.substr(0,4)+"年"+val);
- }
- }
- return val;
- }
- }
- }
- },
- yAxis: {
- type: 'value',
- axisPointer: {
- snap: true
- },
- scale: true,
- minInterval: 1,
- boundaryGap: ['10%', '30%']
- },
- dataZoom: [{//给x轴设置滚动条
- show: false,
- start: dataZoom_end,
- end: 100,
- type: 'slider',
- zoomLock: true,
- },{ //下面这个属性是内容区域配置
- start: dataZoom_end,
- end: 100,
- type: 'inside',
- zoomLock: true,
- }]
- // series: [{
- // name: name,
- // type: 'line',
- // smooth: true,
- // data: yData,
- // lineStyle:{
- // normal: {
- // color: '#12b7f5'
- // }
- // }
- // }]
- };
- var series = [],
- legend = [];
- for(var i=0; i<yDatas.length; i++){
- var obj = {
- name: name[i],
- type: 'line',
- smooth: true,
- data: yDatas[i],
- lineStyle:{
- normal:{
- color: colors[i]
- }
- }
- };
- series.push(obj);
- }
- options.series = series;
- $("#lineChart").removeAttr('_echarts_instance_')
- lineCharts.setOption(options);
- }
- /*
- * 绘制饼图
- */
- function drawPie(elId, arry, color){
- var myChart = echarts.init(document.getElementById(elId));
- var option = {
- tooltip: {
- trigger: 'item',
- formatter: "{b} : {c} ({d}%)",
- position: ['50%', '50%']
- },
- color: color,
- series: [
- {
- type:'pie',
- radius: ['80%', '99%'],
- startAngle: 270,
- legendHoverLink: false,
- hoverAnimation: false,
- avoidLabelOverlap: false,
- label: {
- normal: {
- show: false,
- textStyle: {
- color: "#000"
- }
- }
- },
- labelLine: {
- normal: {
- show: false
- }
- },
- data:arry
- }]
- };
- myChart.setOption(option);
- }
- /*
- * 获取用来排序的字段值,返回数组
- * 参数: list - 列表, key - 字段的名称
- */
- function amountArr(list, key){
- var amountArr = [];
- for(var k in list){
- amountArr.push(list[k][key]);
- }
-
- return amountArr;
- }
- /*
- * 排名
- */
- 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';
- }
- }
- //获取当前时间
- function getDateFromNow(days) {
- if(!days) {
- return new Date().format("yyyy-MM-dd")
- }
- var now = new Date().getTime()
- var diff = 24 * 3600 * 1000 * days
- return new Date(now + diff).format("yyyy-MM-dd")
- }
- //格局化日期:yyyy-MM-dd
- function formatDate(date) {
- var myyear = date.getFullYear();
- var mymonth = date.getMonth() + 1;
- var myweekday = date.getDate();
- if(mymonth < 10) {
- mymonth = "0" + mymonth;
- }
- if(myweekday < 10) {
- myweekday = "0" + myweekday;
- }
- return(myyear + "-" + mymonth + "-" + myweekday);
- }
- //返回事件
- var old_back = mui.back;
- mui.back = function(){
- if(reqList.length == 1){
- old_back();
- }
- else{
- var preInfo = reqList.pop();
- var info = reqList[reqList.length - 1];
- level = info.level;
- areaCode = info.areaCode;
- areaTitle = info.areaTitle;
- lowLevel = info.lowLevel;
- index = info.index;
-
- if(!$(".l-banner li[data-index="+index+"]").hasClass("active")){
- $(".l-banner li").removeClass("active");
- $(".l-banner li[data-index="+index+"]").addClass("active");
- }
- $("#areaTitle").html(areaTitle);
- showBottomTab();
- initReqParams();
- loadData([0,1,2]);
- }
- }
|