<%@ 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"%>
<%@ 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/css/bootstrap.min-3.3.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]-->

<style>
#datainit{
 margin-left:5px;
}
#addRight{
	float:right;
	margin-right: 80px;
}
.tdHide{
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

.breakWord{
  word-break:break-all;
}




.spinner {
  margin: 1px auto;
  width: 50px;
  height: 30px;
  text-align: center;
  font-size: 10px;
}
 
.spinner > div {
  background-color: #67CF22;
  height: 100%;
  width: 6px;
  display: inline-block;
   
  -webkit-animation: stretchdelay 1.2s infinite ease-in-out;
  animation: stretchdelay 1.2s infinite ease-in-out;
}
 
.spinner .rect2 {
  -webkit-animation-delay: -1.1s;
  animation-delay: -1.1s;
}
 
.spinner .rect3 {
  -webkit-animation-delay: -1.0s;
  animation-delay: -1.0s;
}
 
.spinner .rect4 {
  -webkit-animation-delay: -0.9s;
  animation-delay: -0.9s;
}
 
.spinner .rect5 {
  -webkit-animation-delay: -0.8s;
  animation-delay: -0.8s;
}
 
@-webkit-keyframes stretchdelay {
  0%, 40%, 100% { -webkit-transform: scaleY(0.4) } 
  20% { -webkit-transform: scaleY(1.0) }
}
 
@keyframes stretchdelay {
  0%, 40%, 100% {
    transform: scaleY(0.4);
    -webkit-transform: scaleY(0.4);
  }  20% {
    transform: scaleY(1.0);
    -webkit-transform: scaleY(1.0);
  }
}
</style>
<title>用户管理</title>
</head>
<body>
<nav class="breadcrumb" style="height:45px;padding-top:5px;padding-bottom:5px"><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/member/listUI" method="post" id="form1" name="form1" enctype="multipart/form-data">
	<input type="hidden" id="pageNo" value=1 />
	<div > 
		
		<%-- 日期范围：<input readonly="readonly" type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')||\'2020-10-01\'}'})" id="beginDate" name="beginDate" value="${beginDate }" class="input-text Wdate" style="width: 120px;">
		- <input readonly="readonly" type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'beginDate\')}',maxDate:'2020-10-01'})" id="endDate" name="endDate" value="${endDate }" class="input-text Wdate" style="width: 120px;">
		 --%>
		
		<input type="text" class="input-text" style="width:165px" placeholder="分销商" id="name" name="name">
		<input type="text" class="input-text" style="width:165px" placeholder="父级分销商"  id="supperName" name="supperName">
		<input type="text" class="input-text" style="width:165px" placeholder="姓名"  id="openid" name="openid">
		<input type="text" class="input-text" style="width:165px" placeholder="昵称"  id="userNickname" name="userNickname">
		<input type="text" class="input-text" style="width:165px" placeholder="电话号码"  id="tel" name="tel">
		<input type="text" class="input-text" style="width:165px" placeholder="激活码"  id="initCode" name="initCode">
		<input class="btn btn-success round" type="button"   onclick="searchInfo()" value="搜索">
		<input class="btn btn-success round" type="button"   onclick="openWindow()" value="新增">
		<input class="btn btn-success round" type="button"   onclick="downLoadList()" value="批量下载二维码">
		<!-- <input class="btn btn-success round" type="button"   onclick="openWindowBattle()" value="批量新增"> -->
	<!-- 	<input id="" class="btn btn-success round" type="button"   onclick="openWindow2()" value="预售新增"> -->
	   <div id="loadDeal" class="hidden" style="float:right;margin-right:10px;">
				<div class="spinner">
				  <div class="rect1"></div>
				  <div class="rect2"></div>
				  <div class="rect3"></div>
				  <div class="rect4"></div>
				  <div class="rect5"></div>
				</div>
		    </div>
	</div>
	</form>
	
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg table-sort" id="example" style="table-layout: fixed;">
		<thead>
			<tr class="text-c">
			    <th width="100">序号</th>
			    <th width="100">序号</th>
				<th width="100">昵称</th>
				<th width="100">真实姓名</th>
			   <th width="100">OpenID</th> 
				<th width="100">金额</th>
			<!-- 	<th width="60">类型</th> -->
				<th width="91">角色</th>
				<th width="100">是否激活</th>
				<th width="100">联系方式</th>
				<th width="100"  style="word-break:break-all">激活码</th>
				<th width="130">创建时间</th>
				<th width="50">操作</th>
			</tr>
		</thead>
		<tbody>
			
		</tbody>
	</table>
	</div>
