<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/html5.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/respond.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/PIE_IE678.js"></script>
<![endif]-->
<link href="${pageContext.request.contextPath }/common/admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>图片列表</title>
</head>
<body>

<!-- 弹出对话框 start -->
<div class="layui-layer layui-anim layui-layer-iframe" id="layui-layer4" times="4" showtime="0" contype="string" style="display:none; z-index: 19891018; width: 400px; height: 260px; position: absolute; top: 100px; left: 379px;">
	<form action="" method="post" class="form form-horizontal" id="form-admin-add">
	<input type="hidden" name="userMachineId" id="send-machineId"/>
	<div class="layui-layer-title" id="sendOrderDivTitle" style="cursor: move;" move="ok">确认发货</div>
	<br>
	<div class="row cl">
		<label class="form-label col-3"><span class="c-red"></span>&nbsp;&nbsp;物流编号：</label>
		<div class="formControls col-5">
			<input type="text" id="order-post-num-id" class="input-text" value="" placeholder="请输入物流编号" name="postNum" datatype="*2-16" nullmsg="用户名不能为空">
		</div>
		<div class="col-4"> </div>
	</div>
	<br>
	<div class="row cl">
		<label class="form-label col-3"><span class="c-red"></span>&nbsp;&nbsp;物流公司：</label>
		<div class="formControls col-5"> <span class="select-box" style="width:150px;">
			<select class="select" name="postFirm" size="1">
				<option value="sto">申通快递</option>
				<option value="yto">圆通快递</option>
				<option value="sf">顺丰快递</option>
				<option value="ems">邮政EMS</option>
				<option value="zto">中通快递</option>
				<option value="zjs">宅急送</option>
				<option value="yunda">韵达快递</option>
				<option value="cces">cces快递</option>
				<option value="pick">上门提货</option>
				<option value="htky">汇通快递</option>
				<option value="ttkdex">天天快递</option>
				<option value="stars">星晨急便</option>
				<option value="jd">京东快递</option>
				<option value="dbkd">德邦快递</option>
				<option value="01">其他</option>
				<option value="02">上门送货</option>
			</select>
			</span> </div>
	</div>
	<br>
	<div class="col-9 col-offset-3">
        <input class="btn btn-primary radius" onclick="submitSendOrder()" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
      </div>
    </form>
	<span class="layui-layer-setwin">
		<a class="layui-layer-ico layui-layer-close layui-layer-close1" onclick="exitWindowsDiv(this)" href="javascript:;"></a>
	</span>
</div>
<!-- 弹出对话框 end -->

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 礼品卡兑换 <span class="c-gray en">&gt;</span> 兑换管理 <span class="c-gray en">&gt;</span> 兑换列表 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
					<th width="100">姓名</th>
					<th width="80">用户手机号码</th>
					<th width="80">兑换状态</th>
					<th width="100">产品名称</th>
					<th width="80">颜色名称</th>
					<th width="60">收件人姓名</th>
					<th width="150">收件人电话</th>
					<th>收件人地址</th>
					<th width="120">创建时间</th>
					<th width="100">操作</th>
				</tr>
			</thead>
			<tbody>
				<c:choose>
					<c:when test="${!(empty list)}">
						<c:forEach items="${list}" var="obj">
							<tr class="text-c">
								<td class="nick-name-td">${obj.userNickName }</td>
								<td>${obj.userMachineTel }</td>
								<td class="td-status"><span class="label label-success radius">待发货</span></td>
								<td>${obj.userMachineProductName }</td>
								<td>${obj.userMachineColorName }</td>
								<td class="text-l">${obj.userMachineAddressName }</td>
								<td>${obj.userMachineAddressTel }</td>
								<td class="text-c">${obj.userMachineAddressInfo }</td>
								<td><fmt:formatDate value="${obj.userMachineCreateDate }" pattern="MM-dd HH:mm" /></td>
								<td class="td-manage">
									<a style="text-decoration:none" onClick="show('${obj.userMachineId}')" href="javascript:;" title="发货">发货</a>&nbsp;
									<a style="text-decoration:none" onClick="syncStatus(3,'${obj.userMachineId}')" href="javascript:;" title="同步状态">同步状态</a>
								</td>
							</tr>
						</c:forEach>
					</c:when>
					<c:otherwise>
						<tr class="text-c">
							<td colspan="9">暂无数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
			</tbody>
		</table>
	</div>
</div>
<div align="right">
	<%@include file="/common/other/paper/pager.jsp"%>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/layer/1.9.3/layer.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.admin.js"></script>
<script type="text/javascript">
	function exitWindowsDiv(obj) {
		$("#layui-layer4").hide();
	}
	function show(userMachineId) {
		$("#send-machineId").val(userMachineId);
		$("#layui-layer4").show();
	}

    //同步订单状态
    function syncStatus(agentMachineType,agentMachineId) {
        var type = 0;
        switch (agentMachineType) {
            case 1: type = 2;break;
            case 2: type = 2;break;
            case 3: type = 4;break;
        }
        $.ajax({
            type:'POST',
            url: '${pageContext.request.contextPath }/admin/Reserve/efast/select_efast_order/'+ agentMachineId + '/' + type,
            dataType: 'json',
            success:function(data) {
                location.reload();
            }
        });
    }

	function submitSendOrder() {
		// 校验物流信息
		var postNum = $("#order-post-num-id").val();
		if (postNum == null || postNum.length < 1) {
			alert("请输入完整的物流单号!");
			return;
		}
		
		var formData = $("#form-admin-add").serialize();
		console.log(formData)
		var url = "${pageContext.request.contextPath}/admin/card/send?" + formData;
		$.ajax({
			   type: "POST",
			   url: url,
			   dataType: "json",
			   success: function(data){
				   if (data.resultCode == 200 && data.returnCode == 200) {
					   alert("发货成功!");
					   location.replace(location.href);
				   } else {
					   alert("发货失败!");
				   }
			   }
		}); 
	}
</script>
</body>
</html>