Преглед на файлове

更改空间显示名称 X空间 类型 根据布局所属类型来显示

zjs_project преди 1 година
родител
ревизия
afce5f3a78
променени са 4 файла, в които са добавени 56 реда и са изтрити 27 реда
  1. 18 11
      src/components/newBottomCom/viewCareful/viewCareful.vue
  2. 3 0
      src/mixins/loadModel.js
  3. 1 0
      src/pages/webgl_rxdz_test/webgl_rxdz_test.vue
  4. 34 16
      src/utils/util.js

+ 18 - 11
src/components/newBottomCom/viewCareful/viewCareful.vue

@@ -65,10 +65,8 @@
 				this.lastCareList = [];
 				const spaceDetail = this.curHouseObj;
 				const spaceList = JSON.parse(spaceDetail.houseJson);
+				let result = 0;
 				spaceList && spaceList.forEach((item,index)=>{
-					let curSpaceArea = parseFloat(
-						(item.spaceWidth * item.spaceHeight) / 10000
-					).toFixed(1);
 					let minArea = 0;
 					let maxArea = 100;
 					if(item.hasOwnProperty('spaceWidthMin') && item.hasOwnProperty('spaceHeightMin')){
@@ -79,38 +77,47 @@
 					}
 					//修改为显示空间类型名称
 					let text = spaceTypes[item.spaceType - 1] || item.spaceName;
-					// console.warn("***carefulList-change1***", item,item.spaceType)
 					if(item.spaceName && !item.isSizeLock){//楼梯不显示
+						let curSpaceArea = Number(parseFloat(
+							(item.spaceWidth * item.spaceHeight) / 10000
+						).toFixed(1));
 						let data = {
 							spaceId:item.spaceId,
 							index:this.carefulList.length,
 							name:text,
-							area:parseFloat(curSpaceArea),
-							percent:null,
+							area:curSpaceArea,
+							percent:0,
 							minArea:parseFloat(minArea),	//最小面积
 							maxArea:parseFloat(maxArea),	//最大面积
 						}
+						result = result + curSpaceArea;
 						this.carefulList.push(data);
 						this.lastCareList.push({
 							spaceId:item.spaceId,
 							index:this.carefulList.length,
-							area:parseFloat(curSpaceArea),
+							area:curSpaceArea,
 						})
 					}
 				})
-				
-				let result = this.carefulList.reduce((prev, cur)=>{
-				    return prev + parseFloat(cur.area);
-				},0);
+				// let result = this.carefulList.reduce((prev, cur)=>{
+				//     return prev + parseFloat(cur.area);
+				// },0);
 				this.carefulList.forEach(it=>{
 					if(!result){
 						it.percent = 100;
 					}else{
 						it.percent = (parseFloat(it.area) / parseFloat(result)*100).toFixed(0);
 					}
+					// console.warn("***carefulList-change1***", it.area,it)
 				})
 				console.warn("***viewCareful-change***", this.carefulList)
 			},
+			updataData(spaceId,layoutObj){
+				let lable = this.carefulList.find(it=>it.spaceId == spaceId);
+				let name = spaceTypes[layoutObj.type - 1];
+				lable.name = name;
+				console.warn("***updataData***",lable)
+			},
 			sliderChanging(e,item) {
 				// const wallValue = e.detail.value;
 				// item.percent = 60;

+ 3 - 0
src/mixins/loadModel.js

@@ -87,6 +87,9 @@ export default {
 					if(layout){
 						space.layoutSpaceType = layout.type;//更新布局信息到空间对象里面
 						space.layoutSpaceName = layout.name;//更新布局信息到空间对象里面
+						if(this.$refs && this.$refs.viewShell){
+							this.$refs.viewShell.$refs.viewCareful.updataData(space.spaceId,layout);
+						}
 					}
 				}
 			});

+ 1 - 0
src/pages/webgl_rxdz_test/webgl_rxdz_test.vue

@@ -1779,6 +1779,7 @@
 				// 	}
 				// })
 				console.warn("***updataLable***",lable)
