(function () { var page = { init: function ($page) { var gpsNumber = renlian.storage.get('userinfo').baseinfo.gpsNumber; renlian.httpget(config.webapi+"?s=api/get_driving_data", {gpsNumber:gpsNumber}, function (res) { var sData = []; var drivingdata = null; if(res.success){ var respData = res.data; var days5Dist = 0; var day5Time = 0; console.log(respData); respData.forEach(v => { sData.push(v.totalDist.toFixed(2)); days5Dist += v.totalDist; day5Time += v.totalTime; }); var averageSpeed = (days5Dist / day5Time).toFixed(2); if(day5Time == 0){ averageSpeed = 0.00; } drivingdata = [{name:'里程总计', value: days5Dist.toFixed(2) + 'km'}, {name:'累计时长', value: day5Time.toFixed(2) + '小时'}, {name:'平均速度', value: averageSpeed + 'km/h'}] //直方 chartMap = {}; chartMap['drive-data-bar'] = echarts.init(document.getElementById('drive-data-bar')); var xData = []; for(let i = 0;i < 5; ++i){ var time = new Date(new Date() - 24*60*60*1000*i); var date = time.Format("MM-dd"); xData.unshift(date); } var option1 = { title:{ text: '近期行驶里程', x:'center', }, color: ['#3398DB'], tooltip : { trigger: 'axis', axisPointer : { // 坐标轴指示器,坐标轴触发有效 type : 'shadow' // 默认为直线,可选为:'line' | 'shadow' } }, grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, xAxis : [ { type : 'category', data : xData, axisTick: { alignWithLabel: true }, } ], yAxis : [ { name: '里程/公里', type : 'value' } ], series : [ { name:'行驶里程', type:'bar', barWidth: '50%', data:sData } ] }; chartMap['drive-data-bar'].setOption(option1); //列表数据 //renlian.httpget(config.webapi + "renlian/adms/desktop/data", { type: 'Target', id: _item.F_Id }, function(data){}); // var drivingdata = '[{"name":"里程总计","value":"236.00km"},{"name":"累计时长","value":"1天00时00分"},{"name":"平均速度", "value":"9.83km/h"}]'; // data = JSON.parse(drivingdata); var _itemHtml = '' $.each(drivingdata, function (_index, _item) { if(_index == 2){ _itemHtml += '\