XML/HTML代码
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <link rel="dns-prefetch" href="//hd.youyuan.com">
- <link rel="dns-prefetch" href="//x.youyuan.com">
- <link rel="dns-prefetch" href="//f1.youyuan.com">
- <link rel="dns-prefetch" href="//f2.youyuan.com">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
- <meta content="yes" name="apple-mobile-web-app-capable" />
- <meta content="black" name="apple-mobile-web-app-status-bar-style" />
- <meta content="telephone=no" name="format-detection" />
- <title>抽奖结果</title>
- <link href="css/love-qixi.css" rel="stylesheet" type="text/css" />
- <style>
- .ele{ background:url(images/selected.png); display:none}
- .lotteryBox{ width:96%; margin:0 auto;}
- .lotteryBox .lottery{ width:290px; height:290px; margin:0 auto; background:url(images/lottery.png) no-repeat; background-size:100%; position:relative; z-index:101;}
- .lotteryBox .lottery .prize_{ width:25%; height:25%; position:absolute; z-index:102;}
- .lotteryBox .lottery .prize_1{ left:0; top:0;}
- .lotteryBox .lottery .prize_2{ left:25%; top:0;}
- .lotteryBox .lottery .prize_3{ left:50%; top:0;}
- .lotteryBox .lottery .prize_4{ left:75%; top:0;}
- .lotteryBox .lottery .prize_5{ left:75%; top:25%;}
- .lotteryBox .lottery .prize_6{ left:75%; top:50%;}
- .lotteryBox .lottery .prize_7{ left:75%; top:75%;}
- .lotteryBox .lottery .prize_8{ left:50%; top:75%;}
- .lotteryBox .lottery .prize_9{ left:25%; top:75%;}
- .lotteryBox .lottery .prize_10{ left:0%; top:75%;}
- .lotteryBox .lottery .prize_11{ left:0%; top:50%;}
- .lotteryBox .lottery .prize_12{ left:0%; top:25%;}
- .lotteryBox .lottery .selected{ background-image:url(images/selected.png); background-repeat: no-repeat; background-size:90%;}
- .lotteryBox .lottery .prize_1.selected{ background-position: 20% 30%;}
- .lotteryBox .lottery .prize_2.selected{ background-position: 36% 30%;}
- .lotteryBox .lottery .prize_3.selected{ background-position: 40% 30%;}
- .lotteryBox .lottery .prize_4.selected{ background-position: 60% 30%;}
- .lotteryBox .lottery .prize_5.selected{ background-position: 60% 35%;}
- .lotteryBox .lottery .prize_6.selected{ background-position: 60% 35%;}
- .lotteryBox .lottery .prize_7.selected{ background-position: 60% 50%;}
- .lotteryBox .lottery .prize_8.selected{ background-position: 60% 50%;}
- .lotteryBox .lottery .prize_9.selected{ background-position: 36% 50%;}
- .lotteryBox .lottery .prize_10.selected{ background-position: 20% 50%;}
- .lotteryBox .lottery .prize_11.selected{ background-position: 20% 35%;}
- .lotteryBox .lottery .prize_12.selected{ background-position: 20% 35%;}
- </style>
- </head>
- <body>
- <div class="top_blank"></div>
- <nav class="nav">
- <h2 class="pink">抽奖结果</h2>
- <div class="left" onClick="history.go(-1)"> <i class="le_trg"></i></div>
- <div class="right"><!-- <span id="search_sure" class="seach_sure">确定</span>--> </div>
- </nav>
- <div class="ele"></div>
- <div class="blank10"></div>
- <div class="lotteryBox">
- <div class="lottery">
- <div class="prize_ prize_1"></div>
- <div class="prize_ prize_2"></div>
- <div class="prize_ prize_3"></div>
- <div class="prize_ prize_4"></div>
- <div class="prize_ prize_5"></div>
- <div class="prize_ prize_6"></div>
- <div class="prize_ prize_7"></div>
- <div class="prize_ prize_8"></div>
- <div class="prize_ prize_9"></div>
- <div class="prize_ prize_10"></div>
- <div class="prize_ prize_11"></div>
- <div class="prize_ prize_12"></div>
- </div>
- <div class="blank10"></div>
- <div class="upload-btn send-out start_" usable="false">开始抽奖</div>
- </div><!-- lotteryBox -->
- </body>
- <script type="text/javascript" src="//f1.youyuan.com/xfile/www/js/??public/lib/zepto/zepto-1.1.6.js,public/m/ajax-min.js"></script>
- <script type="text/javascript" src="js/all.js"></script>
- <script type="text/javascript">
- var lottery={
- beginning:-1, //从哪个位置【起点】
- prizeNum:-1, //到哪个位置【终点】
- countNum:0, //循环DOM总共有多少个
- bufferNum:60, //转动基本次数:至少转动60次之后才可以停顿
- timer:0, //setTimeout的ID,用clearTimeout清除
- speed:20, //循环DOM转动的速度
- times:0, //向前走过的个数每次+1
- shared:0,
- cNum:0,
- beginFun:function(){
- lottery.times+=1;
- var NTT=lottery.times;
- var datanum=lottery.times;
- var dataccc=Math.ceil(datanum/2)-1;
- if(datanum%2==0){
- $(".game_").addClass("game_on");
- }
- else if(datanum%2!=0){
- $(".game_").removeClass("game_on");
- }
- lottery.rollFun();
- if (lottery.times>lottery.bufferNum&&lottery.prizeNum==lottery.beginning){
- if(lottery.prizeNum==0){
- //alert("恭喜您,中了第5个奖品")
- }else if(lottery.prizeNum==1){
- //alert("恭喜您,中了第5个奖品")
- }else if(lottery.prizeNum==2){
- //alert("恭喜您,中了第5个奖品")
- }else if(lottery.prizeNum==3){
- //alert("恭喜您,中了第5个奖品")
- }else if(lottery.prizeNum==4){
- //alert("恭喜您,中了第5个奖品")
- }else if(lottery.prizeNum==5){
- //alert("恭喜您,中了第5个奖品")
- }else if(lottery.prizeNum==5&&lottery.shared==0&&lottery.cNum==0){
- //alert("恭喜您,中了第5个奖品")
- }else if(lottery.prizeNum==6){
- //alert("恭喜您,中了第5个奖品")
- }else if(lottery.prizeNum==7){
- //alert("恭喜您,中了第5个奖品")
- }
- clearTimeout(lottery.timer);
- lottery.prizeNum=-1;
- lottery.times=0;
- click=false;
- }else{
- if (lottery.times<lottery.bufferNum) {
- lottery.speed-=10;
- }else if(lottery.times==lottery.bufferNum) {
- //var beginning = Math.random()*(lottery.countNum)|0;
- //lottery.prizeNum = 3;
- }else{
- if (lottery.times>lottery.bufferNum&&((lottery.prizeNum==0&&lottery.beginning==7)||lottery.prizeNum==lottery.beginning+1)){
- lottery.speed+=110;
- }else{
- lottery.speed+=20;
- }
- }
- if (lottery.speed<40) {
- lottery.speed=40;
- };
- //console.log(lottery.times+'^^^^^^'+lottery.speed+'^^^^^^^'+lottery.prizeNum);
- lottery.timer=setTimeout(lottery.beginFun,lottery.speed);
- }
- return false;
- },
- initFun:function(className){
- //该模块主要是选择器,最后给起点加上CSS样式
- if ($("."+className).find(".prize_").length>0){
- $objD=$("."+className);
- $childNode=$objD.find(".prize_");
- this.obj=$objD;
- this.countNum=$childNode.length;
- $objD.find(".prize_"+this.index).addClass("selected");
- };
- },
- rollFun:function(){
- //该模块主要是步进值循环移除及添加,到终点后设置Index值为0
- var index=this.beginning;
- var count=this.countNum;
- var objD=this.obj;
- $(objD).find(".prize_"+index).removeClass("selected");
- index+=1;
- if (index>count){
- index=0;
- };
- $(objD).find(".prize_"+index).addClass("selected");
- this.beginning=index;
- return false;
- },
- stopFun:function(index){
- this.prizeNum=index;
- return false;
- }
- };
- //获取整体的宽度并设置子节点宽度
- var _lotteryBoxWidth=$(".lotteryBox").width();
- $(".lottery").css({"width":_lotteryBoxWidth,"height":_lotteryBoxWidth});
- //点击抽奖按钮调用公共方法
- $(".start_").click(function(){
- lottery.initFun('lottery');
- lottery.prizeNum=5;
- lottery.speed=100;
- lottery.cNum=1;
- //开始抽奖执行方法
- lottery.beginFun();
- });
- </script>
- </html>