+				this.$refs.viewShell.$refs.viewCareful.updataData(spaceId,layoutObj);
 			},
 			// 添加文字标签
 			addWordLabel(){

+ 34 - 16
src/utils/util.js

@@ -4,6 +4,7 @@ import {
 } from '@/utils/localStorage';
 window.sessionTime = new Date();
 var socketTaskList = []; //websocket 待发送任务列表
+var socketInter = null;
 /**
  * websocket配置项
  * @type {{serverTimeoutObj: null, timeoutObj: null, timeoutnum: null, lockReconnect: boolean, ws: null, params: {houseId: null, openid: null, userid: null}, timeout: number}}
@@ -56,7 +57,7 @@ function initWebsocket() {
 function websocketonopen() {
 	let data = initPage();
     console.log('建立ws连接', data)
-    start();
+	start();
     //发送链接身份数据
     connectSend(data.openId, data.userId, data.houseId);
 }
@@ -68,7 +69,7 @@ function websocketonopen() {
 function websocketonmessage(e) {
     console.log('客户端接收服务端数据时触发', e);
     //收到服务器信息,心跳重置
-    reset();
+    // reset();
 }
 
 /**
@@ -86,6 +87,8 @@ function websocketonerror() {
 function websocketclose(e) {
     //关闭
     console.log("断开连接", e);
+	socketInter && clearInterval(socketInter);//清空心跳发送
+	socketInter = null;
     //重连
     reconnect();
 }
@@ -234,6 +237,8 @@ function reconnect() {
         initWebsocket()
         wsConfig.lockReconnect = false
     }, 5000)
+	socketInter && clearInterval(socketInter);//清空心跳发送
+	socketInter = null;
 }
 
 /**
@@ -242,36 +247,49 @@ function reconnect() {
 function reset() {
     console.log('重启心跳')
     //重置心跳
-    clearTimeout(wsConfig.timeoutObj);
-    //清除时间
-    clearTimeout(wsConfig.serverTimeoutObj);
+    // clearTimeout(wsConfig.timeoutObj);
+    // //清除时间
+    // clearTimeout(wsConfig.serverTimeoutObj);
     //重启心跳
-    start();
+    wsSendHeartBeat();
+}
+// socket 心跳发送
+function wsSendHeartBeat() {
+	let ws = wsConfig.ws;
+	// var data = ["\n"];//心跳的数据格式
+	if(!socketInter){
+		console.warn('***ws-开启WebSocket心跳***');
+		//5秒钟发送一次心跳
+		socketInter = setInterval(()=>{
+			// console.warn("***ws-SendHeartBeat-尝试心跳发送:");
+			//这里发送一个心跳,后端收到后,返回一个心跳消息,
+			console.warn('***ws-心跳***');
+			if (ws.readyState == 1) {
+			    //如果连接正常
+			    ws.send("heartCheck"); //这里可以自己跟后端约定
+			} else {
+			    //否则重连
+			    reconnect();
+			}
+		},5000)
+	}
 }
-
 /**
  * 开启ws连接
  */
 function start() {
     let ws = wsConfig.ws;
     //开启心跳
-    console.log("开启心跳", wsConfig,ws.readyState);
+    // console.log("开启心跳", wsConfig,ws.readyState);
     wsConfig.timeoutObj && clearTimeout(wsConfig.timeoutObj);
     wsConfig.serverTimeoutObj && clearTimeout(wsConfig.serverTimeoutObj);
     wsConfig.timeoutObj = setTimeout(function() {
-        //这里发送一个心跳,后端收到后,返回一个心跳消息,
-        if (ws.readyState == 1) {
-            //如果连接正常
-            ws.send("heartCheck"); //这里可以自己跟后端约定
-        } else {
-            //否则重连
-            reconnect();
-        }
         wsConfig.serverTimeoutObj = setTimeout(function() {
             //超时关闭
             ws.close();
         }, wsConfig.timeout);
     }, wsConfig.timeout);
+	wsSendHeartBeat();//开始心跳
 }
 var util = {
 	dateFormat(date, fmt) {