Commit 95262d378acc11c4907606d5b76e042d59129c04
Merge remote-tracking branch 'origin/master'
Showing
3 changed files
with
36 additions
and
4 deletions
lottery.html
... | ... | @@ -50,7 +50,9 @@ |
50 | 50 | .result {width: 100%;height: 1120px;box-sizing: border-box;padding: 290px 90px 0;background: url('./img/pc/result_bg.png') no-repeat;background-size: 100% 100%;} |
51 | 51 | .result-title {text-align: center;font-size: 60px;color: #DC4834;margin-bottom: 22px;} |
52 | 52 | .result-main-header, .result-item {display: flex;align-items: center;text-align: center;font-size: 40px;color: #DC4834;} |
53 | - .result-item {margin-top: 11px;} | |
53 | + .result-list {margin-top: 10px;height: 600px;padding: 6px 0; overflow-y: auto;-ms-overflow-style: none;} | |
54 | + .result-list::-webkit-scrollbar {width: 0 !important;} | |
55 | + .result-item:not(:last-of-type) {margin-bottom: 11px;} | |
54 | 56 | .result-cell {flex: 2;-webkit-flex: 2;} |
55 | 57 | .result-cell-del {flex: 1;-webkit-flex: 1;display: flex;justify-content: center;align-items: center;} |
56 | 58 | .fw-500 {font-weight: 500;} |
... | ... | @@ -113,7 +115,7 @@ |
113 | 115 | </div> |
114 | 116 | <div class="lottery-btn start-btn" onclick="action.start()">开始抽奖</div> |
115 | 117 | <div class="lottery-btn stop-btn hide" onclick="action.stop()">暂停</div> |
116 | - <div class="lottery-btn continue-btn hide" onclick="action.togglePage(true)">继续抽奖</div> | |
118 | + <div class="lottery-btn continue-btn hide" onclick="action.continueLottery()">继续抽奖</div> | |
117 | 119 | </div> |
118 | 120 | <div class="main-right"> |
119 | 121 | <div class="result"> | ... | ... |
lottery.js
... | ... | @@ -12,6 +12,7 @@ let action = { |
12 | 12 | curPrizeIndex: -1, // 正在抽奖的奖项的索引 |
13 | 13 | userList: [], // 抽奖用户列表 |
14 | 14 | currentUser: null, // 当前中奖的用户 |
15 | + curUserIndex: -1, // 当前中奖的用户索引 | |
15 | 16 | winnerList: [], // 中奖用户列表 |
16 | 17 | // 初始化数据 |
17 | 18 | init: function() { |
... | ... | @@ -157,6 +158,26 @@ let action = { |
157 | 158 | }, interval); |
158 | 159 | return timer; |
159 | 160 | }, |
161 | + continueLottery: function() { | |
162 | + action.userList.splice(action.curUserIndex, 1); | |
163 | + | |
164 | + // 初始化头像部分 | |
165 | + $('.avatar-img, .user-info .scroll-wrap').show(); | |
166 | + $('.winner, .winner-name, .winner-no').hide(); | |
167 | + // 初始化按钮 | |
168 | + $('.stop-btn').show(); | |
169 | + $('.continue-btn, .start-btn').hide(); | |
170 | + | |
171 | + if (action.userList.length === 0) { | |
172 | + alert('暂无数据'); | |
173 | + return; | |
174 | + } | |
175 | + | |
176 | + // 开始抽奖动画 | |
177 | + imgTimer = this.lotteryAnimation($('.avatar-list'), '.avatar-item', 244); | |
178 | + nameTimer = this.lotteryAnimation($('.user-name .scroll-list'), '.scroll-item', 146); | |
179 | + prizeNoTimer = this.lotteryAnimation($('.user-no .scroll-list'), '.scroll-item', 146); | |
180 | + }, | |
160 | 181 | // 停止 |
161 | 182 | stop: function() { |
162 | 183 | // 按钮效果 |
... | ... | @@ -173,6 +194,7 @@ let action = { |
173 | 194 | let random = Math.floor(Math.random() * (action.userList.length - 1 + 1)); // (0 ~ length-1) |
174 | 195 | console.log('random: ', random); |
175 | 196 | action.currentUser = action.userList[random]; |
197 | + action.curUserIndex = random; | |
176 | 198 | // 保存中奖记录 |
177 | 199 | action.saveLottery(); |
178 | 200 | action.winnerList.push(action.currentUser); |
... | ... | @@ -217,8 +239,14 @@ let action = { |
217 | 239 | }, |
218 | 240 | // 删除中奖用户 |
219 | 241 | delWinner: function(index) { |
220 | - this.winnerList.splice(index, 1); | |
221 | - this.updateResultTmpl(); | |
242 | + var url = '/apicp.DelLottery.php'; | |
243 | + var data = { | |
244 | + id: action.winnerList[index].id | |
245 | + }; | |
246 | + var callback = function() { | |
247 | + action.getWinnerList(action.prizeList[action.curPrizeIndex].id); | |
248 | + }; | |
249 | + baseRquest.post(url, data, callback); | |
222 | 250 | } |
223 | 251 | } |
224 | 252 | // 系统设置动作 | ... | ... |