张延森 3 years ago
parent
commit
2db2de8247

+ 9
- 3
src/components/FireFlies/fireflies.js View File

@@ -5,10 +5,12 @@ function Animation(selector, option) {
5 5
   });
6 6
 }
7 7
 
8
+var resize = null;
9
+
8 10
 Animation.prototype.init = function (canvas) {
9
-  var resize = function () {
10
-    canvas.width = window.innerWidth;
11
-    canvas.height = window.innerHeight;
11
+  resize = function () {
12
+    canvas.width = canvas.clientWidth;
13
+    canvas.height = canvas.clientHeight;
12 14
   }
13 15
 
14 16
   resize();
@@ -26,6 +28,10 @@ Animation.prototype.draw = function () {
26 28
   return function () {
27 29
     console.log('------cancelAnimationFrame----123')
28 30
     cancelAnimationFrame(reqId);
31
+    // window.removeEventListener('resize', resize);
32
+    // resize = null;
33
+    this.canvas = null;
34
+    this.fireflies = null;
29 35
   }
30 36
 }
31 37
 

+ 132
- 32
src/components/FireFlies/index.vue View File

@@ -1,44 +1,24 @@
1 1
 <template>
2
-  <canvas class="fireflies"></canvas>
2
+  <div class="fireflies-box">
3
+    <div class="fireflies">
4
+      <div class="firefly"></div>
5
+      <div class="firefly"></div>
6
+      <div class="firefly"></div>
7
+      <div class="firefly"></div>
8
+      <div class="firefly"></div>
9
+      <div class="firefly"></div>
10
+    </div>
11
+  </div>
3 12
 </template>
4 13
 
5 14
 <script>
6
-import Animation from "./fireflies"
7
-
8 15
 export default {
9
-  name: 'FireFlies',
10
-  data() {
11
-    return {
12
-      animation: undefined,
13
-      deAnimation: undefined,
14
-    }
15
-  },
16
-  mounted() {
17
-    this.$nextTick(() => {
18
-      this.animation = new Animation(this.$el, {
19
-        count: 20,
20
-        color: 'rgba(236, 196, 94, 1)',
21
-        speed: 0.7,
22
-        radius: 3
23
-      })
24
-      const cancelDraw = this.animation.draw();
25
-
26
-      this.deAnimation = () => {
27
-        cancelDraw();
28
-        this.animation = undefined;
29
-      }
30
-    })
31
-  },
32
-  beforeDestroy() {
33
-    if (this.deAnimation) {
34
-      this.deAnimation()
35
-    }
36
-  }
16
+  name: 'FireFlies'
37 17
 }
38 18
 </script>
39 19
 
40 20
 <style lang="less" scoped>
41
-.fireflies {
21
+.fireflies-box {
42 22
   width: 100%;
43 23
   height: 100%;
44 24
   background: transparent;
@@ -46,5 +26,125 @@ export default {
46 26
   position: absolute;
47 27
   top: 0;
48 28
   left: 0;
29
+
30
+  .fireflies {
31
+    position: relative;
32
+    width: 100%;
33
+    height: 100%;
34
+    .firefly {
35
+      position:absolute;
36
+      top:50%;
37
+      left:50%;
38
+      width:0.3em;
39
+      height:0.3em;
40
+      background-color:rgb(255, 244, 48);
41
+      border-radius:50%;
42
+      box-shadow:0 0 1.4em rgb(200, 244, 66);
43
+    }
44
+
45
+    .fly1 {
46
+      animation: flight1 7s ease-in-out alternate infinite;
47
+    }
48
+    .fly2 {
49
+      animation: flight2 9s ease-in-out alternate infinite;
50
+    }
51
+    .fly3 {
52
+      animation: flight3 8s ease-in-out alternate infinite;
53
+    }
54
+    .fly4 {
55
+      animation: flight4 8s ease-in-out alternate infinite;
56
+    }
57
+    .fly5 {
58
+      animation: flight5 6s ease-in-out alternate infinite;
59
+    }
60
+    .fly6 {
61
+      animation:flight6 9s ease-in-out alternate infinite;
62
+    }
63
+  }
64
+
65
+  @keyframes shake {
66
+    0% { 
67
+      opacity: 0.1;
68
+    }
69
+    30% {
70
+      opacity: 1;
71
+      width: 0.5em;
72
+      height: 0.5em;
73
+    }
74
+    70% {
75
+      opacity: 0.7;
76
+      width: 0.4em;
77
+      height: 0.4em;
78
+    }
79
+    100% {
80
+      opacity: 0;
81
+    }
82
+  }
83
+
84
+  @keyframes flight1 {
85
+    0% { 
86
+      top: 50%;
87
+      left: 50%;
88
+      opacity: 0.1;
89
+    }
90
+    10% {
91
+      top: 40%;
92
+      left: 40%;
93
+      opacity:0.5;
94
+      width:0.4em;
95
+      height:0.4em;
96
+    }
97
+    20% {
98
+      top: 32%;
99
+      left: 35%;
100
+      opacity: 1;
101
+    }
102
+    30% {
103
+      top: 25%;
104
+      left: 25%;
105
+      opacity:1;
106
+      width:0.1em;
107
+      height:0.1em;
108
+    }
109
+    40% {
110
+      top: 20%;
111
+      left: 20%;
112
+      opacity: 1;
113
+    }
114
+    60% {
115
+      top: 25%;
116
+      left: 16%;
117
+      opacity: 0.5;
118
+      width:0.4em;
119
+      height:0.4em;
120
+    }
121
+    70% {
122
+      top: 10%;
123
+      left: 10%;
124
+      opacity:0.1;
125
+      width:0.3em;
126
+      height:0.3em;
127
+    }
128
+    100% {
129
+      top:5%;
130
+      left:5%;
131
+      opacity:0;
132
+    }
133
+  }
134
+  @keyframes flight2 {
135
+    
136
+  }
137
+  @keyframes flight3 {
138
+    
139
+  }
140
+  @keyframes flight4 {
141
+    
142
+  }
143
+  @keyframes flight5 {
144
+    
145
+  }
146
+  @keyframes flight6 {
147
+    
148
+  }
49 149
 }
50 150
 </style>

+ 51
- 0
src/components/FireFlies/index2.vue View File

@@ -0,0 +1,51 @@
1
+<template>
2
+  <canvas class="fireflies"></canvas>
3
+</template>
4
+
5
+<script>
6
+import Animation from "./fireflies"
7
+
8
+export default {
9
+  name: 'FireFlies',
10
+  data() {
11
+    return {
12
+      animation: undefined,
13
+      deAnimation: undefined,
14
+    }
15
+  },
16
+  mounted() {
17
+    this.$nextTick(() => {
18
+      this.animation = new Animation(this.$el, {
19
+        count: 10,
20
+        color: 'rgba(236, 196, 94, 1)',
21
+        speed: 0.6,
22
+        radius: 3
23
+      })
24
+      const cancelDraw = this.animation.draw();
25
+
26
+      this.deAnimation = () => {
27
+        cancelDraw();
28
+        this.$el = null;
29
+        this.animation = null;
30
+      }
31
+    })
32
+  },
33
+  beforeDestroy() {
34
+    if (this.deAnimation) {
35
+      this.deAnimation()
36
+    }
37
+  }
38
+}
39
+</script>
40
+
41
+<style lang="less" scoped>
42
+.fireflies {
43
+  width: 100%;
44
+  height: 100%;
45
+  background: transparent;
46
+
47
+  position: absolute;
48
+  top: 0;
49
+  left: 0;
50
+}
51
+</style>

+ 1
- 1
src/pages/Honghe.vue View File

@@ -214,7 +214,7 @@ export default {
214 214
     share({ title: '抽取幸运签,解锁隐藏福利', desc: '每月都有欢乐发生' })
215 215
   },
216 216
   watch: {
217
-    showMyWinning(newValue, oldValue) {
217
+    binggo(newValue, oldValue) {
218 218
       // 微信分享
219 219
       // 1、正常情况下, 分享主题是 抽取幸运签,解锁隐藏福利
220 220
       // 2、中奖弹出情况下, 分享主题是 我中奖啦! 来试试你的运气吧

+ 3
- 1
src/router/index.js View File

@@ -3,11 +3,11 @@
3 3
 import Vue from 'vue'
4 4
 import Router from 'vue-router'
5 5
 import Honghe from '../pages/Honghe.vue'
6
-import SaveShare from '../pages/SaveShare.vue'
7 6
 import { useModel } from '../store'
8 7
 import { getUserInfo } from '../utils/wx'
9 8
 import { login } from '../services/person'
10 9
 import { setToken } from '../utils/token'
10
+import { redirect } from '../utils/wx'
11 11
 
12 12
 Vue.use(Router)
13 13
 
@@ -42,6 +42,8 @@ router.beforeEach((to, from, next) => {
42 42
         setPerson(user)
43 43
         setToken(token)
44 44
       })
45
+    }).catch(() => {
46
+      redirect(true)
45 47
     })
46 48
   }
47 49
 

+ 2
- 2
src/utils/wx.js View File

@@ -64,14 +64,14 @@ function getCode () {
64 64
 /**
65 65
  * 跳转授权页面
66 66
  */
67
-export function redirect () {
67
+export function redirect (force) {
68 68
   if (process.env.NODE_ENV === 'development') return;
69 69
 
70 70
   const originCode = localStorage.getItem('wxcode');
71 71
   const queryCode = getCode();
72 72
   localStorage.setItem('wxcode', queryCode)
73 73
 
74
-  if (!queryCode || queryCode === originCode) {
74
+  if (!queryCode || queryCode === originCode || force) {
75 75
     const local = encodeURIComponent(location.origin + location.pathname)
76 76
     const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd3bab568bc42d1de&redirect_uri=${local}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect`
77 77
     window.location.href = url