</div>
<div align="right" style="margin-right:20px;margin-top:-40px">
	<ul class="pagination" id="pagination2"></ul>
</div>  
<div id="len" class="hidden">
  <div  class="form form-horizontal" >
   <div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">昵称</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" autocomplete="off" placeholder="昵称">
		</div>
	</div>
    <div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">姓名：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" autocomplete="off" placeholder="姓名">
		</div>
	</div>
    
  </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/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/laypage/1.2/laypage.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/lib/datatables/1.10.0/dataTableUtil.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" src="${pageContext.request.contextPath }/common/js/page/jqPaginator.js"></script>
<script type="text/javascript">
var gobaltable;
$(document).ready(function() {
	gobaltable = $('#example').DataTable({
        "fnServerData" : function(sSource, aoData, fnCallback) {
        	var json2 ={
                "pageSize":10,
                "pageNumber":parseInt($("#pageNo").val()),
                "condition":{
                	"name":$("#name").val(),
                	"parentName":$("#supperName").val(),
                	"userName":$("#openid").val(),
                	"userNickname":$("#userNickname").val(),
                	"tel":$("#tel").val(),
                	"initCode":$("#initCode").val(),
                	"type":$("#adminRemarkColor").val()==0?0:$("#adminRemarkColor").val()
                }
              };
        	//alert(JSON.stringify(json2));
            $.ajax({
              "type" : "post",
              "url" : "/watero/admin/drp/initTable",
              "dataType" : "json",
              "contentType": "application/json; charset=utf-8",
              "data" :JSON.stringify(json2),
              "success" : function(resp) {
            	 fnCallback(resp);
            	 var showNo=parseInt(resp.page.pageCount)>5?5:parseInt(resp.page.pageCount);
            	 //$("#allCount").html(resp.page.count);
            	 $("#mytool").html("<span>共有<label id='allCount'>"+resp.page.count+"</label>条记录</span>");
            	 $('#pagination2').jqPaginator('option', {
            		    totalPages: parseInt(resp.page.pageCount),
            		    currentPage: resp.page.pageNumber,
            		    visiblePages: showNo,
            		});           	 
              }
            });
      
          },
     "dom": "<'#mytool.col-md-2'>",//"<'row' <'col-md-3' ><'col-md-8' >r<'#mytool.col-md-1'> >" ,
     "fnRowCallback": function(nRow, aData, iDisplayIndex) {
    	
	     if (aData.qrcodeUrl != null && aData.qrcodeUrl != '') {
	    	 $('td:eq(11)',nRow).append("<a class=\"text-danger\" href=\"javascript:void(0)\" name=\"downLoad\"  title=\"下载二维码\">下载二维码</a>");
	     }
	     if (aData.openid == null || aData.openid == '') {
	    	 $('td:eq(11)',nRow).append("<a class=\"text-danger\" href=\"javascript:void(0)\" name=\"bindingInfo\"  title=\"手动绑定\">手动绑定</a>");
	     }

	     $('td:eq(10)', nRow).html(new Date(aData.createDate).Format("yyyy-MM-dd hh:mm:ss"));
    	 $('td:eq(5)', nRow).html(aData.amount/100);
    	 $('td:eq(0)', nRow).html(iDisplayIndex+1);
    	 return nRow;
     },

     "language": {
	        "sProcessing": ""
     },
	"order": [[ 3, "desc" ]],
	"bAutoWidth":false,
	"sPaginationType" : "full_numbers", // 分页，一共两种样式 另一种为two_button // 是datatables默认
    "bProcessing" : true,
    "bServerSide" : true,
	"aoColumns": [
	      { data: null, "title":"序号","defaultContent":"",className: "text-center",orderable:false},
	      { data: "id", "title":"序号","defaultContent":"",className: "text-center hidden"},
	      { data: "name", "title":"昵称","defaultContent":"",className: "text-center"},
	      { data: "userName", "title":"姓名","defaultContent":"",className: "text-center"},
	      { data: "openid", "title":"微信id","defaultContent":"",className: "text-center hidden"},
	      { data: "amount", "title":"账户金额","defaultContent":"",className: "text-center"},
	      //{ data: "type", "title":"类型","defaultContent":"",className: "text-center"},
	      { data: "roleName", "title":"角色","defaultContent":"",className: "text-center"},
	      { data: "openid", "title":"激活","defaultContent":"",className: "text-center",name:"openid"},
	      { data: "tel", "title":"联系方式","defaultContent":"",className: "text-center"},
	      { data: "initCode", "title":"激活码","defaultContent":"",className: "text-center breakWord tdHide"},
	      { data: "createDate", "title":"创建时间","defaultContent":"",className: "text-center"},
	      { data: "null", "title":"操作","defaultContent":  "<a class=\"text-warning\" href=\"javascript:void(0)\" name=\"updateInfo\" title=\"编辑\">编辑</a>&nbsp;"+
	    	  "<a class=\"text-danger\" href=\"javascript:void(0)\" name=\"deleteSingle\"  title=\"删除\">删除 </a>&nbsp;",
	    	  className: "text-center","sWidth":"65px","orderable":false},
	    	  { data: "qrcodeUrl", "title":"序号","defaultContent":"",className: "text-center hidden"}
	       ],
	 initComplete:function(){
		$("#mytool").append("<span>共有<label id='allCount'>0</label>条记录</span>");
	}, 
	"rowCallback":function(row,data,index){
		 $('td',row).eq(0).html(index+1);
		},
	"fnInitComplete": function(oSettings, json) {
			$(".tdHide").on("click",function(){
				if(this.innerText!="激活码"){
					layer.alert(this.innerText, {title : ['激活码']});
				}
			});
		},
		"aoColumnDefs":[{"aTargets":[7],"mRender":function(data,type,full){
			if (data != null) {
				return "<a href=\"javascript:void(0)\" data-toggle=\"modal\" class=\"smart-mod-eg1\" onclick=\"inUserInfo('"+data+"')\">" + data + "</a>    "}
			}
           }]
	});
});

