Your Name 2 år sedan
förälder
incheckning
4922c1944b
4 ändrade filer med 100 tillägg och 55 borttagningar
  1. 8
    46
      src/components/CoverMap.vue
  2. 89
    2
      src/components/InfoBox.vue
  3. 1
    2
      src/components/OverLay.vue
  4. 2
    5
      src/components/ScenicDetail.vue

+ 8
- 46
src/components/CoverMap.vue Visa fil

@@ -14,37 +14,21 @@
14 14
         <i class="iconfont icon-cc-pointer-right"></i>
15 15
       </div>
16 16
     </CoverBtn>
17
-    
18
-    <AudioVue :audio="scenicSpots.audio" ref="audioRef" @play="playing = true" @stop="playing = false" />
19
-
20
-    <div v-if="show" class="map-info-box" :class="{ show }" @click.stop="show = false">
21
-      <div class="map-info-container" @click.stop="">
22
-        <img class="thumb" :src="scenicSpots.thumb2" alt="">
23
-        <div class="head">
24
-          <div>{{ scenicSpots.name }}</div>
25
-          <div>
26
-            <span @click="onClickAudio">
27
-              <i class="iconfont icon-playcircle" v-if="!playing"></i>
28
-              <i class="iconfont icon-pausecircle" v-else></i>
29
-            </span>
30
-            <span @click="onClickLoc"><i class="iconfont icon-map"></i></span>            
31
-          </div>
32
-        </div>
33
-        <div class="body">{{ scenicSpots.desc }}</div>  
34
-      </div>      
35
-      <div class="action" @click.stop="show = false">
36
-        <i class="iconfont icon-roundclose"></i>
37
-      </div>
38
-    </div>
39
-  </div>
40 17
 
18
+    <InfoBox
19
+      :visible="show"
20
+      :resource="scenicSpots"
21
+      :thumb="scenicSpots.thumb2"
22
+      @close="show = false"
23
+    />
24
+  </div>
41 25
 </template>
42 26
 
43 27
 <script setup>
44 28
   import { ref } from 'vue';
45 29
   import { resources } from '@/utils/resources';
46 30
   import CoverBtn from './CoverBtn.vue';
47
-  import AudioVue from './Audio.vue';
31
+  import InfoBox from './InfoBox.vue';
48 32
 
49 33
   const posList = resources.filter(x => x.mapBtnPos);
50 34
   
@@ -55,8 +39,6 @@
55 39
   const show = ref(false);  
56 40
   const gestureHide = ref(false);
57 41
   const scenicSpots = ref({});
58
-  const audioRef = ref();
59
-  const playing = ref(false);
60 42
   const btnCenters = ref([]);
61 43
 
62 44
   const getGestureStyle = (width, height) => {
@@ -70,26 +52,6 @@
70 52
     scenicSpots.value = it;
71 53
     show.value = true;
72 54
     gestureHide.value = true;
73
-    stopAudio();
74
-  }
75
-  const onClickAudio = () => audioRef.value.toggle();
76
-  const stopAudio = () => {
77
-    if (playing.value) {
78
-      audioRef.value.toggle();
79
-      playing.value = false;
80
-    }
81
-  }
82
-  const onClickLoc = () => {
83
-    if (wx) {
84
-      wx.openLocation({
85
-        latitude: scenicSpots.value.mapPos[1], // 纬度,浮点数,范围为90 ~ -90
86
-        longitude: scenicSpots.value.mapPos[0], // 经度,浮点数,范围为180 ~ -180。
87
-        name: scenicSpots.value.name, // 位置名
88
-        address: '', // 地址详情说明
89
-        scale: 15, // 地图缩放级别,整型值,范围从1~28。默认为最大
90
-        infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
91
-      });
92
-    }
93 55
   }
94 56
 
