init
Showing
14 changed files
with
249 additions
and
69 deletions
This diff could not be displayed because it is too large.
No preview for this file type
| ... | @@ -8,7 +8,7 @@ | ... | @@ -8,7 +8,7 @@ |
| 8 | <link | 8 | <link |
| 9 | rel="stylesheet" | 9 | rel="stylesheet" |
| 10 | href="https://at.alicdn.com/t/font_1594571_5oi8u1hs5fy.css"/> | 10 | href="https://at.alicdn.com/t/font_1594571_5oi8u1hs5fy.css"/> |
| 11 | <title>luckydraw</title> | 11 | <title>赤金科技-年会抽奖</title> |
| 12 | </head> | 12 | </head> |
| 13 | <body> | 13 | <body> |
| 14 | <noscript> | 14 | <noscript> | ... | ... |
| 1 | <template> | 1 | <template> |
| 2 | <div class="rootWrapper"> | ||
| 3 | <img class="bgImg" alt="" src="./assets/bg.png" /> | ||
| 2 | <div id="root"> | 4 | <div id="root"> |
| 3 | <header> | 5 | <header> |
| 4 | <Publicity v-show="!running" /> | 6 | <Publicity v-show="!running && !autoRunning" /> |
| 5 | <el-button class="res" type="text" @click="showResult = true"> | 7 | <el-button class="res" type="text" @click="showResult = true"> |
| 6 | 抽奖结果 | 8 | 抽奖结果 |
| 7 | </el-button> | 9 | </el-button> |
| ... | @@ -17,11 +19,18 @@ | ... | @@ -17,11 +19,18 @@ |
| 17 | href="javascript:void(0);" | 19 | href="javascript:void(0);" |
| 18 | :style="{ | 20 | :style="{ |
| 19 | color: | 21 | color: |
| 20 | !running && allresult.includes(item.key) ? '#ff2200' : '#fff' | 22 | !autoRunning && !running && allresult.includes(item.key) |
| 23 | ? '#fff' | ||
| 24 | : '#fff' | ||
| 21 | }" | 25 | }" |
| 22 | > | 26 | > |
| 23 | {{ item.name ? item.name : item.key }} | 27 | {{ item.name ? item.name : item.key }} |
| 24 | <img v-if="item.photo" :src="item.photo" :width="50" :height="50" /> | 28 | <img |
| 29 | v-if="item.photo" | ||
| 30 | :src="item.photo" | ||
| 31 | :width="50" | ||
| 32 | :height="50" | ||
| 33 | /> | ||
| 25 | </a> | 34 | </a> |
| 26 | </li> | 35 | </li> |
| 27 | </ul> | 36 | </ul> |
| ... | @@ -35,7 +44,7 @@ | ... | @@ -35,7 +44,7 @@ |
| 35 | :key="item" | 44 | :key="item" |
| 36 | class="itemres" | 45 | class="itemres" |
| 37 | :style="resCardStyle" | 46 | :style="resCardStyle" |
| 38 | :data-id="item" | 47 | :data-id="list.find(d => d.key === item).name" |
| 39 | @click="showRes = false" | 48 | @click="showRes = false" |
| 40 | :class="{ | 49 | :class="{ |
| 41 | numberOver: | 50 | numberOver: |
| ... | @@ -61,7 +70,6 @@ | ... | @@ -61,7 +70,6 @@ |
| 61 | :src="photos.find(d => d.id === item).value" | 70 | :src="photos.find(d => d.id === item).value" |
| 62 | alt="photo" | 71 | alt="photo" |
| 63 | :width="160" | 72 | :width="160" |
| 64 | :height="160" | ||
| 65 | /> | 73 | /> |
| 66 | </span> | 74 | </span> |
| 67 | </div> | 75 | </div> |
| ... | @@ -83,20 +91,20 @@ | ... | @@ -83,20 +91,20 @@ |
| 83 | ></i> | 91 | ></i> |
| 84 | </el-button> | 92 | </el-button> |
| 85 | 93 | ||
| 86 | <LotteryConfig :visible.sync="showConfig" @resetconfig="reloadTagCanvas" /> | 94 | <LotteryConfig |
| 95 | :visible.sync="showConfig" | ||
| 96 | @resetconfig="reloadTagCanvas" | ||
| 97 | /> | ||
| 87 | <Tool | 98 | <Tool |
| 88 | @toggle="toggle" | 99 | @toggle="toggle" |
| 89 | @resetConfig="reloadTagCanvas" | 100 | @resetConfig="reloadTagCanvas" |
| 90 | @getPhoto="getPhoto" | 101 | @getPhoto="getPhoto" |
| 91 | :running="running" | 102 | :running="running" |
| 103 | :autoRunning="autoRunning" | ||
| 92 | :closeRes="closeRes" | 104 | :closeRes="closeRes" |
| 93 | /> | 105 | /> |
| 94 | <Result :visible.sync="showResult"></Result> | 106 | <Result :visible.sync="showResult"></Result> |
| 95 | 107 | ||
| 96 | <span class="copy-right"> | ||
| 97 | Copyright©zhangyongfeng5350@gmail.com | ||
| 98 | </span> | ||
| 99 | |||
| 100 | <audio | 108 | <audio |
| 101 | id="audiobg" | 109 | id="audiobg" |
| 102 | preload="auto" | 110 | preload="auto" |
| ... | @@ -110,6 +118,7 @@ | ... | @@ -110,6 +118,7 @@ |
| 110 | 你的浏览器不支持audio标签 | 118 | 你的浏览器不支持audio标签 |
| 111 | </audio> | 119 | </audio> |
| 112 | </div> | 120 | </div> |
| 121 | </div> | ||
| 113 | </template> | 122 | </template> |
| 114 | <script> | 123 | <script> |
| 115 | import LotteryConfig from '@/components/LotteryConfig'; | 124 | import LotteryConfig from '@/components/LotteryConfig'; |
| ... | @@ -170,6 +179,15 @@ export default { | ... | @@ -170,6 +179,15 @@ export default { |
| 170 | allresult = allresult.concat(element); | 179 | allresult = allresult.concat(element); |
| 171 | } | 180 | } |
| 172 | } | 181 | } |
| 182 | |||
| 183 | let times = Math.floor(allresult.length / this.config.number); | ||
| 184 | |||
| 185 | for (let i = 0; i < times; i++) { | ||
| 186 | for (let j = 0; j < this.list.length; j++) { | ||
| 187 | allresult.splice(allresult.indexOf(this.list[j].key), 1); | ||
| 188 | } | ||
| 189 | } | ||
| 190 | |||
| 173 | return allresult; | 191 | return allresult; |
| 174 | }, | 192 | }, |
| 175 | datas() { | 193 | datas() { |
| ... | @@ -222,6 +240,7 @@ export default { | ... | @@ -222,6 +240,7 @@ export default { |
| 222 | 240 | ||
| 223 | data() { | 241 | data() { |
| 224 | return { | 242 | return { |
| 243 | autoRunning: false, | ||
| 225 | running: false, | 244 | running: false, |
| 226 | showRes: false, | 245 | showRes: false, |
| 227 | showConfig: false, | 246 | showConfig: false, |
| ... | @@ -303,8 +322,59 @@ export default { | ... | @@ -303,8 +322,59 @@ export default { |
| 303 | closeRes() { | 322 | closeRes() { |
| 304 | this.showRes = false; | 323 | this.showRes = false; |
| 305 | }, | 324 | }, |
| 306 | toggle(form) { | 325 | toggle(form, auto) { |
| 307 | const { speed, config } = this; | 326 | const { speed, config } = this; |
| 327 | |||
| 328 | if (auto) { | ||
| 329 | if (this.autoRunning) { | ||
| 330 | this.audioSrc = bgaudio; | ||
| 331 | this.loadAudio(); | ||
| 332 | |||
| 333 | window.TagCanvas.SetSpeed('rootcanvas', speed()); | ||
| 334 | this.showRes = true; | ||
| 335 | this.autoRunning = !this.autoRunning; | ||
| 336 | this.$nextTick(() => { | ||
| 337 | this.reloadTagCanvas(); | ||
| 338 | }); | ||
| 339 | } else { | ||
| 340 | this.showRes = false; | ||
| 341 | if (!form) { | ||
| 342 | return; | ||
| 343 | } | ||
| 344 | |||
| 345 | this.audioSrc = beginaudio; | ||
| 346 | this.loadAudio(); | ||
| 347 | |||
| 348 | const { number } = config; | ||
| 349 | const { category, mode, qty, remain, allin } = form; | ||
| 350 | let num = 1; | ||
| 351 | if (mode === 1 || mode === 5) { | ||
| 352 | num = mode; | ||
| 353 | } else if (mode === 0) { | ||
| 354 | num = remain; | ||
| 355 | } else if (mode === 99) { | ||
| 356 | num = qty; | ||
| 357 | } | ||
| 358 | const resArr = luckydrawHandler( | ||
| 359 | number, | ||
| 360 | allin ? [] : this.allresult, | ||
| 361 | num | ||
| 362 | ); | ||
| 363 | this.resArr = resArr; | ||
| 364 | |||
| 365 | this.category = category; | ||
| 366 | if (!this.result[category]) { | ||
| 367 | this.$set(this.result, category, []); | ||
| 368 | } | ||
| 369 | const oldRes = this.result[category] || []; | ||
| 370 | const data = Object.assign({}, this.result, { | ||
| 371 | [category]: oldRes.concat(resArr) | ||
| 372 | }); | ||
| 373 | this.result = data; | ||
| 374 | window.TagCanvas.SetSpeed('rootcanvas', [5, 1]); | ||
| 375 | this.autoRunning = !this.autoRunning; | ||
| 376 | } | ||
| 377 | } else { | ||
| 308 | if (this.running) { | 378 | if (this.running) { |
| 309 | this.audioSrc = bgaudio; | 379 | this.audioSrc = bgaudio; |
| 310 | this.loadAudio(); | 380 | this.loadAudio(); |
| ... | @@ -355,17 +425,26 @@ export default { | ... | @@ -355,17 +425,26 @@ export default { |
| 355 | } | 425 | } |
| 356 | } | 426 | } |
| 357 | } | 427 | } |
| 428 | } | ||
| 358 | }; | 429 | }; |
| 359 | </script> | 430 | </script> |
| 360 | <style lang="scss"> | 431 | <style lang="scss"> |
| 432 | .rootWrapper { | ||
| 433 | height: 100%; | ||
| 434 | position: relative; | ||
| 435 | background-color: #b51c23; | ||
| 436 | .bgImg { | ||
| 437 | width: 100%; | ||
| 438 | position: absolute; | ||
| 439 | top: 40px; | ||
| 440 | left: 0; | ||
| 441 | z-index: 1; | ||
| 442 | } | ||
| 443 | } | ||
| 361 | #root { | 444 | #root { |
| 362 | height: 100%; | 445 | height: 100%; |
| 363 | position: relative; | 446 | position: relative; |
| 364 | background-image: url('./assets/bg1.jpg'); | 447 | z-index: 2; |
| 365 | background-size: 100% 100%; | ||
| 366 | background-position: center center; | ||
| 367 | background-repeat: no-repeat; | ||
| 368 | background-color: #121936; | ||
| 369 | .mask { | 448 | .mask { |
| 370 | -webkit-filter: blur(5px); | 449 | -webkit-filter: blur(5px); |
| 371 | filter: blur(5px); | 450 | filter: blur(5px); |
| ... | @@ -379,6 +458,11 @@ export default { | ... | @@ -379,6 +458,11 @@ export default { |
| 379 | top: 17px; | 458 | top: 17px; |
| 380 | padding: 0; | 459 | padding: 0; |
| 381 | z-index: 9999; | 460 | z-index: 9999; |
| 461 | color: #f1d192; | ||
| 462 | opacity: 0; | ||
| 463 | &:hover { | ||
| 464 | opacity: 0.3; | ||
| 465 | } | ||
| 382 | &.con { | 466 | &.con { |
| 383 | right: 20px; | 467 | right: 20px; |
| 384 | } | 468 | } |
| ... | @@ -388,9 +472,13 @@ export default { | ... | @@ -388,9 +472,13 @@ export default { |
| 388 | } | 472 | } |
| 389 | } | 473 | } |
| 390 | .audio { | 474 | .audio { |
| 475 | opacity: 0; | ||
| 476 | &:hover { | ||
| 477 | opacity: 0.3; | ||
| 478 | } | ||
| 391 | position: absolute; | 479 | position: absolute; |
| 392 | top: 100px; | 480 | top: 150px; |
| 393 | right: 30px; | 481 | right: 50px; |
| 394 | width: 40px; | 482 | width: 40px; |
| 395 | height: 40px; | 483 | height: 40px; |
| 396 | line-height: 40px; | 484 | line-height: 40px; |
| ... | @@ -419,19 +507,20 @@ export default { | ... | @@ -419,19 +507,20 @@ export default { |
| 419 | } | 507 | } |
| 420 | #main { | 508 | #main { |
| 421 | height: 100%; | 509 | height: 100%; |
| 510 | margin-top: 40px; | ||
| 422 | } | 511 | } |
| 423 | 512 | ||
| 424 | #resbox { | 513 | #resbox { |
| 425 | position: absolute; | 514 | position: absolute; |
| 426 | top: 50%; | 515 | top: calc(50% + 90px); |
| 427 | left: 50%; | 516 | left: 50%; |
| 428 | width: 1280px; | 517 | width: 1280px; |
| 429 | transform: translateX(-50%) translateY(-50%); | 518 | transform: translateX(-50%) translateY(-50%); |
| 430 | text-align: center; | 519 | text-align: center; |
| 431 | p { | 520 | p { |
| 432 | color: red; | 521 | color: #fff; |
| 433 | font-size: 50px; | 522 | font-size: 40px; |
| 434 | line-height: 120px; | 523 | line-height: 60px; |
| 435 | } | 524 | } |
| 436 | .container { | 525 | .container { |
| 437 | display: flex; | 526 | display: flex; |
| ... | @@ -442,6 +531,7 @@ export default { | ... | @@ -442,6 +531,7 @@ export default { |
| 442 | background: #fff; | 531 | background: #fff; |
| 443 | width: 160px; | 532 | width: 160px; |
| 444 | height: 160px; | 533 | height: 160px; |
| 534 | overflow: hidden; | ||
| 445 | border-radius: 4px; | 535 | border-radius: 4px; |
| 446 | border: 1px solid #ccc; | 536 | border: 1px solid #ccc; |
| 447 | line-height: 160px; | 537 | line-height: 160px; | ... | ... |
src/assets/bg.png
0 → 100644
689 KB
| ... | @@ -2379,7 +2379,7 @@ | ... | @@ -2379,7 +2379,7 @@ |
| 2379 | shadowOffset: [0, 0], | 2379 | shadowOffset: [0, 0], |
| 2380 | initial: null, | 2380 | initial: null, |
| 2381 | hideTags: true, | 2381 | hideTags: true, |
| 2382 | zoom: 1, | 2382 | zoom: 0.7, |
| 2383 | weight: false, | 2383 | weight: false, |
| 2384 | weightMode: "size", | 2384 | weightMode: "size", |
| 2385 | weightFrom: null, | 2385 | weightFrom: null, |
| ... | @@ -2395,7 +2395,7 @@ | ... | @@ -2395,7 +2395,7 @@ |
| 2395 | txtOpt: true, | 2395 | txtOpt: true, |
| 2396 | txtScale: 2, | 2396 | txtScale: 2, |
| 2397 | frontSelect: false, | 2397 | frontSelect: false, |
| 2398 | wheelZoom: true, | 2398 | wheelZoom: false, |
| 2399 | zoomMin: 0.3, | 2399 | zoomMin: 0.3, |
| 2400 | zoomMax: 3, | 2400 | zoomMax: 3, |
| 2401 | zoomStep: 0.05, | 2401 | zoomStep: 0.05, |
| ... | @@ -2414,7 +2414,7 @@ | ... | @@ -2414,7 +2414,7 @@ |
| 2414 | shuffleTags: false, | 2414 | shuffleTags: false, |
| 2415 | noSelect: false, | 2415 | noSelect: false, |
| 2416 | noMouse: false, | 2416 | noMouse: false, |
| 2417 | imageScale: 1, | 2417 | imageScale: 1.6, |
| 2418 | paused: false, | 2418 | paused: false, |
| 2419 | dragControl: false, | 2419 | dragControl: false, |
| 2420 | dragThreshold: 4, | 2420 | dragThreshold: 4, | ... | ... |
| ... | @@ -75,7 +75,7 @@ export default { | ... | @@ -75,7 +75,7 @@ export default { |
| 75 | const formData = new FormData(); | 75 | const formData = new FormData(); |
| 76 | formData.append('uploadImg', fileList[0]); | 76 | formData.append('uploadImg', fileList[0]); |
| 77 | const reader = new FileReader(); | 77 | const reader = new FileReader(); |
| 78 | const AllowImgFileSize = 1024 * 150; | 78 | const AllowImgFileSize = 1024 * 200; |
| 79 | const file = fileList[0]; | 79 | const file = fileList[0]; |
| 80 | if (file) { | 80 | if (file) { |
| 81 | this.filename = file.name; | 81 | this.filename = file.name; | ... | ... |
| ... | @@ -31,6 +31,7 @@ | ... | @@ -31,6 +31,7 @@ |
| 31 | :step="1" | 31 | :step="1" |
| 32 | ></el-input> | 32 | ></el-input> |
| 33 | </el-form-item> | 33 | </el-form-item> |
| 34 | <!-- | ||
| 34 | <el-form-item label="一等奖"> | 35 | <el-form-item label="一等奖"> |
| 35 | <el-input | 36 | <el-input |
| 36 | type="number" | 37 | type="number" |
| ... | @@ -39,6 +40,7 @@ | ... | @@ -39,6 +40,7 @@ |
| 39 | :step="1" | 40 | :step="1" |
| 40 | ></el-input> | 41 | ></el-input> |
| 41 | </el-form-item> | 42 | </el-form-item> |
| 43 | --> | ||
| 42 | <el-form-item | 44 | <el-form-item |
| 43 | :label="newitem.name" | 45 | :label="newitem.name" |
| 44 | v-for="newitem in storeNewLottery" | 46 | v-for="newitem in storeNewLottery" |
| ... | @@ -126,7 +128,7 @@ export default { | ... | @@ -126,7 +128,7 @@ export default { |
| 126 | const str = 'abcdefghijklmnopqrstuvwxyz'; | 128 | const str = 'abcdefghijklmnopqrstuvwxyz'; |
| 127 | let fieldStr = ''; | 129 | let fieldStr = ''; |
| 128 | for (let index = 0; index < 10; index++) { | 130 | for (let index = 0; index < 10; index++) { |
| 129 | fieldStr += str.split('')[randomNum(1, 27) - 1]; | 131 | fieldStr += str.split('')[randomNum(1, 26) - 1]; |
| 130 | } | 132 | } |
| 131 | return `${fieldStr}${Date.now()}`; | 133 | return `${fieldStr}${Date.now()}`; |
| 132 | }, | 134 | }, | ... | ... |
| ... | @@ -30,8 +30,11 @@ export default { | ... | @@ -30,8 +30,11 @@ export default { |
| 30 | result() { | 30 | result() { |
| 31 | return this.$store.state.result; | 31 | return this.$store.state.result; |
| 32 | }, | 32 | }, |
| 33 | list() { | ||
| 34 | return this.$store.state.list; | ||
| 35 | }, | ||
| 33 | message() { | 36 | message() { |
| 34 | const { result, config } = this; | 37 | const { result, config, list } = this; |
| 35 | const fields = Object.keys(config); | 38 | const fields = Object.keys(config); |
| 36 | 39 | ||
| 37 | let message = [{ key: 0, title: config.name }]; | 40 | let message = [{ key: 0, title: config.name }]; |
| ... | @@ -42,7 +45,12 @@ export default { | ... | @@ -42,7 +45,12 @@ export default { |
| 42 | key: index + 1, | 45 | key: index + 1, |
| 43 | title: `${label}抽奖结果:`, | 46 | title: `${label}抽奖结果:`, |
| 44 | value: `${ | 47 | value: `${ |
| 45 | result[item].length > 0 ? result[item].join('、') : '暂未抽取' | 48 | result[item].length > 0 |
| 49 | ? list | ||
| 50 | .filter(v => result[item].indexOf(v.key) > -1) | ||
| 51 | .map(v => v.name) | ||
| 52 | .join('、') | ||
| 53 | : '暂未抽取' | ||
| 46 | }` | 54 | }` |
| 47 | }); | 55 | }); |
| 48 | } | 56 | } |
| ... | @@ -57,7 +65,6 @@ export default { | ... | @@ -57,7 +65,6 @@ export default { |
| 57 | .c-Publicity { | 65 | .c-Publicity { |
| 58 | height: 100%; | 66 | height: 100%; |
| 59 | // width: 1000px; | 67 | // width: 1000px; |
| 60 | background-color: rgba(255, 255, 255, 0.1); | ||
| 61 | margin: 0 auto; | 68 | margin: 0 auto; |
| 62 | position: relative; | 69 | position: relative; |
| 63 | overflow: hidden; | 70 | overflow: hidden; |
| ... | @@ -66,14 +73,14 @@ export default { | ... | @@ -66,14 +73,14 @@ export default { |
| 66 | color: #fff; | 73 | color: #fff; |
| 67 | font-size: 16px; | 74 | font-size: 16px; |
| 68 | .title { | 75 | .title { |
| 69 | color: #ccc; | 76 | color: #f1d192; |
| 70 | } | 77 | } |
| 71 | .value { | 78 | .value { |
| 72 | margin-left: 10px; | 79 | margin-left: 10px; |
| 73 | } | 80 | } |
| 74 | &.actiname { | 81 | &.actiname { |
| 75 | .title { | 82 | .title { |
| 76 | color: red; | 83 | color: #fff; |
| 77 | font-size: 20px; | 84 | font-size: 20px; |
| 78 | } | 85 | } |
| 79 | } | 86 | } | ... | ... |
| ... | @@ -35,9 +35,9 @@ | ... | @@ -35,9 +35,9 @@ |
| 35 | class="card" | 35 | class="card" |
| 36 | v-for="(data, j) in item.value" | 36 | v-for="(data, j) in item.value" |
| 37 | :key="j" | 37 | :key="j" |
| 38 | :data-res="data" | 38 | :data-res="data.number" |
| 39 | > | 39 | > |
| 40 | {{ data }} | 40 | {{ data.name }} |
| 41 | </span> | 41 | </span> |
| 42 | </span> | 42 | </span> |
| 43 | </div> | 43 | </div> |
| ... | @@ -59,6 +59,9 @@ export default { | ... | @@ -59,6 +59,9 @@ export default { |
| 59 | this.$store.commit('setResult', val); | 59 | this.$store.commit('setResult', val); |
| 60 | } | 60 | } |
| 61 | }, | 61 | }, |
| 62 | list() { | ||
| 63 | return this.$store.state.list; | ||
| 64 | }, | ||
| 62 | resultList() { | 65 | resultList() { |
| 63 | const list = []; | 66 | const list = []; |
| 64 | for (const key in this.result) { | 67 | for (const key in this.result) { |
| ... | @@ -68,7 +71,10 @@ export default { | ... | @@ -68,7 +71,10 @@ export default { |
| 68 | list.push({ | 71 | list.push({ |
| 69 | label: key, | 72 | label: key, |
| 70 | name, | 73 | name, |
| 71 | value: element | 74 | value: element.map(v => ({ |
| 75 | number: v, | ||
| 76 | name: this.list.filter(vv => vv.key === v)[0].name | ||
| 77 | })) | ||
| 72 | }); | 78 | }); |
| 73 | } | 79 | } |
| 74 | } | 80 | } | ... | ... |
| 1 | <template> | 1 | <template> |
| 2 | <div> | ||
| 3 | <el-button | ||
| 4 | class="autoStart" | ||
| 5 | @click="autoHandler" | ||
| 6 | type="primary" | ||
| 7 | size="mini" | ||
| 8 | >{{ autoRunning ? '停!' : '开始抽奖' }}</el-button | ||
| 9 | > | ||
| 2 | <div id="tool"> | 10 | <div id="tool"> |
| 3 | <el-button @click="startHandler" type="primary" size="mini">{{ | 11 | <el-button class="btn" @click="startHandler" size="mini">{{ |
| 4 | running ? '停止' : '开始' | 12 | running ? '停止' : '自定义抽奖' |
| 5 | }}</el-button> | 13 | }}</el-button> |
| 6 | <el-button size="mini" @click="showRemoveoptions = true"> | 14 | <el-button class="btn" size="mini" @click="showRemoveoptions = true"> |
| 7 | 重置 | 15 | 重置 |
| 8 | </el-button> | 16 | </el-button> |
| 9 | <el-button size="mini" @click="showImport = true"> | 17 | <el-button class="btn" size="mini" @click="showImport = true"> |
| 10 | 导入名单 | 18 | 导入名单 |
| 11 | </el-button> | 19 | </el-button> |
| 12 | <el-button size="mini" @click="showImportphoto = true"> | 20 | <el-button class="btn" size="mini" @click="showImportphoto = true"> |
| 13 | 导入照片 | 21 | 导入照片 |
| 14 | </el-button> | 22 | </el-button> |
| 15 | <el-dialog | 23 | <el-dialog |
| ... | @@ -20,7 +28,10 @@ | ... | @@ -20,7 +28,10 @@ |
| 20 | > | 28 | > |
| 21 | <el-form ref="form" :model="form" label-width="80px" size="mini"> | 29 | <el-form ref="form" :model="form" label-width="80px" size="mini"> |
| 22 | <el-form-item label="抽取奖项"> | 30 | <el-form-item label="抽取奖项"> |
| 23 | <el-select v-model="form.category" placeholder="请选取本次抽取的奖项"> | 31 | <el-select |
| 32 | v-model="form.category" | ||
| 33 | placeholder="请选取本次抽取的奖项" | ||
| 34 | > | ||
| 24 | <el-option | 35 | <el-option |
| 25 | :label="item.label" | 36 | :label="item.label" |
| 26 | :value="item.value" | 37 | :value="item.value" |
| ... | @@ -87,9 +98,9 @@ | ... | @@ -87,9 +98,9 @@ |
| 87 | type="textarea" | 98 | type="textarea" |
| 88 | :rows="10" | 99 | :rows="10" |
| 89 | placeholder="请输入对应的号码和名单(可直接从excel复制),格式(号码 名字),导入的名单将代替号码显示在抽奖中。如: | 100 | placeholder="请输入对应的号码和名单(可直接从excel复制),格式(号码 名字),导入的名单将代替号码显示在抽奖中。如: |
| 90 | 1 张三 | 101 | 1 张三 |
| 91 | 2 李四 | 102 | 2 李四 |
| 92 | 3 王五 | 103 | 3 王五 |
| 93 | " | 104 | " |
| 94 | v-model="listStr" | 105 | v-model="listStr" |
| 95 | ></el-input> | 106 | ></el-input> |
| ... | @@ -128,6 +139,7 @@ | ... | @@ -128,6 +139,7 @@ |
| 128 | </el-form> | 139 | </el-form> |
| 129 | </el-dialog> | 140 | </el-dialog> |
| 130 | </div> | 141 | </div> |
| 142 | </div> | ||
| 131 | </template> | 143 | </template> |
| 132 | 144 | ||
| 133 | <script> | 145 | <script> |
| ... | @@ -135,6 +147,7 @@ import { | ... | @@ -135,6 +147,7 @@ import { |
| 135 | clearData, | 147 | clearData, |
| 136 | removeData, | 148 | removeData, |
| 137 | configField, | 149 | configField, |
| 150 | newLotteryField, | ||
| 138 | listField, | 151 | listField, |
| 139 | resultField, | 152 | resultField, |
| 140 | conversionCategoryName | 153 | conversionCategoryName |
| ... | @@ -145,6 +158,7 @@ import { database, DB_STORE_NAME } from '@/helper/db'; | ... | @@ -145,6 +158,7 @@ import { database, DB_STORE_NAME } from '@/helper/db'; |
| 145 | export default { | 158 | export default { |
| 146 | props: { | 159 | props: { |
| 147 | running: Boolean, | 160 | running: Boolean, |
| 161 | autoRunning: Boolean, | ||
| 148 | closeRes: Function | 162 | closeRes: Function |
| 149 | }, | 163 | }, |
| 150 | computed: { | 164 | computed: { |
| ... | @@ -153,6 +167,11 @@ export default { | ... | @@ -153,6 +167,11 @@ export default { |
| 153 | return this.$store.state.config; | 167 | return this.$store.state.config; |
| 154 | } | 168 | } |
| 155 | }, | 169 | }, |
| 170 | newLottery: { | ||
| 171 | get() { | ||
| 172 | return this.$store.state.newLottery; | ||
| 173 | } | ||
| 174 | }, | ||
| 156 | remain() { | 175 | remain() { |
| 157 | return ( | 176 | return ( |
| 158 | this.config[this.form.category] - | 177 | this.config[this.form.category] - |
| ... | @@ -189,10 +208,10 @@ export default { | ... | @@ -189,10 +208,10 @@ export default { |
| 189 | showImport: false, | 208 | showImport: false, |
| 190 | showImportphoto: false, | 209 | showImportphoto: false, |
| 191 | showRemoveoptions: false, | 210 | showRemoveoptions: false, |
| 192 | removeInfo: { type: 0 }, | 211 | removeInfo: { type: 4 }, |
| 193 | form: { | 212 | form: { |
| 194 | category: '', | 213 | category: '', |
| 195 | mode: 1, | 214 | mode: 0, |
| 196 | qty: 1, | 215 | qty: 1, |
| 197 | allin: false | 216 | allin: false |
| 198 | }, | 217 | }, |
| ... | @@ -202,7 +221,7 @@ export default { | ... | @@ -202,7 +221,7 @@ export default { |
| 202 | watch: { | 221 | watch: { |
| 203 | showRemoveoptions(v) { | 222 | showRemoveoptions(v) { |
| 204 | if (!v) { | 223 | if (!v) { |
| 205 | this.removeInfo.type = 0; | 224 | this.removeInfo.type = 4; |
| 206 | } | 225 | } |
| 207 | } | 226 | } |
| 208 | }, | 227 | }, |
| ... | @@ -223,6 +242,7 @@ export default { | ... | @@ -223,6 +242,7 @@ export default { |
| 223 | break; | 242 | break; |
| 224 | case 1: | 243 | case 1: |
| 225 | removeData(configField); | 244 | removeData(configField); |
| 245 | removeData(newLotteryField); | ||
| 226 | this.$store.commit('setClearConfig'); | 246 | this.$store.commit('setClearConfig'); |
| 227 | break; | 247 | break; |
| 228 | case 2: | 248 | case 2: |
| ... | @@ -281,12 +301,36 @@ export default { | ... | @@ -281,12 +301,36 @@ export default { |
| 281 | } | 301 | } |
| 282 | } | 302 | } |
| 283 | this.showSetwat = false; | 303 | this.showSetwat = false; |
| 304 | const form = Object.assign({}, this.form, { remain: this.remain }); | ||
| 305 | this.$emit('toggle', form); | ||
| 306 | }, | ||
| 307 | autoHandler() { | ||
| 308 | if (this.running) return; | ||
| 309 | if (this.autoRunning) { | ||
| 310 | this.$emit('toggle', null, true); | ||
| 311 | } else { | ||
| 312 | const lottery = this.newLottery.filter( | ||
| 313 | v => !Object.prototype.hasOwnProperty.call(this.result, v.key) | ||
| 314 | )[0]; | ||
| 315 | |||
| 316 | if (!lottery) return this.$message.error('奖品全都有主啦~'); | ||
| 317 | const category = lottery.key; | ||
| 318 | |||
| 284 | this.$emit( | 319 | this.$emit( |
| 285 | 'toggle', | 320 | 'toggle', |
| 286 | Object.assign({}, this.form, { remain: this.remain }) | 321 | { |
| 322 | category, | ||
| 323 | mode: 0, | ||
| 324 | qty: this.config[category], | ||
| 325 | allin: false, | ||
| 326 | remain: this.config[category] | ||
| 327 | }, | ||
| 328 | true | ||
| 287 | ); | 329 | ); |
| 330 | } | ||
| 288 | }, | 331 | }, |
| 289 | startHandler() { | 332 | startHandler() { |
| 333 | if (this.autoRunning) return; | ||
| 290 | this.$emit('toggle'); | 334 | this.$emit('toggle'); |
| 291 | if (!this.running) { | 335 | if (!this.running) { |
| 292 | this.showSetwat = true; | 336 | this.showSetwat = true; |
| ... | @@ -328,13 +372,35 @@ export default { | ... | @@ -328,13 +372,35 @@ export default { |
| 328 | }; | 372 | }; |
| 329 | </script> | 373 | </script> |
| 330 | <style lang="scss"> | 374 | <style lang="scss"> |
| 375 | .el-button.autoStart { | ||
| 376 | position: fixed; | ||
| 377 | bottom: 30px; | ||
| 378 | left: 50%; | ||
| 379 | width: 100px; | ||
| 380 | height: 40px; | ||
| 381 | font-size: 18px; | ||
| 382 | transform: translateX(-50%); | ||
| 383 | background: #f1d192 !important; | ||
| 384 | color: #e74c26 !important; | ||
| 385 | border-color: #f1d192 !important; | ||
| 386 | &:hover { | ||
| 387 | background: #f1d192 !important; | ||
| 388 | color: #e74c26 !important; | ||
| 389 | border-color: #f1d192 !important; | ||
| 390 | } | ||
| 391 | } | ||
| 392 | .el-button.btn { | ||
| 393 | opacity: 0; | ||
| 394 | &:hover { | ||
| 395 | opacity: 0.3; | ||
| 396 | } | ||
| 397 | } | ||
| 331 | #tool { | 398 | #tool { |
| 332 | position: fixed; | 399 | position: fixed; |
| 333 | width: 60px; | 400 | width: 60px; |
| 334 | height: 500px; | 401 | height: 300px; |
| 335 | top: 50%; | 402 | bottom: 0; |
| 336 | right: 20px; | 403 | right: 50px; |
| 337 | transform: translateY(-50%); | ||
| 338 | text-align: center; | 404 | text-align: center; |
| 339 | display: flex; | 405 | display: flex; |
| 340 | flex-direction: column; | 406 | flex-direction: column; | ... | ... |
| ... | @@ -35,13 +35,27 @@ export function randomNum(minNum = 1, maxNum) { | ... | @@ -35,13 +35,27 @@ export function randomNum(minNum = 1, maxNum) { |
| 35 | */ | 35 | */ |
| 36 | export function luckydrawHandler(total, won = [], num) { | 36 | export function luckydrawHandler(total, won = [], num) { |
| 37 | const peolist = generateArray(1, Number(total)); | 37 | const peolist = generateArray(1, Number(total)); |
| 38 | const wons = won; | 38 | let wons = won; |
| 39 | const res = []; | 39 | const res = []; |
| 40 | const rest = peolist.filter(item => !wons.includes(item)); | ||
| 41 | |||
| 42 | if (rest.length < num) { | ||
| 43 | res.push(...rest); | ||
| 44 | wons = [...rest]; | ||
| 45 | for (let j = 0; j < num - rest.length; j++) { | ||
| 46 | const nodraws = peolist.filter(item => !wons.includes(item)); | ||
| 47 | const current = nodraws[randomNum(1, nodraws.length) - 1]; | ||
| 48 | res.push(current); | ||
| 49 | wons.push(current); | ||
| 50 | } | ||
| 51 | } else { | ||
| 40 | for (let j = 0; j < num; j++) { | 52 | for (let j = 0; j < num; j++) { |
| 41 | const nodraws = peolist.filter(item => !wons.includes(item)); | 53 | const nodraws = peolist.filter(item => !wons.includes(item)); |
| 42 | const current = nodraws[randomNum(1, nodraws.length) - 1]; | 54 | const current = nodraws[randomNum(1, nodraws.length) - 1]; |
| 43 | res.push(current); | 55 | res.push(current); |
| 44 | wons.push(current); | 56 | wons.push(current); |
| 45 | } | 57 | } |
| 58 | } | ||
| 59 | |||
| 46 | return res; | 60 | return res; |
| 47 | } | 61 | } | ... | ... |
| ... | @@ -39,6 +39,7 @@ export const newLotteryField = 'newLottery'; // 新增奖项 | ... | @@ -39,6 +39,7 @@ export const newLotteryField = 'newLottery'; // 新增奖项 |
| 39 | export const listField = 'list'; // 名单 | 39 | export const listField = 'list'; // 名单 |
| 40 | export function conversionCategoryName(key) { | 40 | export function conversionCategoryName(key) { |
| 41 | let name = ''; | 41 | let name = ''; |
| 42 | /* | ||
| 42 | switch (key) { | 43 | switch (key) { |
| 43 | case 'firstPrize': | 44 | case 'firstPrize': |
| 44 | name = '一等奖'; | 45 | name = '一等奖'; |
| ... | @@ -46,6 +47,7 @@ export function conversionCategoryName(key) { | ... | @@ -46,6 +47,7 @@ export function conversionCategoryName(key) { |
| 46 | default: | 47 | default: |
| 47 | break; | 48 | break; |
| 48 | } | 49 | } |
| 50 | */ | ||
| 49 | const newLottery = getData(newLotteryField) || []; | 51 | const newLottery = getData(newLotteryField) || []; |
| 50 | const findres = newLottery.find(item => item.key === key); | 52 | const findres = newLottery.find(item => item.key === key); |
| 51 | if (findres) { | 53 | if (findres) { | ... | ... |
| ... | @@ -13,12 +13,9 @@ export default new Vuex.Store({ | ... | @@ -13,12 +13,9 @@ export default new Vuex.Store({ |
| 13 | state: { | 13 | state: { |
| 14 | config: { | 14 | config: { |
| 15 | name: '年会抽奖', | 15 | name: '年会抽奖', |
| 16 | number: 70, | 16 | number: 44 |
| 17 | firstPrize: 1 | ||
| 18 | }, | ||
| 19 | result: { | ||
| 20 | firstPrize: [] | ||
| 21 | }, | 17 | }, |
| 18 | result: {}, | ||
| 22 | newLottery: [], | 19 | newLottery: [], |
| 23 | list: [], | 20 | list: [], |
| 24 | photos: [] | 21 | photos: [] |
| ... | @@ -27,8 +24,7 @@ export default new Vuex.Store({ | ... | @@ -27,8 +24,7 @@ export default new Vuex.Store({ |
| 27 | setClearConfig(state) { | 24 | setClearConfig(state) { |
| 28 | state.config = { | 25 | state.config = { |
| 29 | name: '年会抽奖', | 26 | name: '年会抽奖', |
| 30 | number: 70, | 27 | number: 44 |
| 31 | firstPrize: 1 | ||
| 32 | }; | 28 | }; |
| 33 | state.newLottery = []; | 29 | state.newLottery = []; |
| 34 | }, | 30 | }, |
| ... | @@ -39,19 +35,14 @@ export default new Vuex.Store({ | ... | @@ -39,19 +35,14 @@ export default new Vuex.Store({ |
| 39 | state.photos = []; | 35 | state.photos = []; |
| 40 | }, | 36 | }, |
| 41 | setClearResult(state) { | 37 | setClearResult(state) { |
| 42 | state.result = { | 38 | state.result = {}; |
| 43 | firstPrize: [] | ||
| 44 | }; | ||
| 45 | }, | 39 | }, |
| 46 | setClearStore(state) { | 40 | setClearStore(state) { |
| 47 | state.config = { | 41 | state.config = { |
| 48 | name: '年会抽奖', | 42 | name: '年会抽奖', |
| 49 | number: 70, | 43 | number: 44 |
| 50 | firstPrize: 1 | ||
| 51 | }; | ||
| 52 | state.result = { | ||
| 53 | firstPrize: [] | ||
| 54 | }; | 44 | }; |
| 45 | state.result = {}; | ||
| 55 | state.newLottery = []; | 46 | state.newLottery = []; |
| 56 | state.list = []; | 47 | state.list = []; |
| 57 | state.photos = []; | 48 | state.photos = []; |
| ... | @@ -65,9 +56,11 @@ export default new Vuex.Store({ | ... | @@ -65,9 +56,11 @@ export default new Vuex.Store({ |
| 65 | setData(resultField, state.result); | 56 | setData(resultField, state.result); |
| 66 | }, | 57 | }, |
| 67 | setNewLottery(state, newLottery) { | 58 | setNewLottery(state, newLottery) { |
| 59 | /* | ||
| 68 | if (state.newLottery.find(item => item.name === newLottery.name)) { | 60 | if (state.newLottery.find(item => item.name === newLottery.name)) { |
| 69 | return; | 61 | return; |
| 70 | } | 62 | } |
| 63 | */ | ||
| 71 | state.newLottery.push(newLottery); | 64 | state.newLottery.push(newLottery); |
| 72 | setData(newLotteryField, state.newLottery); | 65 | setData(newLotteryField, state.newLottery); |
| 73 | }, | 66 | }, | ... | ... |
-
Please register or sign in to post a comment