function searchInfo(){
	$("#pageNo").val(1);
	gobaltable.ajax.reload();
}

function inUserInfo(value) {
	 $.ajax({
  		  url: "/watero/admin/member/selectUserIdByOpenId",
         dataType:"json",
  		  type:"post",
  		data:{
			  "openId":value
		  },
  		  success: function(data){
  			window.location.href='${pageContext.request.contextPath }/admin/member/showMenberInfo/' + data.data;
  		  },
  		  error:function(data){
  			  alert(data.message);
  			  alert("操作失败，请查看网络是否正常！");
  		  }
  		});
}

//添加一个商户
function openWindow(){
	layer.open({
		  type: 2,
		  area: ['700px', '530px'],
		  fix: false, //不固定
		  maxmin: true,
		  content: '/watero/admin/drp/addPlaceInfo'
		});
}

function openWindowBattle(){
	layer.open({
		  type: 2,
		  area: ['1200px', '630px'],
		  fix: false, //不固定
		  maxmin: true,
		  content: '/watero/admin/drp/addPlaceInfoBattle'
		});
}


function openWindow2(){
	layer.open({
		  type: 2,
		  area: ['700px', '530px'],
		  fix: false, //不固定
		  maxmin: true,
		  content: '/watero/admin/drp/orderPlaceInfo'
		});
}

