流量统计处理数据格式问题

This commit is contained in:
zhanghongqing
2018-10-18 19:12:50 +08:00
parent 075bdfcf5e
commit e40773def2
2 changed files with 43 additions and 11 deletions

View File

@@ -401,15 +401,43 @@ function ajaxinfo(){
dataType:'json', dataType:'json',
cache:false,async:true, cache:false,async:true,
success:function (data){ success:function (data){
dataScroll(".numberRun",Math.floor(data.loopConnNum)); var loopConnNum =loopConnNum= data.loopConnNum;
dataScroll(".numberRun1",Math.floor(data.rejectNum)); var rejectNum =data.rejectNum;
dataScroll(".numberRun2",Math.floor(data.monitorNum)); var monitorNum =data.monitorNum;
dataScroll(".numberRun3",Math.floor(data.dropConnNum)); var dropConnNum =data.dropConnNum;
dataScroll(".numberRun5",Math.floor(data.newUniConnNum)); var newUniConnNum=data.newUniConnNum;
dataScroll(".numberRun6",Math.floor(data.liveConnNum)); var liveConnNum=data.liveConnNum;
if(loopConnNum==null||loopConnNum==""){
loopConnNum=0;
}
if(rejectNum==null||rejectNum==""){
rejectNum=0;
}
if(monitorNum==null||monitorNum==""){
monitorNum=0;
}
if(dropConnNum==null||dropConnNum==""){
dropConnNum=0;
}
if(newUniConnNum==null||newUniConnNum==""){
newUniConnNum=0;
}
if(liveConnNum==null||liveConnNum==""){
liveConnNum=0;
}
dataScroll(".numberRun",Math.floor(loopConnNum));
dataScroll(".numberRun1",Math.floor(rejectNum));
dataScroll(".numberRun2",Math.floor(monitorNum));
dataScroll(".numberRun3",Math.floor(dropConnNum));
dataScroll(".numberRun5",Math.floor(newUniConnNum));
dataScroll(".numberRun6",Math.floor(liveConnNum));
var bandwidth=data.bandwidth; var bandwidth=data.bandwidth;
var bandwidthK=bandwidth/1024; var bandwidthK=bandwidth/1024;
var bandwidthM=bandwidthK/1024; var bandwidthM=bandwidthK/1024;
if(bandwidth==null||bandwidth==""){
bandwidth=0;
}
if(bandwidthK>10){ if(bandwidthK>10){
bandwidth=bandwidthK; bandwidth=bandwidthK;
$(".numberRun4-unit").text(" Kbps"); $(".numberRun4-unit").text(" Kbps");
@@ -464,8 +492,11 @@ function ajaxinfo(){
} }
//动态显示数据 //动态显示数据
function dataScroll(index,nums){ function dataScroll(index,nums){
if(typeof nums=='undefined'||nums==null||nums==""){
nums=0;
}
var num=nums; var num=nums;
var numRun = $(index).numberAnimate({num:num, speed:3000, symbol:","}); var numRun = $(index).numberAnimate({num:1, speed:3000, symbol:","});
numRun.resetData(nums); numRun.resetData(nums);
} }

View File

@@ -5,7 +5,7 @@
$.fn.numberAnimate = function(setting) { $.fn.numberAnimate = function(setting) {
var defaults = { var defaults = {
speed : 3000,//动画速度 speed : 3000,//动画速度
num : "", //初始化值 num : 0, //初始化值
iniAnimate : true, //是否要初始化动画效果 iniAnimate : true, //是否要初始化动画效果
symbol : '',//默认的分割符号,千,万,千万 symbol : '',//默认的分割符号,千,万,千万
dot : 0 //保留几位小数点 dot : 0 //保留几位小数点
@@ -15,13 +15,14 @@
//如果对象有多个,提示出错 //如果对象有多个,提示出错
if($(this).length > 1){ if($(this).length > 1){
alert("just only one obj!"); console.error("just only one obj!");
return; return;
} }
//如果未设置初始化值。提示出错 //如果未设置初始化值。提示出错
if(setting.num == ""){ if(setting.num == ''){
alert("must set a num!"); setting.num=0;
console.error("must set a num!");
return; return;
} }
var nHtml = '<div class="mt-number-animate-dom" data-num="{{num}}">\ var nHtml = '<div class="mt-number-animate-dom" data-num="{{num}}">\