Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
lottery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fushaowu
lottery
Commits
033cee84
Commit
033cee84
authored
Jan 06, 2021
by
rendong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update lottery.js
parent
abe07e6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
20 deletions
+21
-20
lottery.js
src/lottery.js
+21
-20
No files found.
src/lottery.js
View file @
033cee84
...
...
@@ -2,19 +2,17 @@
*
* @param {*} status true: 把中奖名单删除
*/
function
getLotteryList
(
status
=
false
)
{
let
notWinPersonList
=
[...
personInfo
Map
.
values
()];
if
(
vue
.
num
>
notWinPerson
List
.
length
)
{
vue
.
num
=
notWinPerson
List
.
length
;
function
randomNPerson
(
num
,
candidateMap
)
{
let
candidateList
=
[...
candidate
Map
.
values
()];
if
(
num
>
candidate
List
.
length
)
{
num
=
candidate
List
.
length
;
}
// 该批次名单
let
currentWinPersonMap
=
new
Map
();
while
(
currentWinPersonMap
.
size
<
vue
.
num
)
{
let
random
=
Math
.
floor
(
Math
.
random
()
*
notWinPersonList
.
length
);
currentWinPersonMap
.
set
(
notWinPersonList
[
random
][
'name'
],
notWinPersonList
[
random
]);
if
(
status
)
{
notWinPersonList
.
splice
(
random
,
1
);
// 删除中奖人员名单
}
while
(
currentWinPersonMap
.
size
<
num
)
{
let
random
=
Math
.
floor
(
Math
.
random
()
*
candidateList
.
length
);
currentWinPersonMap
.
set
(
candidateList
[
random
][
'name'
],
candidateList
[
random
]);
candidateList
.
splice
(
random
,
1
);
// 删除中奖人员名单
}
return
[...
currentWinPersonMap
.
values
()];
}
...
...
@@ -22,7 +20,7 @@ function getLotteryList(status = false) {
/**
* 获取所有未中过奖名单
*/
function
get
NotWinPersonList
()
{
function
get
CandidateMap
()
{
let
winPerson
=
localStorage
.
getItem
(
'yit'
);
if
(
winPerson
)
{
winPerson
=
JSON
.
parse
(
winPerson
);
...
...
@@ -38,18 +36,21 @@ function getNotWinPersonList() {
/**
* 抽奖开始
*/
function
start
()
{
getNotWinPersonList
();
if
(
personInfo
Map
.
size
===
0
)
{
function
start
(
num
)
{
var
candidateMap
=
getCandidateMap
();
if
(
candidate
Map
.
size
===
0
)
{
let
status
=
window
.
confirm
(
'没有未中奖人员, 去往抽奖结果页面'
);
status
&&
window
.
open
(
'./list.html'
);
vue
.
activePersonList
=
[];
vue
.
step
=
1
;
vue
.
statusText
=
'抽奖完成'
;
if
(
status
)
{
window
.
open
(
'./list.html'
);
}
else
{
vue
.
activePersonList
=
[];
vue
.
step
=
1
;
vue
.
statusText
=
'抽奖完成'
;
}
return
;
}
vue
.
interval
=
setInterval
(()
=>
{
vue
.
activePersonList
=
getLotteryList
(
);
vue
.
activePersonList
=
randomNPerson
(
num
,
candidateMap
);
},
100
);
}
...
...
@@ -107,7 +108,7 @@ let vue = new Vue({
watch
:
{
step
(
newValue
)
{
if
(
newValue
===
2
)
{
start
();
start
(
this
.
num
);
}
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment