<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:66:"/www/wwwroot/10.168.1.202/public/../app/index/view/admin/user.html";i:1609314480;}*/ ?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title><?php echo $web_config['web_site']; ?> - 6gym.com 6G源码 </title>
    <link rel="stylesheet" href="/static/assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="/static/assets/module/admin.css?v=318" media="all"/>
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        /** 数据表格中的select尺寸调整 */
        .layui-table-view .layui-table-cell .layui-select-title .layui-input {
            height: 28px;
            line-height: 28px;
        }

        .layui-table-view [lay-size="lg"] .layui-table-cell .layui-select-title .layui-input {
            height: 40px;
            line-height: 40px;
        }

        .layui-table-view [lay-size="lg"] .layui-table-cell .layui-select-title .layui-input {
            height: 40px;
            line-height: 40px;
        }

        .layui-table-view [lay-size="sm"] .layui-table-cell .layui-select-title .layui-input {
            height: 20px;
            line-height: 20px;
        }

        .layui-table-view [lay-size="sm"] .layui-table-cell .layui-btn-xs {
            height: 18px;
            line-height: 18px;
        }
    </style>
</head>
<body onscroll="layui.admin.hideFixedEl();">
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 表格工具栏 -->
            <form class="layui-form toolbar table-tool-mini">
                <div class="layui-form-item">
                      <div class="layui-inline">
                        <label class="layui-form-label w-auto">商户用户名:</label>
                        <div class="layui-input-inline">
                            <input name="name" class="layui-input" type="text" placeholder="请输入商户用户名"/>
                        </div></div>
                    <div class="layui-inline" style="padding-right: 110px;">
                        <button class="layui-btn icon-btn" lay-filter="tbBasicTbSearch" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                        <button id="tbBasicExportBtn" class="layui-btn icon-btn" type="button">
                            <i class="layui-icon">&#xe67d;</i>导出
                        </button>
                       
                    </div>
                </div>
            </form>
            <!-- 数据表格 -->
            <table id="tbBasicTable" lay-filter="tbBasicTable"></table>
        </div>
    </div>
  
</div>
<!-- 固定底部按钮 -->
<script type="text/html" id="dialogEditDialog1">
    <form id="dialogEditForm1" lay-filter="dialogEditForm1" class="layui-form model-form no-padding">
        <input name="id" type="hidden"/>
	
        <div class="model-form-body" style="max-height: 430px;">
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">商户:</label>
                <div class="layui-input-block">
                    <input name="name" placeholder="商户用户名" class="layui-input"
                           lay-verify="required" required />
                </div>
            </div> 
            
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">密码:</label>
                <div class="layui-input-block">
                     <input name="pwd2" placeholder="不修改密码留空即可" class="layui-input"/>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label layui-form-required">商户余额:</label>
                <div class="layui-input-block">
                    <input name="balance" placeholder="商户余额" class="layui-input"
                           lay-verify="required" required/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">手续费:</label>
                <div class="layui-input-block">
                    <input name="pay_sxf" placeholder="商户手续费点位" class="layui-input"
                           lay-verify="required" required/>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">商户PID:</label>
                <div class="layui-input-block">
                    <input name="api_id" placeholder="商户PID" class="layui-input"
                           lay-verify="required" required/>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">商户KEY:</label>
                <div class="layui-input-block">
                    <input name="api_key" placeholder="商户KEY" class="layui-input"
                           lay-verify="required" required/>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">开放通道:</label>
                <div class="layui-input-block">
                 <input type="checkbox" lay-filter="a_all" class="game" name="game_id[0]" value="0"  title="全部" lay-skin="primary">
                
                 <br>
                <?php if(is_array($game_list) || $game_list instanceof \think\Collection || $game_list instanceof \think\Paginator): $i = 0; $__LIST__ = $game_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                   <input type="checkbox" lay-filter="b_all" class="game_id" name="game_id[<?php echo $vo['id']; ?>]" value="<?php echo $vo['id']; ?>" title="<?php echo $vo['game_name']; ?>" lay-skin="primary">
                <?php endforeach; endif; else: echo "" ;endif; ?>
                </div>
            </div>
             
            
           
			
        </div>
        <div class="layui-form-item text-right model-form-footer">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="dialogEditSubmit1" lay-submit>保存</button>
        </div>
    </form>
</script>

<!-- 表格操作列 -->
<script type="text/html" id="tbBasicTbBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
   
</script>

