Commit 10edc5c487c7809889a2a55093600416a5f8e31d
1 parent
8de94f1a
[年会抽奖]抽奖逻辑调整
Showing
4 changed files
with
15 additions
and
10 deletions
barrage.html
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | <script src="./js/danmaku.min.js"></script> |
20 | 20 | <script src="//cdn.bootcss.com/socket.io/2.0.3/socket.io.js"></script> |
21 | 21 | <script> |
22 | - var socketUrl = '//106.54.64.163:3000'; | |
22 | + var socketUrl = '//localhost:3000'; | |
23 | 23 | var colors = ['#FFD590', '#DE452D', '#FFFFFF']; |
24 | 24 | var danmaku = new Danmaku(); |
25 | 25 | danmaku.init({ |
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 | socket.on('barrage', function(msg) { |
30 | 30 | console.log('socket.on: ', msg); |
31 | 31 | var colorIndex = Math.floor(Math.random() * (2 - 0 + 1)); // 生成 0-2 随机数 |
32 | - var topNum = Math.floor(Math.random() * (13 - 1 + 1) + 1); // 生成 1-13 随机数 | |
32 | + var topNum = Math.floor(Math.random() * (10 - 1 + 1) + 1); // 生成 1-10 随机数 | |
33 | 33 | |
34 | 34 | var comment = { |
35 | 35 | text: msg, |
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | fontSize: '35px', |
38 | 38 | fontWeight: '500', |
39 | 39 | color: colors[colorIndex], |
40 | - top: topNum * 35 + 'px' | |
40 | + top: topNum * 50 + 'px' | |
41 | 41 | }, |
42 | 42 | speed: 144 |
43 | 43 | }; | ... | ... |
lottery.js
... | ... | @@ -164,8 +164,9 @@ let action = { |
164 | 164 | }, interval); |
165 | 165 | return timer; |
166 | 166 | }, |
167 | + // 继续抽奖 | |
167 | 168 | continueLottery: function() { |
168 | - action.userList.splice(action.curUserIndex, 1); | |
169 | + // action.userList.splice(action.curUserIndex, 1); | |
169 | 170 | if (action.userList.length === 0) { |
170 | 171 | alert('暂无数据'); |
171 | 172 | return; |
... | ... | @@ -224,6 +225,8 @@ let action = { |
224 | 225 | |
225 | 226 | // 更新中奖名单模板 |
226 | 227 | action.updateResultTmpl(); |
228 | + // 获取抽奖用户列表 | |
229 | + action.getUserList(); | |
227 | 230 | }, |
228 | 231 | // 更新中奖名单模板 |
229 | 232 | updateResultTmpl: function() { | ... | ... |
mobile.html
... | ... | @@ -28,6 +28,7 @@ |
28 | 28 | img {display: block;} |
29 | 29 | input {outline: none;border: none;-webkit-appearance: none;appearance: none;} |
30 | 30 | .wrap {position: relative;width: 100%;min-height: 100%;box-sizing: border-box;} |
31 | + .sign-in, .pic, .home, .seat {user-select: none;-webkit-user-select: none;-moz-user-select: none;} | |
31 | 32 | .common-btn {position: relative;width: 5.9rem;height: 1.08rem;margin: 0 auto;} |
32 | 33 | .common-btn:not(:first-of-type) {margin-top: .4rem;} |
33 | 34 | .common-btn-bg {display: inline-block;width: 6.82rem;margin-left: -.46rem;margin-top: -.5rem;} |
... | ... | @@ -158,7 +159,8 @@ |
158 | 159 | <!-- 自拍出境 --> |
159 | 160 | <div class="common-btn"> |
160 | 161 | <img class="common-btn-bg" src="./img/mobile/pic_btn1.png"> |
161 | - <div class="common-btn-inner" onclick="action.openCamera(1)"></div> | |
162 | + <!-- <div class="common-btn-inner" onclick="action.openCamera(1)"></div> --> | |
163 | + <div class="common-btn-inner" onclick="action.goHome()"></div> | |
162 | 164 | </div> |
163 | 165 | <div class="pic-btn-album" onclick="action.openCamera(2)"> |
164 | 166 | <span class="album-text">还是相册选一张吧</span> | ... | ... |
server.js
... | ... | @@ -51,16 +51,16 @@ io.on('connection', function(socket) { |
51 | 51 | // 过滤 xss |
52 | 52 | // var msg = xss(msg); |
53 | 53 | io.emit('barrage', msg); |
54 | - clearTimeout(timer); | |
54 | + clearInterval(timer); | |
55 | + timer = setInterval(function() { | |
56 | + var msg = defaultMsgs[Math.floor(Math.random() * (19 - 0 + 1))]; | |
57 | + io.emit('barrage', msg); | |
58 | + }, 20000); | |
55 | 59 | }); |
56 | 60 | |
57 | 61 | // 断开连接 |
58 | 62 | socket.on('disconnect', function() { |
59 | 63 | console.log('user disconnected'); |
60 | - timer = setTimeout(function() { | |
61 | - var msg = defaultMsgs[Math.floor(Math.random() * (19 - 0 + 1))]; | |
62 | - io.emit('barrage', msg); | |
63 | - }, 15000); | |
64 | 64 | }); |
65 | 65 | }); |
66 | 66 | ... | ... |