function confirm_order(){
    var id=$("input[name='id']").val();
    var form = $("form[name='myform']");
    var query=new Object();
    query= $(form).serialize();
    var url=APP+"Shop/InvoicingOrder/confirm_goods";
    $.ajax({
        type: "post",
        url: url,
        data: query,
        success: function(data){
            if(data.status==1){
                $.showSuccess(data.msg,1,'hc');
                window.location.href=data.url;
            }else{
                $.showErr(data.msg,1,'hc');
            }
        }
    });
}
function confirm_prepare_goods(){
    var id=$("input[name='id']").val();
    var form = $("form[name='myform']");
    var query=new Object();
    query= $(form).serialize();
    var url=APP+"Shop/InvoicingOrder/confirm_prepare_goods";
    $.ajax({
        type: "post",
        url: url,
        data: query,
        success: function(data){
            if(data.status==1){
                $.showSuccess(data.msg,1,'hc');
                // window.location.href=data.url;
            }else{
                $.showErr(data.msg,1,'hc');
            }
        }
    });
}
function change_num(obj){
    var num = parseFloat($(obj).val());//数量
     if (isNaN(num) || num <= 0) {num = 1;}
     if(num.toString().split(".")[1].length>3){$.showErr('商品数量不能超过三位小数',1,'hc');}
     num=parseFloat(num.toFixed(3));
    $(obj).val(num);

    var price=parseFloat($(obj).parent().next().find("input").val());
    var all_price=parseFloat(num*price).toFixed(2);
    $(obj).parent().next().next().html(all_price);
    var total=0;
    $(".money").each(function(){
        var money=parseFloat($(this).html());
        total=total+money;
    });
    $('#sum_money').html(foramtmoney(total));
}
function refuse_order(){
    var id=$("input[name='id']").val();
    var query=new Object();
    query.id=id;
    var url=APP+"Shop/InvoicingOrder/refuse_goods";
    $.ajax({
        type: "post",
        url: url,
        data: query,
        success: function(data){
            if(data.status==1){
                $.showSuccess(data.msg,1,'hc');
                //window.location.href=data.url;
            }else{
                $.showErr(data.msg,1,'hc');
            }
            window.location.reload();
        }
    });
}
//格式化价格
function foramtmoney(num,len) {
    len = len > 0 && len <= 20 ? len : 2;
    var result = parseFloat(num);
    num=isNaN(result)?0:result;
    var numpow=Math.pow(10,len);
    result = Math.round(num * numpow) / numpow;//round四舍五入 ceil进一 floor舍去
    var s_x = result.toString();
    var pos_decimal = s_x.indexOf('.');
    if (pos_decimal < 0) {
       pos_decimal = s_x.length;
       s_x += '.';
    }
    while (s_x.length <= pos_decimal + len) {s_x += '0';}
    return s_x;
}