张延森 3 years ago
parent
commit
5a578c8d68

+ 6
- 1
src/components/FireFlies/fireflies.js View File

@@ -21,7 +21,12 @@ Animation.prototype.draw = function () {
21 21
   var drawer = this.draw.bind(this);
22 22
 
23 23
   this.redraw();
24
-  window.requestAnimationFrame(drawer);
24
+  
25
+  var reqId = window.requestAnimationFrame(drawer);
26
+  return function () {
27
+    console.log('------cancelAnimationFrame----123')
28
+    cancelAnimationFrame(reqId);
29
+  }
25 30
 }
26 31
 
27 32
 Animation.prototype.redraw = function () {

+ 19
- 2
src/components/FireFlies/index.vue View File

@@ -7,15 +7,32 @@ import Animation from "./fireflies"
7 7
 
8 8
 export default {
9 9
   name: 'FireFlies',
10
+  data() {
11
+    return {
12
+      animation: undefined,
13
+      deAnimation: undefined,
14
+    }
15
+  },
10 16
   mounted() {
11 17
     this.$nextTick(() => {
12
-      new Animation(this.$el, {
18
+      this.animation = new Animation(this.$el, {
13 19
         count: 20,
14 20
         color: 'rgba(236, 196, 94, 1)',
15 21
         speed: 0.7,
16 22
         radius: 3
17
-      }).draw();
23
+      })
24
+      const cancelDraw = this.animation.draw();
25
+
26
+      this.deAnimation = () => {
27
+        cancelDraw();
28
+        this.animation = undefined;
29
+      }
18 30
     })
31
+  },
32
+  beforeDestroy() {
33
+    if (this.deAnimation) {
34
+      this.deAnimation()
35
+    }
19 36
   }
20 37
 }
21 38
 </script>

+ 24
- 5
src/components/Modal.vue View File

@@ -2,11 +2,15 @@
2 2
   <div class="modal-wrapper" v-show="show">
3 3
     <div class="modal" :style="modalStyle" @click.stop="handleMaskClick">
4 4
       <fire-flies v-if="showFireflies"></fire-flies>
5
-      <div class="back-btn" v-if="showBack" @click.stop="$emit('close')">
5
+      <div class="modal-action back-btn" v-if="showBack" @click.stop="$emit('close')">
6 6
         <img src="~@/assets/buttonImg/backImg.png" alt="">
7 7
       </div>
8
+      <div class="modal-action share-guide" v-if="showShare">
9
+        <img src="~@/assets/buttonImg/shareText.png" alt="">
10
+      </div>
11
+      <div class="modal-action"><slot name="action"></slot></div>
8 12
       <div class="modal-body"><slot></slot></div>
9
-      <slot name="action"></slot>
13
+
10 14
     </div>
11 15
 
12 16
   </div>
@@ -32,7 +36,8 @@ export default {
32 36
     showFireflies: {
33 37
       type: Boolean,
34 38
       default: true
35
-    }
39
+    },
40
+    showShare: Boolean
36 41
   },
37 42
   computed: {
38 43
     modalStyle() {
@@ -68,8 +73,12 @@ export default {
68 73
     justify-content: center;
69 74
     align-items: center;
70 75
 
71
-    .back-btn {
76
+    .modal-action {
72 77
       position: absolute;
78
+      z-index: 50;
79
+    }
80
+
81
+    .back-btn {
73 82
       top: 4em;
74 83
       left: 1.5em;
75 84
       width: 4em;
@@ -79,9 +88,19 @@ export default {
79 88
       }
80 89
     }
81 90
 
91
+    .share-guide {
92
+      top: 0.5em;
93
+      right: 0em;
94
+      width: 3em;
95
+      
96
+      & > img {
97
+        width: 100%;
98
+      }
99
+    }
100
+
82 101
     .modal-body {
83 102
       position: relative;
84
-      z-index: 100;
103
+      z-index: 20;
85 104
     }
86 105
   }
87 106
 }

+ 0
- 2
src/pages/Honghe.vue View File

@@ -1,7 +1,5 @@
1 1
 <template>
2 2
   <div class="index-box">
3
-    <modal :show="true" :show-back="true" >      
4
-    </modal>
5 3
     <bg-music />
6 4
     <popup
7 5
       :show="showPopup"