wszhyWx/pages/target_water_fertilizer_PH/target_water_fertilizer_PH.vue

274 lines
5.9 KiB
Vue
Raw Normal View History

2023-09-28 10:07:02 +00:00
<template>
<view class="target_water_fertilizer_PH">
<!-- 目标水肥PH -->
<u-navbar :background="background" :is-back='true' back-icon-color='#FFFFFF' :border-bottom="false"
2023-10-13 00:55:47 +00:00
:title="titleName+echartName" title-color='#FFFFFF' :title-bold='true' title-size='32'></u-navbar>
2023-09-28 10:07:02 +00:00
<view class="navbar">
2023-10-05 04:08:22 +00:00
<image src="../../static/PH_bg.png" mode=""></image>
2023-09-28 10:07:02 +00:00
</view>
<view class="content">
<view class="number">
2023-10-13 06:58:18 +00:00
{{ valuePH + unit }}
2023-09-28 10:07:02 +00:00
</view>
<view class="data_analysis">
2023-10-05 04:08:22 +00:00
<image src="../../static/data_analysis.png" mode=""></image>
2023-09-28 10:07:02 +00:00
<text>数据分析</text>
</view>
<view class="echart">
<view class="title">
2023-10-05 04:08:22 +00:00
<image src="../../static/icon_ph.png" mode=""></image>
2023-10-13 00:55:47 +00:00
<text>{{ titleName+echartName }}</text>
2023-09-28 10:07:02 +00:00
</view>
<view id="echart_p">
<qiun-data-charts type="line" :opts="opts" :chartData="chartData" :ontouch="true"
background="none" />
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 头部导航背景
background: {
backgroundColor: 'transparent',
},
equipmentId:'',
chartData: {},
opts: {
color: ["#24B383"],
padding: [15, 10, 0, 15],
dataLabel: false,
dataPointShape: false,
enableScroll: true,
legend: {},
xAxis: {
disableGrid: true,
scrollShow: true,
scrollAlign: 'left',
scrollColor: '#24B383',
scrollBackgroundColor: '#DFE5E4',
itemCount: 3,
boundaryGap: "justify",
format: "",
},
yAxis: {
gridType: "dash",
dashLength: 2,
2023-10-13 06:58:18 +00:00
showTitle: true,
2023-09-28 10:07:02 +00:00
data: [{
2023-10-13 06:58:18 +00:00
title: '',
2023-09-28 10:07:02 +00:00
min: 0,
2023-10-13 06:58:18 +00:00
// max: 14
titleOffsetY: -5,
2023-09-28 10:07:02 +00:00
}]
},
extra: {
area: {
type: "curve",
opacity: 0.2,
addLine: true,
width: 2,
gradient: true,
activeType: "hollow"
}
}
},
categoriesList:[],
valuePH:'',
2023-10-13 00:55:47 +00:00
valuePHList:[],
newValuePHList:[],
2023-10-13 06:58:18 +00:00
unit:'',
2023-10-13 00:55:47 +00:00
titleName:'',
echartName:''
2023-09-28 10:07:02 +00:00
};
},
onReady() {
// this.getEchartsData()
// this.getServerData();
},
onLoad(option) {
2023-10-13 06:58:18 +00:00
console.log(option);
2023-09-28 10:07:02 +00:00
if(option.id){
this.equipmentId = option.id
}
if(option.data){
this.valuePH = option.data
}
2023-10-13 00:55:47 +00:00
if(option.name){
this.echartName = option.name
}
2023-10-13 06:58:18 +00:00
if(option.unit){
this.unit = option.unit
this.opts.yAxis.data[0].title = option.unit
}
2023-10-13 00:55:47 +00:00
this.titleName = this.getStatus(option.equipmentNumber,option.targetValue)
2023-09-28 10:07:02 +00:00
},
mounted() {
this.getEchartsData()
},
methods: {
getServerData() {
//模拟从服务器获取数据时的延时
setTimeout(() => {
//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
let res = {
categories: this.categoriesList,
series: [{
2023-10-13 00:55:47 +00:00
name: this.titleName+this.echartName,
data: this.newValuePHList
2023-09-28 10:07:02 +00:00
}, ]
};
this.chartData = JSON.parse(JSON.stringify(res));
}, 500);
},
// 获取折线图数据
getEchartsData(){
this.$http({
url:this.api.chart_fsdata + '?equipmentId=' + this.equipmentId,
method:'POST'
}).then(res=>{
2023-10-13 06:58:18 +00:00
console.log(res,'获取折线图数据');
2023-09-28 10:07:02 +00:00
res.data.forEach((i,index)=>{
this.categoriesList.push(i.time);
2023-10-13 00:55:47 +00:00
this.valuePHList.push(i.value)
2023-09-28 10:07:02 +00:00
})
this.getServerData();
2023-10-13 00:55:47 +00:00
// console.log(this.categoriesList,'this.categoriesList');
// console.log(this.valuePHList,'this.valuePHList');
this.newValuePHList = this.valuePHList.map((e,index)=>{
2023-10-13 06:58:18 +00:00
return e[this.titleName+this.echartName] == undefined ? '' : e[this.titleName+this.echartName]
2023-10-13 00:55:47 +00:00
})
2023-10-13 06:58:18 +00:00
console.log(this.newValuePHList,'121212212121211111111');
2023-09-28 10:07:02 +00:00
})
},
2023-10-13 00:55:47 +00:00
// 判断是否是平均或者目标,或者是1#
getStatus(equipmentNumber,targetValue){
if(targetValue == 1){
return '目标'
}else if(targetValue == 0 && equipmentNumber == 0){
return '1#平均'
}else if(targetValue == 0 && equipmentNumber == 15){
return '2#平均'
}else if(targetValue == 0 && equipmentNumber != 0 && equipmentNumber != 15){
return equipmentNumber + '#'
}
}
2023-09-28 10:07:02 +00:00
}
}
</script>
<style lang="scss" scoped>
.target_water_fertilizer_PH {
width: 100%;
min-height: 100vh;
box-sizing: border-box;
position: relative;
background-color: #F5F6FA;
.navbar {
width: 100%;
height: 100%;
>image {
width: 750rpx;
height: 440rpx;
position: absolute;
top: 0;
left: 0;
}
}
.content {
position: absolute;
z-index: 2;
box-sizing: border-box;
padding: 0 30rpx 30rpx;
display: flex;
flex-direction: column;
align-items: center;
.number {
font-size: 100rpx;
font-family: Nexa Bold;
font-weight: 400;
color: #FFFFFF;
}
.data_analysis {
width: 100%;
text-align: center;
margin-bottom: 59rpx;
>image {
width: 30rpx;
height: 30rpx;
margin-right: 15rpx;
}
>text {
font-size: 28rpx;
font-family: PingFang-SC-Bold;
font-weight: bold;
color: #FFFFFF;
}
}
.echart {
width: 690rpx;
height: 1060rpx;
background: #FFFFFF;
box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(153, 153, 153, 0.1);
border-radius: 20rpx;
box-sizing: border-box;
padding-top: 30rpx;
.title {
width: 200rpx;
height: 44rpx;
background: #EFFCF7;
border: 2px solid rgba(58, 187, 144, 0.25);
border-radius: 22rpx;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
>image {
width: 36rpx;
height: 10rpx;
margin-right: 10rpx;
}
>text {
font-size: 20rpx;
font-family: PingFang-SC-Bold;
font-weight: bold;
color: #37BA8E;
}
}
#echart_p {
width: 100%;
height: calc(100% - 74rpx);
box-sizing: border-box;
padding: 0 20rpx;
}
}
}
}
</style>