123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971 |
- var self, userRole,
- scroller,
- initLevel,
- initCode,
- initTitle,
- level,
- code,
- areaTitle,
- tagCode = 1, //顶部各个tag标签对应的值
- sumType = 1, //记录从筛选页面选择的统计维度 1-订单统计,2-费用统计,3-配送统计,4-年龄统计
- disease = "", //疾病类型
- lowlevel,
- dateType = 1, //折线图坐标值1-日,2-周,3-月
- startDate = "",
- endDate = "";
- var reqParam = []; //请求参数
- var reqList = []; //请求的链接数据,根据这些信息后退的时候使用
- mui.init();
- mui.plusReady(function(){
- var self = plus.webview.currentWebview();
-
- userRole = JSON.parse(plus.storage.getItem("selectedRole"));
- initLevel = level = userRole.code == '350200' ? 4 : userRole.code.length==6 ? 3 : 2;
- lowlevel = level - 1;
- initCode = code = userRole.code;
- initTitle = areaTitle = userRole.name;
- $("#areaTitle").text(areaTitle);
- $("#header-subtitle").text("订单统计");
-
- showLabs();
-
- initReqParams(); //现获得页面请求的接口参数
- //记录返回链接信息
- reqList.push({
- level: level,
- lowlevel: lowlevel,
- code: code,
- areaTitle: areaTitle,
- sumType: sumType,
- tagCode: tagCode,
- req: reqParam
- });
- loadData([0,1,2]);
- initScroller();
- shaixuanInit(self);
- bindEvents();
- });
- function initReqParams(){
- //sumType: 1-订单统计,2-费用统计,3-配送统计,4-年龄统计
- switch(sumType){
- case 1:
- //tagCode: 1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消
- reqParam = [{
- url: "/statistics/getPrescriptionCount",
- reqType: 'get',
- data: {level: level, area: code, disease: disease}
- },{
- url: "/statistics/getPrescriptionTotalHistogram",
- reqType: 'get',
- data: {level: level, area: code, disease: disease, type: tagCode, interval: dateType}
- },{
- url: "/statistics/getPrescriptionTotalLowLevel",
- reqType: 'get',
- data: {level: level, lowlevel: lowlevel, area: code, disease: disease, type: tagCode}
- }];
- break;
- case 2:
- //dateType: 折线图坐标值1-日,2-周,3-月
- //tagCode: 1.总量,2.平均值
- getStartDate(3, dateType);
- getEndDate();
- reqParam = [{
- url: "/statistics/getPrescriptionCost",
- reqType: 'get',
- data: {level: level, area: code, disease: disease}
- },{
- url: "/statistics/getPrescriptionCostAvgLine",
- reqType: 'get',
- data: {level: level, area: code, disease: disease, type: dateType, startDate: startDate, endDate: endDate}
- },{
- url: "/statistics/getPrescriptionCostLowLevel",
- reqType: 'get',
- data: {level: level, lowlevel: lowlevel, area: code, disease: disease, type: tagCode}
- }];
- break;
- case 3:
- //tagCode: 1.自取,2.快递配送,3.健管师配送
- reqParam = [{
- url: "/statistics/getPrescriptionDispatchingTotal",
- reqType: 'get',
- data: {level: level, area: code, disease: disease}
- },{
- url: "/statistics/getPrescriptionDispatchingHistogram",
- reqType: 'get',
- data: {level: level, area: code, disease: disease, type: tagCode, interval: dateType}
- },{
- url: "/statistics/getPrescriptionDispatchingLowLevel",
- reqType: 'get',
- data: {level: level, lowlevel: lowlevel, area: code, disease: disease, type: tagCode}
- }];
- break;
- case 4:
- reqParam = [{
- url: "/statistics/getPrescriptionAgeTotal",
- reqType: 'get',
- data: {level: level, area: code, disease: disease}
- },{
- url: "/statistics/getPrescriptionAgeHistogram",
- reqType: 'get',
- data: {level: level, area: code, disease: disease}
- },{
- url: "/statistics/getPrescriptionAgeLowLevel",
- reqType: 'get',
- data: {level: level, lowlevel: lowlevel, area: code, disease: disease}
- }];
- break;
- default:
- reqParam = [];
- break;
- };
- }
- /*
- * 加载页面数据
- * @param loadArr array 记录需要请求的区域0-顶部,1-中间,2-底部
- */
- function loadData(loadArr){
- plus.nativeUI.showWaiting();
- getJieZhiTime();
-
- var reqPromise = [];
- for(var i=0; i<loadArr.length; i++){
- var j = loadArr[i];
- reqPromise.push(reqParam[j]);
- }
- console.log();
- getReqPromises(reqPromise, true).then(function(ress){
- var res1, res2, res3;
-
- for(var i=0; i<loadArr.length; i++){
- var j = loadArr[i] + 1;
- if(j == 1){
- res1 = ress[i];
- }
- if(j == 2){
- res2 = ress[i];
- }
- if(j == 3){
- res3 = ress[i];
- }
- }
-
- if(res1 && res1.status == 200){
- showTags(res1.data);
- }
- if(res2 && res2.status == 200){
- handleSecondPanelData(res2.data);
- }
- if(res3){
- if(res3.status == 200){
- listHandle(res3.data);
- }else{
- $("#listUl").empty();
- mui.toast(res3.msg);
- }
- }
- 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+")");
- }
- });
- }
- /*
- * 处理年龄分布饼图
- */
- function handleAgeData(data){
- var color = ['#ff5442', '#ffc800 ','#4ce428', '#24bbfa','#fb5dab', "#9b5ffd"],
- name = ['0~6岁', '7~18岁', '19~30岁', '31~50岁', '51~64岁', '65岁以上'],
- objName = ['0age', '7age', '19age', '31age', '51age', '65age'];
- var arr = [];
- for(i=0; i<6; i++){
- var obj = {
- name: name[i],
- value: data[objName[i]],
- color: color[i]
- }
- arr.push(obj);
- }
- var html = template("age_tmp", {list: arr});
- $("#fenbuList").empty().append(html);
- drawPie(arr, color);
- }
- /*
- * 处理第二块区域的数据内容
- */
- function handleSecondPanelData(data){
- switch(sumType){
- case 1:
- case 3:
- //绘制柱状图
- $("#barTitle").text("近半年统计");
- var el = document.getElementById("barChart"),
- color = "#17b3ec",
- xAxisData = [],
- seriesData = [];
- for(i=0; i<data.length; i++){
- var item = data[i];
- xAxisData.push(item.date);
- seriesData.push(item.count);
- }
- var names;
- if(sumType == 1){
- names = ["续方总量", "已完成", "居民取消", "审核未通过", "进行中", "其他原因取消"];
- }else if(sumType == 3){
- names = ["居民自取", "物流配送", "健管师配送"];
- }
- var dataZoom = 1;
- drawBars(el, xAxisData, seriesData, color, names[tagCode -1], dataZoom);
- break;
- case 2:
- //绘制人均费用折线图
- drawChart(data);
- break;
- case 4:
- //绘制柱状图
- $("#barTitle").text("人均使用次数");
- var el = document.getElementById("barChart"),
- color = "#17b3ec",
- xAxisData = ['0~6', '7~18', '19~30', '31~50', '51~64', '65以上'],
- fieldName = ['0ageRate', '7ageRate', '19ageRate', '31ageRate', '51ageRate', '65ageRate']
- seriesData = [];
- for(i=0; i<6; i++){
- seriesData.push(data[fieldName[i]]);
- }
- drawBars(el, xAxisData, seriesData, color, '人均使用次数');
- break;
- }
- }
- /*
- * 根据统计类型显示对应的顶部tag内容
- */
- function showTags(data){
- switch(parseInt(sumType)){
- case 1:
- $(".tag-panel").empty().append(template("dd_tmp", {data: data, selected: tagCode}));
- $(".tag-panel").show();
- $("#dateDiv").show();
- $("#barInfoDiv").show();
- $("#barChartsPanel").show();
- $("#pieChartsPanel").hide();
- $("#lineChartsPanel").hide();
- break;
- case 2:
- $(".tag-panel").empty().append(template("fy_tmp", {data: data, selected: tagCode}));
- $(".tag-panel").show();
- $("#lineChartsPanel").show();
- $("#barChartsPanel").hide();
- $("#pieChartsPanel").hide();
- break;
- case 3:
- $(".tag-panel").empty().append(template("ps_tmp", {data: data, selected: tagCode}));
- $(".tag-panel").show();
- $("#dateDiv").show();
- $("#barInfoDiv").show();
- $("#barChartsPanel").show();
- $("#pieChartsPanel").hide();
- $("#lineChartsPanel").hide();
- break;
- case 4:
- $(".tag-panel").hide();
- $("#dateDiv").hide();
- $("#barInfoDiv").hide();
- $("#barChartsPanel").show();
- $("#pieChartsPanel").show();
- $("#lineChartsPanel").hide();
- handleAgeData(data);
- break;
- }
- // mui('.mui-scroll-wrapper').pullRefresh().refresh();
- }
- /*
- * 显示底部的tab
- */
- function showLabs(){
- $(".area-tab").removeClass("active");
- switch(level){
- case 4:
- $(".area-tab").show();
- $(".area-tab").eq(0).addClass("active");
- areaType = "4";
- break;
- case 3:
- $(".area-tab").eq(0).hide();
- $(".area-tab").eq(1).show();
- $(".area-tab").eq(1).addClass("active");
- areaType = "3";
- break;
- case 2:
- $(".area-tab").eq(0).hide();
- $(".area-tab").eq(1).hide();
- $(".area-tab").eq(2).addClass("active");
- areaType = "2";
- 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 shaixuanInit(main){
- var shaixuan = plus.webview.getWebviewById('prescription-shaixuan.html');
- if(!shaixuan){
- shaixuan = mui.createWindow({
- id: 'prescription-shaixuan.html',
- url: 'prescription-shaixuan.html',
- styles: {
- top: 0,
- bottom: 0,
- left: '20%',
- width: '80%',
- scorllIndicator: "none"
- },
- show:{
- aniShow: "slide-in-right",
- duration: "400"
- },
- extras:{
- }
- });
- }
- window.addEventListener("hideShaiXuan",function(){
- console.log("hideShaiXuan");
- 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(){
- //顶部tag切换
- $(".tag-panel").on('tap', '.tag', function(){
- var $this = $(this);
-
- tagCode = $this.data("code");
-
- if($this.hasClass("active")){
- return false;
- }
- $(".tag-panel .tag").removeClass("active");
- $this.addClass("active");
-
- initReqParams();
- if(sumType == 2){
- loadData([2]);
- }else{
- loadData([1,2]);
- }
-
- })
-
- //底部区,社区,团队切换
- $(".area-tab-panel").on('tap', '.area-tab', function(){
- var $this = $(this),
- type = $this.attr("data-val"); //4 - 各区, 3 - 社区, 2 - 团队
-
- areaType = type;
-
- if($this.hasClass("active")){
- return false;
- }
- $(".area-tab").removeClass("active");
- $this.addClass("active");
-
- if(type == "4"){
- lowlevel = 3;
- }else if(type == "3"){
- lowlevel = 2;
- }else{
- lowlevel = 1;
- }
-
- initReqParams();
- loadData([2]);
- });
-
- //列表点击跳转下一级内容
- $("#listUl").on('tap', ".data-row", function(){
- var $this = $(this);
- if($this.data("next") == "0"){
- return false;
- }
-
- code = $this.data("code");
- areaTitle = $this.data("name");
- if(level == 4 && lowlevel == 2){
- level --;
- }
- level --;
- lowlevel = level - 1;
- $("#areaTitle").text(areaTitle);
- showLabs();
- initReqParams();
- //记录返回链接信息
- reqList.push({
- level: level,
- lowlevel: lowlevel,
- code: code,
- areaTitle: areaTitle,
- sumType: sumType,
- tagCode: tagCode,
- req: reqParam
- });
- loadData([0,1,2]);
- });
-
- //日,月,年选择
- $(".l-zxt-con .div-btn").on('tap', function(){
- var $this = $(this);
- if($this.hasClass("active")){
- return false;
- }
-
- $(".l-zxt-con .div-btn").removeClass("active");
- $this.addClass("active");
-
- dateType = $this.data("id");
- initReqParams();
- loadData([1]);
- });
-
- //日、周、月按钮切换
- $(".date-tag").on("tap",function(){
- dateType = $(this).attr("data-type");
- $(".date-tag").removeClass("active");
- $(this).addClass("active");
-
- initReqParams();
- loadData([1]); //只加载中间区域的数据
- });
-
- template.helper("setRate", function(all, amount){
- if(all == 0)
- return 0;
- var val = amount;
- if(sumType == 2){
- val = (amount+"").replace(",", "");
- }
- return (parseFloat(val) / all * 100).toFixed(2);
- });
-
- template.helper("formatAmount", function(str){
- return formatAmount(str+"");
- })
-
- //左滑筛选区域的数据
- $('.header-link').on("tap", function(){
- var self = plus.webview.currentWebview();
- mui.fire(self, "showShaiXuan");
- });
-
- //添加页面监听
- window.addEventListener("refresh", function(e){
- console.log(e);
- var sumType1 = e.detail.sumType,
- sumName = e.detail.sumName,
- lowCode = e.detail.lowCode,
- name = e.detail.name;
-
- sumType = sumType1;
- disease = lowCode;
- level = initLevel;
- code = initCode;
- areaTitle = initTitle;
- lowlevel = level - 1;
- tagCode = 1;
- dateType = 1;
-
- //日,周,月的标签默认选中日
- $(".l-zxt-con .div-btn").removeClass("active");
- $(".l-zxt-con .div-btn").eq(0).addClass("active");
-
- $("#dateDiv .date-tag").removeClass("active");
- $("#dateDiv .date-tag").eq(0).addClass("active");
-
- //清空请求数组
- reqList.splice(0, reqList.length);
-
- showLabs();
- initReqParams();
- //记录返回链接信息
- reqList.push({
- level: level,
- lowlevel: lowlevel,
- code: code,
- areaTitle: areaTitle,
- sumType: sumType,
- tagCode: tagCode,
- req: reqParam
- });
- loadData([0,1,2]);
-
- $("#areaTitle").text(areaTitle);
- $("#header-subtitle").text(sumName);
- if(name == "全部"){
- name = "所有病种";
- }
- $(".choose-label").text(name);
-
- })
- }
- //底部列表显示
- function listHandle(list){
- var topArr = soreRank(list);
- for(var j in list){
- list[j].top = topArr[j];
- }
- console.log(list);
- var data = {};
- data.all = assAmount(list);
- if(sumType == 4){
- data.amountName = '总人数';
- }else{
- data.amountName = $(".tag[data-code="+tagCode+"] div").eq(1).text();
- }
-
- data.list = _.map(list, function(o){
- if(sumType == 2 && tagCode == 1){
- o.val = formatAmount(o.val + "");
- }
- return o;
- });
- data.lowlevel = lowlevel;
- data.level = level;
- console.log(data);
- var html = template('list-tmp', data);
- $("#listUl").empty().append(html);
- // mui(".mui-scroll-wrapper").pullRefresh().refresh(true);
- }
- //绘制柱状图
- function drawBars(el, xAxisData, seriesData, color, name, dataZoom, grid){
- var myChart = echarts.init(el);
- // 指定图表的配置项和数据
- var option = {
- tooltip: {
- trigger: 'item'
- },
- toolbox: {
- dataZoom: true,
- show: true,
- orient: 'vertical',
- x: 'right',
- y: 'center'
- },
- grid: grid ? grid : {
- x: 35,
- y: 20,
- x2: 20,
- y2: 30
- },
- xAxis: [{
- type: 'category',
- data: xAxisData,
- axisLabel: {
- interval:0,//横轴信息全部显示
- formatter: function (value, index) {
- if(sumType == 1 || sumType ==3){
- if(dateType == 1 || dateType == 2){
- if(index == 0){
- $("#startValue").text(value);
- return value.substr(5,2)+"月"+value.substr(8,2);
- }else{
- if(index == 7){
- $("#endValue").text(value);
- }
- return value.substr(8,2);
- }
- }else if(dateType == 3){
- var val = value.substr(5,2)+"月"
- if(index == 0){
- $("#startValue").text(value.substr(0,4)+"年"+val);
- }else{
- if(index == 7){
- $("#endValue").text(value.substr(0,4)+"年"+val);
- }
- }
- return val;
- }
- }
- return value;
- }
- },
- splitLine: {
- show: false
- }
- }],
- yAxis: [{
- type: 'value'
- }],
- series: [{
- clickable: true,
- name: name || "",
- itemStyle : {
- normal: {
- label : {
- show: true, position: 'top'
- },
- color: color || '#fbba31'
- }
- },
- barWidth: 20,
- type: 'bar',
- data: seriesData
- }]
- };
- if(dataZoom == 1){
- var len = seriesData.length,
- lastIndex = len % 7;
- if(len > 7 ){
- var dataZoom_end = 100-(6/len)*100;
- }else{
- var dataZoom_end = 0;
- }
- //初始给定第一版页面中时间区间
- if(dateType == 3){
- var d1 = xAxisData[len - lastIndex],
- d2 = xAxisData[len -1];
- $("#startValue").text(d1.substr(0,4)+"年"+d1.substr(5,2)+"月");
- $("#endValue").text(d2.substr(0,4)+"年"+d2.substr(5,2)+"月");
- }else{
- $("#startValue").text(xAxisData[len - lastIndex]);
- $("#endValue").text(xAxisData[len -1]);
- }
- option.dataZoom = [{//给x轴设置滚动条
- show: false,
- start: dataZoom_end,
- end: 100,
- type: 'slider',
- zoomLock: true,
- },{ //下面这个属性是内容区域配置
- start: dataZoom_end,
- end: 100,
- type: 'inside',
- zoomLock: true,
- }];
- }
- // 使用刚指定的配置项和数据显示图表。
- myChart.setOption(option);
- if(sumType == 1 || sumType == 3){
- myChart.on('click',function(a,b){
- var arg = {
- date: a.name,
- dateType: dateType,
- disease: disease,
- area: code,
- areaTitle: areaTitle
- }
- if(sumType == 1){
- arg.status = tagCode;
- }
- if(sumType == 3){
- arg.status = 2; // 配送统计的默认是已完成的订单
- arg.expressType = tagCode;
- }
- openWebview("../../prescription/html/prescription-records.html", arg);
- });
- }
- }
- //绘制折线图
- function drawChart(data){
- var recordCount = 10;//一页显示几条数据
- var allData = data.reverse();
-
- var allRecordData = _.map(allData, function(o){
- return o.avg;
- })
- var dateArr = _.map(allData, function(o){
- return o.date.substring(5);
- });
-
- 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: new Date(startDate),
- 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手机)
- event: 'tap'
- });
- 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 drawPie(arry, color){
- var myChart = echarts.init(document.getElementById('fenbuMain'));
- var option = {
- tooltip: {
- trigger: 'item',
- formatter: "{a} <br/>{b} : {c} ({d}%)",
- position: ['50%', '50%']
- },
- color: color,
- series: [
- {
- name:'年龄',
- type:'pie',
- radius : '65%',
- center:['50%','50%'],
- label: {
- normal: {
- show: false,
- textStyle: {
- color: "#000"
- }
- }
- },
- labelLine: {
- normal: {
- show: false
- }
- },
- data:arry
- }]
- };
- myChart.setOption(option);
- }
- //排序
- function soreRank(arr) {
- var temp = [];
- var lis = [];
- for(var i=0;i<arr.length;i++)
- lis.push(arr[i].val)
- lis = _.uniq(lis);
- for(var i=0;i<arr.length;i++)
- temp[i] = lis.indexOf(arr[i].val)+1;
-
- return temp;
- }
- //格式化数量
- function assAmount(list){
- var all = 0;
- for(var k in list){
- var b = list[k].val;
- if(sumType == 2){
- b = (list[k].val + "").replace(",", "");
- }
- all += parseFloat(b);
- }
- return all;
- }
- //获取近阶段时间的开始时间和结束时间
- var now = new Date();
- /*
- * months : 月份差距(例如months=3,则获取今天往前数3个月的那天的值)
- */
- function getStartDate(months,type){
- //type: 折线图坐标值1-日,2-周,3-月
- //从1号开始算每个月开始的时间
- var sDate = new Date();
- sDate.setMonth(now.getMonth() - months + 1);// 包含本月算一个月
-
- var sDateStr = sDate.format("yyyy-MM-dd");
- if(type == '3'){
- startDate = sDateStr.substr(0,8)+"01";
- }else{
- startDate = sDateStr;
- }
- }
- function getEndDate(){
- endDate = now.format("yyyy-MM-dd");
- }
- //获取数据最大值
- function maxData(data){
- var maxData = Math.max.apply(Math,data);
- var yAxis = maxData<10?10:maxData;
- return yAxis;
- }
- //给金额数值加上逗号
- function formatAmount(str) {
- var newStr = "";
- var count = 0;
- if(str.indexOf(".") == -1) {
- for(var i = str.length - 1; i >= 0; i--) {
- if(count % 3 == 0 && count != 0) {
- newStr = str.charAt(i) + "," + newStr;
- } else {
- newStr = str.charAt(i) + newStr;
- }
- count++;
- }
- str = newStr + ".00"; //自动补小数点后两位
- } else {
- for(var i = str.indexOf(".") - 1; i >= 0; i--) {
- if(count % 3 == 0 && count != 0) {
- newStr = str.charAt(i) + "," + newStr;
- } else {
- newStr = str.charAt(i) + newStr; //逐个字符相接起来
- }
- count++;
- }
- str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
- }
- return str;
- }
- //返回事件
- 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;
- code = info.code;
- areaTitle = info.areaTitle;
- lowlevel = info.lowlevel;
- sumType = info.sumType;
- tagCode = info.tagCode;
-
- $("#areaTitle").html(areaTitle);
- showLabs();
- initReqParams();
- loadData([0,1,2]);
- }
- }
|