ソースを参照

环境监测设备详情页面展示要素不全的问题

yf_ldf 2 年 前
コミット
2dd531133b
1 ファイル変更37 行追加22 行削除
  1. 37 22
      pages/environment/equipment.vue

+ 37 - 22
pages/environment/equipment.vue

@@ -43,18 +43,17 @@
 				<p class="realtime_title"><span>实时数据</span></p>
 				<view class="realtime_text">
 					<view class="realtime_text_item">
-						<view class="realtime_text_item_info" v-for="(item,key) in olddata" :key="key"
-							@click="oneday(key)">
-							<view class="item_info_img"
-								:style="{'background-color':olddatas[1]}">
+						<view class="realtime_text_item_info" v-for="(item,index) in olddata" :key="index"
+							@click="oneday(index,item)">
+							<view class="item_info_img" :style="{'background-color':olddatas[1]}">
 								<image
-									:src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/icon_'+item[1]+'.png'"
+									:src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/environment/icon_'+item.value[1]+'.png'"
 									mode=""></image>
 							</view>
 							<view class="item_info_text">
-								<p>{{key}}</p>
+								<p>{{item.lable}}</p>
 								<p style="margin-top: 20rpx;">
-									{{parseFloat(olddata[key][0]) == -99.99 ?'N/A':parseFloat(item[0])}}
+									{{parseFloat(item.value[0]) == -99.99 ?'N/A':parseFloat(item.value[0])}}
 								</p>
 							</view>
 						</view>
@@ -97,7 +96,7 @@
 		data() {
 			return {
 				eqinfo: {},
-				olddata: {},
+				olddata: [],
 				olddatas: ["#fba825", "#53d67c", "#008cf2", "#fb504d", "#d87ffc", "#4ec5f0"],
 				city: "",
 				kongtf: false,
@@ -133,27 +132,33 @@
 					}
 				})
 				this.dataloadingtf = false
-				// this.olddata = res
-				// console.log(res)olddata
-				this.olddata = {}
+				this.olddata = []
 				for (var key in res.conf) {
 					if (res.conf[key]) {
 						if (res.conf[key].indexOf("#") != -1) {
-							this.olddata[res.conf[key].replace("#", "(") + ")"] = res.dat[key].split("#")
+							// let lable = res.conf[key].replace("#", "(") + ")"
+							console.log(res.conf[key])
+							this.olddata.push({
+								lable:res.conf[key].replace("#", "(") + ")",
+								value:res.dat[key].split('#')
+							})
+							// this.olddata[res.conf[key].replace("#", "(") + ")"] = res.dat[key].split("#")
 						} else {
-							this.olddata[res.conf[key]] = res.dat[key].split("#")
+							// this.olddata[res.conf[key]] = res.dat[key].split("#")
 						}
 					}
 				}
+				console.clear()
 				console.log(this.olddata)
-				this.realtimeTF = true
-				for (var key in this.olddata) {
-					this.realtimeTF = false
-				}
+				// this.realtimeTF = true
+				// for (var key in this.olddata) {
+				// 	this.realtimeTF = false
+				// }
+				this.realtimeTF = false
 				// this.realtimeTF = arr.some(function(item){
 				// 	return item!=""
 				// })
-				console.log(this.realtimeTF)
+				// console.log(this.realtimeTF)
 			},
 			// weather.weather.qxz_data_chart 一天的数据
 			async onehistory() { //设备列表
@@ -214,27 +219,33 @@
 					url: "../afterSale/addafter?device_id=" + device_id + "&device_type=" + 5
 				})
 			},
-			oneday(key) {
+			oneday(key,item) {
 				// console.log(key)
 				var obj = {
-					name: key,
+					name: item.lable,
 					data: [],
 				}
 				var xtitle = []
 				var linearr = []
 				var arr = []
 				var timearr = []
+				// console.log(key)
+				// console.log(this.olddata)
+				// console.log(this.onedatas)
+				// return
 				for (var i = 0; i < this.onedatas.length; i++) {
 					var times = new Date(this.onedatas[i].time * 1000)
-					arr.unshift(Number(this.onedatas[i].dat[this.olddata[key][2]].split("#")[0]))
+					// console.log(this.onedatas[i].dat[this.olddata[key].value[2]].split("#")[0])
+					arr.unshift(Number(this.onedatas[i].dat[this.olddata[key].value[2]].split("#")[0]))
 					xtitle.unshift(times.getMonth() + 1 + "/" + times.getDate() + "-" + times.getHours() + ":" + times
 						.getMinutes())
 					timearr.unshift(+new Date(times) / 1000)
-					obj.data.unshift(Number(this.onedatas[i].dat[this.olddata[key][2]].split("#")[0]))
+					obj.data.unshift(Number(this.onedatas[i].dat[this.olddata[key].value[2]].split("#")[0]))
 				}
 				arr.sort(function(a, b) {
 					return a - b
 				})
+				// console.log(arr)
 				this.onedatasMin = arr[0]
 				this.onedatasMax = arr[arr.length - 1]
 				for (var i = 0; i < obj.data.length; i++) {
@@ -245,12 +256,16 @@
 						this.onedatasMintime = timearr[i]
 					}
 				}
+				console.log(obj)
 				linearr.push(obj)
 				if (obj.data.length == 0) {
 					this.tishiTF = true
 				} else {
 					this.tishiTF = false
 				}
+				// console.log(xtitle)
+				// console.log(linearr)
+				// return
 				this.showColumn("canvasColumnA", xtitle, linearr)
 				this.show = true
 			},