pc端轉盤抽獎活動(兼容ie7)




    var playnum = 1; //初始次數,由後臺傳入
    var isture = 0;
    var clickfunc = function () {
        var data = [1, 2, 3, 4, 5, 6, 7, 8, 9];
        //data爲根據概率後的結果
        //data = data[Math.floor(Math.random() * data.length)];
        data = 1;
        var $trophy = $('.trophy');
        switch (data) {
            case 1:
                rotateFunc(1, 0, '大疆無人機')
                setTimeout(function () {
                    $trophy.find('h2').text('中獎啦!').end()
                           .find('img').attr('src', '/images/Turntable/t04.png').removeClass('regret').end()
                           .find('p').text('恭喜您,獲得大疆無人機一臺!');
                    hj();
                }, 4500);
                break;
            case 2:
                rotateFunc(2, 280, '小米電視')//角度數表示圖片逆時針從箭頭數第幾個*40
                setTimeout(function () {
                    $trophy.find('h2').text('中獎啦!').end()
                           .find('img').attr('src', '/images/Turntable/t05.png').removeClass('regret').end()
                           .find('p').text('恭喜您,獲得小米電視一臺!');
                    hj();
                }, 4500);
                break;
            case 3:
                rotateFunc(3, 200, '九陽原汁機')
                setTimeout(function () {
                    $trophy.find('h2').text('中獎啦!').end()
                           .find('img').attr('src', '/images/Turntable/t06.png').removeClass('regret').end()
                           .find('p').text('恭喜您,獲得九陽原汁機一臺!');
                    hj();
                }, 4500);
                break;
            case 4:
                rotateFunc(4, 120, '格力空調扇')
                setTimeout(function () {
                    $trophy.find('h2').text('中獎啦!').end()
                           .find('img').attr('src', '/images/Turntable/t07.png').removeClass('regret').end()
                           .find('p').text('恭喜您,獲得格力空調扇一臺!');
                    hj();
                }, 4500);
                break;
            case 5:
                rotateFunc(5, 40, '美的電烤箱')
                setTimeout(function () {
                    $trophy.find('h2').text('中獎啦!').end()
                           .find('img').attr('src', '/images/Turntable/t08.png').removeClass('regret').end()
                           .find('p').text('恭喜您,獲得美的電烤箱一臺!');
                    hj();
                }, 4500);
                break;
            case 6:
                rotateFunc(6, 80, '小米充電寶')
                setTimeout(function () {
                    $trophy.find('h2').text('中獎啦!').end()
                           .find('img').attr('src', '/images/Turntable/t09.png').removeClass('regret').end()
                           .find('p').text('恭喜您,獲得小米充電寶一個!');
                    hj();
                }, 4500);
                break;
            case 7:
                rotateFunc(7, 160, '50元話費券')
                setTimeout(function () {
                    $trophy.find('h2').text('中獎啦!').end()
                           .find('img').attr('src', '/images/Turntable/t10.png').removeClass('regret').end()
                           .find('p').text('恭喜您,獲得50元話費券一張!');
                    hj();
                }, 4500);
                break;
            case 8:
                rotateFunc(8, 320, '5元返金券')
                setTimeout(function () {
                    $trophy.find('h2').text('中獎啦!').end()
                         .find('img').attr('src', '/images/Turntable/t11.png').removeClass('regret').end()
                             .find('p').text('恭喜您,獲得5元返金券一張!');
                    hj();
                }, 4500);
                break;
            case 9:
                rotateFunc(4, 240, '謝謝參與')
                setTimeout(function () {
                    $trophy.find('h2').text('很遺憾~').end()
                           .find('img').attr('src', '/images/Turntable/t03.png').addClass('regret').end()
                           .find('p').text('本次未中獎,謝謝參與');
                    hj();
                }, 4500);
                break;
        }
    }


 $("#arrows").click(function () {
        if (isture) return; // 如果在執行就退出
        isture = true; // 標誌爲 在執行
        //先判斷是否登錄,未登錄則執行下面的函數
        if ($('#login').length>0){
            window.location.href = '/UserManage/Money/Inpour.aspx';
        } else { //登錄了就執行下面
            if (playnum <= 0) {
                notrophy();
                isture = false;
            } else {
                playnum = playnum - 1; //執行轉盤了則次數減1
                if (playnum <= 0) {
                    playnum = 0;
                }
                clickfunc();
            }
        }
    })

用的jQueryRotate.2.2.js插件




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章