<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改活动</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/bootstrap/bootstrap.min.css" >
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css">
    <link rel="stylesheet" href="<?php echo base_url();?>public/css/jquery.timepicker.min.css">
    <!-- Select2 -->
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/select2/select2.min.css">

    <style type="text/css">
        .thumbnail {
            margin:10px;
        }

        .lang-name {
            margin-left:42px;
        }

        .upimg {
            cursor: pointer;
        }

    </style>
</head>
<body>
<div id="msg-tip">

</div>
<div class="content_wrapper">
    <div class="container-fluid">
        <aside>
            <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="goodForm" action="#" style="margin-top: 20px">
                <input type="hidden" value="<?php echo $id;?>" name="id"/>
                <input type="hidden" value="<?php echo $cid;?>" name="cid"/>
                <header><i class="fa fa-fw fa-file"></i>分群配置</header>
                <section>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <button type="button" class="btn btn-success" id="submitBtn">提交</button>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid" style="margin-top: 2rem">
                        <div class="form-group" >
                            <label class="col-sm-1 control-label">分群号*: </label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" name="groupId" value="<?php echo $info['groupId'];?>">
                            </div>
                        </div>
                        <div class="form-group" >
                            <label class="col-sm-1 control-label">分群名*: </label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control"  name="name" value="<?php echo $info['name'];?>">
                            </div>
                        </div>
                        <div class="form-group" >
                            <label class="col-sm-1 control-label">分群备注*: </label>
                            <div class="col-sm-4">
                                <textarea rows="8" class="form-control" name='remark'><?php echo $info['remark'];?></textarea>
                            </div>
                        </div>
                        <div class="form-group" >
                            <label class="col-sm-1 control-label">广告总次数*: </label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control"  name="adTotal" value="<?php echo $info['adTotal']??0;?>">
                            </div>
                        </div>
                        <div class="form-group" >
                            <label class="col-sm-1 control-label">排序*: </label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control"  name="sort" value="<?php echo $info['sort']??0;?>">
                            </div>
                        </div>
                        <div class="form-group" >
                            <div class="row">
                                <div class="col-sm-12">
                                    <label class="col-sm-1 control-label">分群定义*: </label>
                                    <div class="col-sm-2">
                                        <button type="button" onclick="add()"><i class="fa fa-fw fa-file"></i>添加群条件</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group" <?php if(empty($info['condition'])){  echo 'style="display: none"';} ?> id="condition">
                            <div class="row">
                                <div class="col-sm-12">
                                    <label class="col-sm-1 control-label">分群条件</label>
                                    <div class="col-sm-11 addOrDelControl" id="add" >
                                        <?php foreach ($info['condition'] as $key=>$row){ ?>
                                        <div class="row">
                                            <div class="col-sm-2">
                                                <select class="form-control" name="config[<?php echo $key;?>][action]">
                                                    <option <?php if($row['action'] == 0){ echo 'selected';} ?> value="0">并且</option>
                                                    <option <?php if($row['action'] == 1){ echo 'selected';} ?> value="1">或者</option>
                                                    <option <?php if($row['action'] == 2){ echo 'selected';} ?> value="2">非</option>
                                                </select>
                                            </div>
                                            <div class="col-sm-2">
                                                <select class="form-control" onchange="changeSelect(<?php echo $key;?>,true)" id="condition<?php echo $key;?>" name="config[<?php echo $key;?>][condition]">
                                                    <?php foreach ($condition as $c=>$cn){ ?>
                                                        <option <?php if($row['condition'] == $c){ echo 'selected';} ?> value="<?php echo $c;?>"><?php echo $cn;?></option>
                                                    <?php } ?>
                                                </select>
                                            </div>
                                            <?php if($row['condition'] == 0){ ?>
                                                <div class="col-sm-2">
                                                    <select class="form-control" name="config[<?php echo $key;?>][platform]">
                                                        <option <?php if($row['platform'] == 0){ echo 'selected';} ?> value="0">全选</option>
                                                        <option <?php if($row['platform'] == 1){ echo 'selected';} ?> value="1">安卓</option>
                                                        <option <?php if($row['platform'] == 2){ echo 'selected';} ?> value="2">IOS</option>
                                                    </select>
                                                </div>
                                            <?php } ?>
                                            <?php if($row['condition'] == 1){ ?>
                                                <div class="col-sm-2">
                                                    <select class="form-control" name="config[<?php echo $key;?>][userType]">
                                                        <option <?php if($row['userType'] == 0){ echo 'selected';} ?> value="0">全选</option>
                                                        <option <?php if($row['userType'] == 1){ echo 'selected';} ?> value="1">FB</option>
                                                        <option <?php if($row['userType'] == 2){ echo 'selected';} ?> value="2">游客</option>
                                                    </select>
                                                </div>
                                            <?php } ?>
                                            <?php if($row['condition'] == 2){ ?>
                                                <div class="col-sm-2">
                                                    <select class="form-control" name="config[<?php echo $key;?>][vip]">
                                                        <option <?php if($row['vip'] == 0){ echo 'selected';} ?> value="0">全选</option>
                                                        <option <?php if($row['vip'] == 1){ echo 'selected';} ?> value="1">非VIP</option>
                                                        <option <?php if($row['vip'] == 2){ echo 'selected';} ?> value="2">VIP</option>
                                                    </select>
                                                </div>
                                            <?php } ?>
                                            <?php if($row['condition'] == 3){ ?>
                                                <div class="col-sm-2">
                                                    <select class="form-control" name="config[<?php echo $key;?>][firstPay]">
                                                        <option <?php if($row['firstPay'] == 0){ echo 'selected';} ?> value="0">全选</option>
                                                        <option <?php if($row['firstPay'] == 1){ echo 'selected';} ?> value="1">非首冲</option>
                                                        <option <?php if($row['firstPay'] == 2){ echo 'selected';} ?> value="2">首冲</option>
                                                    </select>
                                                </div>
                                            <?php } ?>

                                            <?php foreach ($between as $b=>$bet){ ?>
                                                <?php if($row['condition'] == $b){ ?>
                                                    <div class="col-sm-6">
                                                        <div class="col-sm-4">
                                                            <select class="form-control typeControl" name="config[<?php echo $key;?>][<?php echo $bet;?>]">
                                                                <option <?php if($row[$bet] == 0){ echo 'selected';} ?> value="0">全选</option>
                                                                <option <?php if($row[$bet] != 0){ echo 'selected';} ?> value="1">区间</option>
                                                            </select>
                                                        </div>
                                                        <div class="col-sm-4" >
                                                            <input type="text" class="form-control" <?php if($row['condition'] == 0){ echo "readonly";} ?>  name="config[<?php echo $key;?>][<?php echo $bet;?>s][]" value="<?php echo $row[$bet][0];?>">
                                                        </div>
                                                        <div class="col-sm-4">
                                                            <input type="text" class="form-control" <?php if($row['condition'] == 0){ echo "readonly";} ?> name="config[<?php echo $key;?>][<?php echo $bet;?>s][]" value="<?php echo $row[$bet][1];?>">
                                                        </div>
                                                    </div>
                                                <?php } ?>
                                            <?php } ?>

                                            <?php if($row['condition'] == 13){ ?>
                                                <div class="col-sm-6">
                                                    <div class="col-sm-4">
                                                        <select class="form-control countrySet" name="config[<?php echo $key;?>][countrySet]">
                                                            <option <?php if($row['countrySet'] == 0) { echo 'selected';} ?> value="0">全选</option>
                                                            <option <?php if($row['countrySet'] != 0){ echo 'selected';} ?> value="1">限定</option>
                                                        </select>
                                                    </div>
                                                    <div class="col-sm-8" <?php if($row['countrySet'] == 0) { echo 'style="display:none;"';} ?>>
                                                        <div class="checkbox">
                                                            <?php foreach ($country as $co=>$cou){ ?>
                                                                <label class="checkbox-inline">
                                                                    <input type="checkbox" <?php if(in_array($co,$row['countrySet'])){ echo 'checked';} ?> name="config[<?php echo $key;?>][countrySetArr][]" value="<?php echo $co;?>"><?php echo $cou;?>
                                                                </label>
                                                            <?php } ?>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php } ?>
                                            <?php if($row['condition'] == 14){ ?>
                                                <div class="col-sm-6">
                                                    <div class="col-sm-4">
                                                        <select class="form-control adjustGroup" name="config[<?php echo $key;?>][adjustGroup]">
                                                            <option <?php if($row['adjustGroup'] == 0) { echo 'selected';} ?> value="0">全选</option>
                                                            <option <?php if($row['adjustGroup'] != 0){ echo 'selected';} ?> value="1">限定</option>
                                                        </select>
                                                    </div>
                                                    <div class="col-sm-8" <?php if($row['adjustGroup'] == 0) { echo 'style="display:none;"';} ?>>
                                                        <div class="checkbox">
                                                            <?php foreach ($adjustGroup as $ad=>$adjust){ ?>
                                                                <label class="checkbox-inline">
                                                                    <input type="checkbox" <?php if(in_array($ad,$row['adjustGroup'])){ echo 'checked';} ?> name="config[<?php echo $key;?>][adjustGroupArr][]" value="<?php echo $ad;?>"><?php echo $adjust;?>
                                                                </label>
                                                            <?php } ?>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php } ?>
                                            <?php if($row['condition'] == 17){ ?>
                                                <div class="col-sm-6">
                                                    <div class="col-sm-4">
                                                        <select class="form-control adjustGroup" name="config[<?php echo $key;?>][vipLv]">
                                                            <option <?php if($row['vipLv'] == 0) { echo 'selected';} ?> value="0">全选</option>
                                                            <option <?php if($row['vipLv'] != 0){ echo 'selected';} ?> value="1">限定</option>
                                                        </select>
                                                    </div>
                                                    <div class="col-sm-8" <?php if($row['vipLv'] == 0) { echo 'style="display:none;"';} ?>>
                                                        <div class="checkbox">
                                                            <?php foreach ($vipLv as $ad=>$lv){ ?>
                                                                <label class="checkbox-inline">
                                                                    <input type="checkbox" <?php if(in_array($lv,$row['vipLv'])){ echo 'checked';} ?> name="config[<?php echo $key;?>][vipLvArr][]" value="<?php echo $lv;?>"><?php echo "LV".$lv;?>
                                                                </label>
                                                            <?php } ?>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php } ?>

                                            <?php if($row['condition'] == 16){ ?>
                                                <div class="col-sm-6">
                                                    <div class="col-sm-4">
                                                        <select class="form-control" name="config[<?php echo $key;?>][channel]">
                                                            <option <?php if($row['channel'] == 1){ echo 'selected';} ?> value="1">GooglePlay</option>
                                                            <option <?php if($row['channel'] == 2){ echo 'selected';} ?> value="2">AppStore</option>
                                                            <option <?php if($row['channel'] == 3){ echo 'selected';} ?> value="3">VIVO</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            <?php } ?>

                                            <?php if($row['condition'] == 15){ ?>
                                                <div class="col-sm-6">
                                                    <div class="col-sm-4">
                                                        <label class="checkbox-inline">R 距离上次充值的时间（天）</label>
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][r][]" value="<?php echo $row['rfm']["r"][0]; ?>">
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][r][]" value="<?php echo $row['rfm']["r"][1]; ?>">
                                                    </div><div class="col-sm-4">
                                                        <label class="checkbox-inline">F 最近90天内充值过的次数</label>
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][f][]" value="<?php echo $row['rfm']["f"][0]; ?>">
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][f][]" value="<?php echo $row['rfm']["f"][1]; ?>">
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <label class="checkbox-inline">M 最近90天内累计充值金额</label>
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][m][]" value="<?php echo $row['rfm']["m"][0]; ?>">
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][m][]" value="<?php echo $row['rfm']["m"][1]; ?>">
                                                    </div>
                                                </div>
                                            <?php } ?>

                                            <?php if($row['condition'] == 19){ ?>
                                                <div class="col-sm-6">
                                                    <div class="col-sm-4">
                                                        <label class="checkbox-inline">注册时间区间（天）</label>
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][regPayTime][]" value="<?php echo $row['regPay']["time"][0]; ?>">
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][regPayTime][]" value="<?php echo $row['regPay']["time"][1]; ?>">
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <label class="checkbox-inline">金额区间</label>
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][regPayNum][]" value="<?php echo $row['regPay']["num"][0]; ?>">
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][regPayNum][]" value="<?php echo $row['regPay']["num"][1]; ?>">
                                                    </div>
                                                </div>
                                            <?php } ?>
                                            <?php if($row['condition'] == 20){ ?>
                                                <div class="col-sm-6">
                                                    <div class="col-sm-4">
                                                        <label class="checkbox-inline">时间区间（天）</label>
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" id="timeControl_<?php echo $key;?>_1" name="config[<?php echo $key;?>][tPayTime][]" value="<?php echo date("Y-m-d",$row['timePay']["time"][0]);?>">
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" id="timeControl_<?php echo $key;?>_2" name="config[<?php echo $key;?>][tPayTime][]" value="<?php echo date("Y-m-d",$row['timePay']["time"][1]);?>">
                                                    </div><div class="col-sm-4">
                                                        <label class="checkbox-inline">金额区间</label>
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][tPayNum][]" value="<?php echo $row['timePay']["num"][0];?>">
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][tPayNum][]" value="<?php echo $row['timePay']["num"][1];?>">
                                                    </div>
                                                </div>
                                            <?php } ?>

                                            <?php if($row['condition'] == 21){ ?>
                                                <div class="col-sm-6">
                                                    <div class="col-sm-4">
                                                        <label class="checkbox-inline">计算判断天数（天）</label>
                                                    </div>
                                                    <div class="col-sm-8">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][rLoginNum][]" value="<?php echo $row['loginNum'][0];?>">
                                                    </div>
                                                    <div class="col-sm-4">
                                                        <label class="checkbox-inline">用户登录天数（天）</label>
                                                    </div>
                                                    <div class="col-sm-8">
                                                        <input type="text" class="form-control" name="config[<?php echo $key;?>][rLoginNum][]" value="<?php echo $row['loginNum'][1];?>">
                                                    </div>
                                                </div>
                                            <?php } ?>

                                            <button type="button" class="btn btn-danger deleteParent" >删除</button>
                                        </div>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group" >
                            <div class="row">
                                <div class="col-sm-12">
                                    <label class="col-sm-1 control-label">数据更新方式*: </label>
                                    <div class="col-sm-2">
                                        <label class="radio-inline" >
                                            <input type="radio" name="update" <?php if($info['update'] == 1){ echo 'checked'; } ;?> value="1" title="创建后不会自动更新用户，可手动点击”更新按钮“更新用户"> 手动更新
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="update" <?php if($info['update'] == 2 || !isset($info['update'])){ echo 'checked'; } ;?> value="2"> 自动更新
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer" style="text-align: left">
                            <button type="button" class="btn btn-default" onclick="history.back()">关闭</button>
                            <?php if(isset($id)){ ?>
                                <button type="button" class="btn btn-primary" onclick="updateGroupData(<?php echo $id;?>)">更新数据</button>
                            <?php } ?>
                        </div>
                    </div>
                </section>
            </form>
        </aside>
    </div>