//删除记录
$("table").on("click","[name='deleteSingle']",function(){
	 if(confirm("确定删除该记录吗？")){
    	 //alert($(this).parent().parent().children().eq(1).text());
    	 var d = $(this).parent().parent().children().eq(1).text();
    	 $.ajax({
   		  url: "/watero/admin/drp/deletePlaceInfo?id="+d,
          dataType:"json",
   		  type:"get",
   		  success: function(data){
   			  //alert(data);
   			  alert(data.message);
   			  gobaltable.ajax.reload();
   		  },
   		  error:function(data){
   			  alert(data.message);
   			  alert("操作失败，可能关联依赖出现问题！");
   		  }
   		});
    	// gobaltable.ajax.reload();
	 }
});

//弹出修改页面
$("table").on("click","[name='updateInfo']",function(){
	layer.open({
		  type: 2,
		  area: ['700px', '530px'],
		  fix: false, 
		  maxmin: true,
		  content: '/watero/admin/drp/EditPlaceInfo?id='+$(this).parent().parent().children().eq(1).text()
		});
});
//弹出绑定页面
$("table").on("click","[name='bindingInfo']",function(){
	layer.open({
		  type: 2,
		  area: ['700px', '530px'],
		  fix: false, 
		  maxmin: true,
		  content: '/watero/admin/drp/bindingPlaceInfo?initCode='+$(this).parent().parent().children().eq(9).text()
		});
});


$("table").on("click","[name='downLoad']",function(){
	var url = $(this).parent().parent().children().eq(12).text();
	var id = $(this).parent().parent().children().eq(1).text();
	var form=$("<form>");//定义一个form表单
	form.attr("style","display:none");
	form.attr("target","");
	form.attr("method","post");
	form.attr("action","/watero/admin/drp/downLoad?url="+url+"&openId="+id);
	var input1=$("<input>");
	input1.attr("type","hidden");
	input1.attr("name","exportData");
	input1.attr("value",(new Date()).getMilliseconds());
	$("body").append(form);//将表单放置在web中
	form.append(input1);
	form.submit();//表单提交
});



$.jqPaginator('#pagination2', {
    totalPages: 5,
    visiblePages: 0,
    currentPage: 1,
    prev: '<li class="prev"><a href="javascript:;">上一页</a></li>',
    next: '<li class="next"><a href="javascript:;">下一页</a></li>',
    page: '<li class="page"><a href="javascript:;">{{page}}</a></li>',
    onPageChange: function (num, type) {
        $("#pageNo").val(num);
    	gobaltable.ajax.reload();
    }
});


function ajaxSend(url,data){
	$.ajax({
		  url: url,
		  data: data,
		  asyn:false,
		  success: function(data){
			  var obj=eval("("+data+")");
			  //alert(obj.message);
			  gobaltable.ajax.reload();
		  },
		  error:function(data){
			  alert("操作失败，可能关联依赖出现问题！");
		  }
		});
}

function uploadExcel() {
	document.form1.action='${pageContext.request.contextPath }/admin/drp/upLoadExcel';
	document.form1.submit();
}

function downLoadList() {
	//document.form1.action='${pageContext.request.contextPath }/admin/drp/downLoadList';
	$("#loadDeal").removeClass("hidden");
	 $.ajax({
  		  url: "/watero/admin/drp/battle2w",
          dataType:"json",
  		  type:"get",
  		  data:{
  			  "name":$("#name").val(),
  			  "supperName":$("#supperName").val(),
  			  "openid":$("#openind").val()
  		  },
  		  success: function(data){
  			  //alert(data.message);
  			//alert(data.fileName);
  			  if(data.status=="true"){
  				window.location.href='${pageContext.request.contextPath }/admin/drp/downLoadList?zipName='+data.fileName+".zip";
  			  }
  			$("#loadDeal").addClass("hidden");
  		  },
  		  error:function(data){
  			 alert(data.message);
  		  }
  		});
	 
}

</script> 
</body>
</html>