wangjiawen 4 years ago
parent
commit
d6f5c2c3eb
1 changed files with 58 additions and 40 deletions
  1. 58 40
      components/detail/Detail.vue

+ 58 - 40
components/detail/Detail.vue

@@ -11,7 +11,7 @@
 		<view class="threeTarget" v-show="targetdetail_visable.targetdetail_target">
 			<view class="target">
 				<view class="target_zi">指标</view>
-				<view class="target_dianLiang">日发电量</view>
+				<view class="target_dianLiang">{{targetName}}</view>
 			</view>
 			<view class="target">
 				<view style="font-size: 16px;margin-top: -7px;">数值</view>
@@ -19,7 +19,7 @@
 			</view>
 			<view class="target">
 				<view style="font-size: 16px;margin-top: -7px;">单位</view>
-				<view class="target_danWei">kw/h</view>
+				<view class="target_danWei">{{targetUnit}}</view>
 			</view>
 		</view>
 
@@ -44,10 +44,15 @@ var canvaColumn = null;
 
 
 
-				
+
 export default {
 	data() {
 		let data = {
+            backStageIp:"192.168.1.104"	,
+			backStagePort:"8082"	,
+			targetName:"日发电量",
+			targetUnit:"kw/h",
+			pointKey:"HB_GD_KBF_JS_P4_L19_220_CI0136",
 			targetdetail_visable: { targetdetail_target: true, targetdetail_curve: true, targetdetail_histogram: true},
 			targetdetail: { targetdetail_target: '', targetdetail_curve: '', targetdetail_histogram: ''},
 			socketTask_targetdetail_target:"",
@@ -62,20 +67,14 @@ export default {
 		 return data;
 		},
 
-		
-	
+
+
 	created: function() {
-		
-		
-		
-		
-		
 		this.address = this.getWindPowerStationNameToSessionStorage();
 		this.windPowerStationId = uni.getStorageSync('windPowerStationId');
 		this.targetdetail_target();
 		this.targetdetail_curve();
 		this.targetdetail_histogram();
-		
 	},
 	onShow() {
 		this.windPowerStationId = uni.getStorageSync('windPowerStationId');
@@ -89,14 +88,21 @@ export default {
 		this.getColumnServerData();
 		this.getLineServerData();
 	},
-
 	onReady() {},
 
 	methods: {
-		async targetdetail_target() {
+		targetInformation(callTargetName,callTargetUnit){
+			this.address = this.getWindPowerStationNameToSessionStorage();
+			this.windPowerStationId = uni.getStorageSync('windPowerStationId');
+			this.targetName = callTargetName;
+			this.targetUnit = callTargetUnit;
+			this.targetdetail_target();
+			this.targetdetail_curve();
+			this.targetdetail_histogram();
+		},async targetdetail_target() {
 			let ip;
 			uni.request({
-			    url: "http://192.168.1.104:8082/targetdetail/targetdetail_target?pointKey=HB_GD_KBF_JS_P4_L19_220_CI0136",
+			    url:'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/targetdetail_target?pointKey='+this.pointKey,
 			    success: (res) => {
 			        ip = res.data;
 			    }
@@ -105,7 +111,7 @@ export default {
 			// 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
 			this.socketTask_targetdetail_target = uni.connectSocket({
 				// 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
-				url: 'ws://192.168.1.104:8082/websocket/pageNumber_8/functionNumber_1',
+				url: 'ws://'+this.backStageIp+':'+this.backStagePort+'/websocket/pageNumber_8/functionNumber_1',
 				success(data) {
 					console.log('websocket连接成功');
 				}
@@ -124,14 +130,19 @@ export default {
 				});
 			});
 			// 这里仅是事件监听【如果socket关闭了会执行】
-			/* 								this.socketTask.onClose(() => {
-									console.log("已经被关闭了")
-								}) */
+/* 			this.socketTask.onClose(() => {
+					uni.request({
+					    url: 'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/close_targetdetail_target?pointKey='+this.pointKey,
+					    success: (res) => {
+
+					    }
+					});
+			}) */
 		},
 		targetdetail_curve() {
 			let ip;
 			uni.request({
-			    url: "http://192.168.1.104:8082/targetdetail/targetdetail_curve?pointKey=HB_GD_KBF_JS_P4_L19_220_CI0136",
+			    url: 'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/targetdetail_curve?pointKey='+this.pointKey,
 			    success: (res) => {
 			        ip = res.data;
 			    }
@@ -140,7 +151,7 @@ export default {
 			// 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
 			this.socketTask_targetdetail_curve = uni.connectSocket({
 				// 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
-				url: 'ws://192.168.1.104:8082/websocket/pageNumber_8/functionNumber_2',
+				url: 'ws://'+this.backStageIp+':'+this.backStagePort+'/websocket/pageNumber_8/functionNumber_2',
 				success(data) {
 					console.log('websocket连接成功');
 				}
@@ -158,12 +169,17 @@ export default {
 				});
 			});
 			// 这里仅是事件监听【如果socket关闭了会执行】
-			/* 								this.socketTask.onClose(() => {
-												console.log("已经被关闭了")
-											}) */
+/* 				this.socketTask.onClose(() => {
+						uni.request({
+						    url: 'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/close_targetdetail_curve?pointKey='+this.pointKey,
+						    success: (res) => {
+
+						    }
+						});
+				}) */
 		},
 		targetdetail_histogram() {
-			
+
 			Date.prototype.Format = function(fmt) {
 						var o = {
 							"M+": this.getMonth() + 1, //月份
@@ -181,10 +197,10 @@ export default {
 								fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
 						return fmt;
 			};
-			
+
 			let ip;
 			uni.request({
-			    url: "http://192.168.1.104:8082/targetdetail/targetdetail_histogram?pointKey=HB_GD_KBF_JS_P4_L19_220_CI0136",
+			    url: 'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/targetdetail_histogram?pointKey='+this.pointKey,
 			    success: (res) => {
 			        ip = res.data;
 			    }
@@ -193,7 +209,7 @@ export default {
 			// 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
 			this.socketTask_targetdetail_histogram = uni.connectSocket({
 				// 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
-				url: 'ws://192.168.1.104:8082/websocket/pageNumber_8/functionNumber_3',
+				url: 'ws://'+this.backStageIp+':'+this.backStagePort+'/websocket/pageNumber_8/functionNumber_3',
 				success(data) {
 					console.log('websocket连接成功');
 				}
@@ -208,7 +224,7 @@ export default {
 				this.socketTask_targetdetail_histogram.onMessage(res => {
 					//console.log("收到服务器内容:" + res.data);
 					_this.targetdetail.targetdetail_histogram = JSON.parse(res.data)[ip];
-					
+
 					let Column = {
 						 "categories": ["04/11","04/12", "04/13", "04/14", "04/15", "04/16", "04/17"],
 						  "series": [{
@@ -219,27 +235,29 @@ export default {
 					};
 					Column.categories=[];
 					Column.series[0].data=[];
+					Column.series[0].name=this.targetName;
 					for(var i=0;i<_this.targetdetail.targetdetail_histogram.length;i++){
 						_this.targetdetail.targetdetail_histogram[i].pointTime = new Date(_this.targetdetail.targetdetail_histogram[i].pointTime*1000).Format("MM/dd");
 						Column.categories.push(_this.targetdetail.targetdetail_histogram[i].pointTime);
 						Column.series[0].data.push(_this.targetdetail.targetdetail_histogram[i].pointValueInDouble);
 					}
-					
+
 					//这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
-					
+
 					_self.showColumn('canvasColumn', Column);
-					
+
 				});
 			});
 			// 这里仅是事件监听【如果socket关闭了会执行】
-			/* 								this.socketTask.onClose(() => {
-												console.log("已经被关闭了")
-											}) */
-		},
-		
-
-
-		pushWindPowerStationNameToSessionStorage(windpowerstationName) {
+/* 				this.socketTask.onClose(() => {
+						uni.request({
+						    url: 'http://'+this.backStageIp+':'+this.backStagePort+'/targetdetail/close_targetdetail_histogram?pointKey='+this.pointKey,
+						    success: (res) => {
+
+						    }
+						});
+		     }); */
+		},pushWindPowerStationNameToSessionStorage(windpowerstationName) {
 			uni.setStorageSync('windpowerstationName', windpowerstationName);
 			//sessionStorage.setItem('windpowerstationName', windpowerstationName);
 			//alert("v"+ sessionStorage.getItem("windpowerstationName"));
@@ -390,7 +408,7 @@ export default {
 				  }]
 			};
 			//这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
-			
+
 			_self.showColumn('canvasColumn', Column);
 		},
 		showColumn(canvasId, chartData) {