<!doctype html>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  <title>中奖实例</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        body,html {
            width: 100%;
            height: 100%;
        }
        .ctn {
            width: 100%;
            height: 100%;
            background-color: #ccc;
        }
        .ctn .disk {
            width: 446px;
            height: 446px;
            border-radius: 1000px;
            position: relative;
            margin: 0 auto;
            background: url(http://sandbox.runjs.cn/uploads/rs/253/e6wsbxul/disk.jpg) no-repeat center;
        }
        .ctn .disk .btn {
            width: 85px;
            height: 85px;
            border-radius: 100px;
            position: absolute;
            top: 189px;
            left: 178px;
            cursor: pointer;
        }
        .ctn .disk img {
            position: absolute;
            top: 119px;
            left: 165px;
        }
        .ctn .disk .word {
            font-weight: bold;
        }
    </style>
    <script id="jquery_182" type="text/javascript" class="library" src="http://runjs.cn/js/sandbox/jquery/jquery-1.8.2.min.js"></script>
    <script id="jqueryplugins9_jquery_rotate_22" type="text/javascript" class="library" src="http://runjs.cn/js/sandbox/jquery-plugins/jQueryRotate.2.2.js"></script>
</head>
<body>
    <div class="ctn">
        <div class="disk">
            <img src="http://sandbox.runjs.cn/uploads/rs/253/e6wsbxul/start.png" width="112" />
            <div class="btn"></div>
            <p class="word">点击小图开始吧~</p>
        </div>
    </div>
<script>
    //转盘数据
    var data = [
        {angle: 0, reward: "恭喜您中了一等奖,呵呵~"},
        {angle: 30, reward: "谢谢参与,呵呵~"},
        {angle: 60, reward: "谢谢您的参与,呵呵~"},
        {angle: 90, reward: "要加油哦,呵呵~"},
        {angle: 120, reward: "恭喜您中了三等奖,呵呵~"},
        {angle: 150, reward: "运气先攒着,呵呵~"},
        {angle: 180, reward: "谢谢您的参与,呵呵~"},
        {angle: 210, reward: "再接再厉,呵呵~"},
        {angle: 240, reward: "恭喜您中了二等奖,呵呵~"},
        {angle: 270, reward: "祝您好运,呵呵~"},
        {angle: 300, eward: "谢谢您的参与,呵呵~"},
        {angle: 330, reward: "不要灰心,呵呵~"}
    ];
    //鼠标事件
    var onoff = true;
    $(".btn").click(function() {
        if(onoff){
            var result = whichNum(),
                angle = 0;
            angle = data[result]["angle"];
            $("img").rotate({
                angle: angle,
                animateTo: 3600 + data[result]["angle"],
                duration: 6000,
                callback: function() {
                    $(".word").text(data[result]["reward"]);
                    onoff = true;
                }
            });
        }
        onoff = false;
    });
    //分散中奖概率
    function whichNum() {
        var index = Math.ceil(Math.random()*100),
            num = 0;
        switch(true) {
            case (index==1)://一等奖
                num = 0;
                break;
            case (index>1&&index<=4)://二等奖
                num = 1;
                break;
            case (index>4&&index<=10)://三等奖
                num = 2;
                break;
            default://参与奖
                num = 3;
        }
        if(num==3) {
            num = Math.floor(Math.random()*9) + 3;
        }
        return num;
    }
</script>
</body>
</html>

最新文章

  1. 借助JavaScript中的Dom属性改变Html中Table边框的颜色
  2. Linux下开启关闭SeLinux
  3. 在Eclipse中添加C/C++插件
  4. August 27th 2016 Week 35th Saturday
  5. Script 语言的简单练习题 乘法口诀
  6. SharePoint\O365 CSOM操作&quot;请求访问设置&quot;功能
  7. Django的是如何工作的
  8. HDU 3333 - Turing Tree (树状数组+离线处理+哈希+贪心)
  9. [Express] Level 1: First Step
  10. 一款基于jQuery饼状图比例分布数据报表
  11. OD: Memory Attach Technology - Off by One, Virtual Function in C++ &amp; Heap Spray
  12. 【Java】【Fulme】Flume-NG源代码阅读之SpoolDirectorySource
  13. Codeforces 282E Sausage Maximization(字典树)
  14. Effective C++ -- 继承和面向对象设计
  15. 跑Java -jar somefile.jar时会发生什么(一个)
  16. 跨进程通信之Messenger
  17. 201521123049 《JAVA程序设计》 第4周学习总结
  18. 思科模拟器PacketTracer7--利用一台交换机将两台pc划分到不同vlan下
  19. #define宏定义中## #@ # \ 符号使用
  20. tomcat端口号被占用的问题

热门文章

  1. 给iOS工程增加Daily Build
  2. Css - 文本溢出处理
  3. NodeJs - 100
  4. java 从args[]中赋值和程序直接赋值不一样?
  5. Eclipse问题提示
  6. HDU 1671 Phone List(Trie的应用与内存释放)
  7. iOS 用宏定义写一个单例(Singleton)
  8. jQuery前端验证多种方式
  9. 浅析php学习的路线图
  10. RT-Thread 线程的让出