<hi:Common_AliOHHeader runat="server" />
<p class="text-center list-empty hide" id="empty">
    <span class="glyphicon glyphicon-shopping-cart"></span>购物车为空
</p>
<div id="cart">
    <div class="pbox">
        <div class="shoppingStepBar clearfix">
            <div class="step active">
                <div class="glyphicon glyphicon-shopping-cart">
                </div>
            </div>
            <div class="step">
                <div class="glyphicon glyphicon-pencil">
                </div>
            </div>
            <div class="step">
                <div class="glyphicon glyphicon-ok">
                </div>
            </div>
        </div>
        <hr />
        <div id="cartProducts">
           <Hi:AliOHTemplatedRepeater id="rptCartProducts" templatefile="/Tags/skin-Common_CartProducts.ascx"
                runat="server" />
        </div>
            <p class="text-right" style="margin-bottom:10px;">
                您一共需要支付（不含运费 ）：<span id="totalPrice"><strong class="text-danger"><asp:literal runat="server" id="litTotal" /></span></strong></p>
            <a id="aLink" href="/AliOH/SubmmitOrder.aspx" class="btn btn-danger btn-block">
        去结算</a>
    </div>
   
</div>
<script type="text/javascript">


    $(function () {

        if (!$.trim($('#cartProducts').html())) {

            $('#cart').addClass('hide');
            $('#empty').removeClass('hide');
        }


        $('div[name="spAdd"]').bind("click", function () {
            var number = $(this).parent().find('[name="buyNum"]');
            number.val(parseInt(number.val()) + 1);
            chageCartProductQuantity(number);
        });
        $('div[name="spSub"]').bind("click", function () {
            var number = $(this).parent().find('[name="buyNum"]');

            var num = parseInt(number.val()) - 1;
            if (num > 0) number.val(parseInt(number.val()) - 1);
            chageCartProductQuantity(number);

        });
        $('[name="buyNum"]').unbind('blur').blur(function () {
            chageCartProductQuantity(this);
        });


        var productSkus = $('.specification');
        $.each(productSkus, function (i, productSKU) {
            var text = '';
            productSKU = $(productSKU);
            var skus = productSKU.find('input[name="skucontent"]');
            $.each(skus.val().split(';'), function (i, sku) {
                if ($.trim(sku))
                    text += '<span class="badge-h">' + sku.split('：')[1] + '</span>';
            });
            var promotionShortName = productSKU.find('input[name="promotionShortName"]').val();
            if (promotionShortName) {
                var promotionName = productSKU.find('input[name="promotionName"]').val();
                text += '<span class="badge-h danger" onclick="alert_h(\'' + promotionName + '\')">' + promotionShortName + '</span>';
            }
            productSKU.html(text);
        });

    });





    function chageCartProductQuantity(obj) {
        $.ajax({
            url: "/API/VshopProcess.ashx",
            type: 'post', dataType: 'json', timeout: 10000,
            data: { action: "ChageQuantity", skuId: $(obj).attr("skuId"), quantity: parseInt($(obj).val()) },
            success: function (resultData) {
                if (resultData.Status != "OK") {
                    alert("最多只可购买" + resultData.Status + "件");

                }
                else {
                    $('#totalPrice').html('¥' + parseFloat(resultData.TotalPrice).toFixed(2));
                }
            }
        });
    }
</script>
<script src="/utility/vshoping.helper.js" type="text/javascript"></script>
<script>
    //禁用右上角菜单
    document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        WeixinJSBridge.call('hideOptionMenu');
    });
</script>
<hi:Common_AliOHFooter runat="server" />