<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:63:"D:\wwwroot\pay.6gym.com\public/../app/index\view\admin\game.html";i:1612239034;}*/ ?>

<!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;
        }
        
        #tbImgTable + .layui-table-view .layui-table-body tbody > tr > td {
            padding: 0;
        }

        #tbImgTable + .layui-table-view .layui-table-body tbody > tr > td > .layui-table-cell {
            height: 48px;
            line-height: 48px;
        }

        .tb-img-circle {
            width: 26px;
            height: 26px;
            cursor: zoom-in;
            border-radius: 50%;
            border: 1px solid #dddddd;
        }

    </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="game_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>
                    </div>
                </div>
            </form>
            <!-- 数据表格 -->
            <table id="tbBasicTable" lay-filter="tbBasicTable"></table>
        </div>
    </div>
  
</div>


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

<script type="text/html" id="dialogEditDialog1">
    <form id="dialogEditForm1" lay-filter="dialogEditForm1" class="layui-form model-form no-padding">
        <input name="id" type="hidden"/>
	    <input name="game_img" id="game_img" type="hidden"/>
        <div class="model-form-body" style="max-height: 530px;overflow-y: inherit;">
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">通道标题:</label>
                <div class="layui-input-block">
                    <input name="game_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-upload">
                  <button type="button" class="layui-btn layui-btn-normal" id="test8">选择文件</button>
                
                  </div>
            </div>
		
            
           	<div class="layui-form-item">
                <label class="layui-form-label layui-form-required">是否启用:</label>
                <div class="layui-input-block">
                    <select name="game_status" lay-verify="required" required>
                        <option value="1">启用</option>
                        <option value="0">不启用</option>
                    </select>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">所属分类:</label>
                <div class="layui-input-block">
                    <select name="game_type_id" lay-verify="required" required>
                        <option value="0">不分类</option>
                        <?php if(is_array($game_type) || $game_type instanceof \think\Collection || $game_type instanceof \think\Paginator): $i = 0; $__LIST__ = $game_type;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                            <option value="<?php echo $vo['id']; ?>"><?php echo $vo['title']; ?></option>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </select>
                </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>





<!-- 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','laytpl','admin','table', 'util', 'dropdown','baseTable','upload'], 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 laytpl = layui.laytpl;
        var admin = layui.admin;
        var upload = layui.upload;
        /* 渲染表格 */
        var insTb = table.render({
            elem: '#tbBasicTable',
            url: "<?php echo url('admin/game_list'); ?>",
            page: true,
            limit: 15,
            cellMinWidth: 100,
            cols: [[
                {
                    title: '通道图标', templet: function (d) {
                        var url = '../../../uploads/'+d.game_img || '----';
                        return '<img data-index="' + (d.LAY_INDEX - 1) + '" src="' + url + '" class="tb-img-circle" tb-img alt=""/>';
                    }, align: 'left', width: 100, unresize: true
                },
                {field: 'game_name', title: '通道名称', align: 'left',width:300},
                {field: 'game_dm', title: '通道代码', align: 'left',width:200},
               
                {
                    field: 'state', title: '通道状态', templet: function (d) {
                        var strs = {
                          
                            1:'<span class="layui-badge layui-badge-green">通道已启用</span>',
                            0:'<span class="layui-badge layui-badge-gray">通道未启用</span>'
                        };
                        return strs[d.game_status];
                    }, align: 'left',width:200
                },
                
                {field: 'game_type_name', title: '通道分类', templet: function (d) {
                        if(!d.game_type_name){
                            return '未分类';
                        }else{
                            return d.game_type_name;
                        }
                    }, align: 'left',width:200
                },
                {field: 'yue_pay_1', title: '本月总收', align: 'left',width:200},
                {field: 'yue_pay', title: '上月总收', align: 'left',width:200},
                {title: '操作', toolbar: '#tbBasicTbBar', align: 'left', minWidth: 120}
            ]]
        });

        /* 表格搜索 */
        form.on('submit(tbBasicTbSearch)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}});
            return false;
        });
        
        

        /* 表格工具条点击事件 */
        table.on('tool(tbBasicTable)', function (obj) {
            var data = obj.data; // 获得当前行数据
            var layEvent = obj.event;
            if (obj.event === 'edit') { // 修改
                showMode(data);
            }
            dropdown.hideAll();
        });
        
        
        
        function showMode(mData){
			admin.open({
                type: 1,
                title: "编辑",
				area: ['640px', '410px'],
                content: $('#dialogEditDialog1').html(),
                success: function (layero, dIndex) {
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    form.val('dialogEditForm1',mData);
                    form.render(null, 'dialogEditForm1');
                    
                    // 表单提交事件
                    form.on('submit(dialogEditSubmit1)', function (data) {
						var loadIndex = layer.load(2);
                        $.post('<?php echo url("admin/game_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;
                    });
                    
                   upload.render({
                          elem: '#test8'
                          ,url: '<?php echo url("admin/game_upload"); ?>' //改成您自己的上传接口
                          ,auto: true
                          ,done: function(res){
                             if(res.code==0){
                             layer.msg('上传成功');
                             $('#game_img').val(res.result);
                             }
                          }
                        }); 
                    

                }
            });
		}
        
	
        
        /* 点击图片放大 */
        $(document).off('click.tbImg').on('click.tbImg', '[tb-img]', function () {
            var imgList = table.cache['tbBasicTable'].map(function (d) {
                return {
                    alt: d.game_name,
                    src: '../../../uploads/'+d.game_img || '-----'
                }
            });
            layer.photos({photos: {data: imgList, start: $(this).data('index')}, shade: .1, closeBtn: true});
        });

   

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