|
|
|
|
@ -42,15 +42,23 @@ class BS {
@@ -42,15 +42,23 @@ class BS {
|
|
|
|
|
return this.fetch('/awards'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static getAward(award_id) { |
|
|
|
|
return this.fetch('/award', { |
|
|
|
|
award_id |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static getUsers() { |
|
|
|
|
return this.fetch('/users'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class UI { |
|
|
|
|
constructor() { |
|
|
|
|
this.running = false; |
|
|
|
|
this.currentAward = ''; |
|
|
|
|
this.entries = []; |
|
|
|
|
this.settings = { |
|
|
|
|
width: 800, |
|
|
|
|
@ -89,7 +97,12 @@ class UI {
@@ -89,7 +97,12 @@ class UI {
|
|
|
|
|
this.svg3DTagCloud = new SVG3DTagCloud(document.getElementById('holder'), this.settings); |
|
|
|
|
}); |
|
|
|
|
this.bindEvent(); |
|
|
|
|
this.initVisualSocket(); |
|
|
|
|
BS.getAwards().then(resp => { |
|
|
|
|
console.log(resp) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
buildCloud() { |
|
|
|
|
return BS.getUsers().then((resp) => { |
|
|
|
|
console.log(resp); |
|
|
|
|
@ -107,13 +120,36 @@ class UI {
@@ -107,13 +120,36 @@ class UI {
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
initVisualSocket() { |
|
|
|
|
let tempAwardId = ''; |
|
|
|
|
setInterval(() => { |
|
|
|
|
tempAwardId = localStorage.getItem('current_award'); |
|
|
|
|
if (this.currentAward !== tempAwardId) { |
|
|
|
|
this.currentAward = tempAwardId; |
|
|
|
|
this.refreshCurrentAward(); |
|
|
|
|
} |
|
|
|
|
}, 2 * 1000); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
refreshCurrentAward() { |
|
|
|
|
BS.getAward(this.currentAward).then((resp) => { |
|
|
|
|
console.log(resp); |
|
|
|
|
if (resp.status === 200) { |
|
|
|
|
let awardInfo = resp.data; |
|
|
|
|
$('#currentAwardName').html(awardInfo.award_name); |
|
|
|
|
$('#currentTimes').html(awardInfo.award_capacity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bindEvent() { |
|
|
|
|
$('#start').click(() => { |
|
|
|
|
if (this.running) { |
|
|
|
|
alert('正在抽奖'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//todo
|
|
|
|
|
BS.run().then(resp => { |
|
|
|
|
console.log(resp); |
|
|
|
|
this.svg3DTagCloud.speed(6); |
|
|
|
|
@ -122,13 +158,11 @@ class UI {
@@ -122,13 +158,11 @@ class UI {
|
|
|
|
|
}); |
|
|
|
|
$('#end').click(() => { |
|
|
|
|
console.log('click'); |
|
|
|
|
//todo
|
|
|
|
|
BS.stopAndResult("9f7cfd85a39e40f2975e7a62ca9dbca5").then(resp=>{ |
|
|
|
|
BS.stopAndResult(this.currentAward).then(resp => { |
|
|
|
|
console.log(resp); |
|
|
|
|
this.stop(); |
|
|
|
|
let uid= 'G0001'; |
|
|
|
|
let index = $(`[data-uid=${uid}]`).data('index'); |
|
|
|
|
this.render(index); |
|
|
|
|
if (resp.status === 200) { |
|
|
|
|
this.render(resp.data, 0); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
$('#test').click(() => { |
|
|
|
|
@ -137,25 +171,17 @@ class UI {
@@ -137,25 +171,17 @@ class UI {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render(i) { |
|
|
|
|
this.chose(i); |
|
|
|
|
/* console.log(i); |
|
|
|
|
if (i >= 5) { |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.stop(); |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.list(); |
|
|
|
|
}, 1000) |
|
|
|
|
}, 1000); |
|
|
|
|
|
|
|
|
|
render(data, i) { |
|
|
|
|
// debugger
|
|
|
|
|
if (i >= data.length) { |
|
|
|
|
this.currentlist(data); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.stop(); |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.chose(i); |
|
|
|
|
this.render(++i); |
|
|
|
|
}, 500) |
|
|
|
|
}, 2500)*/ |
|
|
|
|
this.chose(data[i]).then(() => { |
|
|
|
|
i++; |
|
|
|
|
this.render(data, i); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
stop() { |
|
|
|
|
@ -164,13 +190,48 @@ class UI {
@@ -164,13 +190,48 @@ class UI {
|
|
|
|
|
this.svg3DTagCloud.speed(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
chose(i) { |
|
|
|
|
chose(user) { |
|
|
|
|
return new Promise((resolve) => { |
|
|
|
|
let uid = user.uid; |
|
|
|
|
let name = user.name; |
|
|
|
|
let index = $(`[data-uid=${uid}]`).data('index'); |
|
|
|
|
this.svg3DTagCloud.chose([{ |
|
|
|
|
index: i |
|
|
|
|
index |
|
|
|
|
}]); |
|
|
|
|
|
|
|
|
|
let currentList = `<li><i class="fa fa-user"></i>张三三</li>`; |
|
|
|
|
let currentList = `<li><i class="fa fa-user"></i>${name}</li>`; |
|
|
|
|
$('.current-list').append(currentList); |
|
|
|
|
setTimeout(() => { |
|
|
|
|
// this.stop()
|
|
|
|
|
resolve(); |
|
|
|
|
}, 3 * 1000) |
|
|
|
|
}).then(() => { |
|
|
|
|
return new Promise((resolve) => { |
|
|
|
|
this.stop(); |
|
|
|
|
setTimeout(() => { |
|
|
|
|
resolve(); |
|
|
|
|
}, 500) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
currentlist(data) { |
|
|
|
|
let offset = $(".holder").offset(); |
|
|
|
|
let DOM = '<ul>' |
|
|
|
|
for (let user of data) { |
|
|
|
|
DOM += `<li>${user.name}</li>`; |
|
|
|
|
} |
|
|
|
|
DOM += `</ul>`; |
|
|
|
|
layer.open({ |
|
|
|
|
type: 1, |
|
|
|
|
area: '800px', |
|
|
|
|
offset: [offset.top, offset.left], |
|
|
|
|
closeBtn: 1, //不显示关闭按钮
|
|
|
|
|
anim: 3, |
|
|
|
|
title: '本次中奖名单', |
|
|
|
|
shadeClose: false, //开启遮罩关闭
|
|
|
|
|
content: `<div class="luckerList">${DOM}</div>` |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
list() { |
|
|
|
|
@ -181,7 +242,7 @@ class UI {
@@ -181,7 +242,7 @@ class UI {
|
|
|
|
|
offset: [offset.top, offset.left], |
|
|
|
|
closeBtn: 1, //不显示关闭按钮
|
|
|
|
|
anim: 3, |
|
|
|
|
title: '中奖名单', |
|
|
|
|
title: '本次中奖名单', |
|
|
|
|
shadeClose: false, //开启遮罩关闭
|
|
|
|
|
content: '<div class="luckerList"><ul><li>1111</li><li>111</li><li>2222</li></ul></div>' |
|
|
|
|
}); |
|
|
|
|
|