<div class="wrapper">
    @include('layouts.header')

    <div class="page-content order-details">
        <!-- <ul class="nav nav-tabs">
            @if (isset($_REQUEST['tags']))
                <li><a href="{{URL('erp_order')}}">ERP订单</a></li>
                <li><a href="/details/{{$detail['order_id']}}?tags={{$_REQUEST['tags']}}">订单详情</a></li>
            @else
                <li><a href="{{URL('list')}}">平台订单</a></li>
                <li><a href="{{URL('details', ['order_id'=>$detail['order_id']])}}">订单详情</a></li>
            @endif
            
            <li class="active"><a href="javascript:;">订单收货信息</a></li>
        </ul> -->
        <?php 
            $route = \Route::current()->getActionName();
            $action_name = explode('@', $route)[1];
        ?>
        <input type="hidden" class="action_type" value="{{$action_name}}">

        <div class="tabs-box shipping-info">
            <form action="{{URL('changeShipping')}}" method="POST" class="table-responsive">
                <input type="hidden" name="order_id" value="{{$detail['order_id']}}">
                <table class="table table-hover table-bordered">
                    <caption><h3>订单物流信息</h3></caption>
                    <tr>
                        <th width="10%">配送方式</th>
                        <td>
                            <label class="radio-inline">
                                <input type="radio" name="shipping_type" class="shipping_type" value="1"> 快递配送
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="shipping_type" class="shipping_type" value="2"> 上门自提
                            </label>
                        </td>
                    </tr>

                    <tr>
                        <th width="10%">收货人</th>
                        <td><input type="text" name="consignee" value="{{$detail['consignee']}}"></td>
                    </tr>

                    <tr>
                        <th width="10%">联系电话</th>
                        <td><input type="text" name="mobile" value="{{$detail['mobile']}}"></td>
                    </tr>

                    <tr class="address-info">
                        <th width="10%">收货地址</th>
                        <td>
                            <select class="address s_province" name="province" default="{{$detail['province']}}"></select>
                            <select class="address s_city" name="city" default="{{$detail['city']}}"></select>
                            <select class="address s_county" name="district" default="{{$detail['district']}}"></select>
                        </td>
                    </tr>
                    <tr>
                        <th width="10%">详细地址</th>
                        <td><textarea class="form-control" name="address" placeholder="请输入详细地址">{{$detail['address']}}</textarea></td>
                    </tr>
                    <tr>
                        <td colspan="2"><input type="submit" value="保存" class="btn btn-success"></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>

<script>
    var tags = "{{isset($_REQUEST['tags']) ? $_REQUEST['tags'] : ''}}";
    var shipping_type = "{{isset($order_info) ? $order_info['order_shipping_type'] : 1}}";
    var goods_type = "{{isset($order_info) ? $order_info['order_goods_type'] : 1}}";

    $('.shipping_type').each(function() {
        if ($(this).val() == shipping_type) {
            $(this).attr('checked', true);
        }
    })

    // 自提时隐藏省市区
    if (shipping_type == 2) {
        $('.address-info').hide(); 
    }

    if (goods_type == 2) {
        var self_addr = "{{ Config('params.self_addr') }}";
    } else {
        var self_addr = "{{ Config('params.joint_addr') }}";
    }

    $('.shipping_type').change(function() {
        if ($(this).val() == 2) {
            $('.address-info').hide(); 
            $('textarea[name=address]').val(self_addr).attr('disabled', true); 
        } else {
            $('.address-info').show();
            $('textarea[name=address]').val('').attr('disabled', false); 
        }
    })

    $.lie.order.details();
</script>