<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!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,member-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/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>
<div class="pd-20">
<!-- 添加图片的div -->
<div class="layui-layer layui-anim layui-layer-iframe" id="layui-layer4" times="4" showtime="0" contype="string" style="display:none;z-index: 100; width: 400px; height: 260px; position: absolute; top: 30px; left: 309px;">
  <form action="${pageContext.request.contextPath }/admin/banner/add" method="post" class="form form-horizontal" id="form-member-add">
    <div class="row cl">
      <label class="form-label col-3" style="width:150px"><span class="c-red">*</span>二维码等级：</label>
      <div class="formControls col-5">
      	<select id="qrcodeStatus-input">
      		<option value="1">押金全免二维码</option>
      		<option value="2">需要押金二维码</option>
      	</select>
      </div>
      <div class="col-4"> </div>
    </div>
    <span class="layui-layer-setwin">
		<a class="layui-layer-ico layui-layer-close layui-layer-close1" onclick="exitWindowsDiv(this)" href="javascript:;"></a>
	</span>
	<div class="row cl">
      <div class="formControls col-5" style="width: 100%" align="center">
      	<button class="btn btn-success radius" id="confirm-add-btn"  name="">确认添加</button>
      </div>
      <div class="col-4"> </div>
    </div>
  </form>
</div>
<input type="hidden" id="channelId" value="${channel.channelId }">
  <table class="table table-border table-bordered table-bg table-hover table-sort">
		<thead>
			<tr class="text-c">
				<th width="80">类型</th>
				<th width="100">二维码</th>
				<th width="100">场景值</th>
				<th width="100">二维码状态</th>
				<th width="150">二维码等级</th>
				<th width="150">所属渠道</th>
			</tr>
		</thead>
		<tbody>
			<c:choose>
				<c:when test="${!(empty qrcodes) }">
					<c:forEach items="${qrcodes }" var="qrcode">
						<tr class="text-c">
							<td>机构二维码</td>
							<td>
								<img alt="二维码" src="${qrcode.channelQrcodeUrl }" style="width: 100px;height: 100px">
							</td>
							<td>${qrcode.channelQrcodeValue }</td>
							<td title="此数据由微信维护，不可修改">使用中</td>
							<td class="text-l">${qrcode.channelQrcodeLevel == 1 ? "押金全免二维码" : "需要押金二维码" }</td>
							<td class="text-c">${channel.channelName }</td>
						</tr>
					</c:forEach>
					
					<c:if test="${fn:length(qrcodes) < 2 }">
						<tr align="center">
							<td colspan="6" style="text-align: center;">
								<span class="l" style="text-align: center;width:100%">
									<a style="text-align: center;width:100%" href="javascript:;" onclick="showDivImage()" class="btn btn-primary radius">
										<i class="Hui-iconfont">&#xe600;</i> 添加二维码
									</a>
								</span>
							</td>
						</tr>
					</c:if>
				</c:when>
				<c:otherwise>
					<tr align="center">
						<td colspan="6" style="text-align: center;">
							<span class="l" style="text-align: center;width:100%">
								<a style="text-align: center;width:100%" href="javascript:;" onclick="showDivImage()" class="btn btn-primary radius">
									<i class="Hui-iconfont">&#xe600;</i> 添加二维码
								</a>
							</span>
						</td>
					</tr>
				</c:otherwise>
			</c:choose>
		</tbody>
	</table>
</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/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(_this) {
	$("#layui-layer4").hide();
}
function showDivImage() {
	$("#layui-layer4").show();
}
$(function() {
	$("#confirm-add-btn").click(function() {
		var qrcodeStatus = $("#qrcodeStatus-input").val();
		if (qrcodeStatus != "1" && qrcodeStatus != "2") {
			layer.msg("请选择类型",{icon:5,time:2000});
			return false;
		}
		$.getJSON("${pageContext.request.contextPath}/admin/channel/addQrcode/${channel.channelId }", {"qrcodeType":qrcodeStatus, "dateTime" : new Date().getTime()}, function(data) {
			if (data.flag) {
				layer.msg("添加成功！",{icon:1,time:2000});
				location.replace(location.href);
			} else {
				layer.msg(data.info,{icon:5,time:2000});
			}
		});
		return false;
	});
});
</script>
</body>
</html>