</div>
</body>

<script type="text/javascript">

    <?php foreach ($info['condition'] as $key=>$row){ ?>
        <?php if($row['condition'] == 20){ ?>
            laydate.render({
                elem: '#timeControl_<?php echo $key;?>_1',
                type: 'date',
                format: 'yyyy-MM-dd'
            });
            laydate.render({
                elem: '#timeControl_<?php echo $key;?>_2',
                type: 'date',
                format: 'yyyy-MM-dd'
            });
        <?php } ?>
    <?php } ?>



    var conditionNum = <?php echo count($info['condition']); ?>;
    $('.addOrDelControl').on("click",'.deleteParent',function(){
        conditionNum -=1;
        $(this).parent().remove();
    });

    function add() {
        var str = '<div class="row"><div class="col-sm-2"><select class="form-control" name="config['+conditionNum+'][action]"><option value="0">并且</option><option value="1">或者</option><option value="2">非</option></select></div>';
        str += '<div class="col-sm-2">' +
            '<select class="form-control" onchange="changeSelect('+conditionNum+',true)" id="condition'+conditionNum+'" name="config['+conditionNum+'][condition]">' +
            '<option value="0">平台</option>' +
            '<option value="1">设备</option>' +
            '<option value="2">VIP</option>' +
            '<option value="3">首冲</option>' +
            '<option value="4">VIP积分</option>' +
            '<option value="5">等级</option>' +
            '<option value="6">活跃天数(天)</option>' +
            '<option value="7">累计游戏时长(分)</option>' +
            '<option value="8">注册时长(天)</option>' +
            '<option value="9">好友数量</option>' +
            '<option value="10">好友排行</option>' +
            '<option value="11">国家排行</option>' +
            '<option value="12">世界排行</option>' +
            '<option value="13">国家分组</option>' +
            '<option value="14">Adjust来源分组</option>' +
            '<option value="15">RFM</option>' +
            '<option value="16">渠道</option>' +
            '<option value="17">VIP等级</option>' +
            '<option value="18">充值金额</option>' +
            '<option value="19">注册区间金额</option>' +
            '<option value="20">时间区间金额</option>' +
            '<option value="21">最近登录天数</option>' +
            '</select></div>';
        str += '<button type="button" class="btn btn-danger deleteParent" >删除</button></div>';
        $("#add").append(str);
        changeSelect(conditionNum,false);
        conditionNum += 1;
        $("#condition").show();
    }

    function changeSelect(num,del) {
        var conditionId = $("#condition"+num).val();
        del && $("#condition"+num).parent().next().remove();
        if(conditionId == 0){
            var str = '<div class="col-sm-2"><select class="form-control" name="config['+num+'][platform]"><option value="0">全选</option><option value="1">安卓</option><option value="2">IOS</option></select></div>'
        }else if(conditionId == 1){
            var str = '<div class="col-sm-2"><select class="form-control" name="config['+num+'][userType]"><option value="0" >全选</option><option value="1">FB</option><option value="2">游客</option></select></div>'
        }else if(conditionId == 2){
            var str = '<div class="col-sm-2"><select class="form-control" name="config['+num+'][vip]"><option value="0" >全选</option><option value="1">非VIP</option><option value="2">VIP</option></select></div>'
        }else if(conditionId == 3){
            var str = '<div class="col-sm-2"><select class="form-control" name="config['+num+'][firstPay]"><option value="0" >全选</option><option value="1">非首冲</option><option value="2">首冲</option></select></div>'
        }else if(conditionId == 4){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control typeControl" name="config['+num+'][point]"><option value="0">全选</option><option value="1">区间</option></select></div><div class="col-sm-4"><input type="text" class="form-control" readonly  name="config['+num+'][points][]" value="1"></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][points][]" value="100"></div></div>'
        }else if(conditionId == 5){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control typeControl" name="config['+num+'][levelId]"><option value="0" >全选</option><option value="1">区间</option></select></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][levelIds][]" value="0"></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][levelIds][]" value="0"></div></div>';
        }else if(conditionId == 6){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control typeControl" name="config['+num+'][active]"><option value="0" >全选</option><option value="1">区间</option></select></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][actives][]" value="0"></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][actives][]" value="0"></div> </div>';
        }else if(conditionId == 7){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control typeControl" name="config['+num+'][onlineTime]"><option value="0" >全选</option><option value="1">区间</option></select></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][onlineTimes][]" value="0"></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][onlineTimes][]" value="0"></div> </div>';
        }else if(conditionId == 8){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control typeControl" name="config['+num+'][regTime]"><option value="0" >全选</option><option value="1">区间</option></select></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][regTimes][]" value="0"></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][regTimes][]" value="0"></div> </div>';
        }else if(conditionId == 9){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control typeControl" name="config['+num+'][friendNum]"><option value="0" >全选</option><option value="1">区间</option></select></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][friendNums][]" value="0"></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][friendNums][]" value="0"></div> </div>';
        }else if(conditionId == 10){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control typeControl" name="config['+num+'][friendRank]"><option value="0" >全选</option><option value="1">区间</option></select></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][friendRanks][]" value="0"></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][friendRanks][]" value="0"></div> </div>';
        }else if(conditionId == 11){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control typeControl" name="config['+num+'][countryRank]"><option value="0" >全选</option><option value="1">区间</option></select></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][countryRanks][]" value="0"></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][countryRanks][]" value="0"></div> </div>';
        }else if(conditionId == 12){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control typeControl" name="config['+num+'][worldRank]"><option value="0" >全选</option><option value="1">区间</option></select></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][worldRanks][]" value="0"></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][worldRanks][]" value="0"></div> </div>';
        }else if(conditionId == 13){
            var countryKey = [<?php echo "'".implode(array_keys($country),"','")."'" ?>];
            var country    = [<?php echo "'".implode($country,"','")."'" ?>];
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control countrySet" name="config['+num+'][countrySet]"><option value="0">全选</option><option value="1">限定</option></select></div><div class="col-sm-8" style="display: none"><div class="checkbox">';
            for (var i = 0;i<country.length;i++){
                str += '<label class="checkbox-inline"><input type="checkbox" name="config['+num+'][countrySetArr][]" value="'+countryKey[i]+'">'+country[i]+'</label>'
            }
            str += '</div></div></div>';
        }else if(conditionId == 14){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control adjustGroup" name="config['+num+'][adjustGroup]"><option value="0" >全选</option><option value="1">限定</option></select></div><div class="col-sm-8" style="display: none"><div class="checkbox"><label class="checkbox-inline"><input type="checkbox" name="config['+num+'][adjustGroupArr][]" value="UAC2.0">UAC2.0用户</label><label class="checkbox-inline"><input type="checkbox" name="config['+num+'][adjustGroupArr][]" value="UAC2.5">UAC2.5用户</label><label class="checkbox-inline"><input type="checkbox" name="config['+num+'][adjustGroupArr][]" value="AEO">AEO用户</label><label class="checkbox-inline"><input type="checkbox" name="config['+num+'][adjustGroupArr][]" value="VO">VO用户</label><label class="checkbox-inline"><input type="checkbox" name="config['+num+'][adjustGroupArr][]" value="Recall">Recall用户</label><label class="checkbox-inline"><input type="checkbox" name="config['+num+'][adjustGroupArr][]" value="Not">未归类用户</label></div></div></div>';
        }else if(conditionId == 15){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><label class="checkbox-inline">R 距离上次充值的时间（天）</label></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][r][]" value="1"></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][r][]" value="100"></div><div class="col-sm-4"><label class="checkbox-inline">F 最近90天内充值过的次数</label></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][f][]" value="1"></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][f][]" value="100"></div><div class="col-sm-4"><label class="checkbox-inline">M 最近90天内累计充值金额</label></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][m][]" value="1"></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][m][]" value="100"></div></div>';
        }else if(conditionId == 16){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control channel" name="config['+num+'][channel]"><option value="1" >GooglePlay</option><option value="2">AppStore</option><option value="3">VIVO</option></select></div></div>';
        }else if(conditionId == 17){
            var vipLv    = [<?php echo "'".implode($vipLv,"','")."'" ?>];
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control vipLv" name="config['+num+'][vipLv]"><option value="0">全选</option><option value="1">限定</option></select></div><div class="col-sm-8" style="display: none"><div class="checkbox">';
            for (var i = 0;i<vipLv.length;i++){
                str += '<label class="checkbox-inline"><input type="checkbox" name="config['+num+'][vipLvArr][]" value="'+vipLv[i]+'">LV'+vipLv[i]+'</label>'
            }
            str += '</div></div></div>';
        }else if(conditionId == 18){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><select class="form-control typeControl" name="config['+num+'][payNum]"><option value="0" >全选</option><option value="1">区间</option></select></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][payNums][]" value="0"></div><div class="col-sm-4"><input type="text" class="form-control" readonly name="config['+num+'][payNums][]" value="100"></div> </div>';
        }else if(conditionId == 19){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><label class="checkbox-inline">注册时间区间（天）</label></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][regPayTime][]" value="1"></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][regPayTime][]" value="100"></div><div class="col-sm-4"><label class="checkbox-inline">金额区间</label></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][regPayNum][]" value="1"></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][regPayNum][]" value="100"></div></div>';
        }else if(conditionId == 20){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><label class="checkbox-inline">时间区间（天）</label></div><div class="col-sm-4"><input type="text" class="form-control" id="timeControl_'+num+'_1" name="config['+num+'][tPayTime][]" value="<?php echo date("Y-m-d");?>"></div><div class="col-sm-4"><input type="text" class="form-control" id="timeControl_'+num+'_2" name="config['+num+'][tPayTime][]" value="<?php echo date("Y-m-d");?>"></div><div class="col-sm-4"><label class="checkbox-inline">金额区间</label></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][tPayNum][]" value="1"></div><div class="col-sm-4"><input type="text" class="form-control" name="config['+num+'][tPayNum][]" value="100"></div></div>';
        }else if(conditionId == 21){
            var str = '<div class="col-sm-6"><div class="col-sm-4"><label class="checkbox-inline">计算判断天数（天）</label></div><div class="col-sm-8"><input type="text" class="form-control" name="config['+num+'][rLoginNum][]" value="7"></div><div class="col-sm-4"><label class="checkbox-inline">用户登录天数（天)（>=）</label></div><div class="col-sm-8"><input type="text" class="form-control" name="config['+num+'][rLoginNum][]" value="1"></div></div>';
        }
        $("#condition"+num).parent().after(str);
        if(conditionId == 20){
            laydate.render({
                elem: '#timeControl_'+num+'_1',
                type: 'date',
                format: 'yyyy-MM-dd'
            });
            laydate.render({
                elem: '#timeControl_'+num+'_2',
                type: 'date',
                format: 'yyyy-MM-dd'
            });
        }
    }

    $('#add').on("change",'.typeControl',function(){
        var type = $(this).val();
        if(type == 1){
            $(this).parent().next().children().attr("readonly",false);
            $(this).parent().next().next().children().attr("readonly",false);
        }else{
            $(this).parent().next().children().attr("readonly",true);
            $(this).parent().next().next().children().attr("readonly",true);
        }
    });

    $('#add').on("change",'.countrySet',function(){
        var type = $(this).val();
        if(type == 1){
            $(this).parent().next().show();
        }else{
            $(this).parent().next().hide();
        }
    });

    $('#add').on("change",'.vipLv',function(){
        var type = $(this).val();
        if(type == 1){
            $(this).parent().next().show();
        }else{
            $(this).parent().next().hide();
        }
    });

    $('#add').on("change",'.adjustGroup',function(){
        var type = $(this).val();
        if(type == 1){
            $(this).parent().next().show();
        }else{
            $(this).parent().next().hide();
        }
    });

    $('#submitBtn').click(function () {
        var data = new FormData(document.getElementById("goodForm"));
        $.ajax({
            url: rootPath + 'config/actionUserGroup2',
            type: 'POST',
            data: data,
            dataType: 'json',
            contentType: false, //必须
            processData: false, //必须
            success: function (data) {
                alert(data.msg);
                if(data.ret == 1){
                    return ;
                }
                window.location.href = "/#config/userGroupList/<?php echo $cid;?>";
            },
            error: function (msg) {
                alert(data.msg);
            }
        });
    });
    function updateGroupData(id) {
        if(confirm('确定对当前分组用户进行更新？？')==true){
            $.post('/config/updateUserGroupByUser',{
                id:id
            },function (data) {
                data = JSON.parse(data);
                alert(data.msg);
            });
        }
    }
</script>
</html>
