时间:2021-07-01 10:21:17 帮助过:5人阅读
var zjl = false;
var num = 0;
var goon = true;
$(function() {
$("#scratchpad").wScratchPad({
width: 150,
height: 40,
color: "#a9a9a7",
scratchMove: function() {
num++;
if (num == 2) {
var a = "一等奖";
var b = "二等奖";
var c = "三等奖";
var e = "幸运奖";
var d = "谢谢参与";
var aa = 0.000;//一等奖的概奖
var bb = 0.001;//二等奖的概率
var cc = 0.004;//三等奖的概率
var ee = 0.996;//幸运奖的概率
var dd = 0.000;//未中奖的概率
var shows = [a, b, c,d,e];
var prob = [aa, bb, cc,dd,ee];
var len = 1000;
var probLen = [len*aa, len*bb, len*cc, len*dd, len*ee];
var ran = Math.random() * len;
for(var i = 0; i < probLen.length; i++){
var ranStart = 0;
for(var j = 0; j < i; j++){
ranStart += probLen[j];
}
var ranEnd = ranStart + probLen[i];
if(ran > ranStart && ran <= ranEnd){
var award = shows[i];
if(shows[i]!='谢谢参与')
{
zjl = true;
}
document.getElementById('prize').innerHTML = award;
$("#theAward").html(award);
$data = '{"aa":1,"bb":2,"cc":3,"dd":4}' // 这里也可以从db获取
?>