W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
插件描述:很實(shí)用的大轉(zhuǎn)盤插件,配置簡(jiǎn)單易用,各種回調(diào),方便快捷
<div id="box" class="box">
<div class="outer KinerLottery KinerLotteryContent"><img src="./imgs/lotteryContent.png"></div>
<!-- 大專盤分為三種狀態(tài):活動(dòng)未開(kāi)始(no-start)、活動(dòng)進(jìn)行中(start)、活動(dòng)結(jié)束(completed),可通過(guò)切換class進(jìn)行切換狀態(tài),js會(huì)根據(jù)這3個(gè)class進(jìn)行匹配狀態(tài) -->
<div class="inner KinerLotteryBtn start"></div>
</div>
/**
* 根據(jù)轉(zhuǎn)盤旋轉(zhuǎn)角度判斷獲得什么獎(jiǎng)品
* @param deg
* @returns {*}
*/
var whichAward = function(deg) {
if ((deg > 330 && deg <= 360) || (deg > 0 && deg <= 30)) { //10M流量
return "三網(wǎng)通流量 10M";
} else if ((deg > 30 && deg <= 90)) { //IPhone 7
return "iPhone7";
} else if (deg > 90 && deg <= 150) { //30M流量
return "三網(wǎng)通流量 30M";
} else if (deg > 150 && deg <= 210) { //5元話費(fèi)
return "話費(fèi)5元";
} else if (deg > 210 && deg <= 270) { //IPad mini 4
return "ipad mini4";
} else if (deg > 270 && deg <= 330) { //20元話費(fèi)
return "話費(fèi)20元";
}
}
var KinerLottery = new KinerLottery({
rotateNum: 8,
//轉(zhuǎn)盤轉(zhuǎn)動(dòng)圈數(shù)
body: "#box",
//大轉(zhuǎn)盤整體的選擇符或zepto對(duì)象
direction: 0,
//0為順時(shí)針轉(zhuǎn)動(dòng),1為逆時(shí)針轉(zhuǎn)動(dòng)
disabledHandler: function(key) {
switch (key) {
case "noStart":
alert("活動(dòng)尚未開(kāi)始");
break;
case "completed":
alert("活動(dòng)已結(jié)束");
break;
}
},
//禁止抽獎(jiǎng)時(shí)回調(diào)
clickCallback: function() {
//此處訪問(wèn)接口獲取獎(jiǎng)品
function random() {
return Math.floor(Math.random() * 360);
}
this.goKinerLottery(random());
},
//點(diǎn)擊抽獎(jiǎng)按鈕,再次回調(diào)中實(shí)現(xiàn)訪問(wèn)后臺(tái)獲取抽獎(jiǎng)結(jié)果,拿到抽獎(jiǎng)結(jié)果后顯示抽獎(jiǎng)畫(huà)面
KinerLotteryHandler: function(deg) {
alert("恭喜您獲得:" + whichAward(deg));
} //抽獎(jiǎng)結(jié)束回調(diào)
});
html {
font-size : 20px;
}
@media only screen and (min-width: 401px){
html {
font-size: 25px !important;
}
}
@media only screen and (min-width: 428px){
html {
font-size: 26.75px !important;
}
}
@media only screen and (min-width: 481px){
html {
font-size: 30px !important;
}
}
@media only screen and (min-width: 569px){
html {
font-size: 35px !important;
}
}
@media only screen and (min-width: 641px){
html {
font-size: 40px !important;
}
}
html, body {
padding: 0;
margin: 0;
background: #fffeea;
height: 100%;
}
p,li,b,span,div,strong,h1,h2,h3,h4,h5,h6,a,ul{
margin: 0;
padding: 0;
text-decoration: none;
list-style: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.box {
width: 14rem;
height: 14rem;
position: relative;
margin: 0 auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
-webkit-transform: translate(-50%,-50%);
-moz-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
-o-transform: translate(-50%,-50%);
}
.box .outer {
width: 100%;
height: 100%;
position: absolute;
z-index: 1;
top: 0;
left: 0;
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
}
.box .outer img{
width: 100%;
}
.box .inner{
position: relative;
width: 5rem;
height: 5rem;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
z-index: 2;
background-image: url(../imgs/lotteryBtn.png);
background-size: auto 5rem;
background-repeat: no-repeat;
}
.box .inner.start:active{
-webkit-transform: translate(-50%, -50%) scale(.95);
-moz-transform: translate(-50%, -50%) scale(.95);
-ms-transform: translate(-50%, -50%) scale(.95);
-o-transform: translate(-50%, -50%) scale(.95);
transform: translate(-50%, -50%) scale(.95);
}
.box .inner.start{
background-position: 0 0;
}
.box .inner.no-start{
background-position: -5rem 0;
}
.box .inner.completed{
background-position: -10rem 0;
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: