Browse Source

初步联调测试

master
左文祺 8 years ago
parent
commit
7808619b65
  1. 2
      requirements.txt
  2. 303
      src/static/index.js
  3. 3
      src/static/jquery-svg3dtagcloud-plugin-master/js/jquery.svg3dtagcloud.js
  4. 44
      src/static/manage.js
  5. 3
      src/templates/index.html
  6. 13
      src/templates/manage.html
  7. 33
      src/users_db.py

2
requirements.txt

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
bottle==0.12.13
tinydb==3.7.0

303
src/static/index.js

@ -1,118 +1,19 @@ @@ -1,118 +1,19 @@
$(document).ready(function () {
/* var running;
var settings = {
entries: entries,
width: 800,
height: 600,
radius: '65%',
radiusMin: 75,
bgDraw: true,
bgColor: 'none',
opacityOver: 0.90,
opacityOut: 0.05,
opacitySpeed: 1,
fov: 500,
speed: 1,
fontFamily: 'Oswald, Arial, sans-serif',
fontSize: '15',
hoverFontSize: '55',
fontColor: '#fff',
fontWeight: 'normal',//bold
fontStyle: 'normal',//italic
fontStretch: 'wider',//wider, narrower, ultra-condensed, extra-condensed, condensed, semi-condensed, semi-expanded, expanded, extra-expanded, ultra-expanded
fontToUpperCase: true,
// tooltipFontFamily: 'Oswald, Arial, sans-serif',
// tooltipFontSize: '11',
// tooltipFontColor: '#fff',
// tooltipFontWeight: 'normal',//bold
// tooltipFontStyle: 'normal',//italic
// tooltipFontStretch: 'normal',//wider, narrower, ultra-condensed, extra-condensed, condensed, semi-condensed, semi-expanded, expanded, extra-expanded, ultra-expanded
// tooltipFontToUpperCase: false,
// tooltipTextAnchor: 'left',
// tooltipDiffX: 0,
// tooltipDiffY: 10
};
var svg3DTagCloud = new SVG3DTagCloud(document.getElementById('holder'), settings);*/
/* $('#start').click(function () {
if (running) {
alert('正在抽奖');
return;
}
svg3DTagCloud.speed(6);
running = true;
});
$('#end').click(function () {
stop();
render(1);
});
$('#test').click(function () {
list();
});*/
// $( '#holder' ).svg3DTagCloud( settings );
/* function render(i) {
console.log(i);
if (i === 5) {
setTimeout(function () {
list();
stop();
}, 1000);
return;
}
;
setTimeout(function () {
stop();
setTimeout(function () {
chose(i);
render(++i);
}, 500)
}, 2500)
}
function stop() {
running = false;
svg3DTagCloud.reset();
svg3DTagCloud.speed(1);
}
function chose(i) {
svg3DTagCloud.chose([{
index: i
}]);
}
function list() {
var offset = $(".holder").offset();
layer.open({
type: 1,
area: '800px',
offset: [offset.top, offset.left],
closeBtn: 1, //不显示关闭按钮
anim: 3,
title: '中奖名单',
shadeClose: false, //开启遮罩关闭
content: '<div class="luckerList"><ul><li>1111</li><li>111</li><li>2222</li></ul></div>'
});
}*/
new UI();
});
class BS{
constructor(){
class BS {
constructor() {
}
static fetch(url,data,type){
return new Promise((resolve)=>{
static fetch(url, data, type) {
return new Promise((resolve) => {
$.ajax({
type:type?type:'GET',
data:data?data:{},
type: type ? type : 'GET',
data: data ? data : {},
url,
success(resp){
success(resp) {
resolve(resp)
}
})
@ -120,153 +21,38 @@ class BS{ @@ -120,153 +21,38 @@ class BS{
}
static run(award_id){
return this.fetch('/run',{
award_id
},'POST');
static run() {
return this.fetch('/run');
}
static stopAndResult(){
return this.fetch('/draw_lottery');
static stopAndResult(award_id) {
return this.fetch('/draw_lottery',{award_id});
}
static getLucklessUsers(){
static getLucklessUsers() {
return this.fetch('/luckless_users');
}
static getLuckyUsers(){
static getLuckyUsers() {
return this.fetch('/luckless_users');
}
static getAwards(){
static getAwards() {
return this.fetch('/awards');
}
static getUsers(){
static getUsers() {
return this.fetch('/users');
}
}
class UI {
constructor() {
this.running = false;
this.entries = [
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '张三三', url:'javascript:void(0)', target: '_top', id: 'admin'},
{label: '李四', url: 'http://www.flashforum.de/', target: '_top'},
{label: '王污污', url: 'http://www.jqueryscript.net/', target: '_top'},
{label: '赵六六', url: 'http://www.jqueryscript.net/', target: '_top'},
{label: '赵六六', url: 'http://www.jqueryscript.net/', target: '_top'},
];
this.entries = [];
this.settings = {
entries: this.entries,
width: 800,
height: 600,
radius: '65%',
@ -298,15 +84,26 @@ class UI { @@ -298,15 +84,26 @@ class UI {
// tooltipDiffY: 10
};
this.buildCloud().then(()=>{
this.settings.entries = this.entries;
this.svg3DTagCloud = new SVG3DTagCloud(document.getElementById('holder'), this.settings);
this.buildCloud();
});
this.bindEvent();
}
buildCloud() {
BS.getUsers().then((resp)=>{
console.log(resp)
return BS.getUsers().then((resp) => {
console.log(resp);
let entry = [];
$(resp.data).each((i, val) => {
entry.push({
label: val.name,
uid:val.uid,
role:val.role,
url: 'javascript:void(0)',
target: '_top'
})
});
this.entries = entry;
})
}
@ -316,14 +113,23 @@ class UI { @@ -316,14 +113,23 @@ class UI {
alert('正在抽奖');
return;
}
//todo
BS.run().then(resp=>{
console.log(resp);
this.svg3DTagCloud.speed(6);
this.running = true;
});
});
$('#end').click(() => {
console.log('click');
//todo
BS.stopAndResult("9f7cfd85a39e40f2975e7a62ca9dbca5").then(resp=>{
console.log(resp);
this.stop();
this.render(1);
let uid= 'G0001';
let index = $(`[data-uid=${uid}]`).data('index');
this.render(index);
});
});
$('#test').click(() => {
this.list();
@ -332,13 +138,14 @@ class UI { @@ -332,13 +138,14 @@ class UI {
}
render(i) {
console.log(i);
this.chose(i);
/* console.log(i);
if (i >= 5) {
setTimeout(() => {
this.stop();
setTimeout(()=>{
setTimeout(() => {
this.list();
},1000)
}, 1000)
}, 1000);
return;
}
@ -348,7 +155,7 @@ class UI { @@ -348,7 +155,7 @@ class UI {
this.chose(i);
this.render(++i);
}, 500)
}, 2500)
}, 2500)*/
}
stop() {

3
src/static/jquery-svg3dtagcloud-plugin-master/js/jquery.svg3dtagcloud.js

@ -261,6 +261,9 @@ THE SOFTWARE. @@ -261,6 +261,9 @@ THE SOFTWARE.
entry.link = document.createElementNS( svgNS, 'a' );
entry.link.setAttributeNS( 'http://www.w3.org/1999/xlink', 'xlink:href', entryObj.url );
entry.link.setAttribute( 'target', entryObj.target );
entry.link.setAttribute( 'data-uid', entryObj.uid );
entry.link.setAttribute( 'data-role', entryObj.role );
entry.link.setAttribute( 'data-index', index );
// entry.link.addEventListener( 'mouseover', mouseOverHandler, true );
// entry.link.addEventListener( 'mouseout', mouseOutHandler, true );
entry.link.appendChild( entry.element );

44
src/static/manage.js

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
/**
* Created by zuowenqi on 2018/2/2 0002
*/
class BS{
constructor(){
}
static fetch(url,data,type){
return new Promise((resolve)=>{
$.ajax({
type:type?type:'GET',
data:data?data:{},
url,
success(resp){
resolve(resp)
}
})
})
}
static addAwards(award_name,award_capacity){
console.log();
return this.fetch('/add_award',{
award_name,award_capacity
});
}
static getAwards(){
return this.fetch('/awards');
}
}
$(function(){
BS.addAwards("一等奖",1).then(resp=>{
console.log(resp)
});
BS.addAwards("二等奖",5).then(resp=>{
console.log(resp)
});
BS.addAwards("三等奖",10).then(resp=>{
console.log(resp)
});
BS.getAwards().then(resp=>{
console.log(resp);
})
});

3
src/templates/index.html

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
<div class="row">
<div class="left">
<ul class="current-list">
</ul>
</div>
<div id='holder' class="holder"></div>
@ -25,7 +26,7 @@ @@ -25,7 +26,7 @@
<p class="btns">
<a href="javascript:void (0)" class="button button-3d button-action button-rounded " id="start"><i class="fa fa-camera"></i>开始</a>
<a href="javascript:void (0)" class="button button-3d button-primary button-rounded" id="end"><i class="fa fa-hand-paper"></i>停止</a>
<a href="javascript:void (0)" class="button button-3d button-primary button-rounded" id="test">中奖</a>
<a href="javascript:void (0)" class="button button-3d button-primary button-rounded" id="test">中奖结果</a>
</p>
</div>

13
src/templates/manage.html

@ -3,8 +3,19 @@ @@ -3,8 +3,19 @@
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href='https://fonts.googleapis.com/css?family=Oswald&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="../static/web-fonts-with-css/css/fontawesome-all.min.css">
<link rel="stylesheet" href="../static/buttons.css">
</head>
<body>
<ul>
<li></li>
</ul>
<a href="javascript:void (0)" class="button button-action button-rounded " id="add">增加</a>
<a href="javascript:void (0)" class="button button-action button-rounded " id="change">修改</a>
<a href="javascript:void (0)" class="button button-action button-rounded " id="remove">删除</a>
<script type="text/javascript" src="../static/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../static/layer/layer.js"></script>
<script type="text/javascript" src="../static/manage.js"></script>
</body>
</html>

33
src/users_db.py

@ -3,4 +3,35 @@ @@ -3,4 +3,35 @@
def load():
return []
return [
{
"uid": "G0001",
"name": "谷歌",
"award_id": None,
"role": 0
},
{
"uid": "G0002",
"name": "百度",
"award_id": None,
"role": 1
},
{
"uid": "G0003",
"name": "搜狗",
"award_id": None,
"role": 2
},
{
"uid": "G0004",
"name": "360",
"award_id": None,
"role": 3
},
{
"uid": "G0005",
"name": "亚马逊",
"award_id": None,
"role": 1
}
]

Loading…
Cancel
Save