<%@ page contentType="text/html; charset=utf-8"
		 pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
	<meta name="renderer" content="webkit">
	<!-- 移动设备 viewport -->
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
	<jsp:include page="../../common.jsp" />
</head>
<body>
<div class="row animated fadeInRight" style="margin: 0;">
	<div class="wrapper wrapper-content mt5 right-content ml5 mr5">
		<div class="toolbar-panel bdd">
			<div class="toolbar-box">
				<div class="toolbar-head clearfix lgraybg pt5 pb10 pl10 bdbd">
					<!-- 顶部按钮 -->
					<div class="fl">
						查询条件
					</div>
					<div class="tools fr">
						<a href="javascript:void(0);" class="collapse dblock f14 dgray mr5">
							<i class="fa-2x fa fa-angle-double-up"></i>
						</a>
					</div>
				</div>
			</div>
			<!--搜索条件 -->
			<div class="toolbar-body">
				<form class="layui-form" action="" style="margin-top: 10px">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">昵称</label>
							<div class="layui-input-block">
								<input type="text" name="nickName" id="nickName" placeholder="请输入昵称" autocomplete="off" class="layui-input">
							</div>
						</div>

						<div class="layui-inline">
							<label class="layui-form-label">唯一标识</label>
							<div class="layui-input-block">
								<input type="text" name="soleId" id="soleId" placeholder="请输入唯一标识" autocomplete="off" class="layui-input">
							</div>
						</div>

						<div class="layui-inline">
							<label class="layui-form-label">激活商家</label>
							<div class="layui-input-block">
								<input type="text" name="alias" id="alias" placeholder="请输入激活商户简称" autocomplete="off" class="layui-input">
							</div>
						</div>

						<div class="layui-inline">
							<label class="layui-form-label">开始日期</label>
							<div class="layui-input-inline">
								<input type="text" placeholder="请输入激活开始日期" id="date1" name="startTime" autocomplete="off" class="layui-input">
							</div>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">结束日期</label>
							<div class="layui-input-inline">
								<input type="text" placeholder="请输入激活结束日期" id="date2" name="endTime" autocomplete="off" class="layui-input">
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	<!-- 表单数据 -->
	<div class="mb50 mt10">
		<div class="whitebg pl10 pr10">
			<table class="layui-hide" id="realFansTab" lay-filter="realFansTab"></table>
		</div>
	</div>
</div>

<script type="text/html" id="leftBar">
	<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="search"><i class="layui-icon">&#xe615;</i>查询</button>
</script>
<script>
	layui.use(['table', 'layer','form','laydate'], function(){
		var table = layui.table;
		var layer = layui.layer;
		var form = layui.form;
		var laydate = layui.laydate;

		laydate.render({
			elem: '#date1',//指定元素
			format: 'yyyy-MM-dd'
		});
		laydate.render({
			elem: '#date2', //指定元素
			format: 'yyyy-MM-dd'
		});

		var tableIns = table.render({
			elem: '#realFansTab'
			,url:'${ctx}/realFans/pageData'
			,id: 'realFans'
			,response: {
				statusName: 'code' //数据状态的字段名称，默认：code
				,countName: 'count' //数据总数的字段名称，默认：count
				,dataName: 'data' //默数据列表的字段名称，认：data
				,statusCode : 200
			}
			,parseData: function(res){ //res 即为原始返回的数据
				return {
					"code": res.code, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.data.total, //解析数据长度
					"data": res.data.records //解析数据列表
				};
			}
			,toolbar: '#leftBar' //开启头部工具栏，并为其绑定左侧模板
			, defaultToolbar: ['filter']
			,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
				title: '提示'
				,layEvent: 'LAYTABLE_TIPS'
				,icon: 'layui-icon-tips'
			}]
			,title: '粉丝列表'
			,cols: [[
				{type: 'checkbox', fixed: 'left', hidden: true}
				,{field:'numbers', title:'序号', fixed: 'left', unresize: true, width:80, type:'numbers'}
				,{field:'nickName', title:'昵称', width: 200,templet:function (d) {
						return decodeURI(d.nickName);
					}}
				,{field:'logo', title:'头像',templet:function (d) {
						return "<a href='javascript:void(0)' onclick='openImg(this)' >"+d.logo+"</a>";
				 }}
				,{field:'soleId', title:'唯一标识'}
				,{field:'aliConsum', title:'支付宝消费金额',width: 150,sort:true }
				,{field:'wechatConsum', title:'微信消费金额',width: 150,sort:true }
				,{field:'alias', title:'激活商家名称'}
				,{field: 'enableTime', title: '激活时间',width:160,sort:true ,templet : "<div>{{layui.util.toDateString(d.enableTime,'yyyy-MM-dd HH:mm:ss')}}</div>"}
			]]
			,request: {
				pageName: 'current' //页码的参数名称，默认：page
				,limitName: 'size' //每页数据量的参数名，默认：limit
			}
			,page: true
		});

		//监听头工具栏事件
		table.on('toolbar(realFansTab)', function (obj) {
			switch (obj.event) {
				case 'search':
					var params= serialize($('#form1'));
					table.reload('realFans', {
						where: params
						, page: {
							size: 10
							, current: 1
						}
					});
					break;
			}
		});
	});

	function openImg(obj) {
		var url = $(obj).text();
		if(url){
			var img = new Image();
			img.src = url;

			//弹出层
			layer.photos({
				photos: { "data": [{"src": url}] }
			});

			// layer.open({
			//     type: 1,
			//     shade: 0.8,
			//     area:['auto','auto'],
			//     offset: 'auto',
			//     // area: [500 + 'px',550+'px'],  // area: [width + 'px',height+'px']  //原图显示
			//     shadeClose:true,
			//     scrollbar: false,
			//     title: "预览", //不显示标题
			//     content: imgHtml, //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
			//     cancel: function () {
			//         //layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', { time: 5000, icon: 6 });
			//     }
			// });
		}
	}
	jQuery.prototype.serializeObject=function(){
		var obj=new Object();
		$.each(this.serializeArray(),function(index,param){
			if(!(param.name in obj)){
				obj[param.name]=param.value;
			}
		});
		return obj;
	};
</script>
</body>
</html>
