张延森 3 years ago
parent
commit
5a578c8d68

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

21
   var drawer = this.draw.bind(this);
21
   var drawer = this.draw.bind(this);
22
 
22
 
23
   this.redraw();
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
 Animation.prototype.redraw = function () {
32
 Animation.prototype.redraw = function () {

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

7
 
7
 
8
 export default {
8
 export default {
9
   name: 'FireFlies',
9
   name: 'FireFlies',
10
+  data() {
11
+    return {
12
+      animation: undefined,
13
+      deAnimation: undefined,
14
+    }
15
+  },
10
   mounted() {
16
   mounted() {
11
     this.$nextTick(() => {
17
     this.$nextTick(() => {
12
-      new Animation(this.$el, {
18
+      this.animation = new Animation(this.$el, {
13
         count: 20,
19
         count: 20,
14
         color: 'rgba(236, 196, 94, 1)',
20
         color: 'rgba(236, 196, 94, 1)',
15
         speed: 0.7,
21
         speed: 0.7,
16
         radius: 3
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
 </script>
38
 </script>

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

2
   <div class="modal-wrapper" v-show="show">
2
   <div class="modal-wrapper" v-show="show">
3
     <div class="modal" :style="modalStyle" @click.stop="handleMaskClick">
3
     <div class="modal" :style="modalStyle" @click.stop="handleMaskClick">
4
       <fire-flies v-if="showFireflies"></fire-flies>
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
         <img src="~@/assets/buttonImg/backImg.png" alt="">
6
         <img src="~@/assets/buttonImg/backImg.png" alt="">
7
       </div>
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
       <div class="modal-body"><slot></slot></div>
12
       <div class="modal-body"><slot></slot></div>
9
-      <slot name="action"></slot>
13
+
10
     </div>
14
     </div>
11
 
15
 
12
   </div>
16
   </div>
32
     showFireflies: {
36
     showFireflies: {
33
       type: Boolean,
37
       type: Boolean,
34
       default: true
38
       default: true
35
-    }
39
+    },
40
+    showShare: Boolean
36
   },
41
   },
37
   computed: {
42
   computed: {
38
     modalStyle() {
43
     modalStyle() {
68
     justify-content: center;
73
     justify-content: center;
69
     align-items: center;
74
     align-items: center;
70
 
75
 
71
-    .back-btn {
76
+    .modal-action {
72
       position: absolute;
77
       position: absolute;
78
+      z-index: 50;
79
+    }
80
+
81
+    .back-btn {
73
       top: 4em;
82
       top: 4em;
74
       left: 1.5em;
83
       left: 1.5em;
75
       width: 4em;
84
       width: 4em;
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
     .modal-body {
101
     .modal-body {
83
       position: relative;
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
 <template>
1
 <template>
2
   <div class="index-box">
2
   <div class="index-box">
3
-    <modal :show="true" :show-back="true" >      
4
-    </modal>
5
     <bg-music />
3
     <bg-music />
6
     <popup
4
     <popup
7
       :show="showPopup"
5
       :show="showPopup"