<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{margin: 0;padding: 0;}
p{text-align: center;}
.bg{
width: 405px;
height: 405px;
background: url(imgs/index/8696_1453854253.png) 0 0 no-repeat;
position: relative;
}
.point{
width: 46px;
height: 405px;
background: url(imgs/index/3375_1453854403.png) 0 bottom no-repeat;
position: absolute;
left: 50%;
margin-left: -23px;
transform: rotate(3deg);
}
button,select;{
width: 80px;
height: 40px;
}
</style>
</head>
<body>
<p>
<select name="" id="">
<option value="0">1~6</option>
<option value="6">7~12</option>
<option value="12">13~18</option>
<option value="18">19~24</option>
<option value="24">25~30</option>
<option value="30">31~36</option>
</select>
</p>
<div class="bg">
<div class="point"></div>
</div>
<p>
<button>下注</button>
</p>
<script type="text/javascript" src="js/jquery-2.2.3.min.js"></script>
<script type="text/javascript">
$(function(){
var prize = true;
var posarr = [
35,18,10,16,31,22,
6,28,2,30,26,8,
24,0,14,33,20,4,
15,36,17,3,29,32,
19,11,23,7,5,27,
1,13,34,21,9,25
];
var prizePosArr;
var destPos;
var deg;
//点击下注 判断是否中奖
//获取下注区间
$('button').click(function(){
var qujian = $('select').val();
// console.log(qujian);
if(prize){
prizePosArr = posarr.splice(qujian,6);
console.log(prizePosArr)
var randnum = parseInt(Math.random()6);
destPos = prizePosArr[randnum];
// console.log(destPos)
//中奖,从 下注区间的数字 对应的位置 随机一个位置出来,根据位置 计算一个角度
deg = 3+destPos * 360/37 + 1080;
$('.point').css({
'transform': 'rotate('+ deg+'deg)',
'transition':'6s ease-in-out'
})
}else{
posarr.splice(qujian,6);
var randnum = parseInt(Math.random()30);
destPos = posarr[randnum];
// console.log(destPos)
//不中奖 ,从 出下注区间 数字 之外的对应的位置 随即一个数字出来,根据位置计算一个角度
deg = 3+destPos * 360/37 + 1080;
$('.point').css({
'transform': 'rotate('+ deg+'deg)',
'transition':'6s ease-in-out'
})
}
})
})
</script>
</body>
</html>