dedsudiyu 2 年 前
コミット
31fc61b65e
共有2 個のファイルを変更した93 個の追加61 個の削除を含む
  1. 37 21
      pages/emergencyEvacuationBig.vue
  2. 56 40
      pages/emergencyEvacuationBigFullScreen.vue

+ 37 - 21
pages/emergencyEvacuationBig.vue

@@ -1116,30 +1116,46 @@ export default {
       this.$set(this, 'mapWidth', maxWidth);
       this.$set(this, 'mapHeight', maxHeight);
       //缩放判断
-      if(maxHeight>height&&maxWidth>width){
-        if((maxHeight-height)>(maxWidth-width)){
-          zoomData = height/maxHeight;
-          this.$set(this,'zoomData',height/maxHeight);
-        }else{
-          zoomData = width / maxWidth;
-          this.$set(this,'zoomData',width / maxWidth);
+        let zoomNumOne = height / maxHeight;
+        if(parseInt(this.accMul(zoomNumOne,maxHeight)) <= height && parseInt(this.accMul(zoomNumOne,maxWidth)) <= width){
+          zoomData = zoomNumOne;
+          this.$set(this,'zoomData',zoomNumOne);
         }
-      }else if(maxHeight<height&&maxWidth<width){
-        if((height-maxHeight)>(width-maxWidth)){
-          zoomData = width / maxWidth;
-          this.$set(this,'zoomData',width / maxWidth);
-        }else{
-          zoomData = height / maxHeight;
-          this.$set(this,'zoomData',height / maxHeight);
+        let zoomNumTwo = width / maxWidth;
+        if(parseInt(this.accMul(zoomNumTwo,maxHeight)) <= height && parseInt(this.accMul(zoomNumTwo,maxWidth)) <= width){
+          zoomData = zoomNumTwo;
+          this.$set(this,'zoomData',zoomNumTwo);
         }
-      }else if(maxHeight<height&&maxWidth>width){
-        zoomData = width / maxWidth;
-        this.$set(this,'zoomData',width / maxWidth);
-      }else if(maxHeight>height&&maxWidth<width){
-        zoomData = height / maxHeight;
-        this.$set(this,'zoomData',height / maxHeight);
-      }
+      // if(maxHeight>height&&maxWidth>width){
+      //   if((maxHeight-height)>(maxWidth-width)){
+      //     zoomData = height/maxHeight;
+      //     this.$set(this,'zoomData',height/maxHeight);
+      //   }else{
+      //     zoomData = width / maxWidth;
+      //     this.$set(this,'zoomData',width / maxWidth);
+      //   }
+      // }else if(maxHeight<height&&maxWidth<width){
+      //   if((height-maxHeight)>(width-maxWidth)){
+      //     zoomData = width / maxWidth;
+      //     this.$set(this,'zoomData',width / maxWidth);
+      //   }else{
+      //     zoomData = height / maxHeight;
+      //     this.$set(this,'zoomData',height / maxHeight);
+      //   }
+      // }else if(maxHeight<height&&maxWidth>width){
+      //   zoomData = width / maxWidth;
+      //   this.$set(this,'zoomData',width / maxWidth);
+      // }else if(maxHeight>height&&maxWidth<width){
+      //   zoomData = height / maxHeight;
+      //   this.$set(this,'zoomData',height / maxHeight);
+      // }
     },
+      accMul(arg1,arg2){
+        var m=0,s1=arg1.toString(),s2=arg2.toString();
+        try{m+=s1.split(".")[1].length}catch(e){}
+        try{m+=s2.split(".")[1].length}catch(e){}
+        return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
+      },
     //结束疏散
     evacuationButton() {
       let self = this;

+ 56 - 40
pages/emergencyEvacuationBigFullScreen.vue

@@ -331,48 +331,64 @@
 				}
 				this.$set(this, 'mapWidth', maxWidth);
 				this.$set(this, 'mapHeight', maxHeight);
-				if (maxWidth > maxHeight) {
-					if ((maxWidth / maxHeight) > num) {
-						// 以宽度缩放
-						zoomType = 1;
-					} else {
-						// 以高度缩放
-						zoomType = 2;
-				 }
-				} else {
-					if ((maxHeight / maxWidth) > num) {
-						// 以高度缩放
-						zoomType = 2;
-					} else {
-						// 以宽度缩放
-						zoomType = 1;
-					}
-				}
+				  let zoomNumOne = height / maxHeight;
+				  if(parseInt(this.accMul(zoomNumOne,maxHeight)) <= height && parseInt(this.accMul(zoomNumOne,maxWidth)) <= width){
+				    zoomData = zoomNumOne;
+				    this.$set(this,'zoomData',zoomNumOne);
+				  }
+				  let zoomNumTwo = width / maxWidth;
+				  if(parseInt(this.accMul(zoomNumTwo,maxHeight)) <= height && parseInt(this.accMul(zoomNumTwo,maxWidth)) <= width){
+				    zoomData = zoomNumTwo;
+				    this.$set(this,'zoomData',zoomNumTwo);
+				  }
+				// if (maxWidth > maxHeight) {
+				// 	if ((maxWidth / maxHeight) > num) {
+				// 		// 以宽度缩放
+				// 		zoomType = 1;
+				// 	} else {
+				// 		// 以高度缩放
+				// 		zoomType = 2;
+				//  }
+				// } else {
+				// 	if ((maxHeight / maxWidth) > num) {
+				// 		// 以高度缩放
+				// 		zoomType = 2;
+				// 	} else {
+				// 		// 以宽度缩放
+				// 		zoomType = 1;
+				// 	}
+				// }
 
-				if (zoomType == 1) {
-					if (width > maxWidth) {
-						zoomData = maxWidth / width;
-					} else {
-						zoomData = width / maxWidth;
-					}
-					if (width > maxWidth) {
-						this.$set(this, 'zoomData', maxWidth / width);
-					} else {
-						this.$set(this, 'zoomData', width / maxWidth);
-					}
-				} else if (zoomType == 2) {
-				 if (height > maxHeight) {
-						zoomData = maxHeight / height;
-					} else {
-						zoomData = height / maxHeight;
-					}
-					if (height > maxHeight) {
-						this.$set(this, 'zoomData', maxHeight / height);
-					} else {
-						this.$set(this, 'zoomData', height / maxHeight);
-					}
-				}
+				// if (zoomType == 1) {
+				// 	if (width > maxWidth) {
+				// 		zoomData = maxWidth / width;
+				// 	} else {
+				// 		zoomData = width / maxWidth;
+				// 	}
+				// 	if (width > maxWidth) {
+				// 		this.$set(this, 'zoomData', maxWidth / width);
+				// 	} else {
+				// 		this.$set(this, 'zoomData', width / maxWidth);
+				// 	}
+				// } else if (zoomType == 2) {
+				//  if (height > maxHeight) {
+				// 		zoomData = maxHeight / height;
+				// 	} else {
+				// 		zoomData = height / maxHeight;
+				// 	}
+				// 	if (height > maxHeight) {
+				// 		this.$set(this, 'zoomData', maxHeight / height);
+				// 	} else {
+				// 		this.$set(this, 'zoomData', height / maxHeight);
+				// 	}
+				// }
 			},
+			  accMul(arg1,arg2){
+				var m=0,s1=arg1.toString(),s2=arg2.toString();
+				try{m+=s1.split(".")[1].length}catch(e){}
+				try{m+=s2.split(".")[1].length}catch(e){}
+				return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
+			  },
 			/*MQTT*/
 			//订阅
 			onMQTT() {