<!-- js部分 -->
<script type="text/javascript" src="/static/assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="/static/assets/js/common.js?v=318"></script>
<script>
    layui.use(['layer', 'form','admin','table', 'util', 'dropdown','baseTable'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var dropdown = layui.dropdown;
        var admin = layui.admin;
        /* 渲染表格 */
        var insTb = table.render({
            elem: '#tbBasicTable',
            url: "<?php echo url('admin/user_list'); ?>",
            page: true,
            limit: 15,
            totalRow:true,
            cellMinWidth: 100,
            cols: [[
                {type: 'checkbox',totalRowText: "合计" },
                {field: 'id', title: 'UID', align: 'left',width:80},
                {field: 'name', title: '商户用户名', align: 'left',width:150},
                {field: 'login_ip', title: '最近登录IP', align: 'left',width:150},
                 {
                    field: 'create_time', title: '注册时间',minWidth: 190, templet: function (d) {
                        return util.toDateString(d.create_time*1000);
                    }, align: 'left'
                },
                 {
                    field: 'login_time', title: '登录时间',minWidth: 190, templet: function (d) {
                         if(d.login_time!=''){return util.toDateString(d.login_time*1000)}else{return '从未登录'};
                    }, align: 'left'
                },
                {field: 'balance', title: '商户余额', align: 'left',width:100,templet: function (d) {
                        return d.balance+'元';
                    }},
                {field: 'pay_sxf', title: '手续费', align: 'left',width:80},
                {field: 'api_id', title: '商户PID', align: 'left',width:180},
                {field: 'jr_pay', title: '今日消费', align: 'left',width:100,totalRow:true,templet: function (d) {
                        return d.jr_pay+'元';
                    }},
                {field: 'zr_pay', title: '昨日消费', align: 'left',width:100,totalRow:true,templet: function (d) {
                        return d.zr_pay+'元';
                    }},
                {title: '操作', toolbar: '#tbBasicTbBar', align: 'left', minWidth: 120}
            ]]
        });

        /* 表格搜索 */
        form.on('submit(tbBasicTbSearch)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}});
            return false;
        });
        
        form.on('checkbox(a_all)', function(data){
           
           var a = data.elem.checked;
            if (a == true) {
                $(".game_id").prop("checked", false);
                form.render('checkbox');
            } 

         
        });  
        form.on('checkbox(b_all)', function(data){
           
           var a = data.elem.checked;
            if (a == true) {
                $(".game").prop("checked", false);
                form.render('checkbox');
            } 

         
        });  

        /* 表格工具条点击事件 */
        table.on('tool(tbBasicTable)', function (obj) {
            var data = obj.data; // 获得当前行数据
            if (obj.event === 'edit') { // 修改
                showMode(data);
            } else if (obj.event === 'del') { // 删除
                del(data);
            } 
            dropdown.hideAll();
        });
        
        function del(data){
            layer.confirm('确认要删除该用户吗？', {
                shade: .1,
                skin: 'layui-layer-admin'
                }, function (i) {
                layer.close(i);
                    layer.load(2);
                    $.get('<?php echo url("admin/del_user_list"); ?>', {
                        id: data.id
                    }, function (res) {
                        layer.closeAll('loading');
                        if (res.code == 1) {
                            layer.msg(res.msg, {icon: 1});
                            insTb.reload({page: {curr: 1}});
                           
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'json');
                                
           });
        
        }
        
        function showMode(mData){
			admin.open({
                type: 1,
                title: mData?"编辑":'添加',
				area: ['640px', '570px'],
                content: $('#dialogEditDialog1').html(),
                success: function (layero, dIndex) {
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    form.val('dialogEditForm1',mData);
                    unitType = mData.game_id.split(",");
                    if(unitType.length > 0){
                       for (var i = 0; i < unitType.length; i++) {
                           $(layero).find('[name="game_id[' + unitType[i] + ']"]').attr('checked', true);         
                       }
                    } else {
                       $(layero).find('[name="game_id[' + mData.game_id + ']"]').attr('checked', true);
                    }   
                    form.render(null, 'dialogEditForm1');
                    $(layero).find('[name="name"]').attr('readonly', 'readonly');
                   
                    // 表单提交事件
                    form.on('submit(dialogEditSubmit1)', function (data) {
						var loadIndex = layer.load(2);
                        $.post('<?php echo url("admin/user_save"); ?>', data.field, function (res) {
                            layer.close(loadIndex);
                            if (0 != res.code) {                                
                                layer.msg(res.msg, {icon: 1});
                                insTb.reload({page: {curr: 1}});
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'json');
                        return false;
                    });

                }
            });
		}

        // 导出excel
        $('#tbBasicExportBtn').click(function () {
            var checkRows = table.checkStatus('tbBasicTable');
            if (checkRows.data.length === 0) {
                layer.msg('请选择要导出的数据', {icon: 2});
            } else {
                table.exportFile(insTb.config.id, checkRows.data, 'xls');
            }
        });

    });
</script>
</body>
</html>