Browse Source

Merge branch 'master' of http://git.ycjcjy.com/honghe/h5-draw-lots

Baozhangchao 3 years ago
parent
commit
309fb6a33a

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

5
   });
5
   });
6
 }
6
 }
7
 
7
 
8
+var resize = null;
9
+
8
 Animation.prototype.init = function (canvas) {
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
   resize();
16
   resize();
26
   return function () {
28
   return function () {
27
     console.log('------cancelAnimationFrame----123')
29
     console.log('------cancelAnimationFrame----123')
28
     cancelAnimationFrame(reqId);
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
 <template>
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
 </template>
12
 </template>
4
 
13
 
5
 <script>
14
 <script>
6
-import Animation from "./fireflies"
7
-
8
 export default {
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
 </script>
18
 </script>
39
 
19
 
40
 <style lang="less" scoped>
20
 <style lang="less" scoped>
41
-.fireflies {
21
+.fireflies-box {
42
   width: 100%;
22
   width: 100%;
43
   height: 100%;
23
   height: 100%;
44
   background: transparent;
24
   background: transparent;
46
   position: absolute;
26
   position: absolute;
47
   top: 0;
27
   top: 0;
48
   left: 0;
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
 </style>
150
 </style>

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

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

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

7
 import { getUserInfo } from '../utils/wx'
7
 import { getUserInfo } from '../utils/wx'
8
 import { login } from '../services/person'
8
 import { login } from '../services/person'
9
 import { setToken } from '../utils/token'
9
 import { setToken } from '../utils/token'
10
+import { redirect } from '../utils/wx'
10
 
11
 
11
 Vue.use(Router)
12
 Vue.use(Router)
12
 
13
 
42
         setPerson(user)
43
         setPerson(user)
43
         setToken(token)
44
         setToken(token)
44
       })
45
       })
46
+    }).catch(() => {
47
+      redirect(true)
45
     })
48
     })
46
   }
49
   }
47
 
50
 

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

64
 /**
64
 /**
65
  * 跳转授权页面
65
  * 跳转授权页面
66
  */
66
  */
67
-export function redirect () {
67
+export function redirect (force) {
68
   if (process.env.NODE_ENV === 'development') return;
68
   if (process.env.NODE_ENV === 'development') return;
69
 
69
 
70
   const originCode = localStorage.getItem('wxcode');
70
   const originCode = localStorage.getItem('wxcode');
71
   const queryCode = getCode();
71
   const queryCode = getCode();
72
   localStorage.setItem('wxcode', queryCode)
72
   localStorage.setItem('wxcode', queryCode)
73
 
73
 
74
-  if (!queryCode || queryCode === originCode) {
74
+  if (!queryCode || queryCode === originCode || force) {
75
     const local = encodeURIComponent(location.origin + location.pathname)
75
     const local = encodeURIComponent(location.origin + location.pathname)
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`
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
     window.location.href = url
77
     window.location.href = url