<?php include_once(mvc::$cfg['PATH_TPL'].'seller/publicHead.php');?>
<style type="text/css">.lay-inline {display: inline;width: auto;}</style>
<div class="maintb">
    <div id="memberList-main-middle" class="main_middle">
        <div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title">
                <!-- <li>
                    <a href="<?php echo mvc::$cfg['SELF_URL'];?>seller/memberRegister" style="color:#000">已注册用户</a>
                </li> -->
                <li>
                    <a href="<?php echo mvc::$cfg['SELF_URL'];?>seller/memberList" style="color:#000">店铺会员</a>
                </li>
                <li>
                    <a href="<?php echo mvc::$cfg['SELF_URL'];?>seller/member" style="color:#000">会员等级</a>
                </li>
                <li class="layui-this">
                    <a href="<?php echo mvc::$cfg['SELF_URL'];?>seller/memberColl">店铺收藏</a>
                </li>
                <li>
                    <a href="<?php echo mvc::$cfg['SELF_URL'];?>seller/memberBlack" style="color:#000">黑名单</a>
                </li>
            </ul>
            <div class="layui-tab-conten" style="padding: 10px">
                <div id="searchTable">
                    <form class="form-inline" action="<?php echo mvc::$cfg['SELF_URL'];?>/seller/memberColl" method="get" id="searchForm">
                        <table class="table">
                            <tbody>
                                <tr>
                                    <td class="thr">用户名称：</td>
                                    <td><input type="text" class="layui-input lay-inline" name="userName" value="<?php echo $_GET['userName'];?>"></td>
                                    <td class="thr">收藏时间：</td>
                                    <td>
                                        <input type="text" id="start" onchange="reformatend(this)" style="width: 123px;" readonly="" placeholder="点击选择开始时间" class="layui-input lay-inline" name="starttime" value="<?php echo $_GET['starttime'];?>">
                                        <strong>到</strong>
                                        <input type="text" id="end"  style="width: 123px;"  readonly="" placeholder="点击选择结束时间" class="layui-input lay-inline" name="endtime" value="<?php echo $_GET['endtime'];?>">
                                        <span class="add-on"><i class="icon-remove"></i></span>
                                    </td>
                                </tr>
                                <tr>

                                    <td class="thr">用户ID：</td>
                                    <td><input type="text" class="layui-input lay-inline" name="userId" value="<?php echo $_GET['userId'];?>"></td>
                                    <td colspan="2">
                                        <button type="button" class="layui-btn layui-btn-primary" onclick="window.location.href='<?php echo mvc::$cfg['SELF_URL'];?>seller/memberColl'">清空</button>
                                        <button type="button" class="layui-btn" onclick="return submit();">搜索</button>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
                <div class="inner_container col-tab-box coll-tab">
                    <table class="layui-table">
                        <thead>
                            <tr>
                                <th><input type="checkbox" onclick="checkallcheckbox(this)" name="checkall"/></th>
                                <th>ID</th>
                                <th>用户名</th>
                                <th>会员等级</th>
                                <th>收藏时间</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if(!empty($data)){ ?>
                                <?php foreach($data as $v){ ?>
                                    <tr>
                                        <td><input type="checkbox" class="memluids" value="<?php echo $v['ub_uid'];?>" /></td>
                                        <td><?php echo $v['ub_uid'];?></td>
                                        <td><?php echo $v['ub_username'];?></td>
                                        <td><?php if(empty($userLevel[$v['ub_uid']])) echo '非会员'; else echo $userLevel[$v['ub_uid']]; ?></td>
                                        <td><?php echo date('Y-m-d H:i:s',$v['shc_add_time']);?></td>
                                    </tr>
                                <?php } ?>
                            <?php }else{ ?>
                                <tr><td colspan="5" class="center orange">非常抱歉，未找到对应条件的会员</td></tr>        
                            <?php } ?>
                        </tbody>
                    </table>
                    <div class="padtb5"></div>
                    <div style="width: 100px;float: left;">
                        <button type="button" onclick="setColMem()" class="layui-btn">设置会员等级</button>
                    </div>
                    <?php echo $Page;?>
                </div>
            </div>
        </div>

    
    <div id="setmodel" style="display: none;">
        <div class="modal-body layui-form" style="padding: 10px;">
            <table id="level-model" class="layui-table">
                <thead>
                    <tr class="success">
                        <th>会员等级</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            <?php foreach ($level as $v) { ?>
                            <input type="radio" name="level" value="<?php echo $v['mel_id']; ?>" title="<?php echo $v['mel_name']; ?>">
                            <?php } ?>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
      
    </div>
</div>
<?php include_once(mvc::$cfg['PATH_TPL'].'public/footBase.php');?>


<script type="text/javascript">
    //设置会员等级
    function setColMem(){
        var ids = new Array();
        $(".coll-tab").find("tbody").find("input[type='checkbox']").each(function(index,i){
            if(i.checked){
                ids.push($(i).val());
            }
        });
        if(ids.length==0){
            layer.msg('未选择会员！')
            return false;
        }
        layer.open({
            type:1,
            title:'设置会员等级',
            area:['500px','200px'],
            content:$("#setmodel"),
            btn: ['确定', '关闭'],
            btnAlign: 'c',
            yes:function(index,layero){
                var level = $("#level-model input[name='level']:checked").val();
                if(level==""){
                    layer.msg('请选择会员等级');
                    return false;
                } 
                $.ajax({
                    url:SELF_URL+'seller/setColMem?isAjax=1',
                    data:{'ids':ids.toString(),'level':level},
                    dataType:'json',
                    type:'post',
                    success:function(res){
                        if(res.status){
                            location.reload();
                        } else {
                            layer.msg(res.data)
                        }
                    }
                });
            }
        })
    }
    var level = <?php echo json_encode($level);?>;
    layui.use('laydate',function(){
        laydate = layui.laydate
        laydate.render({
            elem: '#start' //指定元素
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#end' //指定元素
            ,type: 'datetime'
        }); 
    })
    
</script>