pay.qrcode.js 1.3 KB
Newer Older
D
devil_gong 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
$(function()
{
    // 定时查询订单是否已支付
    setInterval(function()
    {
        // ajax请求
        $.ajax({
            url: $('.qrcode-pay').data('ajax-url'),
            type: 'post',
            dataType: "json",
            timeout: 10000,
            data: {"order_no": $('.qrcode-pay').data('order-no')},
            success: function(result)
            {
                if(result.code == 0 && (result.data.url || null) != null)
                {
                    Prompt(result.msg, 'success');
                    setTimeout(function()
                    {
                        window.location.href = result.data.url;
                    }, 1500);
                } else if(result.code == -400 && (result.data.url || null) != null) {
                    Prompt(result.msg);
                    setTimeout(function()
                    {
                        window.location.href = result.data.url;
                    }, 1500);
                } else {
                    if(result.code != -300)
                    {
                        Prompt(result.msg);
                    }
                }
            },
            error: function(xhr, type)
            {
D
Devil 已提交
37
                Prompt(HtmlToString(xhr.responseText) || '异常错误', 'danger', 30);
D
devil_gong 已提交
38 39 40 41
            }
        });
    }, 2000);
});