// pages/new-map/map.js import * as echarts from '../../ec-canvas/echarts'; const app = getApp(); //加载最近一周运行时长 function initChart_1(chart_1, datas_1, datas_2) { var option_1={ grid: { top: "20%", bottom: "18%", left:"0%", right:"0%" }, tooltip: { trigger: "axis", axisPointer: { type: "shadow", label: { show: true } } }, xAxis: { data: datas_2, axisLine: { show: false //隐藏X轴轴线 }, axisTick: { show: false //隐藏X轴刻度 }, axisLabel: { show: true, textStyle: { color: "#ebf8ac", //X轴文字颜色 fontSize:'10' } } }, yAxis: [{ type: "value", nameTextStyle: { color: "#ebf8ac" }, splitLine: { show: false }, axisTick: { show: false }, axisLine: { show: false }, }, { type: "value", nameTextStyle: { color: "#ebf8ac" }, splitLine: { show: false }, axisTick: { show: false }, axisLine: { show: false }, axisLabel: { show: true, } }, ], series: [{ type: "line", yAxisIndex: 1, //使用的 y 轴的 index,在单个图表实例中存在多个 y轴的时候有用 smooth: true, //平滑曲线显示 showAllSymbol: true, //显示所有图形。 symbol: "circle", //标记的图形为实心圆 symbolSize:7, //标记的大小 itemStyle: { //折线拐点标志的样式 color: "#fd9820" }, lineStyle: { color: "#fd9820" }, areaStyle:{ color: "rgba(5,140,255, 0.2)" }, label: { show: true, position: 'top', textStyle: { color: '#ffffff', fontSize:'10' } }, data: datas_1 }, { type: "bar", barWidth: 12, itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: "#51d7ff" }, { offset: 1, color: "#3637a3" } ]) } }, data:datas_1 } ] }; chart_1.setOption(option_1); return chart_1; } //一周油耗 function initChart_2(chart_2, datas_1, datas_2) { var option_2={ grid: { top: "20%", bottom: "18%", left:"0%", right:"0%" }, tooltip: { trigger: "axis", axisPointer: { type: "shadow", label: { show: true } } }, xAxis: { data:datas_2, axisLine: { show: false //隐藏X轴轴线 }, axisTick: { show: false //隐藏X轴刻度 }, axisLabel: { show: true, textStyle: { color: "#ebf8ac", //X轴文字颜色 fontSize:'10' } } }, yAxis: [{ type: "value", nameTextStyle: { color: "#ebf8ac" }, splitLine: { show: false }, axisTick: { show: false }, axisLine: { show: false }, }, { type: "value", nameTextStyle: { color: "#ebf8ac" }, splitLine: { show: false }, axisTick: { show: false }, axisLine: { show: false }, axisLabel: { show: true, } }, ], series: [{ type: "line", yAxisIndex: 1, //使用的 y 轴的 index,在单个图表实例中存在多个 y轴的时候有用 smooth: true, //平滑曲线显示 showAllSymbol: true, //显示所有图形。 symbol: "circle", //标记的图形为实心圆 symbolSize:7, //标记的大小 itemStyle: { //折线拐点标志的样式 color: "#fd9820" }, lineStyle: { color: "#fd9820" }, areaStyle:{ color: "rgba(5,140,255, 0.2)" }, label: { show: true, position: 'top', textStyle: { color: '#ffffff', fontSize:'10' } }, data: datas_1 }, { type: "bar", barWidth: 12, itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: "#51d7ff" }, { offset: 1, color: "#3637a3" } ]) } }, data:datas_1 } ] }; chart_2.setOption(option_2); return chart_2; } Page({ /** * 页面的初始数据 */ data: { ec_1: { lazyLoad: true //动态加载 }, ec_2: { lazyLoad: true //动态加载 }, option1: [], value1: '', currentId: '', //传值与list id 相同 showPopup: false, show:false, bottom: "500rpx", showUp: false, list:[ { id:1, machine_key:"", name:"挖掘机12312", model:"z51110", state:"运行", class:"machinery_state_yx", battery:"50", workingHours:"8小时55分钟", oilCapacity:"358L", proportion:"80%", projectName: "西安地铁8号西安大白杨站智慧工地111", }], lists:[], height:"", longitude:'', latitude:'', markers: [], index:'', machineryTotalList:[], projectId:'', projectName:'', machineKey:"", //机械初始经纬度信息 machineLongitude:'', machineLatitude:'', machineMarkers:[], //刷新字段 initialMachineKey:"", timeLevenStatus:0, }, //页面加载 onClickShow() { this.setData({ show: true }); }, onClickHide() { this.setData({ show: false }); }, upward() { this.setData({ showUp: true }); this.setData({ bottom: "500rpx" }); this.selectMachineryRun(this.data.projectId,this.data.initialMachineKey,this.data.machineryTotalList); }, downward() { this.setData({ showUp: false }); this.setData({ bottom: "50rpx" }); }, showPopup() { this.setData({ showPopup: true }); }, onClose() { this.setData({ showPopup: false }); this.setData({ showType: false }); }, selectList(event){ this.onClickShow(); //加载数据 this.selectMachineryRun(this.data.projectId,event.currentTarget.dataset.machinekey,this.data.machineryTotalList); let timeLevenStatus = this.data.timeLevenStatus; if(timeLevenStatus == 0){ this.selectMachineryWeekTime(event.currentTarget.dataset.machinekey); }else{ this.selectMachineryWeekTankLeven(event.currentTarget.dataset.machinekey); } this.setData({ showPopup: false, index:event.currentTarget.dataset.index, showUp: true , currentId:event.currentTarget.dataset.machinekey }); }, optionChange(event){ this.onClickShow(); var category = ""; var option1 = this.data.option1; for(var i = 0;i { const chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr //解决小程序视图模糊的问题,必写 }); initChart_1(chart,datas_1,datas_2); this.chart = chart; return chart; }); }, //加载油耗数据 init_two: function (datas_1,datas_2) { this.twoComponent.init((canvas, width, height,dpr) => { const chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr //解决小程序视图模糊的问题,必写 }); initChart_2(chart,datas_1,datas_2); this.chart = chart; return chart; }); }, //查询出单个机械设备的基础数据 selectMachineryRun:function(event,event1,event2){ var that = this; wx.request({ url: app.globalData.reqUrl+'/weixin/machicnery/selectMachineryRun', data:{ "projectId":event, "machineKey":event1 }, method:"GET", success:function(res){ if(res.data.partMachineryList.length >0){ var markers = []; for(var i=0;i0){ var markers = []; for(var i=0;i