function start_lottery(){
if(flag){
//alert('正在抽奖,请等待抽奖结果!');
//return false;
return void(0);
}
flag=true;
index = 1; //当前选中对象的位置
fast = rand(3,6); //在哪个位置开始加速
cycle = rand(3,5); //转动多少圈
speed = 300; //开始时速度
$.ajax({
url: 'lottery.php',
type: "post",
data:null,
dataType: "json",
timeout: 20000,
cache: false,
beforeSend: function(){// 提交之前
},
error: function(){//出错
flag=false;
},
success: function(res){//成功
if(typeof(res.award_id)!='undefined'){
lucky = res.award_id; //中奖号码
award = res.award_name; //奖品名称
show_lottery();
}else{
flag=false;
alert(res.err);
}
}
});
}
//奖品配置
$award = array(
// 奖品ID => array('奖品名称',概率)
1 => array('悟空公仔',0.1),
2 => array('小乖虎公仔',0.1),
3 => array('神秘大礼包',0.1),
4 => array('智能游戏手柄',0.1),
5 => array('小角鹿公仔',0.1),
6 => array('豆蛙抱枕',0.1),
7 => array('游戏耳机',0.2),
8 => array('雷蛇键盘',0.2),
);
$r =rand(1,100);