{include file="public/heard"}
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">会员中心</a>
                <a>
                    <cite>会员列表</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" name="username" placeholder="用户名|ID|手机号|邮箱" autocomplete="off" class="layui-input"></div>
                                <div class="layui-inline layui-show-xs-block">
                                    <button class="layui-btn" lay-submit="" lay-filter="sreach" lay-skin="select" lay-filter="type">
                                        <i class="layui-icon">&#xe615;</i></button>
                                </div>
								<div class="layui-inline layui-show-xs-block">
                                    <button class="layui-btn" type="button"  onclick="xadmin.open('新增会员','{:U('simple/Member/memberAdd')}')" ><i class="layui-icon"></i>新增会员</button>  <button class="layui-btn layui-btn-danger" type="button" id="delAll"><i class="layui-icon"></i>批量删除</button>
                                </div>
                        </div>
						 
                        <div class="layui-card-body ">
                            <table class="layui-table" id="mlist" lay-filter="mlist">
                                <thead>
                                    <tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
	<script type="text/html" id="fenzhan">
	 {{#  if(d.fenzhan == 1){ }}
      <p class="layui-bg-red">已开通</p>
     {{#  } else { }}
     <p class="layui-bg-black">未开通</p>
     {{#  } }}
    </script>
    <script type="text/html" id="active">
	 {{#  if(d.active == 1){ }}
      <p class="layui-bg-red">已开通</p>
     {{#  } else { }}
     <p class="layui-bg-black">未开通</p>
     {{#  } }}
    </script>
	<script type="text/html" id="status">
    {{#  if(d.state == 1){ }}
      <p class="layui-bg-red">正常</p>
     {{# }else if(d.state==2){ }}
     <p class="layui-bg-black">冻结</p>
     {{#  } else { }}
	  <p class="layui-bg-blue">未审核</p>
	 {{#  } }}
    </script>
	<script type="text/html" id="action">
	<div class="layui-btn-group">
    <button class="layui-btn" onclick="xadmin.open('修改会员','{:U('simple/Member/memberEdit')}?id={{d.id}}')" >编辑</button>
	<button class="layui-btn layui-btn-normal" onclick="xadmin.open('修改费率','{:U('simple/member/memberFl')}?id={{d.id}}')" >费率设置</button>
	<!--<button class="layui-btn layui-btn-warm" onclick="xadmin.open('本站充值记录','{:U('simple/member/memberMoneyLog')}?id={{d.id}}')" >本站记录</button>-->
	<button class="layui-btn layui-btn-danger" onclick="xadmin.open('登陆记录','{:U('simple/member/memberLoginLog')}?id={{d.id}}')" >登陆记录</button>
	<button class="layui-btn layui-btn-normal" onclick="xadmin.open('资金明细','{:U('simple/member/memberMxLog')}?id={{d.id}}')" >资金明细</button>
    <button class="layui-btn layui-btn-danger"  lay-event="del">删除</button>
	</div>
   </script>
    <script>
	layui.use(['table','form','laydate'], function() {
        var table = layui.table,form = layui.form, $ = layui.jquery,laydate = layui.laydate;
        tableIn = table.render({
            elem: '#mlist',
            url: "{:U('simple/member/memberlist')}",
            method: 'post',
			page:true,
			totalRow:true,
            cols: [[
			    {type: 'checkbox',width:40,minWidth:30},
				{field:'id',title:"ID", width:80,align: 'center', sort: true,totalRowText: '合计：'},
			    {field:'user',title: '用户名',align: 'center', width:110},
                {field:'photo', title: '手机' ,align: 'center', width:130} ,
				{field:'money', sort: true,align: 'center',title:'账户余额', width:85,sort: true,totalRow: true,edit:"text"},
				{field:'price', align: 'center',title:'冻结金额', width:85,sort: true,totalRow: true},
				{field:'dx', sort: true,align: 'center',title:'短信余额', width:100,edit:"text"},
				{field:'yongjin',align: 'center',title:'佣金', width:80,totalRow: true},
                {field: 'tuig', align: 'center',title: '推广人数',sort: true,width:100},
				/*{field: 'fenzhan', align: 'center',title: '是否分站',toolbar: '#fenzhan',sort: true,width:90},
                {field: 'active',align: 'center', title: '提现权限',toolbar: '#active',sort: true,width:90},*/
				{field: 'state',align: 'center', title: '账户状态',sort: true,toolbar: '#status',sort: true,width:90},
                {field: 'addtime',align: 'center', title: '注册时间'},
                {title: '操作',align: 'center', toolbar: '#action'}
            ]],
			limit:20,
			limits:[20,50,60]
        });		
		form.on('submit(sreach)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var name=$("input[name=username]").val();
			var index = layer.load(3, {
					  shade: [0.1,'#fff'] //0.1透明度的白色背景
					});
                 tableIn.reload({
					page:{curr:1
						 },
                     where:{
						 name:name
                     }
                 });
				 layer.close(index);
        });
		table.on('tool(mlist)', function(obj){
            var data = obj.data;
			console.log(obj.event);
            if(obj.event === 'del'){
                layer.confirm('您确定要删除该记录吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("{:U('simple/member/userDel')}",{id:data.id},function(res){
                        layer.close(loading);
                        if(res.code==1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            obj.del();
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                });
            }
        });
		table.on('edit(mlist)', function(obj){
         loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = obj.data.id,str = obj.value,field=obj.field;
            $.post('{:U("simple/member/editmyMoney")}',{'id':id,'count':str,'field':field},function (res) {
                layer.close(loading);
				if(res.code==1){
				  layer.msg(res.msg,{time:1000,icon:1});
				}else{
					layer.msg(res.msg,{time:1000,icon:2});
					return false;
				}
            })		  
		});
		$("#delAll").click(function(){
            layer.confirm('确认要删除选中信息吗？', {icon: 3}, function(index) {
                layer.close(index);
                var checkStatus = table.checkStatus('mlist'); //test即为参数id设定的值
				console.log(checkStatus,table);
                var ids = [];
                $(checkStatus.data).each(function (i, o) {
                    ids.push(o.id);
                });
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post("{:U('simple/member/userDel')}", {ids: ids}, function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.msg(data.msg, {time: 1000, icon: 1});
                        tableIn.reload();
                    } else {
                        layer.msg(data.msg, {time: 1000, icon: 2});
                    }
                });
            });
        });
		 //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });
    </script>
</html>