特效介绍

jquery幸运大转盘,jquery转盘抽奖插件

中奖提示效果图
幸运大转盘抽奖jquery插件,转动起来本身不转,而是转盘上的光斑会转动,跑马灯也会跟着闪烁,转的越快,闪烁越快。转动结束,光斑会停留在中奖的那一栏,并且弹出对应的中奖提示,还可以发微博等等。本插件抽奖概率、中奖奖品等等都可以直接在参数中设置,非常方便,而且兼容性非常好。我爱模板网目前测试到了IE7,没有任何问题。
使用方法
第一步:在head引入下面的代码:
01 | <link rel= "stylesheet" type= "text/css" href= "css/reset.css" /> |
02 | <link rel= "stylesheet" type= "text/css" href= "css/common.css" /> |
03 | <link rel= "stylesheet" type= "text/css" href= "css/jqueryui/jqueryui.css" /> |
05 | <script type= "text/javascript" src= "js/jqueryui.js" ></script> |
06 | <style type= "text/css" > |
07 | body{ background : url ( 'images/bg_01.jpg' ) top center no-repeat #fff ; font : Arial , Helvetica , sans-serif ;} |
08 | #header{ width : 960px ; margin : 0 auto ; position : relative ;} |
09 | #turnplatewrapper{ height : 592px ; width : 592px ; background : url ( 'images/plate_06.png' ) top left no-repeat ; left : 200px ; top : 20px ; position : absolute ;-moz-user-select: none ;user-select: none ;} |
10 | #turnplate{ height : 592px ; width : 592px ; background : url ( 'images/plate_05.png' ) top left no-repeat ;} |
11 | #turnplate #awards{ position : absolute ; width : 100% ; height : 100% ; background : url ( 'images/plate_03.png' ) top left no-repeat ;} |
12 | #platebtn{ position : absolute ; top : 218px ; left : 218px ; background : url ( 'images/plate_04.png' ) top left no-repeat ; height : 155px ; width : 155px ; cursor : pointer ;} |
13 | #platebtn.hover{ background-position : 0 -155px } |
14 | #turnplate #platebtn.click{ background-position : 0 -310px } |
15 | #gift{ width : 398px ; height : 89px ; background : url ( 'images/plate_gift_01.png' ) top left no-repeat ; position : absolute ; left : 90px ; top : 720px ;} |
16 | #msg{ position : absolute ; display : none ; top : 130px ; left : 195px ;border-radius: 5px ; color : #333 ; border : 3px solid #FED33f ;box-shadow: 2px 2px 2px rgba( 0 , 0 , 0 , 0.6 ); background : #fffcf2 ; width : 200px ; padding : 10px ; text-align : center ;} |
18 | #init{ position : absolute ; top : 50% ; left : 50% ; width : 100px ; height : 30px ;border-radius: 5px ; color : #333 ; border : 3px solid #FED33f ;box-shadow: 2px 2px 2px rgba( 0 , 0 , 0 , 0.6 ); background : #fffcf2 ; width : 250px ; padding : 10px ; margin-top : -30px ; margin-left : -138px ; text-align : center ;opacity: 0.9 ;filter:alpha(opacity= 90 );} |
19 | #login{ margin-left : 20px ;} |
20 | #login .tips{ margin-left : 50px ; font-size : 12px ; margin-bottom : -5px ;} |
21 | #login .tips a{ color : #039 ; font-size : 16px ; text-decoration : underline ;} |
22 | #login .msg{ color : red ;} |
23 | #login label{ height : 30px ; line-height : 30px ; font-size : 16px ;} |
24 | #login .ipt{ background : #fff ; border : 1px solid #ccc ; height : 28px ; line-height : 28px ; margin-bottom : 10px ;box-shadow: 0 1px 0 #fff ;border-radius: 2px ; width : 200px ;} |
25 | #login .ipt:focus{box-shadow: 0 0 3px rgba( 86 , 180 , 289 , 0.3 ); border : 1px solid #56b4ef ;} |
27 | #lotteryMsg .msg{ font-size : 16px ; color : red ; font-weight : bold ; text-align : center ; font-size : 26px ; color : #ba0f54 ; line-height : 1 ; margin-bottom : 10px ;} |
28 | #lotteryMsg .tips{ text-align : center ; font-size : 14px ;} |
29 | #lotteryMsg .sp{ border-top : 1px solid #c3c3c3 ; border-bottom : 0 none transparent ; border-right : 0 none transparent ; border-left : 0 none transparent ; overflow : hidden ; height : 0 ; margin : 10px 0 ;} |
30 | #lotteryMsg a{ color : #138cbe ;} |
31 | #lotteryMsg a:hover{ color : #039 ;} |
32 | #lotteryMsg .content{ border : 1px solid #ccc ;border-radius: 5px ; padding : 10px ; background : #fff ; line-height : 1.5 ;} |
33 | #top-menu-wrapper{ height : 51px ; background : url ( 'images/bg_02.png' ) top center repeat-x ; margin-bottom : -51px ;} |
34 | #top-menu{ width : 960px ; margin : 0 auto ;} |
35 | #top-menu a, #top-menu span{ line-height : 50px ; display :inline- block ; font-size : 16px ; color : #fff ; text-decoration : 1px 1px 2px rgba( 0 , 0 , 0 , 0.3 );} |
36 | #top-menu .user{ padding-left : 30px ; display :inline- block ; height : 50px ; color : #fff ; background : url ( 'images/bg_03.png' ) 0 16px no-repeat ;} |
38 | <style type= "text/css" > |
40 | body .ui-dialog{ padding : 0px ; background : #ebeae3 ;box-shadow: 2px 2px 5px rgba( 0 , 0 , 0 , 0.5 );} |
41 | body .ui-dialog .ui-dialog-titlebar{ height : 23px ; padding : 0 ; margin : 0 ; background : none ; border : 0 none transparent ;} |
42 | body .ui-dialog .ui-dialog-titlebar .ui-dialog-title{ display : none ;} |
43 | body .ui-widget-content{ border : 4px solid #F7D102 ;} |
44 | body .ui-dialog .ui-dialog-titlebar-close{ background : #f6d20d ; right : 0 ; margin-top : -12px ;} |
45 | body .ui-dialog .ui-dialog-buttonpane{ border : 0 none transparent ;} |
46 | body .ui-dialog .ui-button-text{ padding : 0.8em 1em ;} |
47 | body .ui-widget-overlay{ background : url ( 'images/bg_04.png' );_filter:alpha(opacity= 60 );} |
48 | .mv 5 { margin-left : 5px ; margin-right : 5px ;} |
第二步:在body引入相关html代码:
01 | < div id = "top-menu-wrapper" class = "dn bgfix" > |
05 | < span >(今天还有</ span >< span class = "lottery-times" >0</ span > |
13 | < div id = "turnplatewrapper" onselectstart = "return false;" class = "bgfix" > |
14 | < div id = "turnplate" class = "bgfix" > |
15 | < div id = "awards" class = "bgfix" ></ div > |
16 | < div id = "platebtn" class = "bgfix" ></ div > |
18 | < p id = "init" class = "dn" >初始化中,请稍后< span ></ span ></ p > |
21 | < div id = "gift" class = "bgfix" ></ div > |
25 | < div id = "lotteryMsg" class = "dn" > |
27 | < p class = "tips" >中奖空间已自动添加到您的快盘帐号中,< a href = "http://www.5imoban.net" title = "网站模板" target = "_blank" >点击查看</ a >。</ p > |
29 | < p class = "mv5" style = "margin-bottom:5px" >发送以下内容到新浪微博,还可额外获得5M永久空间哦!</ p > |
30 | < div class = "content mv5" > |
31 | “幸运大转盘,快盘送空间” < span class = "option" ></ span >每日大转盘摇奖,轻松扩容,惊喜不断,抢100G永久空间点击->http://www.5imoban.net 同步网盘领军产品,4500万用户的选择,值得信赖。 |
37 | < div id = "new-login" class = "dn" ></ div > |
第三步(非必须):如果要兼容IE6,还要引入一个IE6 PNG透明的js文件和代码:
2 | <script src= "js/DD_belatedPNG_0.0.8a-min.js" ></script> |
3 | <script>DD_belatedPNG.fix( '.bgfix' );</script> |
第四步:调用轮盘相关代码:
001 | <script type= "text/javascript" > |
003 | $( '#new-login' ).dialog({ |
013 | <script type= "text/javascript" > |
017 | <script type= "text/javascript" > |
019 | turnplateBox : $( '#turnplate' ), |
020 | turnplateBtn : $( '#platebtn' ), |
021 | lightDom : $( '#turnplatewrapper' ), |
040 | initBoxEle : $( '#turnplate #init' ), |
041 | progressEle : $( '#turnplate #init span' ), |
042 | initProgressContent : '~~~^_^~~~' , |
043 | initFreshInterval : 500, |
044 | virtualDistance : 10000, |
047 | initTime : undefined, |
099 | this .turnplateBtn.click($.proxy( function (){ |
105 | initAnimate : function () { |
106 | this .initBoxEle.show(); |
107 | clearTimeout( this .initTimer); |
108 | var curLength = this .progressEle.text().length, |
109 | totalLength = this .initProgressContent.length; |
111 | if (curLength < totalLength) { |
112 | this .progressEle.text( this .initProgressContent.slice(0, curLength + 1)); |
114 | this .progressEle.text( '' ); |
116 | this .initTimer = setTimeout($.proxy( this .initAnimate, this ), this .initFreshInterval); |
120 | stopInitAnimate : function () { |
121 | clearTimeout( this .initTimer); |
122 | this .initBoxEle.hide(); |
125 | freshLotteryTime : function () { |
126 | $( '#top-menu' ).find( '.lottery-times' ).html( this .lotteryTime); |
130 | freshLottery : function () { |
131 | this .stopInitAnimate(); |
134 | this .lotteryTime = 1; |
135 | this .freshLotteryTime(); |
140 | setBtnHover : function () { |
142 | $( '#platebtn' ).hover( function (){ |
143 | $( this ).addClass( 'hover' ); |
145 | $( this ).removeClass( 'hover click' ); |
146 | }).mousedown( function (){ |
147 | $( this ).addClass( 'click' ); |
148 | }).mouseup( function (){ |
149 | $( this ).removeClass( 'click' ); |
154 | lottery : function () { |
155 | this .lotteryIndex = undefined; |
157 | this .freshLotteryTime(); |
159 | this .curSpeed = this .minSpeed; |
161 | this .lotteryIndex = typeof this .lotteryType[2] !== 'undefined' ? this .lotteryType[2] : this .errorIndex; |
162 | this .lotteryChannel = typeof this .channelList[1] !== 'undefined' ? this .channelList[1] : '' ; |
168 | if ( this .isStop == false ) { |
169 | this .showMsg( '现在还不能抽奖哦' ); |
178 | freshSpeed : function () { |
179 | var totalResistance = this .minResistance + this .curSpeed * this .Cx; |
180 | var accSpeed = this .accSpeed; |
181 | var curSpeed = this .curSpeed; |
182 | if ( this .totalFrame >= this .accFrameLen) { |
185 | curSpeed = curSpeed - totalResistance + accSpeed; |
187 | if (curSpeed < this .minSpeed){ |
188 | curSpeed = this .minSpeed; |
189 | } else if (curSpeed > this .maxSpeed){ |
190 | curSpeed = this .maxSpeed; |
193 | this .curSpeed = curSpeed; |
197 | switchLight : function () { |
198 | this .lightSwitch = this .lightSwitch === 0 ? 1 : 0; |
199 | var lightHeight = - this .lightSwitch * this .height; |
200 | this .lightDom.css( 'backgroundPosition' , '0 ' + lightHeight.toString() + 'px' ); |
204 | turnAround : function () { |
207 | var intervalTime = parseInt( this .virtualDistance/ this .curSpeed); |
208 | this .timer = window.setTimeout( 'turnplate.changeNext()' , intervalTime); |
212 | showAwards : function (){ |
213 | $( '#lotteryMsg' ).dialog( 'open' ); |
217 | showMsg : function (msg, isFresh) { |
218 | isFresh = typeof isFresh == 'undefined' ? false : true ; |
219 | if ( typeof msg != 'string' ){ |
220 | msg = '今天已经抽过奖了,明天再来吧' ; |
222 | var msgBox = this .msgBox; |
223 | var display = msgBox.css( 'display' ); |
227 | window.clearTimeout( this .timer2); |
228 | msgBox.stop( true , true ).show(); |
229 | var fadeOut = $.proxy( function () { |
230 | this .msgBox.fadeOut( 'slow' ); |
232 | this .timer2 = window.setTimeout(fadeOut, this .showMsgTime); |
237 | changeNext : function () { |
239 | if ( this .lotteryIndex !== undefined && this .curFrame == this .lotteryIndex && this .curSpeed <= this .minSpeed+10 && this .totalFrame > this .accFrameLen) { |
245 | var nextFrame = this .curFrame+1 < this .frameLen ? this .curFrame+1 : 0; |
246 | var bgTop = - nextFrame * this .height; |
247 | this .turnplateBox.css( 'backgroundPosition' , '0 ' + bgTop.toString() + 'px' ); |
249 | this .curFrame = nextFrame; |
260 | <script type= "text/javascript" > |
263 | $.fn.login = function (options){ |
266 | loginUrl: 'account/login/' , |
267 | msgEle: $( this ).find( '.msg' ), |
268 | loginIdEle: $( this ).find( '#loginId' ), |
269 | passwordEle: $( this ).find( '#password' ) |
273 | 'inputCorrectEmail' : '请输入正确的用户名' , |
274 | 'inputPassword' : '请填写登录密码' , |
275 | 'passwordLength' : '密码应在6-32位字符内' , |
277 | 'checkemailcode_2' : '此账号未注册' , |
278 | 'checkemailcode_' : '服务器繁忙,请稍后再试' , |
279 | 'accountNotMatch' : '账号密码不匹配' , |
280 | 'serverdown' : '服务器维护中' , |
281 | 'clientUserBaned' : '您的账号被限制登录' , |
282 | 'accUserInvalid' : '正在对该账号进行绑定处理,暂无法登陆' , |
283 | 'userLocked' : '帐号锁定中,暂时无法登录' , |
288 | var loginId = $.trim(settings.loginIdEle.val()), |
289 | password = $.trim(settings.passwordEle.val()); |
301 | $.post(settings.loginUrl, { 'loginId' : loginId, 'password' : password}, function (data){ |
302 | if (data.status == 'ok' ) { |
305 | if ( typeof ERROR_MSG[data.status] == 'string' ) { |
306 | showMsg(ERROR_MSG[data.status]); |
314 | function showMsg(msg) { |
315 | settings.msgEle.html(msg); |
318 | if ( typeof options == 'string' ){ |
332 | $( '#lotteryMsg' ).dialog({ |
340 | var showMsg = '您抽中了: ' + turnplate.lotteryList[turnplate.lotteryIndex] ; |
341 | var options = '今天抽中了' + turnplate.lotteryList[turnplate.lotteryIndex] + ',' + turnplate.lotteryDes[turnplate.lotteryIndex]; |
342 | $( '#lotteryMsg' ).find( '.msg' ).html(showMsg); |
343 | $( '#lotteryMsg' ).find( '.option' ).html(options); |
348 | var options = '今天抽中了' + turnplate.lotteryList[turnplate.lotteryIndex] + ',' + turnplate.lotteryDes[turnplate.lotteryIndex]; |
350 | window.open(jumpUrl, "top" , "width=1024,height=750,menubar=0,scrollbars=1, resizable=1,status=1,titlebar=0,toolbar=0,location=1" ); |
351 | $( this ).dialog( 'close' ); |
365 | $( '#login' ).bind( 'keydown' , function (e){ |
367 | $( '#login' ).login( 'submit' ); |
373 | $( '#login' ).unbind( 'keydown' ); |
374 | $( '#login #password' ).val( '' ); |
379 | $( '#login' ).login( 'submit' ); |
具体怎么设置,上面的参数都已说明。