wechatqrcode.js 1.06 KB
/**
 * 微信支付页面
 */

var $ = require('yoho.jquery'),
    $wOdetail = $('.w-odetail'),
    $wPerm = $('.w-p-erm');

require('../../plugin/jquery.qrcode');

$wOdetail.click(function() {
    $('.w-addrinfo').slideToggle('slow');

    if ($wOdetail.find('i').hasClass('up')) {
        $wOdetail.html('收起详情<i class="down"></i>');
    } else {
        $wOdetail.html('订单详情<i class="up"></i>');
    }
});

$.ajax({
    url: $wPerm.data('url'),
    dataType: 'jsonp',
    success: function(res) {
        if (res.code === '200') {
            $wPerm.qrcode(res.qrcode_url);
        }
    }
});

function checkPayStatus() {
    $.ajax({
        type: 'get',
        async: false,
        url: '',
        dataType: 'jsonp',
        jsonp: 'callback',
        jsonpCallback: 'wxqrcodepay',
        success: function(data) {
            if (data.status === 'success') {
                window.location.href = '';
            }
        },
        error: function() {

        }
    });
}


setInterval(checkPayStatus(), 3000);