  <!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="int" navv="int"/>
    <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">兑换信息 
                <!-- <if condition="$item['status'] eq 2">
                  <button type="button" class="am-btn am-btn-primary confirm" style="margin-left:50px">确认兑换</button>
                </if> -->
                <?php if (!$item['logistics_no']) : ?>
                 <button type="button" class="am-btn am-btn-primary logistics_no_add" id="doc-prompt-toggle">入录物流单号</button>
                <?php else : ?>
                 <!-- <button type="button" class="am-btn am-btn-primary logistics_no_edit">修改物流单号</button> -->
                <?php endif;?>
              </div>
              <div class="am-panel-bd">
                <div class="am-g">
                  <div class="am-u-md-3 tr">兑换编号：</div>
                  <div class="am-u-md-9" id="exchange_no"><?php if (empty($item['exchange_no'])) : ?>-<?php else : ?>{$item.exchange_no}<?php endif;?></div>
                  <div class="am-u-md-3 tr">用户：</div>
                  <div class="am-u-md-9"><a href="{:U('Users/userDetail')}?id={$item.user_id}"><?php if (empty($item['name'])) : ?>-<?php else : ?>{$item.name}<?php endif;?></a></div>
                  <div class="am-u-md-3 tr">商品名称：</div>
                  <div class="am-u-md-9"> <?php if (empty($item['iname'])) : ?>-<?php else : ?>{$item.iname}<?php endif;?></div>
                  <div class="am-u-md-3 tr">联系方式：</div>
                  <div class="am-u-md-9"> <?php if (empty($item['mobile'])) : ?>-<?php else : ?>{$item.mobile}<?php endif;?></div>
                  <div class="am-u-md-3 tr">联系地址：</div>
                  <div class="am-u-md-9"> <?php if (empty($item['address'])) : ?>-<?php else : ?>{$item.address}<?php endif;?></div>
                  <div class="am-u-md-3 tr">物流单号：</div>
                  <div class="am-u-md-9"> 
                  <?php if (empty($item['logistics_no'])) : ?>
                    -
                  <?php else : ?>
                    {$item.logistics_no}
                    <script type="text/javascript">
                      var flag_kuaidi = false;
                      function kuaidi(express_nu){
                        console.log(express_nu)
                        if(flag_kuaidi){return false;}
                        if(express_nu){
                          flag_kuaidi = true;
                          layer.open({
                            type:2, closeBtn:1, anim:0,shadeClose:true,
                            title:["快递单号："+express_nu, 'background-color:#fff;color:#000'],
                            area:['500px','85vh'],
                            content:"https://m.kuaidi100.com/result.jsp?nu="+express_nu
                          });
                          flag_kuaidi = false;
                        }
                       }
                    </script>
                    <a href="javascript:;" onclick="kuaidi('{$item.logistics_no}')" style="font-size: 1.6rem"><span class="am-badge am-badge-primary">点我查看物流</span></a>
                  <?php endif;?>
                  </div>
                  <div class="am-u-md-3 tr">兑换积分：</div>
                  <div class="am-u-md-9"><?php if (empty($item['int'])) : ?>-<?php else : ?>{$item.int}积分<?php endif;?></div>
                  <div class="am-u-md-3 tr">订单状态：</div>
                  <div class="am-u-md-9">
                <?php
                  switch ($item['status']) {
                      case 1: echo "<span class='am-badge am-badge-primary'>已发货</span>"; break;
                      case 2: echo '<span class="am-badge am-badge-warning">未发货</span>'; break;
                      default: break;
                      }
                 ?>
                  </div>
                  <div class="am-u-md-3 tr">兑换时间：</div>
                  <div class="am-u-md-9"><?php if (empty($item['create_time'])) : ?>-<?php else : ?>{:cdate(0,$item['create_time'])}<?php endif;?></div>
                </div>
              </div>
            </div>

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

    </div>

  </div>

  <div class="am-modal am-modal-prompt" tabindex="-1" id="my-prompt">
  <div class="am-modal-dialog">
    <div class="am-modal-hd">入录物流单号</div>
    <div class="am-modal-bd">
      请认真核对您入录的物流单号...
      <input type="text" class="am-modal-prompt-input">
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" data-am-modal-cancel>取消</span>
      <span class="am-modal-btn" data-am-modal-confirm>提交</span>
    </div>
  </div>
</div>

  <include file="Common/footer" />
  </body>
  <script type="text/javascript">
    $(function(){
        // 确认兑换
        $('.confirm').on('click',function(){
          var data = new Object();
            data['id'] = '{$item.id}';

            $.post('{:U(\"detail\")}',data,function(res){
              if (res.status == 1) {
                alert(res.info);
                location.reload();
                // layert(res.info,function(){
                //   location.reload();
                // });
              } else {
                // layert(res.info,function(){
                //   // location.reload();
                //  });
                alert(res.info)
              }
            });
        });

        // 入录物流单号
        $('#doc-prompt-toggle').on('click', function() {
          $('#my-prompt').modal({
            relatedTarget: this,
            onConfirm: function(e) {
              // alert('你输入的是：' + e.data || '')
              var exchange_no = $('#exchange_no').html();
              var data = {logistics_no: e.data, exchange_no: exchange_no};
              // 发送请求
              $.post('{:U(\"logistics_no\")}',data,function(res){
              if (res.status == 1) {
                alert(res.msg);
                location.reload();
              } else {
                alert(res.msg)
              }
            });
            },
            onCancel: function(e) {
              alert('稍后再入录!');
            }
          });
        });
    })
  </script>
  </html>