Yansen 2 年前
父节点
当前提交
cda89ee0cf
共有 7 个文件被更改,包括 76 次插入4 次删除
  1. 二进制
      public/map/bottom.png
  2. 二进制
      public/map/left.png
  3. 二进制
      public/map/map.png
  4. 二进制
      public/map/right.png
  5. 二进制
      public/map/top.png
  6. 60
    4
      src/components/CustMap.vue
  7. 16
    0
      src/utils/resources.js

二进制
public/map/bottom.png 查看文件


二进制
public/map/left.png 查看文件


二进制
public/map/map.png 查看文件


二进制
public/map/right.png 查看文件


二进制
public/map/top.png 查看文件


+ 60
- 4
src/components/CustMap.vue 查看文件

@@ -19,6 +19,10 @@
19 19
         <AudioVue :audio="scenicSpots.audio" ref="audioRef" @play="playing = true" @stop="playing = false" />
20 20
       </div>
21 21
     </div>
22
+    <img class="map-border border-top" src="map/top.png" alt="" @load="onBorderTopLoad">
23
+    <img class="map-border border-bottom" src="map/bottom.png" alt=""  @load="onBorderBottomLoad">
24
+    <img class="map-border border-left" src="map/left.png" alt="" :style="borderLRStyle">
25
+    <img class="map-border border-right" src="map/right.png" alt="" :style="borderLRStyle">
22 26
   </div>
23 27
 </template>
24 28
 
@@ -28,7 +32,7 @@
28 32
   import { useModel } from "@zjxpcyc/vue-tiny-store";
29 33
   import { newMarker } from '@/utils/amap';
30 34
   import { resources } from '@/utils/resources';
31
-import wxsdk from "../utils/wx";
35
+  import wxsdk from "../utils/wx";
32 36
 
33 37
   const props = defineProps({
34 38
     image: {
@@ -51,14 +55,33 @@ import wxsdk from "../utils/wx";
51 55
   const scenicSpots = ref({});
52 56
   const audioRef = ref();
53 57
   const playing = ref(false);
58
+  const borderTopSize = ref();
59
+  const borderBottomSize = ref();
54 60
 
55 61
   const isReady = computed(() => imgRef.value && mapIsReady.value);
62
+  const borderLRStyle = computed(() => {
63
+    if (borderTopSize.value && borderBottomSize.value) {
64
+      return {
65
+        top: `${borderTopSize.value.height}px`,
66
+        height: `calc(100% - ${borderTopSize.value.height + borderBottomSize.value.height}px)`,
67
+      }
68
+    } else {
69
+      return {};
70
+    }
71
+  });
56 72
 
57 73
   watch(() => isReady.value, (nw, od) => {
58 74
     if (nw && !od) {
59 75
       mapInit();
60 76
     }
61 77
   });
78
+
79
+  document.body.addEventListener('click', () => {
80
+    if (audioRef.value) {
81
+      audioRef.value.toggle();
82
+      show.value = false;
83
+    }
84
+  });
62 85
   
63 86
   const onLoad = e => (imgRef.value = e.target);
64 87
   const onClickAudio = () => audioRef.value.toggle();
@@ -75,6 +98,15 @@ import wxsdk from "../utils/wx";
75 98
     }
76 99
   }
77 100
 
101
+  const onBorderTopLoad = (e) => {
102
+    const { width, height } = e.target;
103
+    borderTopSize.value = { width, height };
104
+  }
105
+  const onBorderBottomLoad = (e) => {
106
+    const { width, height } = e.target;
107
+    borderBottomSize.value = { width, height };
108
+  }
109
+
78 110
   const onMapClick = (e) => {
79 111
     const { lnglat } = e;
80 112
 
@@ -129,7 +161,7 @@ import wxsdk from "../utils/wx";
129 161
       bounds,
130 162
       zooms,
131 163
     });
132
-    map.setLayers([imageLayer])
164
+    map.setLayers([imageLayer]);
133 165
 
134 166
     // 背景层
135 167
     const backCovers = [
@@ -150,8 +182,8 @@ import wxsdk from "../utils/wx";
150 182
     const polygon = new AMap.Polygon({
151 183
         pathL: backCovers,
152 184
         strokeWeight: 0,
153
-        fillColor: '#E2E3D6',
154
-        fillOpacity: 0.5
185
+        fillColor: '#FBF8EF',
186
+        fillOpacity: 1,
155 187
     });
156 188
     polygon.setPath(backCovers);
157 189
     map.add(polygon);
@@ -214,6 +246,7 @@ import wxsdk from "../utils/wx";
214 246
       // padding: 1em;
215 247
       border: 1em solid #fff;
216 248
       border-radius: 8px;
249
+      box-shadow:2px 2px 3px #aaaaaa;
217 250
       box-sizing: border-box;
218 251
       background: #fff;
219 252
       overflow-y: auto;
@@ -249,6 +282,29 @@ import wxsdk from "../utils/wx";
249 282
       }
250 283
     }
251 284
   }
285
+
286
+  .map-border {
287
+    display: block;
288
+    position: absolute;
289
+    z-index: 20;
290
+  }
291
+  
292
+  .border-top {
293
+    width: 100%;
294
+    left: 0;
295
+    top: 0;
296
+  }
297
+  .border-bottom {
298
+    width: 100%;
299
+    left: 0;
300
+    bottom: 0;
301
+  }  
302
+  .border-left {
303
+    left: 0;
304
+  }
305
+  .border-right {
306
+    right: 0;
307
+  }
252 308
 }
253 309
 
254 310
 </style>

+ 16
- 0
src/utils/resources.js 查看文件

@@ -16,6 +16,22 @@ export const resources = [
16 16
       key: AMAP_KEY,
17 17
     },
18 18
   },
19
+  {
20
+    image: './map/top.png',
21
+    hidden: true,
22
+  },
23
+  {
24
+    image: './map/bottom.png',
25
+    hidden: true,
26
+  },
27
+  {
28
+    image: './map/left.png',
29
+    hidden: true,
30
+  },
31
+  {
32
+    image: './map/right.png',
33
+    hidden: true,
34
+  },
19 35
   {
20 36
     name: '文德桥',
21 37
     showGesture: true,