jquery老虎机抽奖

引入外部css:

<link rel="stylesheet" href="https://download.shengli.com/ui/control/lottery/css/base.css"> 

引入外部js:

<script type="text/javascript" src="https://download.shengli.com/ui/js/jquery.min.js"></script>
<script type="text/javascript" src="https://download.shengli.com/ui/control/lottery/js/lottery.js"></script> 

引入html:

<div style="width:50%;margin-top: 10px;overflow: hidden;">
    <a class="game-header" href="javascript:void(0);">
        <img src="https://download.shengli.com/ui/control/lottery/images/1p.png">
    </a>
    <div class="game-content">
        <img src="https://download.shengli.com/ui/control/lottery/images/2p.png">
        <div class="game-prize-wrap">
            <div class="game-prize-list">
                <div class="game-prize" style="background: #ffffff;">
                    <div class="game-prize-box" id="game1" data-index="1">
                        <ul class="game-prize-ul" style="">
                        </ul>
                    </div>
                </div>
                <div class="game-prize" style="background: #ffffff;">
                    <div class="game-prize-box" id="game2" data-index="2">
                        <ul class="game-prize-ul" style="">
                        </ul>
                    </div>
                </div>
                <div class="game-prize" style="background: #ffffff;">
                    <div class="game-prize-box" id="game3" data-index="3">
                        <ul class="game-prize-ul">
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <a class="game-rule" href="javascript:void(0);"></a>
        <span class="game-btn"></span>
    </div>
</div>

引入js:

$(function() {
    var _luckGame = $(".game-btn").luckGame({
        sameTimeBegin: 1, //是否同时开始,默认1
        duration: 5000, //动画时间,默认5000
        gameLen: 10, //产品抽奖数量,
        game_pagesize: 6,
        game_front: '', //奖品前缀
        lottery_arr_init: [2, 3, 4], //初始化默认显示奖品数组
        game_prize_box: '.game-prize-box', //奖品盒子
        game_prize_ul: '.game-prize-ul', //奖品数组ul
        game_img_root:'https://download.shengli.com/ui/control/lottery/images/',//奖品图片根目录
        end: function(result) {
            console.log(result);
            alert('中奖结果数组为:' + result.prize);
        }
    });

    //开始抽奖
    $(".game-btn").click(function() {
        _luckGame.lottery_arr_number = [3, 6, 9]; //设置中奖结果数组
        _luckGame.start();
    })
})