95 57
   const onLoad = e => {

+ 89
- 2
src/components/InfoBox.vue Visa fil

@@ -1,17 +1,104 @@
1 1
 <template>
2 2
   <OverLay :visible="visible" @close="emit('close')">
3
-    1234
3
+    <div class="info-container" @click.stop="">
4
+      <img class="thumb" :src="thumb" alt="">
5
+      <div class="head">
6
+        <div>{{ resource.name }}</div>
7
+        <div>
8
+          <span @click="onClickAudio">
9
+            <i class="iconfont icon-playcircle" v-if="!playing"></i>
10
+            <i class="iconfont icon-pausecircle" v-else></i>
11
+          </span>
12
+          <span @click="onClickLoc"><i class="iconfont icon-map"></i></span>            
13
+        </div>
14
+      </div>
15
+      <div class="body">{{ resource.desc }}</div>  
16
+    </div>
17
+    <AudioVue :audio="resource.audio" ref="audioRef" @play="playing = true" @stop="playing = false" />
4 18
   </OverLay>
5 19
 </template>
6 20
 
7 21
 <script setup>
8
-  import { ref } from 'vue';
22
+  import { ref, watch } from 'vue';
9 23
   import OverLay from './OverLay.vue';
24
+  import AudioVue from './Audio.vue';
25
+
10 26
   
11 27
   const props = defineProps({
12 28
     visible: Boolean,
29
+    thumb: String,
30
+    resource: {
31
+      type: Object,
32
+      default: () => ({}),
33
+    }
13 34
   });
14 35
   
15 36
   const emit = defineEmits(['close']);
37
+
38
+  const audioRef = ref();
39
+  const playing = ref(false);
40
+
41
+  const onClickAudio = () => audioRef.value.toggle();
42
+  const stopAudio = () => {
43
+    if (playing.value) {
44
+      audioRef.value.toggle();
45
+      playing.value = false;
46
+    }
47
+  }
48
+  const onClickLoc = () => {
49
+    if (wx) {
50
+      wx.openLocation({
51
+        latitude: props.resource.mapPos[1], // 纬度,浮点数,范围为90 ~ -90
52
+        longitude: props.resource.mapPos[0], // 经度,浮点数,范围为180 ~ -180。
53
+        name: props.resource.name, // 位置名
54
+        address: '', // 地址详情说明
55
+        scale: 15, // 地图缩放级别,整型值,范围从1~28。默认为最大
56
+        infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
57
+      });
58
+    }
59
+  }
60
+
61
+  watch(() => props.visible, (val) => {
62
+    if (val) {
63
+      stopAudio();
64
+    }
65
+  })
16 66
   
17 67
 </script>
68
+
69
+<style lang="less" scoped>
70
+  .info-container {
71
+    width: 60vw;
72
+    max-height: 60vh;
73
+    overflow-y: auto;
74
+
75
+    .thumb {
76
+          width: 100%;
77
+        }
78
+
79
+    .head {
80
+      box-sizing: border-box;
81
+      padding: 1em 0;
82
+      border-bottom: 1px solid #f5f5f5;
83
+      display: flex;
84
+      justify-content: space-between;
85
+
86
+      .iconfont {
87
+        display: inline-block;
88
+        font-size: 24px;
89
+        padding: 0 4px;
90
+      }
91
+
92
+      & > div {
93
+        flex: none;
94
+      }
95
+    }
96
+
97
+    .body {
98
+      box-sizing: border-box;
99
+      padding: 1em 0;
100
+      line-height: 1.6em;
101
+      text-indent: 2em;
102
+    }
103
+  }
104
+</style>

+ 1
- 2
src/components/OverLay.vue Visa fil

@@ -65,6 +65,7 @@
65 65
 
66 66
     &.hidden {
67 67
       opacity: 0;
68
+      visibility: hidden;
68 69
     }
69 70
 
70 71
     .mask {
@@ -94,8 +95,6 @@
94 95
         box-shadow:2px 2px 3px #aaaaaa;
95 96
         box-sizing: border-box;
96 97
         background: #fff;
97
-        overflow-y: auto;
98
-        overflow-x: hidden;
99 98
       }
100 99
 
101 100
       .close {

+ 2
- 5
src/components/ScenicDetail.vue Visa fil

@@ -5,7 +5,7 @@
5 5
     :height="height"
6 6
     @click="onShowInfoBtn"
7 7
   />
8
-  <PopUpVue :show="showInfo" :info="resource" :onClose="onCloseInfoBtn" />
8
+  <InfoBox :visible="showInfo" :resource="resource" :thumb="resource.thumb1" @close="showInfo = false" />
9 9
   <div v-if="resource.showGesture" class="gesture2" :class="{ hidden: gestureHide }" :style="gestureStyle">
10 10
     <i class="iconfont icon-cc-pointer-right"></i>
11 11
   </div>
@@ -14,7 +14,7 @@
14 14
 <script setup>  
15 15
   import { computed, ref, watch } from "vue";
16 16
   import CoverBtn from "./CoverBtn.vue";
17
-  import PopUpVue from "./PopUp.vue";
17
+  import InfoBox from './InfoBox.vue';
18 18
 
19 19
   const props = defineProps({
20 20
     center: Array,
@@ -45,9 +45,6 @@
45 45
     showInfo.value = true
46 46
   };
47 47
 
48
-  const onCloseInfoBtn = () => {
49
-    showInfo.value=false
50
-  };
51 48
 </script>
52 49
 
53 50
 <style lang="less" scoped>