diff --git a/pages/target_water_fertilizer_PH/target_water_fertilizer_PH.vue b/pages/target_water_fertilizer_PH/target_water_fertilizer_PH.vue index 42980ba0..59461e7d 100644 --- a/pages/target_water_fertilizer_PH/target_water_fertilizer_PH.vue +++ b/pages/target_water_fertilizer_PH/target_water_fertilizer_PH.vue @@ -10,7 +10,7 @@ - {{ echartName == '风向' ? getWindDirection(valuePH) : (valuePH + unit) }} + {{ echartName == '风向' ? getWindDirection(valuePH) : valuePH!='暂无数据'?(valuePH + unit):valuePH}} @@ -103,22 +103,30 @@ }, onLoad(option) { - // console.log(option); - if (option.id) { + console.log(option); + if (option.id&&option.id!='undefined') { this.equipmentId = option.id } - if (option.data) { + if (option.data&&option.data!='undefined') { this.valuePH = option.data + }else{ + this.valuePH='暂无数据' } - if (option.name) { + if (option.name&&option.name!='undefined') { this.echartName = option.name + }else{ + this.echartName='暂无数据' } - if (option.unit) { + if (option.unit&&option.unit!='undefined') { this.unit = option.unit this.opts.yAxis.data[0].title = option.unit + }else{ + this.unit='' } - if(option.equipmentName){ + if(option.equipmentName&&option.equipmentName!='undefined'){ this.equipmentName = option.equipmentName + }else{ + this.equipmentName='' } if(option.flag){ this.flag = option.flag @@ -146,9 +154,25 @@ this.chartData = JSON.parse(JSON.stringify(res)); }, 500); }, +getServerData1() { + //模拟从服务器获取数据时的延时 + //模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接 + let res = { + categories: [], + series: [{ + name: '暂无数据', + data: [] + }, ] + }; + this.chartData = JSON.parse(JSON.stringify(res)); + }, // 获取折线图数据 getEchartsData() { + if(!this.equipmentId||this.equipmentId=='undefined'){ + this.getServerData1(); + return + } if(this.flag == 1){ this.$http({ @@ -235,6 +259,9 @@ // 风向判定 getWindDirection(number){ + if(number=='暂无数据'){ + return '暂无数据' + } let num = Number(number) if(num <= 67 && num >= 22 ){ return '东北'