//订单简单的变化，比如商家接单
function order_change(obj,order_id,shipping_status,is_count){
    var query=new Object();
    query.id=order_id;
    query.shipping_status=shipping_status;
    query.type=14;
    $.ajax({
        url:APP+"Shop/Order/order_change",
        data:query,
        dataType:'json',
        success:function(data){
            if(data.status){
                if(is_count>0){
                    refurbish();
                }else {
                    var obj_parent = $(obj).parent().parent();
                    obj_parent.prev().find('span.color-aaaaaa')
                        .html('未配送');
                    obj_parent.html('<div class="order-operation text-c" id="yes_ship_' + order_id + '"><a onclick="ship(' + order_id + ')" class="order-ok">配送</a></div>');
                }
            }else{
                $.showSuccess(data.info,0,'hc');
            }
        }
    });
}
function child_add(id){
    $.openUrl(APP+"Shop/Order/change_wuliu/id/"+id, '物流选择', 'ID', '500','hc');
}
/**
 * 发货
 */
function ship(id,is_count){
    var query=new Object();
    var wuliu =  $('input[name="code"]:checked').val();
    var id_d = $('input[name="id"]').val();
    if(id_d){
        query.order_id = id_d;
        if(!wuliu){alert('请选择物流！');return;}
        query.wuliu = wuliu;
    }else{        
        query.order_id=id;
    }
    query.order_type=4;//外卖
    $.ajax({
        type:'GET',
        data:query,
        url:APP+"Shop/Order/ship.html",
        success:function(data){
            if(data.status==1){
                if(is_count>0){
                    refurbish();
                }else {
                    var str = "<a class='order-ok'>已发货</a>";
                    $('#yes_ship_' + id).html(str);
                    $('#yes_ship').val('已配送');
                    $('#yes_ship').attr("disabled", "true");
                    close_pop();
                }
            }else{
                $.showErr(data.info,1,'hc');
            }
        }
    });
}
function close_pop(){

    $('.dialog-mask').hide();
    $('.hcbox').hide();

}
function cancel_order(order_id){
    $.showConfirm("您确定要取消订单吗？",function(){
        var query = new Object;
        query.order_id=order_id;
        $.ajax({
            type:'post',
            data:query,
            url:APP+"Shop/Order/cancel_order",
            success:function(data){
                if(data.status==1){
                    $.showSuccess(data.msg,1,'hc');
                    window.location.reload();
                }else{
                    $.showErr(data.msg,1,'hc');
                }
            }
        });
    },'hc')
}
/**
 * 确认收货
 * @param order_id  订单id
 */
function confirm(order_id){
    $.showConfirm("您确定要收货吗？",function(){
        var query = new Object;
        query.order_id=order_id;
        $.ajax({
            type:'post',
            data:query,
            url:APP+"Shop/Order/confirm_order",
            success:function(data){
                if(data.status==1){
                    $.showSuccess(data.msg,1,'hc');
                    window.location.reload();
                }else{
                    $.showErr(data.msg,1,'hc');
                }
            }
        });
    },'hc')
}