@extends('vip.layouts')
@section('seo_title')
{{ trans('menu.list') }}
@endsection
@section('content')
    <style>
        body{overflow-y: scroll;}
        .layui-laydate-range {
            width: auto;
        }

        .layui-form-switch em {
            width: auto;
        }

        .layui-form-switch {
            width: 44px;
            line-height: 20px;
        }

        .layui-form-item .checkbox {
            width: auto;
        }

        .red{
            color: red;
        }
        .blue{
            color: #1E9FFF;
        }
        .layui-layout-admin .layui-body{
        	top: 60px;
        }
        .green{
            color: green;
        }
        .yellow{
            color: #ffca10;
        }
        .layui-table-cell{
        	line-height: 20px;
        }
		.bottom-txt{
			padding: 0.5em;
			line-height: 2em;
		}
    </style>

	<script type="text/html" id="agent">
		@{{#if(d.fanshui==1){ }}
			<div onclick="isfs(2,@{{d.id}})" class="layui-input-inline checkbox">
				<input type="checkbox" lay-skin="switch" lay-text="是|否" class="layui-input" eventType=event-query>
			</div>
		@{{#}else{ }}
			<div onclick="isfs(1,@{{d.id}})" class="layui-input-inline checkbox">
				<input type="checkbox" lay-skin="switch" lay-text="否|是" class="layui-input" eventType=event-query>
			</div>
		@{{#} }}
	</script>	
    <script type="text/html" id="waterTool">
        <a href="/admin/MoneyList/index?account_name=@{{d.account}}&star_time=&end_time=&" class="green"><strong>流水</strong></a> <!-- style="margin-bottom:5px;margin-left:0px;" -->
		@if(checkRriv('/admin/User/setPwdview'))<a href="/admin/User/setPwdview?id=@{{d.id}}&parentid=@{{d.parent_id}}" class="red"><strong>修改</strong></a>@endif
		<a href="/admin/Hitcode/index?account_identity=@{{d.identity}}" class="blue"><strong>打码量</strong></a>
    </script>

	<script type="text/html" id="selectip">
	  <a href="/admin/user/index?select_value=@{{d.register_ip}}&select_type=register_ip&regist_startime=&regist_endtime=">
	  @{{#if(d.register_ip!=null){ }}
		<span>@{{ d.register_ip}}</span>
	  @{{#} }}</a><br>
	  <a href="/admin/user/index?select_value=@{{d.last_ip}}&select_type=last_ip&regist_startime=&regist_endtime=">
	  @{{#if(d.last_ip!=null){ }}
		<span>@{{ d.last_ip}}</span>
	  @{{#} }}</a>
	</script>

	<script type="text/html" id="register_last">
	  @{{#if(d.register_time!=null){ }}
		<span>@{{ d.register_time}}</span>
	  @{{#} }}<br>
	  @{{#if(d.last_time!=null){ }}
		<span>@{{ d.last_time}}</span>
	  @{{#} }}
	</script>

	<script type="text/html" id="selecturl">
	  <a class="aUrl" href="/admin/user/index?select_value=@{{d.register_url}}&select_type=register_url&regist_startime=&regist_endtime=">
		  @{{#if(d.register_url!=null){ }}
			@{{ d.register_url}}
		  @{{#} }}
	 </a><br>
	  <a class="aUrl" href="/admin/user/index?select_value=@{{d.last_url}}&select_type=last_url&regist_startime=&regist_endtime=">
		  @{{#if(d.last_url!=null){ }}
			@{{ d.last_url}}
		  @{{#} }}
	  </a>
	</script>

	<script type="text/html" id="userdetail">
	  @{{ d.account}}<br>
	  
	  @{{d.group_name}}
	</script>

	<!--<script type="text/html" id="moneynum">
	  @{{#if(d.recharge_num!=null){ }}
		@{{ d.recharge_num}}
	  @{{#}else{ }}
		0
	  @{{#} }}
	  <br>
	  @{{#if(d.take_num!=null){ }}
		@{{ d.take_num}}
	  @{{#}else{ }}
		0
	  @{{#} }}
	</script>-->

	<script type="text/html" id="selectphone">
	  <a href="/admin/user/index?select_value=@{{d.phone}}&select_type=phone&regist_startime=&regist_endtime=">
	  @{{#if(d.phone!=null){ }}
		@{{ d.phone}}
	  @{{#} }}</a><!-- <br>
	  @{{#if(d.last_time!=null){ }}
		@{{ d.last_time}}
	  @{{#} }} -->
	</script>

	<script type="text/html" id="selectemail">
	  <a class="aUrl" href="/admin/user/index?select_value=@{{d.email}}&select_type=email&regist_startime=&regist_endtime=">
	  @{{#if(d.email!=null){ }}
		@{{ d.email}}
	  @{{#} }}</a>
	</script>

	<script type="text/html" id="selectname">
	  <a class="aUrl"  href="/admin/user/index?select_value=@{{d.name}}&select_type=name&regist_startime=&regist_endtime=">
		  @{{#if(d.name!=null){ }}
			@{{ d.name}}
		  @{{#} }}
	  </a><!-- <br>
	  @{{#if(d.register_time!=null){ }}
		@{{ d.register_time}}
	  @{{#} }} -->
	</script>

	<script type="text/html" id="openstatus">
		@{{#if(d.status==1){ }}
			<div style="color:green;">启用&nbsp;&nbsp;<a href="/admin/User/changeStatus?id=@{{d.id}}&account=@{{d.account}}" class="layui-btn layui-btn-xs layui-btn-danger">禁用</a></div>
		@{{#}else{ }}
			<div style="color:red;">禁用&nbsp;&nbsp;<a href="/admin/User/changeStatus?id=@{{d.id}}&account=@{{d.account}}" class="layui-btn layui-btn-xs">启用</a></div>
		@{{#} }}
		@{{#if(d.statuss==0){ }}
			<div>离线</div>
		@{{#}else{ }}
			<div style="color:green;">在线&nbsp;&nbsp;<a href="/admin/User/changeStatuss?id=@{{d.id}}&account=@{{d.account}}" class="layui-btn layui-btn-xs">踢线</a></div>
		@{{#} }}
	</script>
	<!--<script type="text/html" id="">		
		@{{d.online}}
		@if(checkRriv('/admin/User/UserStart'))<input type="checkbox" name="status" value="@{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="openStatus" @{{ d.status == '1' ? 'checked' : '' }}>@endif<br>
		@{{d.online}}
	</script>-->

	<script type="text/html" id="moneyrecord">
	  <a href="/admin/fund/index?isuser=1&account_name=@{{d.account}}&star_time=&end_time=&seo_title=@{{d.account}}财务列表">查看财务</a><br>@{{ d.cash}}
	</script>
    <div class="layui-row">

        <div class="layui-col-xs12">
            <input type="hidden" name="sta">
            <form class="layui-form rewrite" action="" id="submitForm" eventType=eventForm>
                <div class="layui-form-item">
					<div class="layui-block">
						<div class="layui-inline">
							<label class="layui-form-label">{{ trans('user.account') }}</label>
							<div class="layui-input-inline">
								<input type="text" name="account" id="form_account" lay-verify="required" autocomplete="off" class="layui-input" eventType=event-query  value="{{ $account }}">
							</div>
							<div class="layui-input-inline checkbox">
								<input type="checkbox" name="sureblur" id="form_sureblur" lay-skin="switch" lay-text="精确|模糊" @if(!isset($sureblurs) || $sureblurs=='on') checked @endif  class="layui-input" eventType=event-query>
								<input type="hidden" name="sureblurs" id="form_sureblurs" lay-verify="required" autocomplete="off" class="layui-input" eventType=event-query  value="{{ $sureblurs }}">
							</div>
						</div>
					
						 <div class="layui-inline" style="width: 480px">
							<div class="layui-input-inline"  style="width: 200px">
								<select name="select_type" id="form_select_type" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
									<option value="">{{ trans('user.select_option') }}</option>
									@foreach(trans('user.select_type') as $k=>$v):
										@if($select_type==$k))
											<option value="{{$k}}" selected="selected">{{$v}}</option>
										@else
											<option value="{{$k}}">{{$v}}</option>
										@endif
									@endforeach
								</select>
							</div>
							<div class="layui-input-inline" >
								<input type="text" name="select_value" id="form_select_value" lay-verify="required" autocomplete="off" class="layui-input" eventType=event-query value="{{$select_value}}">
							</div>
						</div>
					
						<div class="layui-inline" style="width: 360px">
							<label class="layui-form-label">{{ trans('user.grade') }}</label>
							<div class="layui-input-inline"  style="width: 200px">
								<select name="grade" id="form_grade" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
									<option value="">{{ trans('user.select_grade') }}</option>
									@foreach($gradelist as $k=>$v):
										@if($grade==$k))
											<option value="{{$k}}" selected="selected">{{$v}}</option>
										@else
											<option value="{{$k}}">{{$v}}</option>
										@endif
									@endforeach
								</select>
							</div>
						</div>

						<div class="layui-inline" style="width: 360px">
							<label class="layui-form-label">{{ trans('user.group') }}</label>
							<div class="layui-input-inline"  style="width: 200px">
								<select name="group" id="form_group" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
									<option value="">{{ trans('user.select_group') }}</option>
									@foreach($select_group as $k=>$v):
									@if($group==$v['group_code']))
									<option value="{{$v['group_code']}}" selected="selected">{{$v['group_name']}}</option>
									@else
										<option value="{{$v['group_code']}}">{{$v['group_name']}}</option>
									@endif
									@endforeach
								</select>
							</div>
						</div>

						<div class="layui-inline" style="width: 360px">
							<label class="layui-form-label">{{ trans('user.statuss') }}</label>
							<div class="layui-input-inline" style="width: 200px">
								<select name="statuss" id="form_statuss" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
									<option value="">{{ trans('user.select_statuss') }}</option>
									@foreach(trans('status.account_detailed.statuss') as $k=>$v):
										@if($statuss==$k))
											<option value="{{$k}}" selected="selected">{{$v}}</option>
										@else
											<option value="{{$k}}">{{$v}}</option>
										@endif
									@endforeach
								</select>
							</div>
						</div>
						
						<div class="layui-inline" style="width: 360px">
							<label class="layui-form-label">{{ trans('user.isfs') }}</label>
							<div class="layui-input-inline" style="width: 200px">
								<select name="fanshui" id="form_fanshui" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
									<option value="">{{ trans('user.select_isfs') }}</option>
									@foreach(trans('status.isfs.fanshui') as $k=>$v):
										@if($fanshui==$k))
											<option value="{{$k}}" selected="selected">{{$v}}</option>
										@else
											<option value="{{$k}}">{{$v}}</option>
										@endif
									@endforeach
								</select>
							</div>
						</div>

					</div>

					<input type="hidden" name="status" value="{{$status}}" eventType=event-query>
						
					<div class="layui-inline">
						<label class="layui-form-label">{{ trans('user.regist_startime') }}</label>
						<div class="layui-input-inline">
							<input type="text" name="regist_startime"  id="form_regist_startime" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item"
							 eventType=event-query  value="{{ $regist_startime }}">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">{{ trans('user.regist_endtime') }}</label>
						<div class="layui-input-inline">
							<input type="text" name="regist_endtime"  id="form_regist_endtime" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item"
							 eventType=event-query  value="{{ $regist_endtime }}">
						</div>
				   </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('user.rechargenum_area') }}</label>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="rechargenum_small" id="form_rechargenum_small" placeholder="0" autocomplete="off" class="layui-input" eventType=event-query value="{{ $rechargenum_small }}">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="rechargenum_big" id="form_rechargenum_big" placeholder="0" autocomplete="off" class="layui-input" eventType=event-query value="{{ $rechargenum_big }}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('user.takenum_area') }}</label>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="takenum_small" id="form_takenum_small" placeholder="0" autocomplete="off" class="layui-input" eventType=event-query value="{{ $takenum_small }}">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline" style="width: 100px;">
                            <input type="text" name="takenum_big" id="form_takenum_big" placeholder="0" autocomplete="off" class="layui-input" eventType=event-query value="{{ $takenum_big }}">
                        </div>
                    </div>
					
					<div class="layui-inline">
                        <a class="layui-btn layui-btn-sm lay-btn-diy" data-type="reload"
                           style="opacity: 1; pointer-events: auto;" eventType=event-query-submit>提交</a>
                        <!--<a class="layui-btn   layui-btn-sm  layui-btn-normal reset" data-type="reload" style="opacity: 1; pointer-events: auto;" >重置</a>
                         <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload" style="opacity: 1; pointer-events: auto;" eventType=event-query-submit><i class="layui-icon">ဂ</i></a>-->
                    </div>
					<div class="layui-inline">
						<a href="/admin/user/index?regist_startime={{ trans('money.today_start') }}&regist_endtime={{ trans('money.today_end') }}" class="layui-btn layui-btn-sm registtoday" data-id="{{ trans('money.today_start') }}" data-name="{{ trans('money.today_end') }}"   data-type="reload" style="opacity: 1; pointer-events: auto;">今日注册</a>
						<a href="/admin/user/index?last_startime={{ trans('money.today_start') }}&last_endtime={{ trans('money.today_end') }}" class="layui-btn layui-btn-sm onlinetoday" data-id="{{ trans('money.today_start') }}" data-name="{{ trans('money.today_end') }}"   data-type="reload" style="opacity: 1; pointer-events: auto;">今日在线</a>
						<a href="/admin/user/index?statuss=1" class="layui-btn layui-btn-sm online"  data-type="reload" style="opacity: 1; pointer-events: auto;">当前在线</a>
						<a href="/admin/user/index?status=5" class="layui-btn layui-btn-sm onlines"  data-type="reload" style="opacity: 1; pointer-events: auto;">禁用会员列表</a>
						<a href="/admin/user/index?rechargenum_small=1&account={{ $account }}&select_type={{$select_type}}&select_value={{$select_value}}&grade={{$grade}}&statuss={{$statuss}}&status={{$status}}&regist_startime={{$regist_startime}}&regist_endtime={{$regist_endtime}}&takenum_small={{$takenum_small}}&takenum_big={{$takenum_big}}" class="layui-btn layui-btn-sm hasrecharge" }}"   data-type="reload" style="opacity: 1; pointer-events: auto;">有充值</a>
						 @if(checkRriv('/admin/User/checkPwd'))<a  class="layui-btn layui-btn-sm" data-type="reload" style="opacity: 1; pointer-events: auto;" onclick="exportWord()">导出</a>@endif
				   </div>
					<input type="hidden" name="last_startime" id="form_last_startime" placeholder=" - " lay-verify="" autocomplete="off" class="layui-input test-item" value="{{ $last_startime }}" eventType=event-query>
                    <input type="hidden" name="last_endtime" id="form_last_endtime" placeholder=" - " lay-verify="" autocomplete="off" class="layui-input test-item" value="{{ $last_endtime }}" eventType=event-query>
                    <!-- <div class="layui-inline"><a href="javascript:delWin('/admin/user/delete?id=');"
                                                 class="layui-btn layui-btn-sm  layui-btn-danger">删除</a></div> -->
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            $('body').on('click', 'a[eventtype="event-delete"]', function () {
                var span = $(this).prev();
                var id = span.attr('data-id');
                // openWin('/admin/system/AddMenu','{{ trans("menu.menu_edit")}}','600px','500px',id);
            })
            $('body').on('click','#form_sureblur~.layui-form-switch',function(){
            	var sus = $('#form_sureblur').next().text();
            	if(sus=='精确'){
            		$('#form_sureblurs').val('on');
            	}else{
            		$('#form_sureblurs').val('off');
            	}
            })
        })

    	function exportWord(){
//    		var data = setData();
			$.post("/admin/User/checkPwd",$("form").serialize(),function(data1){
			var url = data1.data; //回调函数，返回值是地址，data
			console.log(url);
			window.location.href=url;
//			$('#submitForm').submit(url);
			});
		}

		function isfs(type,id){
			$.ajax({
                type: 'POST',
                dataType: 'json',
                url: '/admin/User/ajaxfsup',
                data: {id:id,type:type},
                success: function(data) {
                	location. reload()//刷新当前页面
                }
            })
		}

    </script>
    @push('dataTableJS')
        /*var active = {
			reload: function(){
			//执行重载
			table.reload('{{ $dataId }}', {
				page: {
				curr: 1 //重新从第 1 页开始
				}
				,where: {
					account:$("#form_account").val(),
					select_type:$("#form_select_type").val(),
					select_value:$("#form_select_value").val(),
					grade:$('#form_grade').val(),
					regist_startime:$('#form_regist_startime').val(),
					regist_endtime:$('#form_regist_endtime').val(),
					last_startime:$('#form_last_startime').val(),
					last_endtime:$('#form_last_endtime').val(),
					statuss:$('#form_statuss').val(),
					cash_small:$('#form_cash_small').val(),
					cash_big:$('#form_cash_big').val(),
					sureblur:$('#form_sureblur').next().text(),
					rechargenum_small:$('#form_rechargenum_small').val(),
					rechargenum_big:$('#form_rechargenum_big').val(),
					takenum_small:$('#form_takenum_small').val(),
					takenum_big:$('#form_takenum_big').val(),
				}
			});
			}
        };


        $('.lay-btn-diy').on('click', function(){
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
        });*/
		

		//今日注册
		$('.registtoday').on('click', function(){
			$('input').val('');
			$('#form_statuss').val('');
			$('#form_fanshui').val('');
			$('#form_grade').val('');
			$('#form_select_type').val('');
			$('#form_regist_startime').val($(this).attr('data-id'));
			$('#form_regist_endtime').val($(this).attr('data-name'));
			//var type = $(this).data('type');
			//active[type] ? active[type].call(this) : '';
		  });
		  //今日在线
		$('.onlinetoday').on('click', function(){
			$('input').val('');
			$('#form_statuss').val('');
			$('#form_fanshui').val('');
			$('#form_grade').val('');
			$('#form_select_type').val('');
			$('#form_last_startime').val($(this).attr('data-id'));
			$('#form_last_endtime').val($(this).attr('data-name'));
			$('#form_statuss').val(1);
			//var type = $(this).data('type');
			//active[type] ? active[type].call(this) : '';
		  });

		  //当前在线
		$('.online').on('click', function(){
			$('input').val('');
			$('#form_statuss').val('');
			$('#form_fanshui').val('');
			$('#form_grade').val('');
			$('#form_select_type').val('');
			$('#form_statuss').val(1);
			//var type = $(this).data('type');
			//active[type] ? active[type].call(this) : '';
		  });

		//会员禁用
		$('.onlines').on('click', function(){
		$('input').val('');
		$('#form_statuss').val('');
			$('#form_fanshui').val('');
		$('#form_grade').val('');
		$('#form_select_type').val('');
		$('#status').val(5);
		//var type = $(this).data('type');
		//active[type] ? active[type].call(this) : '';
		});

		//有充值
		$('.hasrecharge').on('click', function(){
			//$('input').val('');
			//$('#form_statuss').val('');
			//$('#form_grade').val('');
			//$('#form_select_type').val('');
			$('#form_rechargenum_small').val(1);
			//var type = $(this).data('type');
			//active[type] ? active[type].call(this) : '';
		  });

        //重置表单
        $('.reset').on('click',function(){
			$('input').val('');
			$('#form_statuss').val('');
			$('#form_fanshui').val('');
			$('#form_grade').val('');
			$('#form_select_type').val('');
			//var type = $(this).data('type');
			//active[type] ? active[type].call(this) : '';
        });

        //刷新表单
        $('.set').on('click',function(){
        //var type = $(this).data('type');
        //active[type] ? active[type].call(this) : '';
        });


function dataTableLoadFinished(res,curr,count){
    var str='';
    if(document.getElementById("statistics")){

    }else{
    $('.layui-table-page').after('<div id="statistics"></div>');
    }

	var datau=res.data;
	var curpage_cash=0;
	for(var i=0;i<datau.length;i++){
	curpage_cash+=parseFloat(datau[i].cash);
	}
    $.ajax({
        type: 'get',
        url: '/admin/user/userCashCount',
        data: {where:res.extras},
        dataType: 'json',
        async: false,
        success: function (data) {
        var data=data.data;
        str+='<div class="bottom-txt"><p>本页会员总余额：<span class="blue">'+Math.floor(curpage_cash*100)/100+'</span>,所有会员总余额：<span class="green">'+data.allcash+'</span>所有正常会员总余额：<span class="red">'+data.normalcash+'</span>,所有停用会员总余额；<span class="yellow">'+data.stopcash+'</span></p>'
        str+='<p>所有异常会员总余额：<span class="blue">'+data.speccash+'</span></p></div>'
        $('#statistics').html(str);
        }
    });
var height1=$('.layui-table-view').height();
var height2=$('#statistics').height();

$('.layui-table-view').css({height:(height1+height2)});

}

	//启用|禁用用户
	form.on('switch(openStatus)', function(obj){
		var status = -1;
		if(obj.elem.checked==true){
			status =1;
		}
		setcolumn('/admin/User/UserStart',this.name,status,this.value,obj);
		//layer.tips(msg, obj.othis);
	});

	function setcolumn(url,column,value,id,obj){
		//console.log('aa');
		//console.log(this.name+','+status+','+this.value+','+obj);
		$.ajax({
			url: url+'?'+column+'='+value+'&id='+id,
			dataType: 'json',
			type: 'get',
			success:function(data){
				layer.msg(data.msg);
				if(data.status!=1){
					if(value==1){
						obj.othis[0].setAttribute("class", "layui-unselect layui-form-switch");
						obj.othis[0].innerHTML='<em>禁用</em><i></i>';
					}else{
						obj.othis[0].setAttribute("class",'layui-unselect layui-form-switch layui-form-onswitch');
						obj.othis[0].innerHTML='<em>启用</em><i></i>';
					}
				}
			}
		});
	}

    @endpush

    @include('vip.datatable')
    <style type="text/css">
		.layui-table-view .layui-table td, .layui-table-view .layui-table th{
			padding: 0px 0px;
		}
	</style>
	<link rel="stylesheet" href="{{ asset('/css/untablelist.css') }}"  />
@endsection
