溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

在線抽獎(jiǎng)大轉(zhuǎn)盤和概率計(jì)算

發(fā)布時(shí)間:2020-07-06 20:48:35 來源:網(wǎng)絡(luò) 閱讀:1734 作者:飛揚(yáng)php 欄目:開發(fā)技術(shù)
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>抽獎(jiǎng)效果演示</title>
<style>
.rotary { position: relative; width: 854px; height: 504px; margin: 0 auto; background: #d71f2e url(p_w_picpaths/bg1.png);}
.rotaryArrow { position: absolute; left: 181px; top: 104px; width: 294px; height: 294px; cursor: pointer; background-p_w_picpath: url(p_w_picpaths/arrow.png);}

.list { position: absolute; right: 48px; top: 144px; width: 120px; height: 320px; overflow: hidden;}
.list h4 { display: none;}
.list ul { list-style-type: none;}
.list li { height: 37px; font: 14px/37px "Microsoft Yahei"; color: #ffea76; text-indent: 25px; background: url(p_w_picpaths/user.png) 0 no-repeat;}

.result { display: none; position: absolute; left: 130px; top: 190px; width: 395px; height: 118px; background-color: rgba(0,0,0,0.75); filter: alpha(opacity=90);}
.result a { position: absolute; right: 5px; top: 5px; width: 25px; height: 25px; text-indent: -100px; background-p_w_picpath: url(p_w_picpaths/close.png); overflow: hidden;}
.result p { padding: 45px 15px 0; font: 16px "Microsoft Yahei"; color: #fff; text-align: center;}
.result em { color: #ffea76; font-style: normal;}
</style>
</head>

<body>
<h2>抽獎(jiǎng)效果演示</h2>

<!-- Demo start  -->
<div class="rotary">
	<div class="rotaryArrow" id="rotaryArrow"></div>
	<!--<div class="list">
		<h4>中獎(jiǎng)名單</h4>
		<ul>
			<li>jq22.com</li>
			<li>1569****851</li>
			<li>1515****206</li>
			<li>1550****789</li>
			<li>1370****627</li>
			<li>1828****215</li>
			<li>1589****572</li>
			<li>1583****825</li>
			<li>1396****805</li>
			<li>1332****261</li>
			<li>1884****863</li>
			<li>1384****955</li>
			<li>1897****137</li>
			<li>1342****973</li>
			<li>1558****071</li>
			<li>1554****168</li>
			<li>1562****018</li>
			<li>1805****856</li>
			<li>1354****809</li>
			<li>1383****364</li>
		</ul>
	</div>-->
	<div class="result" id="result">
		<p id="resultTxt"></p>
		<a href="javascript:" id="resultBtn" title="關(guān)閉">關(guān)閉</a>
	</div>
</div>
<!-- Demo end -->

<script src="js/jquery-1.8.3.min.js"></script>
<script src="js/jquery.rotate.min.js"></script>
<script>
$(function(){
	var $rotaryArrow = $('#rotaryArrow');
	var $result = $('#result');
	var $resultTxt = $('#resultTxt');
	var $resultBtn = $('#result');

	$rotaryArrow.click(function(){
		var lottery_flag = 0;
		/**
		 * 數(shù)組 lottery為中獎(jiǎng)概率數(shù)組
		 *
		 * 中獎(jiǎng)概率:
		 * 0-不中獎(jiǎng):20%
		 * 1-1元代金券:35%
		 * 2-5元代金券:20%
		 * 3-10元代金券:12%
		 * 4-20元代金券:8%
		 * 5-50元代金券:1%
		 * 6-30元代金券:4%
		 */
		var lottery = [5,3,5,8,12,100,25];
		var data = [0, 1, 2, 3, 4, 5, 6];
		for (i=0;i<data.length;i++){
			if (Math.floor(Math.random()*lottery[i]) == 1){
               lottery_flag = data[i];
				break;
			}
		}
		var flag = 177;     //設(shè)置未中獎(jiǎng)的默認(rèn)角度
		var date = new Date();
		var seconds = date.getSeconds();
		if(seconds % 2 == 0){
			//根據(jù)時(shí)間秒數(shù)是否被2整除,模擬未中獎(jiǎng)時(shí)指針對(duì)兩個(gè)未中獎(jiǎng)角度的隨機(jī)
            flag = 0;
		}
		switch(lottery_flag){
			case 1:
				rotateFunc(1,87,'恭喜您獲得了 <em>1</em> 元代金券');
				break;
			case 2:
				rotateFunc(2,43,'恭喜您獲得了 <em>5</em> 元代金券');
				break;
			case 3:
				rotateFunc(3,134,'恭喜您獲得了 <em>10</em> 元代金券');
				break;
			case 4:
				rotateFunc(5,223,'恭喜您獲得了 <em>20</em> 元代金券');
				break;
			case 5:
				rotateFunc(6,268,'恭喜您獲得了 <em>50</em> 元代金券');
				break;
			case 6:
				rotateFunc(7,316,'恭喜您獲得了 <em>30</em> 元代金券');
				break;
			default:
				rotateFunc(0,flag,'很遺憾,這次您未抽中獎(jiǎng),繼續(xù)加油吧');
		}
	});

	var rotateFunc = function(awards,angle,text){  //awards:獎(jiǎng)項(xiàng),angle:獎(jiǎng)項(xiàng)對(duì)應(yīng)的角度
		$rotaryArrow.stopRotate();
		$rotaryArrow.rotate({
			angle: 0,
			duration: 5000,
			animateTo: angle + 1440,  //angle是圖片上各獎(jiǎng)項(xiàng)對(duì)應(yīng)的角度,1440是讓指針固定旋轉(zhuǎn)4圈
			callback: function(){
				$resultTxt.html(text);
				$result.show();
			}
		});
	};

	$resultBtn.click(function(){
		$result.hide();
	});
});
</script>










<!-- 以下是統(tǒng)計(jì)及其他信息,與演示無關(guān),不必理會(huì) -->
<style>
* { margin: 0; padding: 0;}
body { font-family: Consolas,arial,"宋體";}
h2 { width: 900px; margin: 40px auto; font: 32px "Microsoft Yahei"; text-align: center;}
.explain, .dowebok-explain { margin-top: 20px; font-size: 14px; text-align: center; color: #f50;}

.vad { margin: 50px 0 5px; font-family: Consolas,arial,宋體; text-align:center;}
.vad a { display: inline-block; height: 36px; line-height: 36px; margin: 0 5px; padding: 0 50px; font-size: 14px; text-align:center; color:#eee; text-decoration: none; background-color: #222;}
.vad a:hover { color: #fff; background-color: #000;}
.thead { width: 728px; height: 90px; margin: 0 auto; border-bottom: 40px solid #fff;}

.code { position: relative; margin-top: 100px; padding-top: 41px;}
.code h4 { position: absolute; top: 0; z-index: 10; width: 100px; height: 40px; font: 16px/40px "Microsoft Yahei"; text-align: center; cursor: pointer;}
.code .cur { border: 1px solid #f0f0f0; border-bottom: 1px solid #f8f8f8; background-color: #f8f8f8;}
.code .h41 { left: 0;}
.code .h42 { left: 102px;}
.code .h43 { left: 204px;}
.code .h44 { left: 306px;}
.code { width: 900px; margin-left: auto; margin-right: auto;}
pre { padding: 15px 0; border: 1px solid #f0f0f0; background-color: #f8f8f8;}
.f-dn { display: none;}
</style>

</body>
</html>


附件:http://down.51cto.com/data/2368005
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI