web前端js实现倒计时效果

var header_timer;
var current_timer;
var intDiff = 300;
function timer(intDiff){
    current_timer =   window.setInterval(function(){
        var     day=0,
                hour=0,
                minute=0,
                second=0;
        if(intDiff > 0){
            minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
            second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
        }
        if(intDiff==0) {
            $("#wx_img_src img").attr("src","/static/images/whchar_art.jpg");
            $("#ai_img_src img").attr("src","/static/images/whchar_art.jpg");
        }
        if (minute <= 9) minute = '0' + minute;
        if (second <= 9) second = '0' + second;
        $('.minute_time').html(''+minute+'');
        $('.second_time').html(''+second+'');
        intDiff--;
    }, 1000);
    header_timer = current_timer;
}


var reslut="请在"
    +""
    +"内扫二微码,否则将会失效。";
if (platCode == "XINBPAY" || platCode == "DINPAYWX") {
    timer(intDiff);
    $("#wx_img_src").html("");
     $('#qrcode').qrcode({text: data.obj,width: 200,height: 200});
    $(".wx_img_tips").html(reslut);
}else{
    timer(intDiff);
    $('#qrcode').html("");
    $(".wx_img").css("display","block");
    $("#wx_img_src img").attr("src",data.obj);
    $(".wx_img_tips").html(reslut);
}

你可能感兴趣的:(web前端开发)