<%@ 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: 320px; position: absolute; top: 100px; left: 379px;">
	<form action="" method="post" class="form form-horizontal" id="form-admin-add">
	<input type="hidden" name="cardCashId" id="cardCashId"/>
	<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">
			<select id="cardCashStatus" style="width:100px;">
				<option value="1">退款中</option>
				<option value="3">退款成功</option>
			</select>
		</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">
			<textarea class="textarea" placeholder="说点什么..." name="cardCashRemark" id="cardCashRemark" onkeyup="textarealength(this,500)">${cardCashRemark}</textarea>
						<p class="textarea-numberbar"><em class="textarea-length">0</em>/500</p>
		</div>
	</div>
	<br>
	<div class="col-9 col-offset-3">
        <input class="btn btn-primary radius" onclick="submitCash()" 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">
<form action="${pageContext.request.contextPath }/admin/card/selectCardCashList" method="post" id="myForm">
			<input type="text" name="nickName" id="nickName" value="${nickName }" placeholder="用户昵称" style="width: 150px" class="input-text">
			<input type="text" name="agentTel" id="agentTel" value="${agentTel }" placeholder="电话号码" style="width: 150px" class="input-text">
			<input type="text" name="cardPassword" id="cardPassword" value="${cardPassword }" placeholder="礼品卡密码" style="width: 150px" class="input-text">
			<span>状态：</span><select name="cardCashStatus" id="cardCashStatus" style="width: 150px;height: 30px;">
				<option value="0">------请选择状态------</option>
				<option value="1" <c:if test="${cardCashStatus ==  '1'}">selected="selected"</c:if>>退款中</option>
				<option value="3" <c:if test="${cardCashStatus ==  '3'}">selected="selected"</c:if>>退款成功</option>
			</select>
			<button name="" id="submitBtn" class="btn btn-success" type="submit">
				<i class="Hui-iconfont">&#xe665;</i> 搜索
			</button>
		</form>
	<div class="mt-20">
	<div class="text-c">
		</div>
		<table class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
					<th width="80">用户昵称</th>
					<th width="150">地区</th>
					<th width="100">电话</th>
					<th width="100">礼品卡密码</th>
					<th width="60">状态</th>
					<th width="100">操作</th>
				</tr>
			</thead>
			<tbody>
				<c:choose>
					<c:when test="${!(empty cardCashList)}">
						<c:forEach items="${cardCashList}" var="cardCash">
							<tr class="text-c">
								<td>${cardCash.cardCashSalesNickname }</td>
								<td>${cardCash.agentArea }</td>
								<td>${cardCash.agentTel }</td>
								<td>${cardCash.cardPassword }</td>
								<td id="cardStatus">
									<c:if test="${cardCash.cardCashStatus == 1}">
										退款中
									</c:if>
									<c:if test="${cardCash.cardCashStatus == 2}">
										驳回
									</c:if>
									<c:if test="${cardCash.cardCashStatus == 3}">
										退款成功
									</c:if>
								</td>
								<td class="td-manage">
									<c:if test="${cardCash.cardCashStatus == 1}">
											<a id="dispose" style="text-decoration:none" onClick="show('${cardCash.cardCashId}')" href="javascript:;" title="处理"><i class="Hui-iconfont">处理</i></a> 
									</c:if>
								</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/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(cardCashId) {
		$("#cardCashId").val(cardCashId);
		$("#layui-layer4").show();
	}
	
	function submitCash() {
		// 校验物流信息
		var cardCashStatus = $("#cardCashStatus").val();
		if (cardCashStatus == null) {
			alert("请选择审批结果!");
			return;
		}
		var cardCashRemark = $("#cardCashRemark").val();
		if (cardCashRemark == null) {
			alert("审批备注不能为空!");
			return;
		}
		var cardCashId = $("#cardCashId").val();
		var url = "${pageContext.request.contextPath}/admin/card/checkCash?cardCashStatus=" + 
				cardCashStatus +"&cardCashRemark=" + cardCashRemark + "&cardCashId=" + cardCashId;
		$.ajax({
			   type: "POST",
			   url: url,
			   dataType: "json",
			   success: function(data){
				   $("#layui-layer4").hide();
				   if (data) {
					   layer.msg("退款成功!",{icon:1,time:2000});
					   if (cardCashStatus == 1) {
						   $("#cardStatus").html("退款中");
					   } else if (cardCashStatus == 2) {
						   $("#cardStatus").html("驳回");
					   } else {
						   $("#cardStatus").html("退款成功");
						   $("#dispose").hide();
					   }
				   } else {
					   layer.msg("退款失败!",{icon:5,time:2000});
				   }
			   }
		}); 
	}
</script>
</body>
</html>