<style>
    .contet {
        width: 100%;
        margin: 0 auto;
        padding: 10px 20px;
        background-color: white;
    }
    .center{
        margin: 0 200px;
        width: 800px;
    }

    .a_btn  {
         padding: 5px;
         border: grey solid 1px;
         border-radius: 10%;
         text-decoration: none;
    }

    .m-l-30{
        margin-left: 30px;
    }

    .center span{
        font-size: 18px;
        padding: 10px 0px 5px 0px;
        display: block;
    }

    .imgs{
        height: 500px;
        display: block;
    }
</style>

<div class="contet">
    <div class="center">
        <h2 style="display: inline-block">订单详情</h2>
        @if($data->orderPatient)
            @if($data->order_status == 3)
            <a class = "a_btn m-l-30" href="/cdms/chats">会话</a>
            <a class = "a_btn complet m-l-30" href="javascript:void(0)">完成</a>
            @endif
        @endif
    </div>
    <div class="center">
        <span>订单号:{{$data->order_sn}}</span>
        @if(!empty($data->orderPatient))
            <span>患者:  {{$data->orderPatient->name}}</span>
            <span>年龄:  {{birthday_to_age($data->orderPatient->birthday)}}</span>
            <span>身份证号:  {{$data->orderPatient->card_number}}</span>
            <span>下单时间:  {{$data->orderPatient->created_at}}</span>
            <span>订单状态:  {{$status[$data->order_status]}}@if($data->order_status == 2)  <a class = "a_btn add m-l-30" href="javascript:void(0)">接单</a> @endif </span>
            <span>病情描述:  {{$data->orderPatient->symptoms}}</span>
            <span>图片: </span>
            @foreach($data->orderPatient->medical_imgs as $img)
                <img class="imgs" src="{{$img}}" alt="">
            @endforeach
        @else
            <span>患者:</span>
            <span>年龄:</span>
            <span>身份证号:</span>
            <span>下单时间:</span>
            <span>订单状态:</span>
            <span>病情描述:</span>
            <span>图片:</span>
        @endif
    </div>
</div>
<script src="/jquery-3.5.1.min.js"></script>
<script>
    var id = {{$data->id}}
    $('.complet').click(function () {
        $.post('/cdms/api/update_order',{'id':id,'status':4},function (res) {
            console.log(res)
            if(res.code == 200){
                alert('操作成功')
                location.reload();
            } else{
                alert('操作失敗')
            }
        });
    })
    $('.add').click(function () {
        $.post('/cdms/api/update_order',{'id':id,'status':3},function (res) {
            if(res.code == 200){
                alert('接单成功')
                location.reload();
            } else{
                alert('接单失敗')
            }
        });
    })
</script>
