<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<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/icheck/icheck.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>
<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/saveCardList" method="post" class="form form-horizontal" id="form-coupon-add">
    <div class="row cl">
		<label class="form-label col-2"><span class="c-red">*</span>付费代理商：</label>
		<div class="formControls col-8" id="agentInfo">
			
		</div>
	</div>
	
	<div class="row cl">
		<label class="form-label col-2"><span class="c-red">*</span>添加礼品卡数量：</label>
		<div class="formControls col-2">
			<input type="text" name="cardNum" id="cardNum"  class="input-text" style="width:90%"></div>
	</div>
		
		
    <div class="row cl">
      <div class="col-9 col-offset-3">
        <input class="btn btn-primary radius" onclick="return checkForm()" type="submit" id="submitBtn" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
      </div>
    </div>
  </form>
</div>
</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/icheck/jquery.icheck.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/Validform/5.3.2/Validform.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/js/tips.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/lib/My97DatePicker/WdatePicker.js"></script>  
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.admin.js"></script>
<script type="text/javascript">
	$(function(){
		addSelect();
	});
	
	function addSelect() {
		var url = "${pageContext.request.contextPath}/admin/card/selectAgentList";
		$.ajax({
			   type: "POST",
			   url: url,
			   dataType: "json",
			   success: function(dt){
				   if (dt.status) {
					   $("#agentInfo").append("<select id='openId' name='openId'></select>");
						// 设置默认选项
						$("<option></option>").val("0").text("---请选择付费代理商---").appendTo($("select"));
				        $("select").val('0');
					   $(dt.data).each(function(){
						    console.log(this.agentOpenId);
						    $("<option></option>").val(this.agentOpenId).text(this.agentNickname).appendTo($("select"));
						  });
				   }
			   }
		}); 
	}
	
	function checkForm() {
		var openId = $("#openId").val();
		var cardNum = $("#cardNum").val();
		if (openId == 0 || openId == null) {
			alert("请选择付费代理商");
			return false;
		}
		if (cardNum == null || cardNum == '') {
			alert("请输入需要添加礼品卡数量");
			return false;
		}
		return true;
	}
</script>
</body>
</html>