  <!doctype html>
  <html class="no-js">
  <head>

    <include file="Common/head" />
    <style type="text/css">
      a.am-text-secondary:visited{color:#3bb4f2;}
      a.am-text-danger:visited{color:#dd514c;}
      .am-btn-default {background-color: #fff;}
      th {text-align:center;}
      tr td{text-align:center;}
      select{padding: 4px;border: 1px solid #ccc;}
      .am-popup-bd {background:#fff;}
      .am-popup-bd img {max-width: 100%}
      .am-table>tbody>tr>td.user-info {padding: 1px;text-align: left;}
      .am-table>tbody>tr>td.user-info img{height: 42px}
      myred{color:#dd514c;}
      mygreen {color:#1aad19;}
      mygery {color:#999;}
      .wxgreen {color:#1aad19;}
      .search-div.am-input-group .am-form-field{width:120px;float: right;}
      .search-div select {float: right;}
      .ttt-switch {margin: 0 auto;}
      .am-form select{
        font-size: 1.2rem;
        border-color: #e6e6e6;
        width: unset;
        padding: .5em 2em .5em 1em;
        margin: 0 auto;
      }
      .am-table>tbody>tr>td.td-img {
        padding: 1px;
        text-align: left;
        padding-left: 10px;
      }
      .am-table>tbody>tr>td.td-img img {
        height: 40px;width: 40px;
      }
      .am-table>tbody>tr>td.td-img a {
        display: inline-block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 13vw;
        cursor: pointer;
      }
      .am-table>thead>tr>th {
        border-bottom: 0;
      }
      .am-table>tbody>tr:first-child>td {
        border-top: 0;
      }
      .am-table>thead.am-thead-hide>tr>th {
        border-left: 0;
        background-color: #f5f5f5;
      }
      p {
        margin: 0;
      }
      .am-table>tbody>tr>td {
        vertical-align: middle;
        font-size: 1.4rem;
        line-height: 1.6rem;
        color: #444;
        background-color: #fdfdfd;
      }
      .format-price>p {
        display: table;
        width: 100%;
        text-align: right;
      }
      .format-price>p>span {
        display: table-cell;
        width: 50%;
        text-align: right;
      }
      .am-filter>.am-input-group:not(:first-child) {
        padding-top: 1.25rem;
      }
      .am-input-group-label.toumin {
        background-color: rgba(0,0,0,0);
        border: 0;
      }
      input[type=datetime-local].am-form-field {
        height: 33px;
      }
      .am-btn {
        font-size: 1.4rem;
      }
      .tr {
        text-align: right;
      }
      .tl {
        float: left !important;
      }
    </style>
  </head>
  <body>
  <include file="Common/header" />

  <div class="am-cf admin">

    <include file="Common/sidebar" nav="order" navv="order_list"/>
    <div class="content-page" style="background: white;">

      <div class="admin-content">
        <div class="admin-content-body">
          <div class="am-cf am-padding">
            <div class="am-fl am-cf">
              <strong class="am-text-primary am-text-lg">订单管理</strong> /
              <small>订单详情</small>
            </div>
          </div>

          <hr style="margin-top:0px;">


          <div class="am-g">
            <div class="am-panel am-panel-default" style="margin:0 1.5rem 1.5rem;">
              <div class="am-panel-hd">订单信息</div>
              <div class="am-panel-bd">
                <div class="am-g">

                  <div class="am-u-md-3 tr">订单号：</div>
                  <div class="am-u-md-9">
                    <?php if (!empty($order['order_sn'])) : ?>
                      {$order.order_sn}
                    <?php else : ?>
                      -
                    <?php endif;?>
                 </div>

                  <div class="am-u-md-3 tr">用户：</div>
                  <div class="am-u-md-9">
                    <a href="{:U('./Users')}?uid={$goods_user.uid}" target="_blank">
                    <?php if (!empty($goods_user['nickname'])) : ?>
                      {$goods_user.nickname}
                    <?php else : ?>
                      -
                    <?php endif;?>
                    </a>
                  </div>

                  <div class="am-u-md-3 tr">订单金额：</div>
                  <div class="am-u-md-9">
                    <?php if (!empty($order['total_price'])) : ?>
                      ￥{$order.total_price}
                    <?php else : ?>
                      -
                    <?php endif;?>
                  </div>

                  <div class="am-u-md-3 tr">优惠金额：</div>
                  <div class="am-u-md-9">
                    <?php if (!empty($order['pre_money'])) : ?>
                     优惠券抵消￥{$order.pre_money}
                    <?php else : ?>
                      优惠券抵消￥0.00
                    <?php endif;?>
                  </div>

                  <div class="am-u-md-3 tr">支付金额：</div>
                  <div class="am-u-md-9">
                    <?php if (!empty($order['price'])) : ?>
                      ￥{$order.price}
                    <?php else : ?>
                      -
                    <?php endif;?>
                  </div>

                  <div class="am-u-md-3 tr">订单状态：</div>
                  <div class="am-u-md-9">
                    <?php
                switch ($order['status']) {

                  case 1: echo '<span class="am-badge am-badge-primary">待付款</span>'; break;
                    case 2: echo '<span class="am-badge am-badge-primary">已下单</span>'; break;
                    case 3: echo '<span class="am-badge am-badge-primary">已送货</span>'; break;
                    case 5: echo '<span class="am-badge am-badge-warning">已关闭</span>'; break;
                    case 9: echo '<span class="am-badge am-badge-success">已退款/货</span>'; break;
                    default: break;
                    }
                    ?>
                  </div>
                  
            		  <div class="am-u-md-3 tr">订单类型：</div>
                  <div class="am-u-md-9">
            		  <?php if ($order['order_type'] == 1) : ?>
            		    	<span class="am-badge am-badge-primary">外卖订单</span>
            		  <?php elseif ($order['order_type'] == 2) : ?>	    
            			    <span class="am-badge am-badge-primary">食堂订单</span>
            		  <?php else : ?>
            			    -
            		  <?php endif;?>
                  </div>

                  <div class="am-u-md-3 tr">支付类型：</div>
                  <div class="am-u-md-9">
                  <?php if ($order['pay_type'] == 1) : ?>
                      <span class="am-badge am-badge-primary">微信支付</span>
                  <?php elseif ($order['pay_type'] == 2) : ?>     
                      <span class="am-badge am-badge-primary">余额支付</span>
                  <?php else : ?>
                      -
                  <?php endif;?>
                  </div>

                  <div class="am-u-md-3 tr">座位号：</div>
                  <div class="am-u-md-9">
                    <?php if (!empty($order['seat'])) : ?>
                      {$order.seat}
                    <?php else : ?>
                      -
                    <?php endif;?>
                  </div>

                  <div class="am-u-md-3 tr">备注：</div>
                  <div class="am-u-md-9">
                    <?php if (!empty($order['mark'])) : ?>
                      {$order.mark}
                    <?php else : ?>
                      -
                    <?php endif;?>
                  </div>

                  <if condition="$order['status'] egt 2">
                    <div class="am-u-md-3 tr">支付时间：</div>
                    <div class="am-u-md-9">
                      <?php if (!empty($order['pay_time'])) : ?>
                        {:cdate(0,$order['pay_time'])}
                      <?php else : ?>
                        -
                      <?php endif;?>
                    </div>
                  </if>

                  <if condition="$order['status'] egt 3">
                    <div class="am-u-md-3 tr">发货时间：</div>
                    <div class="am-u-md-9">
                      <?php if (!empty($order['fachu_time'])) : ?>
                        {:cdate(0,$order['fachu_time'])}
                      <?php else : ?>
                        -
                      <?php endif;?>
                    </div>
                  </if>

                  <if condition="$order['order_type'] EQ 1">
                    <div class="am-u-md-3 tr">街道：</div>
                    <div class="am-u-md-9">
                      <?php if (!empty($order['address_area'])) : ?>
                        {$order.address_area}
                      <?php else : ?>
                        -
                      <?php endif;?>
                    </div>

                    <div class="am-u-md-3 tr">详细地址：</div>
                    <div class="am-u-md-9">
                      <?php if (!empty($order['info'])) : ?>
                        {$order.info}
                      <?php else : ?>
                        -
                      <?php endif;?>
                    </div>
                  </if>

		              <div class="am-u-md-3 tr">下单时间：</div>
                  <div class="am-u-md-9">
                    <?php if (!empty($order['create_time'])) : ?>
                        {:cdate(0,$order['create_time'])}
                    <?php else : ?>
                        -
                    <?php endif;?>
                  </div>
                </div>
              </div>
            </div>
            <div class="am-panel am-panel-default" style="margin:0 1.5rem 1.5rem;">
              <div class="am-panel-bd" style="padding: 0;">
                <div class="am-scrollable-horizontal">
                  <table class="am-table am-text-nowrap" style="margin: 0;">
                    <thead class="am-thead-hide">
                    <tr>
                      <th width="5%">ID</th>
                      <th width="10%">商品名称</th>
                      <th width="10%">购买数量</th>
                      <!-- <th width="10%">属性备注</th> -->
                      <th width="10%">总金额</th>
                    </tr>
                    </thead>
                    <tbody>
                    <foreach name="car_content" item="vo">
                      <tr>
                        <td>{$vo.goods_id}</td>
                        <td class="td-img" style="text-align: center;">
                          <img src="__UPLOADS__/{$vo.img}">
                          <a href="{:U('Goods/goods')}?id={$vo.goods_id}" target="_blank">{$vo.title}</a>
                        </td>
                        <td>{$vo.goods_num}</td>

                        <!-- <td>{$vp.remarks}</td> -->
                        <!--<td>￥{:cmoney($vp['buy_price'])}</td>-->
                        <!--<td>￥{:cmoney($vp['orig_price'])}</td>-->
                        <td>￥{:cmoney($vo['sum_price'])}</td>
                        <!--<td>￥{:cmoney($vp['sum_gold'])}</td>-->
                      </tr>
                    </foreach>
                    </tbody>
                  </table>

                </div>
              </div>
            </div>


            <?php if($auth){ ?>
            <div class="am-panel am-panel-default" style="margin:0 1.5rem 1.5rem;">
              <div class="am-panel-hd">订单操作</div>
              <div class="am-panel-bd">
                <div class="am-form">
                  <!-- 未付款 -->
                  <if condition="$order['status'] eq 1">
                    <!-- 未发货 -->
                    <elseif condition="$order['status'] eq 2" />

                    <div class="am-g am-margin-top">
                      <div class="am-u-md-2 tr">&nbsp;</div>
                      <div class="am-u-md-4 tl">
                        <button class="am-btn am-btn-default fachu">确认发货</button>
                      </div>
                    </div>
                    <elseif condition="$order['status'] eq 3 or $order['status'] eq 4" />

                    <!-- 申请退款 -->


                    <script type="text/javascript">
                        $('.true').on('click',function(){
                            var data = new Object();
                            data['op'] = "refund";
                            data['order_sn'] = "{$order.order_sn}";
                            data['status'] = 8;



                            $.post('{:U("order_op")}',data,function(res){
                                layert('审核成功',function(){
                                    location.reload();
                                });
                            });
                        });
                        $('.false').on('click',function(){
                            var data = new Object();
                            data['op'] = "refund";
                            data['order_sn'] = "{$order.order_sn}";
                            data['status'] = 7;

                            $.post('{:U("order_op")}',data,function(res){
                                layert('驳回成功',function(){
                                    location.reload();
                                });
                            });
                        });
                    </script>
                    <!-- 申请退款 -->
                    <elseif condition="$order['status'] eq 8" />
                    <!-- 退款 -->
                    <?php if($order['apply_type']==1){?>
                    <div class="am-g am-margin-top">
                      <div class="am-u-md-2 tr">&nbsp;</div>
                      <div class="am-u-md-4 tl">
                        <button class="am-btn am-btn-default apply_true">确认退款</button>
                        <button class="am-btn am-btn-default apply_false">驳回</button>
                      </div>
                    </div>
                    <?php } ?>
                    <!-- 退货 -->
                    <?php if($order['apply_type']==2){?>
                    <div class="am-g am-margin-top">
                      <div class="am-u-md-2 tr">快递公司名称</div>
                      <div class="am-u-md-4 tl">
                        <input type="text" name="" value="<?php echo $order['apply']['express_name']; ?>" >
                      </div>
                    </div>
                    <div class="am-g am-margin-top">
                      <div class="am-u-md-2 tr">快递单号</div>
                      <div class="am-u-md-4 tl">
                        <input type="text" name="" class="am-input-sm" value="<?php echo $order[apply][express_sn]; ?>" >
                      </div>
                    </div>
                    <div class="am-g am-margin-top">
                      <div class="am-u-md-2 tr">联系电话</div>
                      <div class="am-u-md-4 tl">
                        <input type="text" name="" class="am-input-sm" value="<?php echo $order[apply][phone]; ?>" >
                      </div>
                    </div>
                    <div class="am-g am-margin-top">
                      <div class="am-u-md-2 tr">&nbsp;</div>
                      <div class="am-u-md-4 tl">
                        <button class="am-btn am-btn-default apply_true">确认收货</button>
                        <button class="am-btn am-btn-default apply_false">驳回</button>
                      </div>
                    </div>
                    <?php } ?>

                    <script type="text/javascript">
                        $('.apply_true').on('click',function(){
                            var data = new Object();
                            data['op'] = "express";
                            data['order_sn'] = "{$order.order_sn}";
                            data['status'] = 9;
                            data['sum_gold']="{$order.sum_gold}";
                            data['uid']="{$order.uid}";


                            $.post('{:U("order_op")}',data,function(res){
                                layert('收货成功',function(){
                                    location.reload();
                                });
                            });
                        });
                        $('.apply_false').on('click',function(){
                            var data = new Object();
                            data['op'] = "express";
                            data['order_sn'] = "{$order.order_sn}";
                            data['status'] = 7;

                            $.post('{:U("order_op")}',data,function(res){
                                layert('驳回成功',function(){
                                    location.reload();
                                });
                            });
                        });
                    </script>

                    <elseif condition="$order['status'] eq 4" />
                    <div class="am-g am-margin-top">
                      <div class="am-u-md-2 tr">&nbsp;</div>
                      <div class="am-u-md-4 tl">
                        <button class="am-btn am-btn-default" disabled>已完成</button>
                      </div>
                    </div>
                    <elseif condition="$order['status'] eq 5" />
                    <div class="am-g am-margin-top">
                      <div class="am-u-md-2 tr">订单已关闭</div>
                      <div class="am-u-md-4 tl">
                        <button class="am-btn am-btn-default recovery" >恢复订单</button>
                      </div>
                    </div>
                    <script type="text/javascript">
                        $('.recovery').on('click',function(){
                            var data = new Object();
                            data['op'] = "recovery";
                            data['order_sn'] = "{$order.order_sn}";

                            $.post('{:U("order_op")}',data,function(res){
                                layert('订单恢复成功',function(){
                                    location.reload();
                                });
                            });
                        });

                    </script>
                  </if>
                  <div class="am-g am-margin-top"></div>
                </div>
              </div>
            </div>
            <?php } ?>
          </div>

        </div>
        <footer class="admin-content-footer"><hr></footer>
      </div>

    </div>



  </div>
  <include file="Common/footer" />

  <script type="text/javascript">
      $(function(){
          // 重置密码
          $(".reset_link").on("click",function(){
              var id=$(this).attr('data-id');
              var name=$(this).attr("data-name");
              var bool = confirm("确认重置管理员“"+name+"”的密码吗？");
              if (bool) {
                  $("#float_id").val(id);
                  $("#float_name").html(name);
                  $("#shade_div").show();
                  $("#float_div").show();
              };
          });
          $("#btclose").on("click",function(){
              $("#shade_div").hide();
              $("#float_div").hide();
          });
          // 删除
          $(".del_link").on("click",function(){
              var name=$(this).attr("data-name");
              var the_link=$(this).attr("data-url");
              var bool = confirm("确认删除管理员“"+name+"”吗？");
              if (bool) {
                  location.href = the_link;
              };
          });
      });
  </script>
  </body>

  </html>