|
|
|
@ -1,5 +1,5 @@ |
|
|
|
$(document).ready(function () { |
|
|
|
$(document).ready(function () { |
|
|
|
new UI(); |
|
|
|
new Index(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
class BS { |
|
|
|
class BS { |
|
|
|
@ -34,8 +34,7 @@ class BS { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static getLuckyUsers() { |
|
|
|
static getLuckyUsers() { |
|
|
|
return this.fetch('/luckless_users'); |
|
|
|
return this.fetch('/lucky_users'); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static getAwards() { |
|
|
|
static getAwards() { |
|
|
|
@ -55,7 +54,7 @@ class BS { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class UI { |
|
|
|
class Index { |
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
|
this.running = false; |
|
|
|
this.running = false; |
|
|
|
this.currentAward = ''; |
|
|
|
this.currentAward = ''; |
|
|
|
@ -93,18 +92,15 @@ class UI { |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
this.buildCloud().then(() => { |
|
|
|
this.buildCloud().then(() => { |
|
|
|
this.settings.entries = this.entries; |
|
|
|
|
|
|
|
this.svg3DTagCloud = new SVG3DTagCloud(document.getElementById('holder'), this.settings); |
|
|
|
this.svg3DTagCloud = new SVG3DTagCloud(document.getElementById('holder'), this.settings); |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.bindEvent(); |
|
|
|
this.bindEvent(); |
|
|
|
this.initVisualSocket(); |
|
|
|
this.initVisualSocket(); |
|
|
|
BS.getAwards().then(resp => { |
|
|
|
|
|
|
|
console.log(resp) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
buildCloud() { |
|
|
|
buildCloud() { |
|
|
|
return BS.getUsers().then((resp) => { |
|
|
|
return BS.getLucklessUsers().then((resp) => { |
|
|
|
console.log(resp); |
|
|
|
console.log(resp); |
|
|
|
let entry = []; |
|
|
|
let entry = []; |
|
|
|
$(resp.data).each((i, val) => { |
|
|
|
$(resp.data).each((i, val) => { |
|
|
|
@ -117,14 +113,26 @@ class UI { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.entries = entry; |
|
|
|
this.entries = entry; |
|
|
|
|
|
|
|
this.settings.entries = this.entries; |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rebuild() { |
|
|
|
|
|
|
|
this.buildCloud().then(() => { |
|
|
|
|
|
|
|
$('.holder').empty(); |
|
|
|
|
|
|
|
this.svg3DTagCloud = new SVG3DTagCloud(document.getElementById('holder'), this.settings); |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
initVisualSocket() { |
|
|
|
initVisualSocket() { |
|
|
|
|
|
|
|
// this.refreshCurrentAward();
|
|
|
|
let tempAwardId = ''; |
|
|
|
let tempAwardId = ''; |
|
|
|
setInterval(() => { |
|
|
|
setInterval(() => { |
|
|
|
tempAwardId = localStorage.getItem('current_award'); |
|
|
|
tempAwardId = localStorage.getItem('current_award'); |
|
|
|
if (this.currentAward !== tempAwardId) { |
|
|
|
if (this.currentAward !== tempAwardId) { |
|
|
|
|
|
|
|
/*change*/ |
|
|
|
|
|
|
|
// window.location.reload(1);
|
|
|
|
this.currentAward = tempAwardId; |
|
|
|
this.currentAward = tempAwardId; |
|
|
|
this.refreshCurrentAward(); |
|
|
|
this.refreshCurrentAward(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -132,6 +140,7 @@ class UI { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
refreshCurrentAward() { |
|
|
|
refreshCurrentAward() { |
|
|
|
|
|
|
|
if (this.currentAward === '') return; |
|
|
|
BS.getAward(this.currentAward).then((resp) => { |
|
|
|
BS.getAward(this.currentAward).then((resp) => { |
|
|
|
console.log(resp); |
|
|
|
console.log(resp); |
|
|
|
if (resp.status === 200) { |
|
|
|
if (resp.status === 200) { |
|
|
|
@ -157,25 +166,29 @@ class UI { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
$('#end').click(() => { |
|
|
|
$('#end').click(() => { |
|
|
|
|
|
|
|
if (!this.running) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
console.log('click'); |
|
|
|
console.log('click'); |
|
|
|
BS.stopAndResult(this.currentAward).then(resp => { |
|
|
|
BS.stopAndResult(this.currentAward).then(resp => { |
|
|
|
|
|
|
|
this.running = false; |
|
|
|
console.log(resp); |
|
|
|
console.log(resp); |
|
|
|
if (resp.status === 200) { |
|
|
|
if (resp.status === 200) { |
|
|
|
this.render(resp.data, 0); |
|
|
|
this.render(resp.data, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
$('#test').click(() => { |
|
|
|
$('#luckyUsers').click(() => { |
|
|
|
this.list(); |
|
|
|
this.list(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render(data, i) { |
|
|
|
render(data, i) { |
|
|
|
// debugger
|
|
|
|
// debugger
|
|
|
|
if (i >= data.length) { |
|
|
|
if (i >= data.length) { |
|
|
|
this.currentlist(data); |
|
|
|
this.currentlist(data); |
|
|
|
|
|
|
|
this.rebuild(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
this.chose(data[i]).then(() => { |
|
|
|
this.chose(data[i]).then(() => { |
|
|
|
@ -185,7 +198,6 @@ class UI { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
stop() { |
|
|
|
stop() { |
|
|
|
this.running = false; |
|
|
|
|
|
|
|
this.svg3DTagCloud.reset(); |
|
|
|
this.svg3DTagCloud.reset(); |
|
|
|
this.svg3DTagCloud.speed(1); |
|
|
|
this.svg3DTagCloud.speed(1); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -225,6 +237,7 @@ class UI { |
|
|
|
layer.open({ |
|
|
|
layer.open({ |
|
|
|
type: 1, |
|
|
|
type: 1, |
|
|
|
area: '800px', |
|
|
|
area: '800px', |
|
|
|
|
|
|
|
skin: 'layui-layer-lan', //样式类名
|
|
|
|
offset: [offset.top, offset.left], |
|
|
|
offset: [offset.top, offset.left], |
|
|
|
closeBtn: 1, //不显示关闭按钮
|
|
|
|
closeBtn: 1, //不显示关闭按钮
|
|
|
|
anim: 3, |
|
|
|
anim: 3, |
|
|
|
@ -236,15 +249,55 @@ class UI { |
|
|
|
|
|
|
|
|
|
|
|
list() { |
|
|
|
list() { |
|
|
|
let offset = $(".holder").offset(); |
|
|
|
let offset = $(".holder").offset(); |
|
|
|
layer.open({ |
|
|
|
let awards={}; |
|
|
|
type: 1, |
|
|
|
let load=layer.load(2); |
|
|
|
area: '800px', |
|
|
|
BS.getAwards().then(resp=>{ |
|
|
|
offset: [offset.top, offset.left], |
|
|
|
resp.data.map((val)=>{ |
|
|
|
closeBtn: 1, //不显示关闭按钮
|
|
|
|
console.log(val); |
|
|
|
anim: 3, |
|
|
|
if(typeof awards[val.award_id]==="undefined"){ |
|
|
|
title: '本次中奖名单', |
|
|
|
awards[val.award_id]={}; |
|
|
|
shadeClose: false, //开启遮罩关闭
|
|
|
|
} |
|
|
|
content: '<div class="luckerList"><ul><li>1111</li><li>111</li><li>2222</li></ul></div>' |
|
|
|
awards[val.award_id].name = val.award_name; |
|
|
|
|
|
|
|
awards[val.award_id].data=[]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).then(()=>{ |
|
|
|
|
|
|
|
return BS.getLuckyUsers().then(resp => { |
|
|
|
|
|
|
|
resp.data.map(val=>{ |
|
|
|
|
|
|
|
awards[val.award_id].data.push(val) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}).then(()=>{ |
|
|
|
|
|
|
|
layer.close(load); |
|
|
|
|
|
|
|
console.log(awards); |
|
|
|
|
|
|
|
let content = ``; |
|
|
|
|
|
|
|
for(let key of Object.keys(awards)){ |
|
|
|
|
|
|
|
let award = awards[key]; |
|
|
|
|
|
|
|
let lisArray=award.data.map((data)=>{ |
|
|
|
|
|
|
|
return `<li class="${data.role==2||data.role==3?'sp':''}">${data.name}<span>【${data.uid}】</span></li>` |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
content+=` |
|
|
|
|
|
|
|
<section> |
|
|
|
|
|
|
|
<h5>${award.name}</h5> |
|
|
|
|
|
|
|
<ul> |
|
|
|
|
|
|
|
${lisArray.join("")} |
|
|
|
|
|
|
|
</ul> |
|
|
|
|
|
|
|
</section>`; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
layer.open({ |
|
|
|
|
|
|
|
type: 1, |
|
|
|
|
|
|
|
area: '800px', |
|
|
|
|
|
|
|
skin: 'layui-layer-lan', //样式类名
|
|
|
|
|
|
|
|
offset: [offset.top, offset.left], |
|
|
|
|
|
|
|
closeBtn: 1, //不显示关闭按钮
|
|
|
|
|
|
|
|
anim: 3, |
|
|
|
|
|
|
|
title: '所有中奖名单', |
|
|
|
|
|
|
|
shadeClose: false, //开启遮罩关闭
|
|
|
|
|
|
|
|
content: ` |
|
|
|
|
|
|
|
<div class="luckerList">${content} |
|
|
|
|
|
|
|
</div>` |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|