Kaynağa Gözat

fix(devicePhoto): 修复缩放比例和标记位置计算逻辑

1. 恢复并修正原图缩放比例的判断逻辑,替换硬编码值为精确计算值
2. 将标记位置计算的缩放系数从105调整为100,适配页面显示比例
allen 4 gün önce
ebeveyn
işleme
0568aa9387
1 değiştirilmiş dosya ile 9 ekleme ve 9 silme
  1. 9 9
      pages/sy/devicePhoto.vue

+ 9 - 9
pages/sy/devicePhoto.vue

@@ -512,13 +512,13 @@ export default {
         const markers = [];
         // 根据原图宽度计算缩放比例
         let scaleRatio = 3.07;
-        // if (this.imageWidth >= 5000) {
-        //   scaleRatio = 4;
-        // } else if (this.imageWidth >= 4000) {
-        //   scaleRatio = 1;
-        // } else {
-        //   scaleRatio = 2.5;
-        // }
+        if (this.imageWidth >= 5000) {
+          scaleRatio = 4;
+        } else if (this.imageWidth >= 4000) {
+          scaleRatio = 100/31;
+        } else {
+          scaleRatio = 2.5;
+        }
         // const pestArr = new Map()
         this.currentImg.mark.map((item, index) => {
           // if(pestArr.has(item.text)){
@@ -540,8 +540,8 @@ export default {
           this.is_mark = 1
           const { startX, startY,text } = item;
           // 使用缩放比例计算标记位置和尺寸
-          const x = item.width > 0 ? (startX * scaleRatio / this.imageWidth) * 105 : ((startX + item.width) * scaleRatio / this.imageWidth) * 105;
-          const y = item.height > 0 ? (startY * scaleRatio / this.imageHeight) * 105 : ((startY + item.height) * scaleRatio / this.imageHeight) * 105;
+          const x = item.width > 0 ? (startX * scaleRatio / this.imageWidth) * 100 : ((startX + item.width) * scaleRatio / this.imageWidth) * 100;
+          const y = item.height > 0 ? (startY * scaleRatio / this.imageHeight) * 100 : ((startY + item.height) * scaleRatio / this.imageHeight) * 100;
           const width = (item.width > 0 ? item.width : -item.width) * scaleRatio / this.imageWidth * 100;
           const height = (item.height > 0 ? item.height : -item.height) * scaleRatio / this.imageHeight * 100;