js 跑马灯抽奖

 
.kk{
    width: 146px;
    height: 158px;
}
var core={
            startScroll:function(endIndex){
                if(!core.isClick){
                    core.isClick=true;
                    var speed = true, curIndex = 0, minSpeed = 60, countTimes = 0, truns = 5;//,endIndex=woBase.getRandom(1,8);
                    var scroll=function(){
                        $(".k"+curIndex).addClass('cur').siblings(".cicle").removeClass("cur");
                        curIndex=(curIndex==8)?0:curIndex+1;
                        speed=(speed<=minSpeed)?minSpeed:(speed-10);
                        var sCreate=setTimeout(function(){
                            countTimes++;
                            if(countTimes<=truns*8-endIndex){
                                scroll();
                            }else {
                                speed+=40;
                                if(countTimes==8*(truns+1)+endIndex){
                                    clearInterval(sCreate);
                                    sCreate=null;
// core.showResult(endIndex);
                                    core.isClick = false;
                                    if (endIndex == 4) {
                                        $.WoDialog.success("恭喜您,获得3积分", function () {
                                            $.WoDialog.close();
                                        }, 1);
                                    }else if(endIndex == 2){
                                        $.WoDialog.success("很遗憾,您没有中奖", function () {
                                            $.WoDialog.close();
                                        }, 1);
                                    } else if (endIndex == 1) {
                                        $.WoDialog.success("恭喜您,抽中30元现金红包", function () {
                                            $.WoDialog.close();
                                        }, 1);
                                    } else if (endIndex == 3) {
                                        $.WoDialog.success("恭喜您,抽中5元现金红包", function () {
                                            $.WoDialog.close();
                                        }, 1);
                                    } else if (endIndex == 5) {
                                        $.WoDialog.success("恭喜您,抽中20元现金红包", function () {
                                            $.WoDialog.close();
                                        }, 1);
                                    } else if (endIndex == 6) {
                                        $.WoDialog.success("恭喜您,抽中2元现金红包", function () {
                                            $.WoDialog.close();
                                        }, 1);
                                    } else if (endIndex == 7) {
                                        $.WoDialog.success("恭喜您,抽中50元现金红包", function () {
                                            $.WoDialog.close();
                                        }, 1);
                                    } else if (endIndex == 8) {
                                        $.WoDialog.success("恭喜您,抽中10元现金红包", function () {
                                            $.WoDialog.close();
                                        }, 1);
                                    }
                                    getScoreData();
                                }else {
                                    scroll()
                                }
                            }
                        },speed)
                    };
                    scroll()
                }
            }
        };

 

你可能感兴趣的:(前端各式)