wxpay.page.js 1.08 KB
/**
 *
 * @author: jiangfeng<jeff.jiang@yoho.cn>
 * @date: 16/9/8
 */

var $orderDetail = $('.order-detail'),
    $qrCode = $('.qr-code'),
    $orderDetailCtrl = $('#order-detail-ctrl');

require('yoho-jquery-qrcode');

$(function() {
    // 展开详情/收起详情
    $orderDetailCtrl.click(function() {
        var $this = $(this);

        if ($orderDetail.is(':hidden')) {
            // 展开状态
            $this.html('收起详情<i class="iconfont up">&#xe617;</i>');
        } else {
            // 收起状态
            $this.html('订单详情<i class="iconfont down">&#xe616;</i>');
        }

        $orderDetail.slideToggle('slow');
    });

    $qrCode.qrcode({
        render: 'div',
        size: 270,
        text: $qrCode.data('qr')
    });

    function queryOrderState() {
        var code = $('.qr-code').data('code');

        $.get('/shopping/pay/online/weixin/state', {code: code}, function(data) {
            if (data && data.code === 200) {
                location.href = data.data.href;
            }
        });
    }

    setInterval(queryOrderState, 2500);
});