<link href="<?php echo base_url();?>public/h5/css/bootstrap.min14ed.css" rel="stylesheet">
<link href="<?php echo base_url();?>public/h5/css/font-awesome.min93e3.css" rel="stylesheet">
<link href="<?php echo base_url();?>public/h5/css/animate.min.css" rel="stylesheet">
<link href="<?php echo base_url();?>public/h5/css/style.min862f.css" rel="stylesheet">
<style>
    #alertmod_activity_list {
        top: 900px !important;
        display: none;
    }
    #alertmod_table_list_2 {
        top: 900px !important;
        display: none;
    }
    .my-fcheck {
        position: absolute;
        top: 0%; left: 0%;
        display: block;
        width: 100%;
        height: 100%;
        margin: 0px;
        padding: 0px;
        background: rgb(255, 255, 255);
        border: 0px;
        opacity: 0;
    }
</style>
<div class="row">
    <div class="col-sm-12" id="showDiv">
        <div class="tabs-container">
            <ul class="nav nav-tabs">
                <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true"><?php echo $info['name'];?>配置(<?php echo $id;?>)</a></li>
            </ul>
            <div class="tab-content">
                <div id="tab-1" class="tab-pane active">
                    <div class="panel-body">
                        <div class="ibox float-e-margins">
                            <div class="ibox-content" style="padding:25px 0;" id="reward_info">

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<div class="modal inmodal fade" id="myModal5" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog modal-lg" style="width:1000px">
        <div class="modal-content" style="width: 100%;left: -15%;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" onclick="closePrize()"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">奖励配置</h4>
            </div>
            <div class="modal-body" style="height: 600px;">
                <table class="table table-bordered" id="prize_table">
                    <thead><tr class="ths"><th>阶段</th><th>阶段值</th><th>奖励</th></tr></thead>
                    <tbody id="prize_body">

                    </tbody>
                </table>
            </div>
            <hr><hr>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal" onclick="closePrize()">关闭</button>
                <button type="button" class="btn btn-primary" onclick="scheduleSubmit()">保存</button>
            </div>
        </div>
    </div>
</div>

<script src="<?php echo base_url();?>public/h5/js/jquery.min.js"></script>
<script src="<?php echo base_url();?>public/h5/js/bootstrap.min.js"></script>
<script src="<?php echo base_url();?>public/h5/js/content.min.js"></script>
<script src="<?php echo base_url();?>public/js/laydate/laydate.js"></script>
<script>
    var typeGrout = ["architecture","time_limit_invite","accumulated_pay",'spins_master'];
    var spansTypeGrout =["collect","steal","attack","collect_only","super_collect","rank","easter_egg"];
    var act_type ='';//当前活动类型
    var reward_limit= 0;
    var reward_limit2= 0; //阶段奖励2
    var reward_limit3= 0; //阶段奖励3
    var rank_limit=[];
    var treasure_limit=0;
    var trafficPermit_limit=-1;
    var callbackTask_limit =0;
    var trafficPermitTask_limit =0;
    var trafficPermitTask_limit2=0;
    var bet_limit=0;
    var betSpinsRange_limit=0;
    var reward_type=[];//奖品道具分类
    var reward_type_arr =[];//奖品分类数组
    var reward_conf=[];//收集进度值获取配置
    var reward_pro=[];//收集触发概率配置
    var reward_info=[];//奖励详情
    var reward_info_new =[];
    var extra_reward =[];//额外奖励配置 ，包括排行榜排行奖励配置
    var activity_extra_data =[];//额外奖励配置 ，包括排行榜排行奖励配置
    var actProps =[];
    var rootPath = '<?php echo site_url();?>';
    var aid = '<?php echo intval($id);?>';
    var imgNames=[];//资源类型
    var chain_gift_conf=[];//连环礼包配置
    var chain_gift=[];
    var spinStage=0;//体力限制收集奖励阶段
    var rankSpinStage=0;//体力限制排行排名奖励
    var spin_reward_limit =[];
    var this_index =0; //当前的spin奖励项id
    var golden_card = [];
    var shop_promotion_limit = 0;
    var steel_safelimit_limit = 0;
    var steel_safelimit_tr = 1;
    var premium_limit = 0;
    var goodSku =[];//礼包商品sku列表
    var coins_list =["coins01","coins02","coins03","coins04","coins05","coins06"];
    var actPropArr =[25,26,27,28,31,32,33,34,35,36,39,40,41];//活动道具id
    var actTypeProp =["chain_gift","super_serial_pack","traffic_permit","super_collect","choose_one","fund"];//允许活动道具的活动类型
    var scoreCGType = 1;//超级连环礼包模式
    var scoreCGGidArr  = [];//超级连环礼包模式
    var timeLimit = 0;//当前限时次数
    var timeLimitBet=0;//当前限时bet次数
    var balloon_bet_limit=[];
    var betStage=0;
    var spinsProLimit=0;//体力影响概率系数行次
    var chestArr = JSON.parse('<?php echo json_encode($chestSkin) ?>');
    var chestPropsArr = [19];
    var chooseOne=0;
    $(document).ready(function() {
        imgNames_str ='<?php echo $imgNames;?>';//资源类型
        imgNames = JSON.parse(imgNames_str);

        var reward_type_str ='<?php echo $reward_type;?>';
        reward_type =JSON.parse(reward_type_str);//奖励类型
        $.each(reward_type,function(k,v){
            reward_type_arr[k]=v;
        });
        // console.log("初始化数据：奖品分类数组==",reward_type_arr);

        goodSku_str = '<?php echo $goodSku?>';
        goodSku = JSON.parse(goodSku_str);//礼包类商品sku

        var actProps_str ='<?php echo $actProps;?>';//活动道具
        if(actProps_str.length>0){
            actProps =JSON.parse(actProps_str);
        }
        var reward_conf_str = '<?php echo $info["reward_conf"];?>';
        if(reward_conf_str.length>0){
            reward_conf =JSON.parse(reward_conf_str);
        }
        var reward_pro_str = '<?php echo $info["reward_pro"];?>';
        if(reward_pro_str.length>0){
            reward_pro =JSON.parse(reward_pro_str);
        }

        var reward_info_str = '<?php echo $info["reward_info"];?>';
        if(reward_info_str.length>0&&reward_info_str!='null'){
            reward_info =JSON.parse(reward_info_str);
        }
        var extra_reward_str = '<?php echo $info["extra_reward"];?>';
        if(extra_reward_str.length>0&&extra_reward_str!='null'){
            extra_reward =JSON.parse(extra_reward_str);
        }
        var reward_info_new_str = '<?php echo $info["reward_info_new"];?>';
        if(reward_info_new_str.length>0&&reward_info_new_str!='null'){
            reward_info_new =JSON.parse(reward_info_new_str);
        }

        var activity_extra_data_str = '<?php echo json_encode($info['extraData']);?>';
        if(activity_extra_data_str.length>0&&activity_extra_data_str!='null'){
            activity_extra_data =JSON.parse(activity_extra_data_str);
        }

        //初始化显示
        act_type = '<?php echo $info['type']; ?>';
        if(Object.keys(reward_info).length>0||(["chain_gift","super_collect","super_serial_pack","premium","super_balloon","easter_egg"].includes(act_type)&&Object.keys(extra_reward).length>0) || ["premium","traffic_permit_bet"].includes(act_type)||(reward_conf!=null&&Object.keys(reward_conf).length>0&&["collect_bet","easter_egg","change_collect"].includes(act_type))){
            initReward(act_type);
        }else{
            console.log('没有数据:初始化配置');
            showHtmlByType(act_type);
        }

        //监听选类
        $("#select_type").change(function(){
            reward_info =[];
            extra_reward=[];
            reward_limit =0;
            reward_limit2 =0;
            reward_limit3 =0;
            rank_limit=[];
            bet_limit =0;
            this_index=0;
            spin_reward_limit =[];
            spinStage =0;
            rankSpinStage=0;
            act_type = $(this).val();
            showCidSelect();
            if(act_type=='chain_gift'){
                getChainGiftConf();
            }
            if(act_type=='golden_card_trade'){
                getAllGoldenCardByGroup();
            }
            showHtmlByType(act_type);
        });
        //监听选收集物
        $("#select_cid").change(function(){
            var cid = $(this).val();
            // console.log(act_type);
            if(imgNames[act_type]){
                setImgName(imgNames[act_type][cid]['type']);
            }
        });
        //初始化进度奖励行

    });
    //添加分体力阶段配置监听
    $(document).on('click', '#addSpinStageBtn', function(e) {
        spinStage++;
        var d ={"star":0,"end":0};
        if(act_type=='easter_egg'){
            d.star=spinStage;
        }
        html2 = spinStageRewardTable(spinStage,d);
        $("#spinStageTable").append(html2);
    });
    //删除分体力阶段配置监听
    $(document).on('click', '#delSpinStageBtn', function(e) {
        if(spinStage>1){
            $("#spinStageTable").children(".spinStageRewardTable:last-child").remove();
            spinStage--;
        }
    });
    //添加排行榜奖励table
    $(document).on('click', '#addSpinRankBtn', function(e) {
        rankSpinStage++;
        var d ={"star":0,"end":0};
        html2 = spinRankTable(rankSpinStage,d);
        $("#rank_table").append(html2);
    });
    //删除排行榜奖励table
    $(document).on('click', '#delSpinRankBtn', function(e) {
        if(rankSpinStage>1){
            $("#rank_table").children(".spinRankTable:last-child").remove();
            rankSpinStage--;
        }
    });
    //添加积分分区超级连环礼包
    $(document).on('click', '#addCGTableBtn', function(e) {
        spinStage++;
        if(scoreCGType == 1){
            var d ={"star":0,"end":0};
        }else{
            var d ={"gid":0};
        }
        var html2 = scoreCGRewardTable(scoreCGType,spinStage,d);
        $("#scoreCGTable").append(html2);
    });
    //删除积分分区超级连环礼包
    $(document).on('click', '#delCGTableBtn', function(e) {
        console.log('del-CGtable:',spinStage);
        if(spinStage>1){
            if(scoreCGType == 2){
                $("input[name='scoreStage["+spinStage+"][gid][]']").each(function(){
                    var vaule = $(this).val()
                    scoreCGGidArr = scoreCGGidArr.filter(v=>{
                        return v != vaule;
                    });
                })
            }
            $("#scoreCGTable").children(".scoreCGRewardTable:last-child").remove();
            spinStage--;
        }
    });
    //超级连环礼包监听选择购买类型
    $(document).on('change', '.selMtype', function(e) {
        var mtype = e.currentTarget.value;
        var this_selSku = e.currentTarget.parentElement.nextElementSibling;
        $(this_selSku).empty();

        var index=$(this_selSku).attr('t_index');
        var stage=$(this_selSku).attr('t_stage');
        var data = {"stage":stage,"coin":"coins01","mtype":mtype,"bet":0,"price":"0","sku":"com.unioncity.crazycoin.1.99"};
        var html = selSku(index,data);
        $(this_selSku).append(html);
            // console.log();
    });
    //超级连环礼包监听选择价格
    $(document).on('change','.selPrice',function(e){
        var tds = e.currentTarget.parentElement;
        var price = e.currentTarget.value;
        $.each(goodSku, function (k, v) {
            if (price == v["price"]) {
                sku = v["sku"];
            }
        });
        tds.children[1].value = sku;
    });
    //连环礼包道具选择监听
    $(document).on('change','.selChainProp',function(e){
        var prop = e.currentTarget.value;
        $res = propSelVersion(prop);
        if(!$res){
            e.currentTarget.value =1;
            return false;
        }
    });
    //监听任务选择限制
    $(document).on('change','.seltask',function (e) {
        var tids = [];
        var tid = e.currentTarget.value;
        $('.seltask').each(function(index,val){
            tids.push(val.value);
        });
        if(tids.indexOf(tid)>=0){
            alert('不能存在相同的任务');
            return false;
        }
    });
   //======================请求=====================
    //连环礼包
    function getChainGiftConf(){
        $.ajax({
            url: rootPath + 'activity/chainGiftcCfg',
            type: 'POST',
            data: {},
            dataType:'json',
            async:false,
            success: function (data) {
                chain_gift_conf = data.data;
                console.log(data);
            },
            error: function (data) {
                console.log(data);
            }
        });
    }
    //卡组
    function getAllGoldenCardByGroup() {
        if(golden_card.length != 0){
            return true;
        }
        $.ajax({
            url: rootPath + 'card/getGoldenCard',
            type: 'POST',
            data: {},
            dataType:'json',
            async:false,
            success: function (data) {
                golden_card = data.data;
            },
            error: function (data) {
                console.log(data);
            }
        });
    }

//===========================================
    //初始进度化奖励行
    function initReward(type) {
        var html2,html3,html4,html_a='';
        if(["collect","steal","attack","rank","collect_only","super_collect"].includes(type)){//偷，打，收集，排行 概率及收集底数设置
            if(Object.keys(reward_conf).length>0){
                data = reward_conf;
            }
            if($.inArray(type,["collect","collect_only","super_collect"])!=-1){
                html_a +=addTimeLimit();
                html_a +=addTimeLimitBet();
                html_a +=setProChange();
            }
            html_a +=addStagePro(type,data);
            html_a +=spinStageTable(type);//阶段table外框
            $("#reward_info").append(html_a);
        }
        if(["easter_egg"].includes(type)){//彩蛋阶段
            html_a +=spinStageTable(type);//阶段table外框
            $("#reward_info").append(html_a);
        }
        if(type==='time_limit_invite'){//邀请进度奖励前的设置邀请模式
            data = reward_conf;
            // html_b +=;
            $("#reward_info").append(timelimitInvite(data));
        }

        if(["architecture","time_limit_invite","accumulated_pay","spins_master"].includes(type)){//建筑大师，邀请，累充,体力大师 单套进度奖励（默认设置table头）
            var html =rewardTable(type);
            $("#reward_info").append(html);
        }


        if(Object.prototype.toString.call(reward_info) === '[object Object]'&&Object.keys(reward_info).length>0){
            console.log("==进度==",reward_info);
            if((typeGrout.includes(type))){//建筑大师 -进度奖励
                $.each(reward_info,function(k,v) {
                    var html = rewardTableTR(v);
                    $("#table_body").append(html);
                    reward_limit++;
                });
            }
        }
        if(spansTypeGrout.includes(type)||type==='rank'){//收集，偷，打（体力套）初始化数据
            // $('#spinStageRewardOpt').show();
            if(type==='rank'){
                if(Object.prototype.toString.call(reward_info[1]['list']) === '[object Object]'){
                    var stageReward = reward_info;
                    console.log('--new_rank_stage_reward--');
                }else{//过度兼容
                    var stageReward = {1:{"star":0,"end":1000000,"list":reward_info}};
                    console.log('--old_rank_stage_reward--');
                }

            }else{
                var stageReward = extra_reward;
            }

            if(Object.prototype.toString.call(stageReward) === '[object Object]'&&Object.keys(stageReward).length>0){
                console.log("==阶段体力套==",stageReward);
                $.each(stageReward,function(k,v) {
                    spinStage++;
                    var d ={"star":v['star'],"end":v['end']};
                    html2 = spinStageRewardTable(spinStage,d);
                    $("#spinStageTable").append(html2);
                    $.each(v['list'],function(key,val) {
                        var html = spinStageRwardTR(spinStage,val);
                        $("#table_body_"+spinStage).append(html);
                        if(!spin_reward_limit[spinStage]){
                            spin_reward_limit[spinStage] =1;
                        }else{
                            spin_reward_limit[spinStage]++;
                        }
                    });
                });
                console.log("体力套数：",spinStage);
            }
        }

        switch(type){
            case 'rank'://排行榜-额外
                html2 = rankTable();
                $("#reward_info").append(html2);
                if(Object.prototype.toString.call(extra_reward[1]['list']) === '[object Object]'){
                    var rankReward = extra_reward;
                    console.log('--new_rank_reward--');
                }else{//过度兼容
                    var rankReward = {1:{"star":0,"end":1000000,"list":extra_reward}};
                    console.log('--old_rank_reward--');
                }
                if(Object.prototype.toString.call(rankReward) === '[object Object]'&&Object.keys(rankReward).length>0){
                    console.log("==排名体力套==",rankReward);
                    $.each(rankReward,function(k,v) {
                        rankSpinStage++;
                        var d ={"star":v['star'],"end":v['end']};
                        html2 = spinRankTable(rankSpinStage,d);
                        $("#rank_table").append(html2);
                        $.each(v['list'],function(key,val) {
                            var html = rankTableTR(rankSpinStage,val);
                            $("#table_body2_"+rankSpinStage).append(html);
                            if(!rank_limit[rankSpinStage]){
                                rank_limit[rankSpinStage] =1;
                            }else{
                                rank_limit[rankSpinStage]++;
                            }
                        });
                    });
                    console.log("排名体力套数：",rankSpinStage);
                }
                $("#stage_pro").append(rankVipSet());
                $("#reward_info").append(rankRobot() + rankLimit());
                break;
            case 'collect':
                break;
            case 'speed_spins'://体力加速
                // html3= speedSpinsLine(reward_info);
                commonLineTitles = [{"tname":"加速倍率","vname":"bet"}];
                html3 = commonInput(reward_conf);
                $("#reward_info").append(html3);

                break;
            case 'crazy_bet'://超级倍率
                if(Object.prototype.toString.call(reward_info) === '[object Object]'&&Object.keys(reward_info).length>0){
                    html2 = crazyBetInput(reward_info);
                    $("#reward_info").append(html2);
                    html3 = crazyBetSpinsRange();
                    $("#reward_info").append(html3);

                    console.log("==bet==",reward_info);
                    if(reward_info['conf']){
                        $.each(reward_info['conf'],function(k,v) {
                            var html3 = crazyBetLine(v);
                            $("#addCrazyBetLine").before(html3);
                            bet_limit++;
                        });
                    }
                    if(reward_info['init']['spinsRange']){
                        $.each(reward_info['init']['spinsRange'],function(k,v) {
                            var html3 = crazyBetSpinsRangeLine(v);
                            $("#addCrazyBetSpinsRange").before(html3);
                            betSpinsRange_limit++;
                        });
                    }
                }
                break;
            case 'chain_gift'://连环礼包
                getChainGiftConf();//拉取基础模板数据chain_gift_conf
                if(Object.prototype.toString.call(extra_reward) === '[object Object]'&&Object.keys(extra_reward).length>0) {
                    $.each(extra_reward,function(key,val) {
                        this_index++;
                        var html3 ='';
                        var initData = {"score_star":val['score_star'],"score_end":val['score_end']};
                        html2 = chainGiftTable(this_index,initData);
                        $("#reward_info").append(html2);
                        $.each(val['giftList'],function (ke,va) {
                            html3 += chainGift(va,this_index);
                        });
                        $("#chainInfo_"+this_index).append(html3);
                    });
                    html4 = chainOptBtn();
                    $("#reward_info").append(html4);
                }
                break;
            case 'crazy_card_group'://疯狂卡组
                html2=crazyCardRewardTable();
                $("#reward_info").append(html2);
                if(Object.prototype.toString.call(reward_info) === '[object Object]'&&Object.keys(reward_info).length>0) {
                    $.each(reward_info,function(key,val) {
                        var html3 = crazyCardTR(val);
                        $("#table_body").append(html3);
                        reward_limit++;
                    });
                }
            break;
            case 'architecture'://建筑大师

            break;
            case 'time_limit_invite'://限时邀请

                break;
            case 'golden_card_trade'://金卡交换
                $("#reward_info").append(goldenCardTradeHtml([]));
            break;
        	case 'shop_promotion'://商城促销
				console.log("商城促销 - initReward");
                $("#reward_info").append(shop_promotion_html());
                for(var i = 0; i < reward_info.init.length; i++){
                	addShopPromotionConf(reward_info.init[i]);
                }
            break;
            case 'accumulated_pay'://累充

            break;
            case 'treasure'://宝藏
                commonLineTitles =[{"tname":"bouns消耗/倍率","vname":"pro"},{"tname":"修正值","vname":"fix"}];
                $("#reward_info").append(getTreasureSettingHtml());
                $("#reward_info").append(commonTable('金币老虎机bouns修正'))
                if(Object.prototype.toString.call(extra_reward.fixCo) === '[object Object]'&&Object.keys(extra_reward.fixCo).length>0) {
                    $.each(extra_reward.fixCo,function(key,val) {
                        commonLineNum++;
                        $("#commonLine").append(commonLine(val));
                    });
                }
                $("#reward_info").append(getTreasureHtml());
                if(Object.prototype.toString.call(reward_info) === '[object Array]'&&Object.keys(reward_info).length>0) {
                    $.each(reward_info,function(key,val) {
                        var html3 = treasureTableTR(val);
                        $("#table_body3").append(html3);
                        treasure_limit++;
                    });
                }
            break;
            case 'traffic_permit'://通信证
                $("#reward_info").append(getTrafficPermitSettingHtml());
                $("#reward_info").append(getTrafficPermitHtml());
                $("#table_body4").append(trafficPermitExtraTR({"prize":activity_extra_data.maxReward.prize,"specialPrize":activity_extra_data.maxReward.specialPrize}));
                if(Object.prototype.toString.call(reward_info) === '[object Array]'&&Object.keys(reward_info).length>0) {
                    $.each(reward_info,function(key,val) {
                        $("#table_body4").append(trafficPermitTR(val));
                        trafficPermit_limit++;
                    });
                }
                $("#reward_info").append(getTrafficPermitTaskHtml(1));
                if(Object.prototype.toString.call(extra_reward) === '[object Array]'&&Object.keys(extra_reward).length>0) {
                    $.each(extra_reward,function(key,val) {
                        $("#table_body_TrafficPermitTask_1").append(trafficPermitTaskTR(val,1));
                        trafficPermitTask_limit++;
                    });
                }
                $("#reward_info").append(getTrafficPermitTaskHtml(2));
                if(Object.prototype.toString.call(activity_extra_data.task) === '[object Array]'&&Object.keys(activity_extra_data.task).length>0) {
                    $.each(activity_extra_data.task,function(key,val) {
                        $("#table_body_TrafficPermitTask_2").append(trafficPermitTaskTR(val,2));
                        trafficPermitTask_limit2++;
                    });
                }
            break;
            case 'discounts_architecture'://建筑打折
                html2= disArchConf(reward_info);
                $("#reward_info").append(html2);
            break;
            case 'spin_safe'://保险柜
                $("#reward_info").append(getSteelSafeNHtml(extra_reward.n));
                $("#reward_info").append(getSteelSafeHtml());
                $("#reward_info").append(getSteelSafeLimitHtml());
                $("#reward_info").append(getSteelSafeLimitRewardHtml());
                if(Object.prototype.toString.call(extra_reward) === '[object Object]'&&Object.keys(extra_reward).length>0){
                    $.each(extra_reward.config,function(key,val) {
                        getSteelSafeTr(val)
                    });
                    $.each(extra_reward.limit,function(key,val) {
                        getSteelSafeLimitTr(val)
                    });
                }
                if(Object.prototype.toString.call(reward_info) === '[object Array]'&&Object.keys(reward_info).length>0) {
                    $.each(reward_info,function(key,val) {
                        $("#table_SteelSafeLimitReward").append(getSteelSafeLimitRewardTr(val));
                        steel_safelimit_limit++;
                    });
                }
            break;
            case 'super_serial_pack'://新连环礼包
                scoreCGType = reward_info['scoreCGType'];
                var html    = scoreCGTable(scoreCGType);//体力分套table外框
                $("#reward_info").append(html);
                if(Object.prototype.toString.call(extra_reward) === '[object Object]'&&Object.keys(extra_reward).length>0){
                    console.log("==阶段积分套==",extra_reward);
                    $.each(extra_reward,function(k,v) {
                        spinStage++;
                        if(scoreCGType == 1){
                            var d ={"star":v['star'],"end":v['end']};
                        }else{
                            var d ={"gid":v['gid']};
                        }
                        html2 = scoreCGRewardTable(scoreCGType,spinStage,d);
                        $("#scoreCGTable").append(html2);
                        $.each(v['list'],function(key,val) {
                            var html = scoreCGRwardTR(spinStage,val);
                            $("#table_body_"+spinStage).append(html);
                            if(!spin_reward_limit[spinStage]){
                                spin_reward_limit[spinStage] =1;
                            }else{
                                spin_reward_limit[spinStage]++;
                            }
                        });
                    });
                }
            break;
            case "coin_blast"://金币大爆炸
                $("#reward_info").append(getCoinCfgHtml(reward_info));
                break;
            case "premium"://
                $("#reward_info").append(getPremiumHtml(reward_conf.spins));
                if(Object.prototype.toString.call(reward_conf.groupArr) === '[object Array]'&&Object.keys(reward_conf.groupArr).length>0) {
                    $.each(reward_conf.groupArr,function(key,val) {
                        $("#table_body_premium").append(premiumTR(val));
                        premium_limit++;
                    });
                }
                break;
            case "super_balloon"://超级气球
                var html2 ='';
                html2 += setBalloonStyleHtml(activity_extra_data);
                html2 += balloonTable();
                $("#reward_info").append(html2);
                if(Object.prototype.toString.call(extra_reward) === '[object Object]'&&Object.keys(extra_reward).length>0) {
                    console.log("==阶段Bet套==",extra_reward);
                    $.each(extra_reward,function(k,v) {
                        betStage++;
                        var d ={"star":v['star'],"end":v['end']};
                        $("#balloon_table").append(balloonBetTable(betStage,d));
                        $.each(v['list'],function(key,val) {
                            var html = balloonTableTRHtml(betStage,val);
                            $("#table_body3_"+betStage).append(html);
                            if(!balloon_bet_limit[betStage]){
                                balloon_bet_limit[betStage] =1;
                            }else{
                                balloon_bet_limit[betStage]++;
                            }
                        });
                    });
                }
                break;
            case "traffic_permit_bet":
                $("#reward_info").append(getTrafficPermitBetHtml(activity_extra_data.bet));
                break;
            case "choose_one":
                $("#reward_info").append(ChooseOne(1));
                if(Object.prototype.toString.call(reward_info) === '[object Object]'&&Object.keys(reward_info).length>0) {
                    $.each(reward_info,function(key,val) {
                        chooseOne++
                        $("#table_body_ChooseOne").append(ChooseOneTR(val))
                    });
                }
                break;
            case "fund":
                $("#reward_info").append(Fund());
                if(Object.prototype.toString.call(reward_info) === '[object Array]'&&Object.keys(reward_info).length>0) {
                    FundPriceGroupHtml(reward_conf);
                    FundHtml(reward_info);
                }
                break;
            case "collect_bet":
                commonLineTitles = [{"tname":"倍率","vname":"bet"}];
                html3 = commonInput(reward_conf);
                $("#reward_info").append(html3);
                break;
            case "easter_egg"://四选一
                commonLineTitles =[{"tname":"复活次数","vname":"limit"},{"tname":"复活金币倍数","vname":"bet"},{"tname":"关卡修正系数","vname":"ce"}];
                html3 = commonTable('复活配置');
                $("#reward_info").prepend(html3);
                if(Object.prototype.toString.call(reward_conf) === '[object Object]'&&Object.keys(reward_conf).length>0) {
                    $.each(reward_conf,function(key,val) {
                        commonLineNum++;
                        $("#commonLine").append(commonLine(val));
                    });
                }
                //复活礼包
                html4 = easterGiftTable(activity_extra_data);
                $("#reward_info").prepend(html4);
                break;
            case "callback_score": //好友召回
                html3 = commIboxTable('被召回对象<span style="color: #ff0000;">注：召回对象最少有一组必填不能为空</span>');
                $("#reward_info").prepend(html3); //赛选条件
                $("#reward_info").append(callbackCondTb()); //召回对象,赛选条件
                if(Object.prototype.toString.call(activity_extra_data) === '[object Object]'&&Object.keys(activity_extra_data).length>0){
                    $.each(activity_extra_data,function(k,v) {
                        var html = friendCallbackCond(v, k);
                        $('#callback_cond_body').append(html);
                        var sign = v['sign']==undefined?{}:v['sign'];
                        if(Object.prototype.toString.call(sign) === '[object Object]'&&Object.keys(sign).length>0){
                            $.each(sign,function(kk,v) {
                                callbackSignTR(v, k);
                            });
                        };
                    });
                }
                html3= rewardTable2('回归后回归奖励:(绑定uid后得到的奖励)<span style="color: #ff0000;">注：回归奖励必填不能为空</span>', 3, 15);
                $("#reward_info").append(html3);
                if(Object.prototype.toString.call(reward_pro) === '[object Object]'&&Object.keys(reward_pro).length>0){
                    console.log("==进度==",reward_pro);
                    $.each(reward_pro,function(k,v) {
                        var html = rewardTableTR2(v, 15, 3);
                        $("#table_body3").append(html);
                        reward_limit3++;
                    });
                }
                //任务配置,有数据
                html3 = friendCallbackTaskTb('活动任务配置');
                $("#reward_info").append(html3);
                if(Object.prototype.toString.call(reward_conf) === '[object Object]'&&Object.keys(reward_conf).length>0){
                    $.each(reward_conf,function(k,v) {
                        callbackTask_limit++;
                        var html = callbackTaskTR(v);
                        $("#callback_task").append(html);
                    });
                }

                //回进度奖励,有数据
                var html =rewardTable(type);
                $("#reward_info").append(html);
                if(reward_info['callback']!=undefined&&Object.prototype.toString.call(reward_info['callback']) === '[object Object]'&&Object.keys(reward_info['callback']).length>0){
                    $.each(reward_info['callback'],function(k,v) {
                        var html = callbackRewardTableTR(v);
                        $("#table_body").append(html);
                        reward_limit++;
                    });
                }
                //召回进度奖励,有数据
                var html = rewardTable2('被召回进度奖励<span style="color: #ff0000;">注：最多只能配置10个进度奖励</span>', 2, 15);
                $("#reward_info").append(html);
                if(reward_info['becallback']!=undefined&&Object.prototype.toString.call(reward_info['becallback']) === '[object Object]'&&Object.keys(reward_info['becallback']).length>0){
                    console.log("==进度==",reward_info);
                    $.each(reward_info['becallback'],function(k,v) {
                        var html = rewardTableTR2(v, 15, 2);
                        $("#table_body2").append(html);
                        reward_limit2++;
                    });
                }
                html3 = callBackCfg(extra_reward);
                $("#reward_info").prepend(html3);
                break;
            case "daily_chest":
                var html3 = dailyChest(reward_conf);
                $("#reward_info").append(html3);
                break;
            case "change_collect"://小玩法收集
                var html3 = collectChangeSel(reward_conf);
                $("#reward_info").append(html3);
                commonLineTitles =[{"tname":"收集物1奖励数","vname":"one_hit"},{"tname":"收集物2奖励数","vname":"tow_hit"},{"tname":"收集物3奖励数","vname":"three_hit"}];
                $("#reward_info").append(commonInput(reward_conf));
                break;
            default:
        }

    }

    function showCidSelect(){
        $("#select_cid").empty();
        $("#imgName").val('');
        var html = cidSelectOp();
        $("#select_cid").append(html);
        $("#select_cid").val(1)
    }
    //设置资源名，显示资源图（展不实现）
    function setImgName(str) {
        $("#imgName").val(str);
    }
    //无数据状态初始化样式及数据
    function showHtmlByType(type) {
        var html='';
        var cid = $("#select_cid").val();
        if(!$("#imgName").val()&&imgNames[act_type]){
            setImgName(imgNames[act_type][cid]['type']);
        }
        $("#reward_info").empty();
        if(["collect","steal","attack","rank","collect_only","super_collect"].includes(type)) {//偷，打，收集，排行 概率及收集底数（默认设置）
            data = {"attack_success":0,"attack_break":0,"three_hit":0,"steal_success":0,"steal_break":0,"tow_hit":0,"one_hit":0};
            if($.inArray(type,["collect","collect_only","super_collect"])!=-1) {
                html += addTimeLimit();
                html +=addTimeLimitBet();
                html +=setProChange();
            }
            html +=addStagePro(type,data);
            html +=spinStageTable(type);//阶段table外框
        }
        if(type=="easter_egg"){//四选一
            html +=spinStageTable(type);//阶段table外框
        }
        if(["architecture","time_limit_invite","accumulated_pay","spins_master"].includes(type)){//建筑大师，邀请，累充,体力大师 单套进度奖励（默认设置）

            html +=rewardTable(type);
        }
        $("#reward_info").append(html);

        if(spansTypeGrout.includes(type)){//收集，偷，打（体力套）,排行榜,四选一（默认配置）
            spinStage =1;
            var d ={"star":0,"end":0};
            if(type=='easter_egg'){
                d.star=1;
            }
            html = spinStageRewardTable(spinStage,d);//阶段奖励内部table
            $("#spinStageTable").append(html);
        }
        switch(type){
            case 'collect':
                break;
            case 'rank'://排行榜-额外
                var html2='';
                // html2 = rankTable();
                // $("#reward_info").append(html2);
                html2 = rankTable();
                $("#reward_info").append(html2);
                rankSpinStage=1;
                html2 = spinRankTable(rankSpinStage,d);
                $("#rank_table").append(html2);
                $("#stage_pro").append(rankVipSet());
                $("#reward_info").append(rankRobot() + rankLimit());
                break;
            case 'speed_spins'://体力加速
                commonLineTitles = [{"tname":"加速倍率","vname":"bet"}];
                html2 = commonInput({"bet":2});
                $("#reward_info").append(html2);
                break;
            case 'crazy_bet'://超级倍率
                reward_info ={"init":{"actSpinsLimit":150}};
                html2 = crazyBetInput(reward_info);
                $("#reward_info").append(html2);
                html3 = crazyBetSpinsRange();
                $("#reward_info").append(html3);
                break;
            case 'chain_gift'://连环礼包
                this_index = 1;
                var html2= html3= html4='';
                var initData = {"score_star":0,"score_end":0,};
                html2 = chainGiftTable(this_index,initData);
                $("#reward_info").append(html2);
                for(var i=0;i<chain_gift_conf.length;i++){
                    html3 +=chainGift(chain_gift_conf[i],this_index);
                }
                $("#chainInfo_"+this_index).append(html3);
                html4 = chainOptBtn();
                $("#reward_info").append(html4);
                break;
            case 'crazy_card_group':
                html2=crazyCardRewardTable();
                $("#reward_info").append(html2);
                break;
            case 'architecture'://建筑大师
                break;
            case 'golden_card_trade'://金卡交换
                $("#reward_info").append(goldenCardTradeHtml([]));
                break;
            case 'time_limit_invite'://限时邀请
                data = {"type":3,"ext_num":2};
                html +=timelimitInvite(data);
                $("#reward_info").prepend(html);
                break;
            case 'shop_promotion'://商城促销
                $("#reward_info").append(shop_promotion_html());
                break;
            case 'accumulated_pay'://累充
                break;
            case 'treasure'://宝藏活动
                $("#reward_info").append(getTreasureSettingHtml());
                $("#reward_info").append(getTreasureHtml());
                break;
            case 'traffic_permit'://通信证
                $("#reward_info").append(getTrafficPermitSettingHtml());
                $("#reward_info").append(getTrafficPermitHtml());
                $("#table_body4").append(trafficPermitExtraTR({}));
                $("#reward_info").append(getTrafficPermitTaskHtml(1));
                $("#reward_info").append(getTrafficPermitTaskHtml(2));
                break;
            case 'discounts_architecture'://建筑打折
                var conf = [{"level":1,"disNum":20},{"level":2,"disNum":20},{"level":3,"disNum":20},{"level":4,"disNum":20},{"level":5,"disNum":20}];
                html2= disArchConf(conf);
                $("#reward_info").append(html2);
                break;
            case 'super_serial_pack'://新版连环礼包
                html +=scoreCGTable(scoreCGType);//体力分套table外框
                $("#reward_info").append(html);
                if(scoreCGType == 1){
                    var d ={"star":0,"end":0};
                }else{
                    var d ={"gid":0};
                }
                html = scoreCGRewardTable(scoreCGType,++spinStage,d);//阶段奖励内部table
                $("#scoreCGTable").append(html);
            break;
            case "spin_safe":
                $("#reward_info").append(getSteelSafeNHtml(2));
                $("#reward_info").append(getSteelSafeHtml());
                var conf = [{"progress":1,"coins":"coins01","bet":1,"n":1},{"progress":2,"coins":"coins01","bet":1,"n":1},{"progress":3,"coins":"coins01","bet":1,"n":1}];
                conf.forEach(function (data,index) {
                    getSteelSafeTr(data);
                });
                $("#reward_info").append(getSteelSafeLimitHtml());
                $("#reward_info").append(getSteelSafeLimitRewardHtml());
                break;
            case "coin_blast"://金币大爆炸
                var d = [{"type":"steal","bet":0},{"type":"attack","bet":0},{"type":"slot","bet":0}];
                $("#reward_info").append(getCoinCfgHtml(d));
                break;
            case "premium"://premium
                $("#reward_info").append(getPremiumHtml(50));
                break;
            case "super_balloon":
                var html2 ='';
                var d  = {"moveType":1,"speed":1,"outPut":{1:600,2:30,3:10},"showPv":50};
                html2 += setBalloonStyleHtml(d);
                html2 += balloonTable();
                $("#reward_info").append(html2);
                betStage =1;
                var d2 ={"star":1,"end":20};
                $("#balloon_table").append(balloonBetTable(betStage,d2));
                break;
            case "traffic_permit_bet":
                $("#reward_info").append(getTrafficPermitBetHtml(2));
                break;
            case "choose_one":
                $("#reward_info").append(ChooseOne(1));
                addChooseOneBtn(1)
                addChooseOneBtn(2)
                break;
            case "fund":
                $("#reward_info").append(Fund());
                FundPriceGroupHtml(reward_conf);
                FundHtml([{"id":1},{"id":2},{"id":3},{"id":4},{"id":5},{"id":6},{"id":7},{"id":8},{"id":9},{"id":10},{"id":11},{"id":12},{"id":13},{"id":14}]);
                break;
            case "collect_bet":
                commonLineTitles = [{"tname":"倍率","vname":"bet"}];
                $("#reward_info").append(commonInput({"bet":2}));
                break;
            case "easter_egg":
                commonLineTitles =[{"tname":"复活次数","vname":"limit"},{"tname":"复活金币倍数","vname":"bet"},{"tname":"关卡修正系数","vname":"ce"}];
                html2 = commonTable('复活配置');
                $("#reward_info").prepend(html2);
                var d = [{"stage":1,"bet":1,"prize":1.9,"sku":"com.unioncity.crazycoin.1.99"}];
                html3 = easterGiftTable(d);
                $("#reward_info").prepend(html3);
                break;
            case "callback_score": //好友召回
                //commonLineTitles =[{"tname":"召回等级区间","vname":"level"},{"tname":"未登录时间","vname":"ts"},{"tname":"RFM分组","vname":"gid"}];
                html3 = commIboxTable('被召回对象<span style="color: #ff0000;">注：召回对象最少有一组必填不能为空</span>');
                $("#reward_info").prepend(html3);
                $("#reward_info").append(callbackCondTb()); //召回对象,赛选条件
                html3= rewardTable2('回归后回归奖励:(绑定uid后得到的奖励)<span style="color: #ff0000;">注：回归奖励必填不能为空</span>', 3, 15);
                $("#reward_info").append(html3);
                if(Object.prototype.toString.call(reward_info) === '[object Object]'&&Object.keys(reward_info).length>0){
                    console.log("==进度==",reward_info);
                    $.each(reward_info,function(k,v) {
                        var html = rewardTableTR2(v, 15, 3);
                        $("#table_body3").append(html);
                        reward_limit3++;
                    });
                }
                //任务配置
		        html3 = friendCallbackTaskTb('活动任务配置');
                $("#reward_info").append(html3);
                //回归进度奖励
                var html = rewardTable(type);
                $("#reward_info").append(html);
                if(Object.prototype.toString.call(reward_info) === '[object Object]'&&Object.keys(reward_info).length>0){
                    console.log("==进度==",reward_info);
                    if((typeGrout.includes(type))){
                        $.each(reward_info,function(k,v) {
                            var html = callbackRewardTableTR(v);
                            $("#table_body").append(html);
                            reward_limit++;
                        });
                    }
                }
                //召回进度奖励
                var html =rewardTable2('被召回进度奖励<span style="color: #ff0000;">注：最多只能配10个进度奖励</span>', 2, 15);
                $("#reward_info").append(html);
                if(Object.prototype.toString.call(reward_info) === '[object Object]'&&Object.keys(reward_info).length>0){
                    console.log("==进度==",reward_info);
                    if((typeGrout.includes(type))){
                        $.each(reward_info,function(k,v) {
                            var html = rewardTableTR2(v, 15, 2);
                            $("#table_body2").append(html);
                            reward_limit2++;
                        });
                    }
                }

                html3 = callBackCfg({"score":5,"days":3});
                $("#reward_info").prepend(html3);
                break;
            case "daily_chest":
                var html3 = dailyChest(reward_conf);
                $("#reward_info").append(html3);
                break;
            case "change_collect":
                var html3 = collectChangeSel({"item":1});
                $("#reward_info").append(html3);
                commonLineTitles =[{"tname":"收集物1奖励数","vname":"one_hit"},{"tname":"收集物2奖励数","vname":"tow_hit"},{"tname":"收集物3奖励数","vname":"three_hit"}];
                $("#reward_info").append(commonInput({"one_hit":1,"tow_hit":2,"three_hit":3}));
                break;
            default:
        }
    }
//==================公共方法===================
//============================================
    //添加进度奖行
    function addRewardNum() {
        reward_limit++;
        if(act_type=='crazy_card_group'){//疯狂卡组奖励行
            var data ={"stage":reward_limit,"slv":10,"elv":20,"num":50};
            var html = crazyCardTR(data);
        }else{
            if(act_type=='callback_score'&&reward_limit>10){
                alert('不能超过10行');
                return ;
            }
            var data ={"stage":reward_limit,"stepnum":0,"progressBarId":0,"lv":1};
            var html = rewardTableTR(data);
        }
        $("#table_body").append(html);
    }
    //删除进度奖励行
    function delRewardNum() {
        if(reward_limit>0){
            // console.log(reward_limit);
            $("#table_body").children("tr:last-child").remove();
            reward_limit--;
        }
    }
    //第二个阶段奖励
    function addRewardNum2(index, t) {
        if(index == 2){
            reward_limit2++;
            if(reward_limit2>10){
                alert('不能超过10行');
                return ;
            }
            var data ={"stage":reward_limit2,"stepnum":0,"progressBarId":0,"lv":1};
        }else if(index == 3){
            reward_limit3++;
            if(reward_limit3>1){
                alert('不能超过1行');
                return ;
            }
            var data ={"stage":reward_limit3,"stepnum":0,"progressBarId":0,"lv":1};
        }
        var html = rewardTableTR2(data, t, index);
        $("#table_body"+index).append(html);
    }
    //删除进度奖励行
    function delRewardNum2(index) {
        if(index == 2 && reward_limit2>0){
            // console.log(reward_limit2);
            $("#table_body2").children("tr:last-child").remove();
            reward_limit2--;
        } else if(index == 3 && reward_limit3>0){
            $("#table_body3").children("tr:last-child").remove();
            reward_limit3--;
        }
    }

    function addSpinRewardNum(index) {
        if(!spin_reward_limit[index]){
            spin_reward_limit[index] =1;
        }else{
            spin_reward_limit[index]++;
        }
        var data ={"stage":spin_reward_limit[index],"stepnum":0,"progressBarId":0,"lv":1};
        var html = spinStageRwardTR(index,data);
        // console.log(html);

        $("#table_body_"+index).append(html);
    }
    function delSpinRewardNum(index) {
        if(spin_reward_limit[index]>0){
            // console.log(reward_limit);
            $("#table_body_"+index).children("tr:last-child").remove();
            spin_reward_limit[index]--;
        }
    }
    //道具版本支持判别
    function propSelVersion(pid){
        var isok = true;
        var pname =reward_type_arr[pid]['name'];
        if($.inArray(parseInt(pid),[25,26])!= -1){//建筑,大师气球
            $('input[name="act_version[]"]:checked').each(function(){
                var selVersion = $(this).val();
                if(toNum(selVersion)<toNum('1.7.5.0')){
                    alert(pname+'仅支持1.7.5.0及之后版本');
                    isok =false;
                    return false;
                }
            });
            if($('input[name="act_version[]"]:checked').length==0){
                var ret =window.confirm('当前没有选择任何版本,默认所有版本,但活动道具只支持1.7.5.0及之后的版本,可能出现老版本无法展示道具('+pname+'),确认如此操作么!!!');
                if(!ret){
                    return false;
                }
            }
        }
        if($.inArray(parseInt(pid),[28,31,32,33,34])!= -1){//金币爆炸,疯狂加倍,建筑打折,卡片活动,商场优惠
            $('input[name="act_version[]"]:checked').each(function(){
                var selVersion = $(this).val();
                if(toNum(selVersion)<toNum('1.7.7.0')){
                    alert('('+pname+')仅支持1.7.7.0及之后版本');
                    isok =false;
                    return false;
                }
            });
            if($('input[name="act_version[]"]:checked').length==0){
                var ret =window.confirm('当前没有选择任何版本,默认所有版本,但此活动道具只支持1.7.7.0及之后的版本,可能出现老版本无法展示此道具('+pname+'),确认如此操作么!!!');
                if(!ret){
                    return false;
                }
            }
        }
        if($.inArray(parseInt(pid),actPropArr)!= -1&&$.inArray(act_type,actTypeProp) == -1){
            alert('('+pname+')仅支持(收集活动限时,特殊收集限时,通行证,连环礼包,超级连环礼包,二选一活动)');
            return false;
        }
        // console.log("=========>"+actProps[pid]+"<=========");
        if(actProps[pid]!=null||actProps[pid]!=undefined){
            $('input[name="act_version[]"]:checked').each(function(){
                var selVersion = $(this).val();
                if(toNum(selVersion)<toNum(actProps[pid])){
                    alert('('+pname+')仅支持'+actProps[pid]+'及之后版本');
                    isok =false;
                    return false;
                }
            });
            if($('input[name="act_version[]"]:checked').length==0){
                var ret =window.confirm('当前没有选择任何版本,默认所有版本,但此活动道具只支持('+actProps[pid]+')及之后的版本,可能出现老版本无法展示此道具('+pname+'),确认如此操作么!!!');
                if(!ret){
                    return false;
                }
            }
        }

        if(!isok){
            return false;
        }
        return true;
    }
    //===============新连环礼包====================

    function addCGScoreRewardNum(index) {
        if(!spin_reward_limit[index]){
            spin_reward_limit[index] =1;
        }else{
            spin_reward_limit[index]++;
        }
        console.log('分组：阶段-',index,spin_reward_limit[index]);

        var data ={"stage":spin_reward_limit[index],"name":"连环礼包"+spin_reward_limit[index],"mtype":1,"sku":0,"price":0,"coin":"coin01","bet":0,'gMax':1};
        var html = scoreCGRwardTR(index,data);
        // console.log(html);

        $("#table_body_"+index).append(html);
    }
    function delCGScoreRewardNum(index) {
        if(spin_reward_limit[index]>0){
            // console.log(reward_limit);
            $("#table_body_"+index).children("tr:last-child").remove();
            spin_reward_limit[index]--;
        }
    }
    //===================================
    //添加排行奖励行
    function addRankNum(index){
        if(!rank_limit[index]){
            rank_limit[index] =1;
        }else{
            rank_limit[index]++;
        }
        console.log('排名分组：阶段-',index,rank_limit[index]);
        var data ={"stage":rank_limit[index],"rankNum":0};
        var html = rankTableTR(index,data);
        $("#table_body2_"+index).append(html);
    }
    //删除排行奖励行
    function delRankNum(index){
        if(rank_limit[index]>0){
            $("#table_body2_"+index).children("tr:last-child").remove();
            rank_limit[index]--;
        }
    }
    //添加bet行
    function addBetConf() {
        bet_limit++;
        var data = {"id":bet_limit,"bet":1,"levelId":1,"spins":0};
        var html =  crazyBetLine(data);
        $("#addCrazyBetLine").before(html);
    }
    //添加bet spins range行
    function addBetSpinsRangeConf() {
        betSpinsRange_limit++;
        var data = {"id":betSpinsRange_limit,"bet":1,"spins":1};
        var html =  crazyBetSpinsRangeLine(data);
        $("#addCrazyBetSpinsRange").before(html);
    }
    //删除bet行
    function delBetConf() {
        if(bet_limit){
            $("#bet_line").children(".row")[bet_limit-1].remove();
            bet_limit--;
        }
    }
    //删除bet行
    function delBetSpinsRangeConf() {
        if(betSpinsRange_limit){
            $("#betSpinsRange_line").children(".row")[betSpinsRange_limit-1].remove();
            betSpinsRange_limit--;
        }
    }

    function addChainStage() {
        this_index++;console.log("新增连环礼包配置行："+this_index);
        var html2=html3='';
        var initData = {"score_star":0,"score_end":0,};
        html2 = chainGiftTable(this_index,initData);
        $("#chainOptBtn").before(html2);
        for(var i=0;i<chain_gift_conf.length;i++){
            html3 +=chainGift(chain_gift_conf[i],this_index);
        }
        console.log(chain_gift_conf);
        $("#chainInfo_"+this_index).append(html3);
    }
    function delChainStage() {
        if(this_index>1){
            $("#reward_info").find("#chainTable_"+this_index).remove();
            this_index--;
        }
    }
    //添加连环礼包奖励行
    function addprops(gid,index) {
        var prop = {"pronId":14,"num":1};
        var pid=$("#props_"+index+'_'+gid).children().length;
        var html = chainGiftProps(prop,pid,gid,index);
        $("#props_"+index+'_'+gid).append(html);
    }
    //删除连环礼包奖励行
    function delprops(gid,index) {
        $("#props_"+index+'_'+gid).children(".props_line:last-child").remove();
    }
    //添加限时排期
    function addTimeLimitTs(){
        timeLimit++;
        var date1 = '<?php echo date('Y-m-d H:i',time());?>';
        var html =  timeLimitTs(timeLimit,date1,date1);
        $("#timelimit_ts").append(html);
    }
    //删除限时排期
    function delTimeLimitTs() {
        if(timeLimit>1){
            $("#timelimit_ts").children(".ttss")[timeLimit-1].remove();
            timeLimit--;
        }
    }
    //添加限时bet奖励值排期
    function addTimeLimitBetTs(){
        timeLimitBet++;
        var date1 = '<?php echo date('Y-m-d H:i',time());?>';
        var html =  timeLimitBetTs(timeLimitBet,date1,date1);
        $("#timelimit_bet_ts").append(html);
    }
    //删除限时bet奖励值排期
    function delTimeLimitBetTs() {
        if(timeLimitBet>1){
            $("#timelimit_bet_ts").children(".ttss")[timeLimitBet-1].remove();
            timeLimitBet--;
        }
    }
    function addSpinsProTR() {
        spinsProLimit++;
        var data = {"stage":spinsProLimit,"spins":0,"num":1};
        var html =  SpinsProTR(data);
        $("#table_body_changeSpinsPro").append(html);
    }
    function delSpinsProTR() {
        if(spinsProLimit>1){
            $("#table_body_changeSpinsPro").children(".ttss")[spinsProLimit-1].remove();
            spinsProLimit--;
        }
    }
    //================================================
    //资源目录选项html
    function cidSelectOp() {
        var html ='';
        console.log(imgNames[act_type]);
        if(imgNames[act_type]&&imgNames[act_type]!=undefined){
            $.each(imgNames[act_type],function(k,v) {
                html+='<option value="'+k+'">'+v['name']+'</option>';
            });
        }
        return html;
    }

    //====================收集类型=======================
    function addTimeLimit(){
        var html = '';
        html +='<div class="form-group">';
        var sel = activity_extra_data['open']==1?'checked':'';
        html +='<label class="col-sm-2 control-label">是否开启限时奖励:</label><div class="col-sm-1"><input type="checkbox" class="form-check-input" name="extraData[open][]" value="1" '+sel+'></div>';
        html +='</div>';
        html +='<br><div id="timelimit_ts" class="form-group">';
        console.log(activity_extra_data['ts']);
        if(activity_extra_data['ts']&&Object.keys(activity_extra_data['ts']).length>0){
            $.each(activity_extra_data['ts'],function(k,v){
            //     console.log(v);
                html +=timeLimitTs(k,v['s'],v['e']);
                timeLimit++;
            });
        }
        html +='</div>';
        html += '<div class="text-center"><botton class="btn btn-primary" id="addReward2" onclick="addTimeLimitTs()">添加</botton><botton class="btn btn-danger del-tr" onclick="delTimeLimitTs()">删除</botton>';
        html +='<hr style=" height:2px;border:none;border-top:2px dotted #0b0;">';
        return html;
    }
    function timeLimitTs(n,value1,value2){
    var html = '<div class="col-sm-3 ttss">';
        html +='<input type="text" class="form-control" id="time_'+n+'" placeholder=" 时间选择 " name="extraData[ts]['+n+']" value="'+value1+' ~ '+value2+'">';
        html +='</div>';
        var id ='#time_'+ n;
        laydate.render({
            elem: id
            ,type: 'datetime'
            , range: '~'
        });
        return html;
    }
    function addTimeLimitBet(){
        console.log(activity_extra_data);
        var html = '';
        html +='<div class="form-group">';
        var sel = activity_extra_data['open_bet']==1?'checked':'';
        var bet = activity_extra_data['bet']>0?activity_extra_data['bet']:2;
        html +='<label class="col-sm-2 control-label">是否开启限时进度值加倍:</label><div class="col-sm-1"><input type="checkbox" class="form-check-input" name="extraData[open_bet][]" value="1" '+sel+'></div>';
        html +='<label class="col-sm-2 control-label">加倍BET值:</label><div class="col-sm-1"><input type="text" class="form-control" name="extraData[bet]" value="'+bet+'" ></div>';
        html +='</div>';
        html +='<br><div id="timelimit_bet_ts" class="form-group">';
        console.log(activity_extra_data['bet_ts']);
        if(activity_extra_data['bet_ts']&&Object.keys(activity_extra_data['bet_ts']).length>0){
            $.each(activity_extra_data['bet_ts'],function(k,v){
                //     console.log(v);
                html +=timeLimitBetTs(k,v['s'],v['e']);
                timeLimitBet++;
            });
        }
        html +='</div>';
        html += '<div class="text-center"><botton class="btn btn-primary" id="addReward3" onclick="addTimeLimitBetTs()">添加</botton><botton class="btn btn-danger del-tr" onclick="delTimeLimitBetTs()">删除</botton>';
        html +='<hr style=" height:2px;border:none;border-top:2px dotted #0b0;">';
        return html;
    }
    function timeLimitBetTs(n,value1,value2){
        var html = '<div class="col-sm-3 ttss">';
        html +='<input type="text" class="form-control" id="bet_time_'+n+'" placeholder=" 时间选择 " name="extraData[bet_ts]['+n+']" value="'+value1+' ~ '+value2+'">';
        html +='</div>';
        var id ='#bet_time_'+ n;
        laydate.render({
            elem: id
            ,type: 'datetime'
            , range: '~'
        });
        return html;
    }
    //体力对概率系数修正
    function setProChange() {
        var html ='';
        var cols = 3;
        html +='<div class="form-group" id="spinsPro_table">';
        var selected = activity_extra_data['openPro']==1?'selected':'';
        html +='<div class="form-group">';
        html +='<label class="col-sm-2 control-label">是否开启体力及阶段对概率的修正:</label>';
        html +='<div class="col-sm-1"><select name="extraData[openPro]" class="form-control"><option value="0" '+selected+'>关闭</option><option value="1" '+selected+'>开启</option></select></div>';
        html +='</div>';
        html +='<div class="form-group">';
        html +='<label class="col-sm-2 control-label">体力对概率的修正配置:</label>';
        html +='</div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>stage</th><th>体力值</th><th>系数</th></thead>';
        html +='<tbody id="table_body_changeSpinsPro">';
        if(activity_extra_data['spinsPro']&&Object.keys(activity_extra_data['spinsPro']).length>0){
            $.each(activity_extra_data['spinsPro'],function(k,v) {
                html += SpinsProTR(v);
                spinsProLimit++;
            });
        }
        html +='</tbody><tr><td colspan="'+cols+'"><div class="text-center"><botton class="btn btn-primary" id="addReward" onclick="addSpinsProTR()">添加</botton><botton class="btn btn-danger del-tr" onclick="delSpinsProTR()">删除</botton>';
        html +='</div></td></tr></table></div>';
        html +='<hr style=" height:2px;border:none;border-top:2px dotted #0b0;">';
        return html;
    }
    function SpinsProTR(data) {
        var html ='';
        html +='<tr id="spinsPro_'+data['stage']+'" class="ttss">';
        html +='<td><input type="text" class="form-control" name="extraData[spinsPro]['+data['stage']+'][stage]" value="'+data['stage']+'" readonly></td>';
        html +='<td><input type="text" class="form-control" name="extraData[spinsPro]['+data['stage']+'][spins]" value="'+data['spins']+'" ></td>';
        html +='<td><input type="text" class="form-control" name="extraData[spinsPro]['+data['stage']+'][num]" value="'+data['num']+'"></td>';
        html +='</tr>';
        return html;
    }
    //添加奖励html
    function addStagePro(type,data=[]){
        var pro =["攻击","偷袭","体力","护盾","1个金币","2个金币","3个金币","1个钱袋","2个钱袋","3个钱袋","没有奖励","活动"];
        var html = '';
        html +='<div aria-hidden="true" id="stage_pro">';
        html +='<div class="form-group">';
        if($.inArray(type,["collect","rank","attack","super_collect"])!=-1){
            html +='<label class="col-xs-1 control-label">打:</label><div class="col-sm-1"><input type="text"  name="attack_success" value="'+data.attack_success+'" class="form-control"></div>';
            html +='<label class="col-xs-1 control-label">打破:</label><div class="col-sm-1"><input type="text"  name="attack_break" value="'+data.attack_break+'" class="form-control"></div>';
        }
        if($.inArray(type,["collect","rank","steal","super_collect"])!=-1){
            html +='<label class="col-xs-1 control-label">偷袭:</label><div class="col-sm-1"><input type="text"  name="steal_success" value="'+data.steal_success+'" class="form-control"></div>';
            html +='<label class="col-xs-1 control-label">完美偷:</label><div class="col-sm-1"><input type="text"  name="steal_break" value="'+data.steal_break+'" class="form-control"></div>';
        }
        if($.inArray(type,["collect_only","super_collect"])!=-1){
            html +='<label class="col-xs-1 control-label">一连击:</label><div class="col-sm-1"><input type="text"  name="one_hit" value="'+data.one_hit+'" class="form-control"></div>';
            html +='<label class="col-xs-1 control-label">二连击:</label><div class="col-sm-1"><input type="text"  name="tow_hit" value="'+data.tow_hit+'" class="form-control"></div>';
        }
        if($.inArray(type,["collect","rank","collect_only","super_collect"])!=-1){
            html +='<label class="col-xs-1 control-label">三连击:</label><div class="col-sm-1"><input type="text"  name="three_hit" value="'+data.three_hit+'" class="form-control"></div>';
        }
        html +='</div>';
        html+='<div class="col-sm-12"><div class="form-group"><label class="col-sm-1 control-label">概率调整:</label><div class="col-sm-11">';
        // 循环
        for(i=0;i<pro.length;i++){
            j=i+1;
            var val=0;
            if(Object.keys(reward_pro).length>0){
                val =  reward_pro[j];
            }
            html+='<div class="col-sm-1" style="text-align: center"><span>'+pro[i]+'</span><input type="text" style="text-align: center" class="form-control" name="pro['+j+']" value="'+val+'"></div>';
        }
        html+='</div></div></div>';
        html+='</div>';

        return html;
    }
    //创建表格式html
    function rewardTable(type){
        var cols = 4;
        var html ='';
        var str = type == 'callback_score' ? '发起回归进度奖励<span style="color: #ff0000;">注：最多10个进度奖励</span>' : '阶段奖励';
        html +='<div class="form-group" id="reward_table">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">'+str+'</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>阶段</th>';
        if(type=='rank'){
            html += '<th>进度条</th>';
            cols = 5
        }
        if(type=='architecture'){
            html +='<th>等级</th>';
        }else{
            html +='<th>阶段值</th>';
        }
        html +='<th>奖品</th><th>奖励设置</th></tr></thead>' ;
        html +='<tbody id="table_body">';

        html +='</tbody><tr><td colspan="'+cols+'"><div class="text-center"><botton class="btn btn-primary" id="addReward" onclick="addRewardNum()">添加</botton><botton class="btn btn-danger del-tr" onclick="delRewardNum()">删除</botton>';
        html +='</div></td></tr></table></div>';
        return html;
    }

    //阶段奖励2
    function rewardTable2(title, index, t) {
        return rewardTableOrig(title, index, t);
    }

    function rewardTableOrig(title, index, t){
        var cols = 4;
        var html ='';
        html +='<div class="form-group" id="reward_table'+index+'">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">'+title+'</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr>';
        if(index!=3){
            html +='<th>阶段</th>';
            html +='<th>阶段值</th>';
        }else{
            html +='<th>ID</th>';
        }
        html +='<th>奖品</th><th>奖励设置</th></tr></thead>' ;
        html +='<tbody id="table_body'+index+'">';

        html +='</tbody><tr><td colspan="'+cols+'"><div class="text-center"><botton class="btn btn-primary" id="addReward'+index+'" onclick="addRewardNum2('+index+','+t+')">添加</botton><botton class="btn btn-danger del-tr" onclick="delRewardNum2('+index+')">删除</botton>';
        html +='</div></td></tr></table></div>';
        return html;
    }

    //奖励阶段行数据html
    function rewardTableTR2(data, t, index){
        var stage = data['stage'];
        var prize = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var prize_show_arr = JSON.parse(prize);
        prize = escape(prize);
        var html ='';
        html+='<tr id="rewardInfo'+index+'_'+data['stage']+'">';
        html +='<td><input type="text" class="form-control" name="reward'+index+'['+data['stage']+'][stage]" value="'+data['stage']+'" readonly></td>';
        if(index!=3) {
            html += '<td><input type="text" class="form-control" name="reward' + index + '[' + data['stage'] + '][stepnum]" value="' + data['stepnum'] + '"></td>';
        }
        html +='<td class="showStagePrize_'+index+'_'+data['stage']+'">';
        if(prize_show_arr.length>0){
            for(var j=0;j<prize_show_arr.length;j++){
                html+= chestPropsHtml(prize_show_arr[j]);
            }
        }
        html+='</td>';
        html +='<input type="hidden" name="reward'+index+'['+data['stage']+'][prize]" value="'+prize+'">';
        html +='<td><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+','+t+','+index+')">奖励配置</button></td>';// data-toggle="modal"
        html +='</tr>';
        return html;
    }

    //奖励阶段行数据html
    function rewardTableTR(data){
        // console.log(data);
        var stage = data['stage'];
        var prize = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var prize_show_arr = JSON.parse(prize);
        prize = escape(prize);
        var html ='';
        html+='<tr id="rewardInfo_'+data['stage']+'">';
        html +='<td><input type="text" class="form-control" name="reward['+data['stage']+'][stage]" value="'+data['stage']+'"></td>';
        if(act_type=='rank'){
            html +='<td><input type="text" class="form-control" name="reward['+data['stage']+'][progressBarId]" value="'+data['progressBarId']+'"></td>';
        }
        if(act_type=='architecture'){
            html +='<td><input type="text" class="form-control" name="reward['+data['stage']+'][lv]" value="'+data['lv']+'"></td>';
        }else{
            html +='<td><input type="text" class="form-control" name="reward['+data['stage']+'][stepnum]" value="'+data['stepnum']+'"></td>';
        }

        html +='<td class="showStagePrize_'+data['stage']+'">';
        if(prize_show_arr.length>0){
            for(var j=0;j<prize_show_arr.length;j++){
                html+= chestPropsHtml(prize_show_arr[j]);
            }
        }
        html+='</td>';
        html +='<input type="hidden" name="reward['+data['stage']+'][prize]" value="'+prize+'">';
        html +='<td><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+',1)">奖励配置</button></td>';// data-toggle="modal"
        html +='</tr>';

        return html;
    }

    //每日宝箱奖励配置
    function dailyChest(data){
        var stage = 1;
        var prize = (data!==null&&data['prize']!=undefined)?JSON.stringify(data['prize']):'[]';
        var prize_show_arr = JSON.parse(prize);
        prize = escape(prize);
        var html ='';
        html+='<tr id="rewardInfo_1">';
        html +='<td class="showStagePrize_1">';
        if(prize_show_arr.length>0){
            for(var j=0;j<prize_show_arr.length;j++){
                html+= chestPropsHtml(prize_show_arr[j]);
            }
        }
        html+='</td>';
        html +='<input type="hidden" name="reward['+stage+'][prize]" value="'+prize+'">';
        html +='<td><button type="button" class="btn btn-outline btn-success" onclick="setPrize(1,1)">奖励配置</button></td>';// data-toggle="modal"
        html +='</tr>';

        return html;
    }

    //排行榜排名奖励table html
    function rankTable() {
        var html ='';
        html +='<hr style=" height:2px;border:none;border-top:2px dotted #0b0;"><div class="form-group" id="rank_table">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">排行榜榜单奖励</h5></div>';

        html +='</div>';
        html +='<div class="form-group"><div class="col-sm-12 col-sm-offset-2">';
        html += '<button class="btn btn-primary" id="addSpinRankBtn" type="button">添加</button>';
        html +='<button class="btn btn-white"   id="delSpinRankBtn" type="button">删除</button>';
        html +='</div></div><hr style=" height:2px;border:none;border-top:2px dotted #0b0;">';
        return html;
    }
    function spinRankTable(index,data){
        var html ='';
        html +='<table class="table table-bordered spinRankTable">';
        html +='<thead><tr><td colspan="4">';
        html +='<div class="form-group"><label class="col-sm-2 control-label m-b">体力区间 </label><div class="col-sm-3 input-group">';
        html +='<input type="text" style="text-align: center" class="form-control" name="rank_spinStage['+index+'][star]" value="'+data['star']+'">';
        html +='<span class="input-group-addon">-</span>';
        html +='<input type="text" style="text-align: center" class="form-control" name="rank_spinStage['+index+'][end]" value="'+data['end']+'">';
        html +='</div></div></td></tr>';
        html +='<tr><th>ID</th><th>排名</th><th>奖励</th><th>奖励配置</th></tr></thead>' ;
        html +='<tbody id="table_body2_'+index+'">';

        html +='</tbody><tr><td colspan="4"><div class="text-center"><botton class="btn btn-primary" id="addRank" onclick="addRankNum('+index+')">添加</botton><botton class="btn btn-danger del-tr" onclick="delRankNum('+index+')">删除</botton>';
        html +='</div></td></tr></table>';

        return html;
    }

    //奖励阶段行数据html
    function rankTableTR(index,data){
        // console.log(data);
        var stage = data['stage'];
        var prize = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var prize_show_arr = JSON.parse(prize);
        prize = escape(prize);
        var html ='';
        html+='<tr id="rankInfo_'+data['stage']+'">';
        html +='<td><input type="text" class="form-control" name="rank['+index+']['+data['stage']+'][stage]" value="'+data['stage']+'" readonly></td>';
        html +='<td><input type="text" class="form-control" name="rank['+index+']['+data['stage']+'][rankNum]" value="'+data['rankNum']+'"></td>';
        html +='<td class="showRankStagePrize_'+index+'_'+data['stage']+'">';
        if(prize_show_arr.length>0){
            for(var j=0;j<prize_show_arr.length;j++){
                if($.inArray(parseInt(prize_show_arr[j]['type']),actPropArr)!= -1){
                    var dv = "分钟";
                    var dc = "btn-danger";
                }else{
                    var dv = prize_show_arr[j]['rtype']==1?'个':'倍';
                    var dc = prize_show_arr[j]['rtype']==1?'btn-primary':'btn-danger';
                }
                html +='<span class="btn btn-outline '+dc+'">'+reward_type_arr[prize_show_arr[j]['type']]['name']+':'+prize_show_arr[j]['num']+dv+'</span>';
            }
        }
        html +='</td>';
        html +='<input type="hidden" name="rank['+index+']['+data['stage']+'][prize]" value="'+prize+'">';
        html +='<td><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+',2,'+index+')">奖励配置</button></td>';// data-toggle="modal"
        html +='</tr>';
        return html;
    }

    //排行榜机器人
    function rankVipSet() {
        <?php if(!empty($info['extraData']['setType'])){ ?>
            var setType = <?php echo $info['extraData']['setType'];?>;
        <?php }else{?>
            var setType = 1;
        <?php }?>

        if(setType == 1){
            var vipSetHiden = "";
            var spinsSetHiden = "display:none";

        }else{
            var vipSetHiden = "display:none";
            var spinsSetHiden = "";
        }
        var html = '<div class="col-sm-12"><div class="form-group"><label class="col-sm-1 control-label">分区类型：</label><div class="col-sm-11"><div class="col-sm-4"><select id="setType" class="form-control m-b" name="setType" onchange="setTypeFunction()">';
        arr = {1:'VIP积分', 2:'体力'};
        for (var i=1;i<=2;i++) {
            if(setType == i){
                html += '<option selected value="'+i+'">'+arr[i]+'</option>'
            }else{
                html += '<option value="'+i+'">'+arr[i]+'</option>'
            }
        }
        html += '</select></div></div></div></div>';

        <?php if(!empty($info['extraData']['vipSet'])){ ?>
            var arr = [<?php echo implode(',',$info['extraData']['vipSet']);?>];
        <?php }else{?>
            var arr = [0,1000,5000,10000,50000,100000];
        <?php }?>

        html+='<div class="col-sm-12" id="vipSet" style="'+vipSetHiden+'"><div class="form-group"><label class="col-sm-1 control-label">vip分块:</label><div class="col-sm-11">';
        for(i=0;i<arr.length;i++){
            html+='<div class="col-sm-1" style="text-align: center"><input type="text" style="text-align: center" class="form-control" name="vipSet['+i+']" value="'+arr[i]+'"></div>';
        }
        html+='</div></div>';

        <?php if(!empty($info['extraData']['vipSetSpins'])){ ?>
            var vipSetSpins  = [<?php echo implode(',',$info['extraData']['vipSetSpins']);?>];
        <?php }else{?>
            var vipSetSpins  = [500,800,800,800,800,800];
        <?php }?>

        html+='<div class="form-group"><label class="col-sm-1 control-label">机器人停止标准:</label><div class="col-sm-11">';
        for(i=0;i<vipSetSpins.length;i++){
            html+='<div class="col-sm-1" style="text-align: center"><input type="text" style="text-align: center" class="form-control" name="vipSetSpins['+i+']" value="'+vipSetSpins[i]+'"></div>';
        }
        html+='</div></div>';
        html+='</div>';

        // 体力分区
        <?php if(!empty($info['extraData']['spinsSet'])){ ?>
            arr  = [<?php echo implode(',',$info['extraData']['spinsSet']);?>];
        <?php }else{?>
            arr  = [0,200,300,500,1000,3000,5000,8000,10000];
        <?php }?>
        html+='<div class="col-sm-12" id="spinsSet" style="'+spinsSetHiden+'"><div class="form-group"><label class="col-sm-1 control-label">体力分块:</label><div class="col-sm-11">';

        for(i=0;i<arr.length;i++){
            html+='<div class="col-sm-1" style="text-align: center"><input type="text" style="text-align: center" class="form-control" name="spinsSet['+i+']" value="'+arr[i]+'"></div>';
        }
        html+='</div></div>';

        <?php if(!empty($info['extraData']['spinsSetSpins'])){ ?>
            var spinsSetSpins  = [<?php echo implode(',',$info['extraData']['spinsSetSpins']);?>];
        <?php }else{?>
            var spinsSetSpins  = [250,500,800,1500,3000,3000,5000,8000,10000];
        <?php }?>
        html+='<div class="form-group"><label class="col-sm-1 control-label">机器人停止标准:</label><div class="col-sm-11">';
        for(i=0;i<spinsSetSpins.length;i++){
            html+='<div class="col-sm-1" style="text-align: center"><input type="text" style="text-align: center" class="form-control" name="spinsSetSpins['+i+']" value="'+spinsSetSpins[i]+'"></div>';
        }
        html+='</div></div>';
        html+='</div>';
        return html;
    }
    //设置类型
    function setTypeFunction() {
        var setType = $('#setType').val();
        if(setType == 1){
            $("#vipSet").show();
            $("#spinsSet").hide();
        }else{
            $("#vipSet").hide();
            $("#spinsSet").show();
        }
    }

    //机器人配置
    function rankRobot() {
        var html ='';
        html +='<div class="col-sm-6"><div class="form-group">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">排行榜机器人配置</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>ID</th><th>排名比例</th><th>排名值</th><th>系数A</th><th>系数B</th></tr></thead>' ;
        html +='<tbody id="table_body3">';
        var readPro = "";
        var readNum = "";
        var readCo = "";
        <?php if(!empty($info['extraData']['robot'])){ ?>
            var json = JSON.parse('<?php echo json_encode($info['extraData']['robot']);?>');
            $.each(json,function (i,data) {
                if(i > 4){
                    readPro = "readonly"
                }
                if(i <= 4){
                    readNum = "readonly"
                }
                if(i > 2){
                    readCo = "readonly"
                }
                html +='<tr>'
                    +'<td><input type="text" class="form-control" name="robot['+i+'][id]"  value="'+i+'"></td>'
                    +'<td><input type="text" class="form-control" name="robot['+i+'][pro]" '+readPro+' value="'+data.pro+'"></td>'
                    +'<td><input type="text" class="form-control" name="robot['+i+'][num]" '+readNum+' value="'+data.num+'"></td>'
                    +'<td><input type="text" class="form-control" name="robot['+i+'][co1]" '+readCo+' value="'+data.co1+'"></td>'
                    +'<td><input type="text" class="form-control" name="robot['+i+'][co2]" '+readCo+' value="'+data.co2+'"></td>'
                    +'</tr>';
                readPro = '';
                readNum = '';
                readCo = '';
            });
        <?php }else{?>
            for (var i=1;i<=10;i++){
                if(i > 4){
                    readPro = "readonly"
                }
                if(i <= 4){
                    readNum = "readonly"
                }
                if(i > 2){
                    readCo = "readonly"
                }
                html +='<tr>'
                    +'<td><input type="text" class="form-control" name="robot['+i+'][id]"  value="'+i+'"></td>'
                    +'<td><input type="text" class="form-control" name="robot['+i+'][pro]" '+readPro+' value="0"></td>'
                    +'<td><input type="text" class="form-control" name="robot['+i+'][num]" '+readNum+' value="0"></td>'
                    +'<td><input type="text" class="form-control" name="robot['+i+'][co1]" '+readCo+' value="0"></td>'
                    +'<td><input type="text" class="form-control" name="robot['+i+'][co2]" '+readCo+' value="0"></td>'
                    +'</tr>';
                readPro = '';
                readNum = '';
                readCo = '';
            }

            html +='<tr>'
                +'<td><input type="text" class="form-control" name="robot[49][id]"  value="49"></td>'
                +'<td><input type="text" class="form-control" name="robot[49][pro]" readonly value="0"></td>'
                +'<td><input type="text" class="form-control" name="robot[49][num]"  value="0"></td>'
                +'<td><input type="text" class="form-control" name="robot[49][co1]" readonly value="0"></td>'
                +'<td><input type="text" class="form-control" name="robot[49][co2]" readonly value="0"></td>'
                +'</tr>';
        <?php }?>
        html +='</tbody>';
        html +='</table></div></div>';
        return html;
    }

    //机器人配置
    function rankLimit() {
        var html ='';
        html +='<div class="col-sm-6"><div class="form-group">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">排行榜人数限制配置</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>剩余小时数</th><th>房间人数</th></tr></thead>' ;
        html +='<tbody id="table_body3">';
        <?php if(!empty($info['extraData']['rankLimit'])){ ?>
            var json = JSON.parse('<?php echo json_encode($info['extraData']['rankLimit']);?>');
            $.each(json,function (i,data) {
                html +='<tr><td><input type="text" class="form-control" name="rankLimit['+i+'][time]" value="'+data.time+'"></td><td><input type="text" class="form-control" name="rankLimit['+i+'][limit]" value="'+data.limit+'"></td></tr>'
            });
        <?php }else{?>
            html +='<tr><td><input type="text" class="form-control" name="rankLimit[0][time]" value="12"></td><td><input type="text" class="form-control" name="rankLimit[0][limit]" value="30"></td></tr>'
            html +='<tr><td><input type="text" class="form-control" name="rankLimit[1][time]"  value="6"></td><td><input type="text" class="form-control" name="rankLimit[1][limit]" value="40"></td></tr>'
            html +='<tr><td><input type="text" class="form-control" name="rankLimit[2][time]"  value="3"></td><td><input type="text" class="form-control" name="rankLimit[2][limit]" value="45"></td></tr>'
            html +='<tr><td><input type="text" class="form-control" name="rankLimit[3][time]"  value="1"></td><td><input type="text" class="form-control" name="rankLimit[3][limit]" value="50"></td></tr>'
        <?php }?>
        html +='</tbody>';
        html +='</table></div></div>';
        return html;
    }

    //体力加速配置html
    function speedSpinsLine(data) {
        console.log(data);
        var html = '';
        for(var i=0;i<data.length;i++){
            html+='<div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;"><div class="form-group" >';
            html+='<label class="col-sm-1 control-label">ID*: </label>';
            html+='<div class="col-sm-1"><input type="text" class="form-control" readonly name="reward['+i+'][id]" value="'+data[i]['id']+'"></div>';
            html+='<label class="col-sm-1 control-label">加速来源*: </label>';
            html+='<div class="col-sm-2"><input type="text" class="form-control" readonly name="reward['+i+'][tips]" value="'+data[i]['tips']+'"></div>';
            html+='<label class="col-sm-1 control-label">加速倍率*: </label>';
            html+='<div class="col-sm-1"><input type="text" class="form-control"  name="reward['+i+'][bet]" value="'+data[i]['bet']+'"></div>';
            html+='<label class="col-sm-1 control-label">加速时长(秒)*: </label>';
            html+='<div class="col-sm-1"><input type="text" class="form-control"  name="reward['+i+'][effecteTime]" value="'+data[i]['effecteTime']+'"></div>';
            html+='<label class="col-sm-1 control-label">加速次数(每天)*: </label>';
            html+='<div class="col-sm-1"><input type="text" class="form-control"  name="reward['+i+'][max]" value="'+data[i]['max']+'"></div>';
            html+='<label class="col-sm-1 control-label">是否开启*: </label>';
            var selected = data[i]['open']==1?'selected':"";
            html+='<div class="col-sm-1"><select name="reward['+i+'][open]" class="form-control"><option value="0" '+selected+'>关闭</option><option value="1" '+selected+'>开启</option></select></div>';
            html+='</div></div>';
        }
        return html;
    }
    //超级bet输入html
    function crazyBetInput(data) {//actSpinsLimit
        var html='';
        html+='<div class="col-sm-6"><div class="form-group"><label class="col-sm-4 control-label">超级Bet触发体力点:</label>';
        html+='<div class="col-sm-8"><input type="text" placeholder="体力值" name="reward[init][actSpinsLimit]" value="'+data["init"]["actSpinsLimit"]+'" class="form-control"></div>';
        html+='</div>';
        html+='<div class="text-center" id="bet_line"><botton class="btn btn-primary" id="addCrazyBetLine" onclick="addBetConf()">添加</botton><botton class="btn btn-danger del-tr" onclick="delBetConf()">删除</botton>';
        html+='</div></div>';
        return html;
    }
    //超级bet配置行html
    function crazyBetLine(data) {
        var html='';
        var i = data["id"];
        html += '<div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;"><div class="form-group" >';
        html += '<input type="hidden" class="form-control" readonly name="reward[conf]['+i+'][id]" value="'+data["id"]+'">';
        html += '<label class="col-sm-1 control-label">倍率</label><div class="col-sm-2"><input type="text" class="form-control"  name="reward[conf]['+i+'][bet]" value="'+data["bet"]+'"></div>';
        html += '<label class="col-sm-1 control-label">等级</label><div class="col-sm-2"><input type="text" class="form-control"  name="reward[conf]['+i+'][levelId]" value="'+data["levelId"]+'"></div>';
        html += '<label class="col-sm-1 control-label">体力</label><div class="col-sm-2"><input type="text" class="form-control"  name="reward[conf]['+i+'][spins]" value="'+data["spins"]+'"></div>';
        html += '</div></div>';
       return html;
    }

    // crazy_bet 体力弹框规则html
    function crazyBetSpinsRange() {
        var html='';
        html+='<div class="col-sm-6"><div class="form-group"><label class="col-sm-4 control-label">超级Bet体力不足弹框规则:</label>';
        html+='<div class="col-sm-4"></div>';
        html+='</div> ';
        html+='<div class="text-center" id="betSpinsRange_line"><botton class="btn btn-primary" id="addCrazyBetSpinsRange" onclick="addBetSpinsRangeConf()">添加</botton><botton class="btn btn-danger del-tr" onclick="delBetSpinsRangeConf()">删除</botton>';
        html+='</div></div>';
        return html;
    }

    // crazy_bet 体力弹框规则行
    function crazyBetSpinsRangeLine(data) {
        var html='';
        var i = data["id"];
        html += '<div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;"><div class="form-group" >';
        html += '<input type="hidden" class="form-control" readonly name="reward[init][spinsRange]['+i+'][id]" value="'+data["id"]+'">';
        html += '<label class="col-sm-1 control-label">体力</label><div class="col-sm-2"><input type="text" class="form-control"  name="reward[init][spinsRange]['+i+'][spins]" value="'+data["spins"]+'"></div>';
        html += '<label class="col-sm-1 control-label">倍率</label><div class="col-sm-2"><input type="text" class="form-control"  name="reward[init][spinsRange]['+i+'][bet]" value="'+data["bet"]+'"></div>';
        html += '</div></div>';
        return html;
    }
    //==========================连环礼包 star=======================================
    //连环礼包积分table Html
    function chainGiftTable(index,data) {
        var html='';
        html +='<div  id="chainTable_'+index+'"><table class="table table-bordered chainTable">';
        html +='<thead><tr><td>';
        html +='<div class="form-group"><label class="col-sm-2 control-label m-b">积分区间</label><div class="col-sm-3 input-group">';
        html +='<input type="text" style="text-align: center" class="form-control" name="scoreStage['+index+'][score_star]" value="'+data['score_star']+'">';
        html +='<span class="input-group-addon">-</span>';
        html +='<input type="text" style="text-align: center" class="form-control" name="scoreStage['+index+'][score_end]" value="'+data['score_end']+'">';
        html +='</div></div>';
        html +='</td></tr></thead>';
        html +='<tr><td id="chainInfo_'+index+'">';

        html+='</td></tr></table><div>';
        return html;
    }
    function chainOptBtn() {
        var html='';
        html +='<div class="text-center" id="chainOptBtn"><botton class="btn btn-primary" onclick="addChainStage()">添加</botton><botton class="btn btn-danger del-tr" onclick="delChainStage()">删除</botton></div>';
        return html;
    }
    //连环礼包配置html
    function chainGift(data,index=0) {
        var sel = '';
        var coins = ["coins01","coins02","coins03","coins04","coins05","coins06"];
        var html='';
        html+='<div class="row AllTypeControl" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">';//0-->
        //====>>
        html+='<div class="form-group" >';
        html+='<label class="col-sm-1 control-label">商品GID*: </label><div class="col-sm-1"><input type="text" class="form-control" readonly name="rewardnew['+index+']['+data['gid']+'][gid]" value="'+data['gid']+'"></div>';
        html+='<label class="col-sm-1 control-label">商品名称*: </label><div class="col-sm-2"><input type="text" class="form-control"  name="rewardnew['+index+']['+data['gid']+'][gname]" value="'+data['gname']+'"></div>';
        html+='<label class="col-sm-1 control-label">商品SKU*: : </label><div class="col-sm-2"><input type="text" class="form-control"  name="rewardnew['+index+']['+data['gid']+'][gsku]" value="'+data['gsku']+'"></div>';
        html+='<label class="col-sm-1 control-label">商品简介*: </label><div class="col-sm-2"><input type="text" class="form-control"  name="rewardnew['+index+']['+data['gid']+'][gdesc]" value="'+data['gdesc']+'"></div>';
        html+='</div>';
        //<<====
        //====>>
        html+='<div class="form-group">';
        html+=' <label class="col-sm-1 control-label">商品价格*: </label> <div class="col-sm-1"><input type="text" class="form-control"  name="rewardnew['+index+']['+data['gid']+'][gprice]" value="'+data['gprice']+'"></div>';
        html+='<label class="col-sm-1 control-label">商品金币价格*: </label>';
        html+='<div class="col-sm-2"><select class="form-control typeControl" name="rewardnew['+index+']['+data['gid']+'][gsku1][coins]">';
        for(i=0;i<coins.length;i++){
            if(coins[i]==data['gsku1']['coins']){
               sel =  'selected';
            }else{
               sel = '';
            }
            html+='<option value="'+coins[i]+'" '+sel+'>'+coins[i]+'</option>';
        }
        html+='</select></div>';
        html+='<label class="col-sm-1 control-label">价格倍率*: </label><div class="col-sm-2"><input type="text" class="form-control"  name="rewardnew['+index+']['+data['gid']+'][gsku1][bet]" value="'+data['gsku1']['bet']+'"></div>';
        html+='<label class="col-sm-1 control-label">商品限购*: </label><div class="col-sm-2"><input type="text" class="form-control"  name="rewardnew['+index+']['+data['gid']+'][gMax]" value="'+data['gMax']+'"></div>';
        html+='</div>';
        //<<====
        //=========
        html+='<div class="form-group"><label class="col-sm-1 control-label">商品货物*: </label>';//1-->
        html+='<div class="col-sm-8"><div class="container-fluid addOrDelControl" style="border: 1px solid #CCC;margin: 20px 15px;padding-top: 10px;" >';//2-->,3-->


        html+='<div class="form-group">';//4-->
        //====>>
        html+='<label class="col-sm-2 control-label">金币*: </label>';
        html+='<div class="col-sm-3"><select class="form-control typeControl" name="rewardnew['+index+']['+data['gid']+'][gbaseReward][coins][coins]">';
        for(i=0;i<coins.length;i++){
            var sel2 = '';
            if(coins[i]==data['gbaseReward']['coins']['coins']){
                sel2 =  'selected';
            }else{
                sel2 = '';
            }
            html+='<option value="'+coins[i]+'" '+sel2+'>'+coins[i]+'</option>';
        }
        html+='</select></div>';
        html+='<label class="col-sm-2 control-label">倍率*: </label>';
        html+='<div class="col-sm-3"><input type="text" class="form-control"  name="rewardnew['+index+']['+data['gid']+'][gbaseReward][coins][bet]" value="'+data['gbaseReward']['coins']['bet']+'"></div>';
        html+='</div>';//<--4
        //<<====
        html+='<div class="form-group"><label class="col-sm-2 control-label">体力*: </label>';
        html+='<div class="col-sm-3"><input type="text" class="form-control"  name="rewardnew['+index+']['+data['gid']+'][gbaseReward][spins]" value="'+data['gbaseReward']['spins']+'"></div></div>';

        var  prons = data['gbaseReward']['props']?data['gbaseReward']['props']:[];
        html+='<div class="form-group" id="props_'+index+'_'+data['gid']+'">';
        for(var j =0;j<prons.length;j++){
            html+=chainGiftProps(prons[j],j,data['gid'],index);
        }
        html+='</div>';

        html+='<button type="button" class="btn btn-success addParent"  style="margin-left: 12px;margin-bottom: 10px;" onclick="addprops('+data['gid']+','+index+')">增加</button>';
        html+='<button type="button" class="btn btn-danger deleteParent" style="margin-left: 12px;margin-bottom: 10px;" onclick="delprops('+data['gid']+','+index+')">删除</button>';
        html+='</div></div></div>';
        html+='</div>';

        return html;
    }
    //连环礼包道具行html
    function chainGiftProps(prons,pid,gid,index=0) {
        var html='';
        html+="<div class='props_line'>";
        html+='<div class="form-group"><label class="col-sm-2 control-label">道具*: </label><div class="col-sm-3"><select class="form-control selChainProp" name="rewardnew['+index+']['+gid+'][gbaseReward][props]['+pid+'][propsId]">';
        $.each(reward_type,function(k,v){
            var sel3 = "";
            if(prons['propsId']==v["id"]){
                sel3 = "selected";
            }else{
                sel3 = '';
            }
            html +='<option value="'+v["id"]+'" '+sel3+'>'+v["name"]+'</option>';
        });
        html+='</select></div>';
        html+='<label class="col-sm-2 control-label">数量*: </label><div class="col-sm-2"><input type="text" class="form-control"  name="rewardnew['+index+']['+gid+'][gbaseReward][props]['+pid+'][num]" value="'+prons['num']+'"></div>';
        html+='</div>';
        html+="</div>";
        return html;
    }
    //=================================end========================================
    //==========================新连环礼包 star=======================================
    function scoreCGTable(scoreCGType) {
        var sel1 = scoreCGType == 1 ? "selected" : "";
        var sel2 = scoreCGType == 2 ? "selected" : "";
        var html ='';
        html +='<div aria-hidden="true">';
        html +='<div class="form-group">';
        html +='<label class="col-sm-1 control-label">分阶段模式:</label><div class="col-sm-1"><select class="form-control typeControl" name="scoreCGType" onchange="ScoreCGType(this,this.value)">';
        html +='<option '+sel1+' value="1">积分</option>';
        html +='<option '+sel2+' value="2">分组</option>';
        html+='</select></div>';
        html +='</div>';
        html +='</div>';
        html +='<hr style=" height:2px;border:none;border-top:2px dotted #0b0;"><div class="form-group" id="scoreCGTable">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">分阶段配置</h5></div>';

        html+='</div>';
        html+='<div class="form-group"><div class="col-sm-4 col-sm-offset-2">';
        html+='<button class="btn btn-primary" id="addCGTableBtn" type="button">添加</button>';
        html+='<button class="btn btn-white"   id="delCGTableBtn" type="button">删除</button>';
        html+='</div></div><hr style=" height:2px;border:none;border-top:2px dotted #0b0;">';
        return html;
    }

    function ScoreCGType(obj,value) {
        spinStage = 1;
        spin_reward_limit = [];
        scoreCGType = value
        if(value == 1){
            var d ={"star":0,"end":0};
        }else{
            var d ={"gid":0};
        }
        var html = scoreCGRewardTable(scoreCGType,1,d);//阶段奖励内部table
        $("#scoreCGTable").html(html);
    }

    //分体力阶段奖励配置表html
    function scoreCGRewardTable(scoreCGType,index,data) {
        var html ='';
        cols =7;
        html +='<table class="table table-bordered scoreCGRewardTable" id="reward_table_'+index+'">';
        html +='<thead><tr><td colspan="'+cols+'"><div class="form-group">';
        if(scoreCGType == 1){
            html +='<label class="col-sm-1 control-label m-b">积分区间</label><div class="col-sm-3 input-group">';
            html +='<input type="text" style="text-align: center" class="form-control" name="scoreStage['+index+'][star]" value="'+data['star']+'">';
            html +='<span class="input-group-addon">-</span>';
            html +='<input type="text" style="text-align: center" class="form-control" name="scoreStage['+index+'][end]" value="'+data['end']+'">';
            html +='</div>';
        }else{
            var arr = JSON.parse('<?php echo json_encode($userGroup2);?>');
            html +='<label class="col-sm-1 control-label m-b">添加分组</label><div class="col-sm-1"><select class="form-control" onchange="AddScoreCGRGid(this,'+index+')">';
            html += '<option value="0">默认</option>';
            for(let i in arr){
                html += '<option value="'+i+'">'+arr[i]+'</option>';
            }
            html +='</select></div><div class="col-sm-10" id="scoreCGGidDiv'+index+'">';
            if(index == 1){
                html +='<div class="col-sm-1"><input class="btn btn-primary" type="button" value="默认"><input class="btn btn-primary" type="hidden" name="scoreStage['+index+'][gid][]" value="0"></div>';
            }
            if(data['gid'] != 0){
                var gidArr = data['gid'].split(",");
                for (var i = 0;gidArr.length>i;i++){
                    var val = parseInt(gidArr[i])
                    if(val != 0){
                        html +='<div class="col-sm-1" onclick="DelScoreCGRGid(this,'+val+')"><input class="btn btn-primary" type="button" value="'+arr[val]+'"><input class="btn btn-primary" type="hidden" name="scoreStage['+index+'][gid][]" value="'+val+'"></div>';
                    }
                }
            }
            html +='</div>';
        }
        html +='</div></td></tr><tr><th>阶段</th><th>名称</th><th>限量</th><th>购买货币</th><th>价格</th><th>奖励</th><th>奖励设置</th></tr>';
        html +='</thead>' ;
        html +='<tbody id="table_body_'+index+'">';
        html +='</tbody><tr><td colspan="'+cols+'"><div class="text-center"><botton class="btn btn-primary" onclick="addCGScoreRewardNum('+index+')">添加</botton><botton class="btn btn-danger del-tr" onclick="delCGScoreRewardNum('+index+')">删除</botton>';
        html +='</div></td></tr></table>';
        return html;
    }

    //召回好友活动选择RFM分组id
    function ChooseRFMGroup(data, index, flag = 1){
        var html = '', name = flag ? 'cond' : 'scoreStage';
        cols =2;
        html +='<tr><td colspan="'+cols+'"><div class="form-group">';
        var arr = JSON.parse('<?php echo json_encode($userGroup2);?>');
        html +='<label class="col-sm-1 control-label m-b">RFM分组</label><div class="col-sm-1"><select class="form-control" onchange="AddScoreCGRGid(this,'+index+','+0+')">';
        html += '<option value="0">默认</option>';
        for(let i in arr){
            html += '<option value="'+i+'">'+arr[i]+'</option>';
        }
        html +='</select></div><div class="col-sm-10" id="scoreCGGidDiv'+index+'">';
        //html +='<div class="col-sm-1"><input class="btn btn-primary" type="button" value="默认"><input class="btn btn-primary" type="hidden" name="'+name+'['+index+'][gid][]" value="0"></div>';
        if(data.gid != undefined){
            var gidArr = data.gid;
            for (var i = 0;gidArr.length>i;i++){
                var val = parseInt(gidArr[i]);
                if(val != 0){
                    html +='<div class="col-sm-1" onclick="DelScoreCGRGid(this,'+val+')"><input class="btn btn-primary" type="button" value="'+arr[val]+'"><input class="btn btn-primary" type="hidden" name="'+name+'['+index+'][gid][]" value="'+val+'"></div>';
                }else{
                    html +='<div class="col-sm-1" onclick="DelScoreCGRGid(this,'+val+')"><input class="btn btn-primary" type="button" value="默认"><input class="btn btn-primary" type="hidden" name="'+name+'['+index+'][gid][]" value="0"></div>';
                }
            }
        }
        html +='</div></td></tr>';
        return html;
    }

    function AddScoreCGRGid(obj,index,alertFlag=1) {
        var name  = $(obj).find("option:selected").text();
        var value = $(obj).val();
        for (var i = 0;scoreCGGidArr.length>i;i++){
            if(scoreCGGidArr[i] == value){
                if(alertFlag){
                    alert("分组冲突");
                }else{
                    return;
                }
            }
        }
        scoreCGGidArr.push(value)
        //if(value != 0){
            var html ='<div class="col-sm-1" onclick="DelScoreCGRGid(this,'+value+')"><input class="btn btn-primary" type="button" value="'+name+'"><input class="btn btn-primary" type="hidden" name="scoreStage['+index+'][gid][]" value="'+value+'"></div>';
            $("#scoreCGGidDiv"+index).append(html)
        //}
    }

    function DelScoreCGRGid(obj,value) {
        $(obj).remove();
        scoreCGGidArr = scoreCGGidArr.filter(v=>{
            return v != value;
        });
    }

    //分体力阶段奖励行html
    function scoreCGRwardTR(index,data) {
        var stage = data['stage'];
        var prize = data['prize'] != undefined ? JSON.stringify(data['prize']) : '[]';
        var prize_show_arr = JSON.parse(prize);
        prize = escape(prize);
        var html = '';
        html += '<tr id="rewardInfo_' + data['stage'] + '">';
        html += '<td><input type="text" class="form-control" readonly name="rewardnew[' + index + '][' + data['stage'] + '][stage]" value="' + data['stage'] + '"></td>';
        html += '<td><input type="text" class="form-control" name="rewardnew[' + index + '][' + data['stage'] + '][name]" value="' + data['name'] + '"></td>';
        html += '<td><input type="text" class="form-control" name="rewardnew[' + index + '][' + data['stage'] + '][gMax]" value="' + data['gMax'] + '"></td>';
        html += '<td><select class="form-control selMtype" name="rewardnew[' + index + '][' + data['stage'] + '][mtype]">';
        var arr = {1:"金币",2:"美元"};
        for (var i = 1; i < 3; i++) {
            data['mtype'] == i ? sel = 'selected' : sel = '';
            html += '<option value="' + i + '" ' + sel + '>' + arr[i] + '</option>';
        }
        html += '</select></td>';
        html += '<td class="selSku" t_index="'+index+'" t_stage="'+data['stage']+'">';
        html += selSku(index,data);
        html += '</td>';
        html +='<td class="showStagePrize_'+index+'_'+data['stage']+'">';
        if(prize_show_arr.length>0){
            for(var j=0;j<prize_show_arr.length;j++){
                html+= chestPropsHtml(prize_show_arr[j]);
            }
        }
        html+='</td>';
        html +='<input type="hidden" name="rewardnew['+index+']['+data['stage']+'][prize]" value="'+prize+'">';
        html +='<td><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+',1,'+index+')">奖励配置</button></td>';// data-toggle="modal"
        html +='</tr>';

        return html;
    }
    function selSku(index,data){
        var html = '';
        if(data['mtype']==2){
            html += '价格:<select class="form-control m-b selPrice" name="rewardnew[' + index + '][' + data['stage'] + '][price]">';
            $.each(goodSku, function (k, v) {
                if (data["price"] == v["price"]) {
                    sel = "selected";
                } else {
                    sel = "";
                }
                html += '<option value="' + v["price"] + '" ' + sel + '>' + v["price"] + '</option>';
            });
            html +='</select>';
            html +='商品sku:<input class="form-control t_sku" type="text" name="rewardnew['+index+']['+data['stage']+'][sku]" value="'+data['sku']+'">';
            html +='<input type="hidden" name="rewardnew['+index+']['+data['stage']+'][coin]" value="0">';
            html +='<input type="hidden" name="rewardnew['+index+']['+data['stage']+'][bet]" value="0">';
        }else{
            html += '价格:<select class="form-control m-b" name="rewardnew[' + index + '][' + data['stage'] + '][coin]">';
            for(var i=0;i<coins_list.length;i++){
                if (data["coin"] == coins_list[i]) {
                    sel = "selected";
                } else {
                    sel = "";
                }
                html += '<option value="' + coins_list[i] + '" ' + sel + '>' + coins_list[i] + '</option>';
            }
            html +='</select>倍数:<input class="form-control" type="text" name="rewardnew['+index+']['+data['stage']+'][bet]" value="'+data['bet']+'">';
            html +='<input type="hidden" name="rewardnew['+index+']['+data['stage']+'][sku]" value="0">';
            html +='<input type="hidden" name="rewardnew['+index+']['+data['stage']+'][price]" value="0">';
        }
        return html;
    }

    //=================================end========================================
    //疯狂的卡组奖励加成html
    function crazyCardRewardTable(){
        var cols = 4;
        var html ='';
        html +='<div class="form-group" id="reward_table">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">等级奖励加成</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>阶段</th>';
        html +='<th>起始等级</th>';
        html +='<th>终止等级</th>';
        html +='<th>加成百分比</th></tr></thead>' ;
        html +='<tbody id="table_body">';

        html +='</tbody><tr><td colspan="'+cols+'"><div class="text-center"><botton class="btn btn-primary" id="addReward" onclick="addRewardNum()">添加</botton><botton class="btn btn-danger del-tr" onclick="delRewardNum()">删除</botton>';
        html +='</div></td></tr></table></div>';

        return html;
    }
    //疯狂的卡组奖励行html
    function crazyCardTR(data) {
        var html ='';
        html+='<tr id="rewardInfo_'+data['stage']+'">';
        html +='<td><input type="text" class="form-control" name="reward['+data['stage']+'][stage]" value="'+data['stage']+'" readonly></td>';
        html +='<td><input type="text" class="form-control" name="reward['+data['stage']+'][slv]" value="'+data['slv']+'"></td>';
        html +='<td><input type="text" class="form-control" name="reward['+data['stage']+'][elv]" value="'+data['elv']+'"></td>';
        html +='<td><div class="col-sm-3 input-group"><input type="text" class="form-control" name="reward['+data['stage']+'][num]" value="'+data['num']+'"><span class="input-group-addon">%</span></dev></td>';
        html +='</tr>';
        return html;
    }

    //========================体力分套阶段收集======================================
    function spinStageTable(type) {
        var html ='';
        html+='<hr style=" height:2px;border:none;border-top:2px dotted #0b0;">';
        html +='<div class="" id="spinStageTable" style="top:10px">';
        var str ='分体力阶段奖励';
        if(type=='easter_egg'){
            str='关卡奖励'
        }
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">'+str+'</h5></div>';

        html+='</div>';
        html+='<div class="form-group"><div class="col-sm-4 col-sm-offset-2">';
        html+='<button class="btn btn-primary" id="addSpinStageBtn" type="button">添加</button>';
        html+='<button class="btn btn-white"   id="delSpinStageBtn" type="button">删除</button>';
        html+='</div></div><hr style=" height:2px;border:none;border-top:2px dotted #0b0;">';
        return html;
    }
    //收集分体力阶段奖励配置表html
    function spinStageRewardTable(index,data) {
        var type=act_type;
        var cols = 4;
        if(["architecture","rank","super_collect"].includes(type)){
            cols = 5
        }
        var html ='';
        html +='<table class="table table-bordered spinStageRewardTable" id="reward_table_'+index+'">';
        html +='<thead><tr><td colspan="'+cols+'">';
        if(type=='easter_egg'){
            html +='<div class="form-group"><label class="col-sm-2 control-label m-b">关卡</label><div class="col-sm-3 input-group">';
            html +='<input type="text" style="text-align: center" class="form-control" name="spinStage['+index+'][star]" value="'+data['star']+'">';
            html +='</div></div>';
        }else{
            html +='<div class="form-group"><label class="col-sm-2 control-label m-b">体力区间 </label><div class="col-sm-3 input-group">';
            html +='<input type="text" style="text-align: center" class="form-control" name="spinStage['+index+'][star]" value="'+data['star']+'">';
            html +='<span class="input-group-addon">-</span>';
            html +='<input type="text" style="text-align: center" class="form-control" name="spinStage['+index+'][end]" value="'+data['end']+'">';
            html +='</div></div>';
        }
        html +='</td></tr>';
        html +='<tr><th>阶段</th>';
        if(type=='super_collect'){
            html += '<th>概率修正系数</th>';
        }
        if(type=='rank'){
            html += '<th>进度条</th>';
        }
        if(type=='architecture'){
            html +='<th>等级</th>';
        }else if(type=='easter_egg'){
            html +='<th>权重值</th>';
        }else{
            html +='<th>阶段值</th>';
        }
        html +='<th>奖品</th><th>奖励设置</th></tr></thead>' ;
        html +='<tbody id="table_body_'+index+'">';

        html +='</tbody><tr><td colspan="'+cols+'"><div class="text-center"><botton class="btn btn-primary" onclick="addSpinRewardNum('+index+')">添加</botton><botton class="btn btn-danger del-tr" onclick="delSpinRewardNum('+index+')">删除</botton>';
        html +='</div></td></tr></table>';

        return html;
    }
    //收集分体力阶段奖励行html
    function spinStageRwardTR(index,data) {
        var stage = data['stage'];
        var prize = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var prize_show_arr = JSON.parse(prize);
        prize = escape(prize);
        var html ='';
        html+='<tr id="rewardInfo_'+data['stage']+'">';
        html +='<td><input type="text" class="form-control" name="rewardnew['+index+']['+data['stage']+'][stage]" value="'+data['stage']+'"></td>';
        if(act_type=='super_collect'){
            var stagePro = data['stagePro']&&data['stagePro']!=undefined?data['stagePro']:1;
            html +='<td><input type="text" class="form-control" name="rewardnew['+index+']['+data['stage']+'][stagePro]" value="'+stagePro+'"></td>';
        }
        if(act_type=='rank'){
            html +='<td><input type="text" class="form-control" name="rewardnew['+index+']['+data['stage']+'][progressBarId]" value="'+data['progressBarId']+'"></td>';
        }
        if(act_type=='architecture'){
            html +='<td><input type="text" class="form-control" name="rewardnew['+index+']['+data['stage']+'][lv]" value="'+data['lv']+'"></td>';
        }else{
            html +='<td><input type="text" class="form-control" name="rewardnew['+index+']['+data['stage']+'][stepnum]" value="'+data['stepnum']+'"></td>';
        }

        html +='<td class="showStagePrize_'+index+'_'+data['stage']+'">';
        if(prize_show_arr.length>0){
            for(var j=0;j<prize_show_arr.length;j++){
                html+= chestPropsHtml(prize_show_arr[j]);
            }

        }
        html+='</td>';
        html +='<input type="hidden" name="rewardnew['+index+']['+data['stage']+'][prize]" value="'+prize+'">';
        html +='<td><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+',1,'+index+')">奖励配置</button></td>';// data-toggle="modal"
        html +='</tr>';

        return html;
    }
    //=================================end========================================

    //=======================限时邀请 star=========================================
    function timelimitInvite(data) {
        console.log(data);
        var html='';
        html+='<div class="form-group"><label class="col-sm-2 control-label">成功条件：</label>';
        html+='<div class="col-sm-2"> <select class="form-control" name="reward_conf[type]">';
        var sel,sel2,sel3='';
        data['type']==1?sel='selected':(data['type']==2?sel2='selected':sel3='selected');
        // html+= '<option value="1" '+sel+'>完成注册绑定FB</option>';
        html+= '<option value="2" '+sel2+'>完成新手引导</option>';
        html+= '<option value="3" '+sel3+'>完成指定等级</option>';
        html+='</select></div>';
        html+='<div class="col-sm-1"><input type="text" class="form-control" name="reward_conf[ext_num]" value="'+data["ext_num"]+'"></div>';
        html+='</div>';
        return html;
    }
    //=================================end========================================


    function goldenCardTradeHtml(data) {
        if(golden_card.length == 0){
            getAllGoldenCardByGroup();
        }
        var arr  = [];
        <?php if(!empty($info['extraData'])){ ?>
            arr  = <?php echo json_encode($info['extraData'],JSON_NUMERIC_CHECK);?>;
        <?php }?>
        var html = '<div class="form-group">';
        for(c=0;c<=1;c++){
            html += '<label class="col-sm-1 control-label">金卡：</label><div class="col-sm-4"><select class="form-control m-b" name="goldenCard['+c+']">';
            for(j=0;j<golden_card.length;j++){
                var tStr = "";
                if(arr[c] == golden_card[j].ciid*1){
                    tStr = "selected";
                }
                html += '<option '+tStr+' value="'+golden_card[j].ciid+'">'+golden_card[j].ci_name_zh+'</option>';
            }
            html += '</select></div>';
        }
        html += '</select></div>';
        html += '</div>';
        return html;
    }

    //商城促销
    function shop_promotion_html() {
        var html='';
        html+='<div class="col-sm-12"><div class="form-group"><label class="col-sm-2 control-label">积分配置:</label>';
        html+='<div class="col-sm-10" id="shop_promotion_point"></div>';
        html+='</div>';
        html+='<div class="text-center"><botton class="btn btn-primary" id="addCrazyBetLine" onclick="addShopPromotionConf([])">添加</botton><botton class="btn btn-danger del-tr" onclick="delShopPromotionConf()">删除</botton>';
        html+='</div></div>';
        return html;
    }
    //商城促销
    function addShopPromotionConf(data){
        var html = addShopPromotionLine(data);
        $("#shop_promotion_point").append(html);
        shop_promotion_limit++;
    }
	//商城促销
    function addShopPromotionLine(data = []) {
        var html='';
        if(JSON.stringify(data) === '[]'){
            html+='<div class="row"><div class="form-group">';
            html+='<label class="col-sm-2 control-label">截止积分:</label>';
            html+='<div class="col-sm-2"><input type="text" placeholder="积分" name="reward[init]['+shop_promotion_limit+'][point]" value="" class="form-control"></div>';
            html+='<label class="col-sm-2 control-label">奖励倍数:</label>';
            html+='<div class="col-sm-2"><input type="text" placeholder="奖励倍数" name="reward[init]['+shop_promotion_limit+'][bet]" value="" class="form-control"></div>';
            html+='<label class="col-sm-2 control-label">限购次数:</label>';
            html+='<div class="col-sm-2"><input type="text" placeholder="限购次数" name="reward[init]['+shop_promotion_limit+'][buyNum]" value="" class="form-control"></div>';
            html+='</div></div>';
        }else{
            html+='<div class="row"><div class="form-group">';
            html+='<label class="col-sm-2 control-label">截止积分:</label>';
            html+='<div class="col-sm-2"><input type="text" placeholder="积分" name="reward[init]['+shop_promotion_limit+'][point]" value="'+data.point+'" class="form-control"></div>';
            html+='<label class="col-sm-2 control-label">奖励倍数:</label>';
            html+='<div class="col-sm-2"><input type="text" placeholder="奖励倍数" name="reward[init]['+shop_promotion_limit+'][bet]" value="'+data.bet+'" class="form-control"></div>';
            html+='<label class="col-sm-2 control-label">限购次数:</label>';
            html+='<div class="col-sm-2"><input type="text" placeholder="限购次数" name="reward[init]['+shop_promotion_limit+'][buyNum]" value="'+data.buyNum+'" class="form-control"></div>';
            html+='</div></div>';
        }
        return html;
    }
    //商城促销
    function delShopPromotionConf() {
        if(shop_promotion_limit>0){
            $("#shop_promotion_point").children(":last-child").remove();
            shop_promotion_limit--;
        }
    }

    /**
     * 宝藏活动 ----------------------------- start -------------------------------------------------
     */
    function getTreasureSettingHtml() {
        var openLv = 1;
        <?php if(!empty($info['extraData']['openLv'])){ ?>
            openLv = <?php echo $info['extraData']['openLv'] ?? 1;?>;
        <?php }?>
        var html = '';
        html +='<div aria-hidden="true" id="TreasureSetting">';
        html +='<div class="form-group">';
        html +='<label class="col-sm-1 control-label">开放等级:</label><div class="col-sm-1"><input type="text"  name="treasureOpenLv" value="'+openLv+'" class="form-control"></div>';
        html +='<div class="col-sm-1"><a target="_blank" class="btn btn-primary " href="#config/treasurepro/" role="button">概率倍率配置</a></div>';
        html +='</div>';
        html+='</div>';
        return html;
    }

    function getTreasureHtml() {
        var html ='';
        html +='<div class="form-group" id="treasure_table">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">宝藏任务</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>ID</th><th>任务类型</th><th>任务值</th><th>修正频率</th><th>奖励</th><th>下注值</th><th>操作</th></tr></thead>' ;
        html +='<tbody id="table_body3">';

        html +='</tbody><tr><td colspan="7"><div class="text-center"><botton class="btn btn-primary" id="addRank" onclick="addTreasureNum()">添加</botton><botton class="btn btn-danger del-tr" onclick="delTreasureNum()">删除</botton>';
        html +='</div></td></tr></table></div>';

        return html;
    }

    function addTreasureNum(){
        treasure_limit++;
        var data ={"id":treasure_limit,"taskType":1,"target":0,"frequency":50};
        var html = treasureTableTR(data);
        $("#table_body3").append(html);
    }

    //删排行奖励行
    function delTreasureNum(){
        if(treasure_limit>0){
            // console.log(reward_limit);
            $("#table_body3").children("tr:last-child").remove();
            treasure_limit--;
        }
    }

    function betFunction(id){
        var bet = prompt("请输入添加倍率");
        if(bet){
            var html = '<span class="btn btn-outline btn-primary" id="'+id+'_'+bet+'" onclick="betDelFunction('+id+','+bet+')">'+bet+'</span>';
            $(".showTreasureBet_"+id).append(html);
            var cur = unescape($('input[name="treasure['+id+'][bet]"]').val());
            cur = JSON.parse(cur);
            cur.push(bet);
            $('input[name="treasure['+id+'][bet]"]').val(escape(JSON.stringify(cur)));
        }
    }

    function betDelFunction(id,bet){
        console.log(id,bet);
        $("#"+id+"_"+bet).remove();
        var cur = unescape($('input[name="treasure['+id+'][bet]"]').val());
        cur = JSON.parse(cur);
        cur = cur.filter(v=>{
            return v!=bet;
        });
        $('input[name="treasure['+id+'][bet]"]').val(escape(JSON.stringify(cur)));
    }

    //奖励阶段行数据html
    function treasureTableTR(data){
        var stage = data['id'];
        var reward = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var reward_show_arr = JSON.parse(reward);
        reward = escape(reward);

        var bet = data['bet']!=undefined?JSON.stringify(data['bet']):'[]';
        var bet_show_arr = JSON.parse(bet);
        bet = escape(bet);

        var html ='';
        html+='<tr id="treasureInfo_'+stage+'">';
        html +='<td style="width: 5%;"><input type="text" class="form-control" name="treasure['+stage+'][id]" value="'+stage+'" readonly></td>';
        var taskTypeArr = {1:"下注次数",2:"获得金币",3:"Bonus Wheel"};
        html +='<td style="width: 10%;"><select class="form-control" name="treasure['+stage+'][taskType]">';
        for(j=1;j<=3;j++){
            var tStr = "";
            if(j == data['taskType']){
                tStr = "selected";
            }
            html += '<option '+tStr+' value="'+j+'">'+taskTypeArr[j]+'</option>';
        }
        html +='</select></td>';
        html +='<td style="width: 10%;"><input type="text" class="form-control" name="treasure['+stage+'][target]"    value="'+data['target']+'"></td>';
        html +='<td style="width: 10%;"><input type="text" class="form-control" name="treasure['+stage+'][frequency]" value="'+data['frequency']+'"></td>';
        html +='<td class="showTreasurePrize_'+stage+'">';
        if(reward_show_arr.length>0){
            for(var j=0;j<reward_show_arr.length;j++){
                html+= chestPropsHtml(reward_show_arr[j]);
            }
        }
        html +='</td>';
        html +='<td class="showTreasureBet_'+stage+'">';
        console.log(bet_show_arr);
        if(bet_show_arr.length>0){
            for(var j=0;j<bet_show_arr.length;j++){
                var tempBet = bet_show_arr[j];
                html += '<span class="btn btn-outline btn-primary" id="'+stage+'_'+tempBet+'" onclick="betDelFunction('+stage+','+tempBet+')">'+tempBet+'</span>';
            }
        }
        html +='</td>';
        html +='<input type="hidden" name="treasure['+stage+'][prize]" value="'+reward+'">';
        html +='<input type="hidden" name="treasure['+stage+'][bet]" value="'+bet+'">';
        html +='<td style="width: 15%;"><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+',3)">奖励配置</button><button type="button" class="btn btn-outline btn-success" onclick="betFunction('+stage+')">下注配置</button></td>';
        html +='</tr>';
        return html;
    }

    /**
     * 宝藏活动 ----------------------------- end -------------------------------------------------
     */

    /**
     * 通信证 ----------------------------- star -------------------------------------------------
     */

    function getTrafficPermitSettingHtml() {
        var openLv = 1;
        var guideLv = 1;
        var upLv   = 1;
        var passExp= 3;
        var itemColor= "#FF689896";
        var iconColor= "#FF689896";
        var maxLevelExpGap = 500;
        <?php if(!empty($info['extraData']['openLv'])){ ?>
            openLv = <?php echo $info['extraData']['openLv'] ?? 1;?>;
            guideLv = <?php echo $info['extraData']['guideLv'] ?? 1;?>;
            upLv = <?php echo $info['extraData']['upLvDiamondNum'] ?? 1;?>;
            passExp = <?php echo $info['extraData']['passExp'] ?? 3;?>;
            itemColor = "<?php echo $info['extraData']['itemColor'] ?? "#FF689896";?>";
            iconColor = "<?php echo $info['extraData']['iconColor'] ?? "#FF689896";?>";
            maxLevelExpGap  = "<?php echo $info['extraData']['maxLevelExpGap'] ?? 500;?>";
        <?php }?>
        var html = '';
        html +='<div aria-hidden="true" id="TrafficPermitSetting">';
        html +='<div class="form-group">';
        html +='<label class="col-sm-1 control-label">开放等级:</label><div class="col-sm-1"><input type="text"  name="trafficPermitOpenLv" value="'+openLv+'" class="form-control"></div>';
        html +='<label class="col-sm-1 control-label">指引等级:</label><div class="col-sm-1"><input type="text"  name="trafficPermitGuideLv" value="'+guideLv+'" class="form-control"></div>';
        html +='<label class="col-sm-1 control-label">提升等级钻石数:</label><div class="col-sm-1"><input type="text"  name="trafficPermitUpLv" value="'+upLv+'" class="form-control"></div>';
        html +='<label class="col-sm-1 control-label">通行证获得经验:</label><div class="col-sm-1"><input type="text"  name="trafficPermitPassExp" value="'+passExp+'" class="form-control"></div>';
        html +='<label class="col-sm-1 control-label">扫光颜色:</label><div class="col-sm-1"><input type="text"  name="trafficPermitItemColor" value="'+itemColor+'" class="form-control"></div>';
        html +='<label class="col-sm-1 control-label">图标底色:</label><div class="col-sm-1"><input type="text"  name="trafficPermitIconColor" value="'+iconColor+'" class="form-control"></div>';
        html +='<label class="col-sm-1 control-label">额外等级经验差:</label><div class="col-sm-1"><input type="text"  name="trafficPermitMaxLevelExpGap" value="'+maxLevelExpGap+'" class="form-control"></div>';
        html +='</div>';
        html+='</div>';
        return html;
    }

    function getTrafficPermitHtml() {
        var html ='';
        html +='<div class="form-group" id="trafficPermit_table">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">通行证奖励</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>等级</th><th>经验值</th><th>大奖</th><th>免费奖励</th><th>令牌奖励</th><th>操作</th></tr></thead>' ;
        html +='<tbody id="table_body4">';

        html +='</tbody><tr><td colspan="6"><div class="text-center"><botton class="btn btn-primary" onclick="addTrafficPermitNum()">添加</botton><botton class="btn btn-danger del-tr" onclick="delTrafficPermitNum()">删除</botton>';
        html +='</div></td></tr></table></div>';

        return html;
    }

    function addTrafficPermitNum() {
        trafficPermit_limit++;
        var data ={"levelId":trafficPermit_limit,"max":1};
        var html = trafficPermitTR(data);
        $("#table_body4").append(html);
    }

    //删排行奖励行
    function delTrafficPermitNum(){
        if(trafficPermit_limit>=0){
            // console.log(reward_limit);
            $("#table_body4").children("tr:last-child").remove();
            trafficPermit_limit--;
        }
    }

    //奖励阶段行数据html
    function trafficPermitExtraTR(data){
        var stage  = -1;
        var reward = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var reward_show_arr = JSON.parse(reward);
        reward = escape(reward);

        var special = data['specialPrize']!=undefined?JSON.stringify(data['specialPrize']):'[]';
        var special_show_arr = JSON.parse(special);
        special = escape(special);

        var html ='';
        html+='<tr id="treasureInfo_'+stage+'">';
        html +='<td style="width: 5%;"><input type="text" class="form-control"  value="额外" readonly></td>';
        html +='<td style="width: 10%;"><input type="text" class="form-control" value="额外等级" readonly></td>';
        html +='<td style="width: 15%;"><select class="form-control">';
        html +='</select></td>';
        html +='<td class="showTrafficPermitPrize_'+stage+'">';
        if(reward_show_arr.length>0){
            for(var j=0;j<reward_show_arr.length;j++){
                html+= chestPropsHtml(reward_show_arr[j]);
            }
        }
        html +='</td>';
        html +='<td class="showTrafficPermitSpecial_'+stage+'">';
        if(special_show_arr.length>0){
            for(var j=0;j<special_show_arr.length;j++){
                html+= chestPropsHtml(special_show_arr[j]);
            }
        }
        html +='</td>';
        html +='<input type="hidden" name="trafficPermit['+stage+'][prize]" value="'+reward+'">';
        html +='<input type="hidden" name="trafficPermit['+stage+'][specialPrize]" value="'+special+'">';
        html +='<td style="width: 15%;"><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+',4)">免费奖励配置</button><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+',5)">令牌奖励配置</button></td>';
        html +='</tr>';
        return html;
    }
    //奖励阶段行数据html
    function trafficPermitTR(data){
        var stage = data['levelId'];
        var reward = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var reward_show_arr = JSON.parse(reward);
        reward = escape(reward);

        var special = data['specialPrize']!=undefined?JSON.stringify(data['specialPrize']):'[]';
        var special_show_arr = JSON.parse(special);
        special = escape(special);

        var html ='';
        html+='<tr id="treasureInfo_'+stage+'">';
        html +='<td style="width: 5%;"><input type="text" class="form-control" name="trafficPermit['+stage+'][levelId]" value="'+stage+'" readonly></td>';
        html +='<td style="width: 10%;"><input type="text" class="form-control" name="trafficPermit['+stage+'][max]" value="'+data['max']+'"></td>';
        var taskTypeArr = {0:"否",1:"是"};
        html +='<td style="width: 15%;"><select class="form-control" name="trafficPermit['+stage+'][isGrandPrize]">';
        for(var j=0;j<=1;j++){
            var tStr = "";
            if(j == data['isGrandPrize']){
                tStr = "selected";
            }
            html += '<option '+tStr+' value="'+j+'">'+taskTypeArr[j]+'</option>';
        }
        html +='</select></td>';
        html +='<td class="showTrafficPermitPrize_'+stage+'">';
        if(reward_show_arr.length>0){
            for(var j=0;j<reward_show_arr.length;j++){
                html+= chestPropsHtml(reward_show_arr[j]);
            }
        }
        html +='</td>';
        html +='<td class="showTrafficPermitSpecial_'+stage+'">';
        if(special_show_arr.length>0){
            for(var j=0;j<special_show_arr.length;j++){
                html+= chestPropsHtml(special_show_arr[j]);
            }
        }
        html +='</td>';
        html +='<input type="hidden" name="trafficPermit['+stage+'][prize]" value="'+reward+'">';
        html +='<input type="hidden" name="trafficPermit['+stage+'][specialPrize]" value="'+special+'">';
        html +='<td style="width: 15%;"><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+',4)">免费奖励配置</button><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+',5)">令牌奖励配置</button></td>';
        html +='</tr>';
        return html;
    }

    function getTrafficPermitTaskHtml(id) {
        var html ='';
        var text = id == 1?"双日-默认":"单日";
        html +='<div class="form-group" id="trafficPermitTask_table">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">通行证任务('+text+')</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>任务ID</th><th>任务类型</th><th>达成次数</th><th>获得经验（次）</th></tr></thead>' ;
        html +='<tbody id="table_body_TrafficPermitTask_'+id+'">';
        html +='</tbody><tr><td colspan="6"><div class="text-center"><botton class="btn btn-primary" onclick="addTrafficPermitTaskNum('+id+')">添加</botton><botton class="btn btn-danger del-tr" onclick="delTrafficPermitTaskNum('+id+')">删除</botton>';
        html +='</div></td></tr></table></div>';
        return html;
    }

    function addTrafficPermitTaskNum(id) {
        if(id == 1){
            trafficPermitTask_limit++;
            var data ={"id":trafficPermitTask_limit,"max":1,"num":1,"getNum":1};
        }else{
            trafficPermitTask_limit2++;
            var data ={"id":trafficPermitTask_limit2,"max":1,"num":1,"getNum":1};
        }
        var html = trafficPermitTaskTR(data,id);
        $("#table_body_TrafficPermitTask_"+id).append(html);
    }

    function delTrafficPermitTaskNum(id) {
        if(id == 1){
            if(trafficPermitTask_limit>0){
                $("#table_body_TrafficPermitTask_"+id).children("tr:last-child").remove();
                trafficPermitTask_limit--;
            }
        }else{
            if(trafficPermitTask_limit2>0){
                $("#table_body_TrafficPermitTask_"+id).children("tr:last-child").remove();
                trafficPermitTask_limit2--;
            }
        }
    }

    function trafficPermitTaskTR(data,type) {
        var name  = type == 1 ? "trafficPermitTask":"trafficPermitTask2"
        var stage = data['id'];
        var html ='';
        html+='<tr id="treasureInfo_'+stage+'">';
        html +='<td style="width: 5%;"><input type="text" class="form-control" name="'+name+'['+stage+'][id]" value="'+stage+'"></td>';
        var taskTypeArr = {1:"邀请好友",2:"完成世界",3:"偷",4:"打",5:"和大盗莫里一起偷袭",6:"和拳手莫里一起进攻",7:"转一次黄金转盘",8:"夺宝一次",9:"玩一次黄金矿工",10:"分享游戏",11:"召回好友",12:"消耗体力200",13:"消耗体力800",14:"消耗体力2000"};
        html +='<td style="width: 15%;"><select class="form-control" name="'+name+'['+stage+'][type]">';
        for(var j=1;j<=14;j++){
            var tStr = "";
            if(j == data['type']){
                tStr = "selected";
            }
            html += '<option '+tStr+' value="'+j+'">'+taskTypeArr[j]+'</option>';
        }
        html +='</select></td>';
        html +='<td><input type="text" class="form-control" name="'+name+'['+stage+'][num]" value="'+data['num']+'"></td>';
        html +='<td><input type="text" class="form-control" name="'+name+'['+stage+'][getNum]" value="'+data['getNum']+'"></td>';
        html +='</tr>';
        return html;
    }

    /**
     * 通信证 ----------------------------- end -------------------------------------------------
     */
    function disArchConf(data) {
        var html ='';
        html+='<table class="table table-bordered"><thead><tr><td>建筑</td><td>优化力度（%）</td><tr></thead>';
        html+='<tr><td>1<input type="hidden" name="reward[0][level]" value="1"></td><td><input type="text" placeholder="" name="reward[0][disNum]" value="'+data[0]['disNum']+'" class="form-control"></td></tr>';
        html+='<tr><td>2<input type="hidden" name="reward[1][level]" value="2"></td><td><input type="text" placeholder="" name="reward[1][disNum]" value="'+data[1]['disNum']+'" class="form-control"></td></tr>';
        html+='<tr><td>3<input type="hidden" name="reward[2][level]" value="3"></td><td><input type="text" placeholder="" name="reward[2][disNum]" value="'+data[2]['disNum']+'" class="form-control"></td></tr>';
        html+='<tr><td>4<input type="hidden" name="reward[3][level]" value="4"></td><td><input type="text" placeholder="" name="reward[3][disNum]" value="'+data[3]['disNum']+'" class="form-control"></td></tr>';
        html+='<tr><td>5<input type="hidden" name="reward[4][level]" value="5"></td><td><input type="text" placeholder="" name="reward[4][disNum]" value="'+data[4]['disNum']+'" class="form-control"></td></tr>';
        html+='</table>';
        return html;
    }


    /**
     *  保险柜 ---------------------------------
     */
    function getSteelSafeHtml() {
        var html ='';
        html +='<div class="col-sm-4"><div class="form-group">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">保险柜奖励配置</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>阶段</th><th>金币类型</th><th>倍率</th><th>系数</th></thead>' ;
        html +='<tbody id="table_body5">';
        html +='</tbody>';
        html +='</table></div></div>';
        return html;
    }

    function getSteelSafeTr(data){
        var progress = data['progress'];
        var html ='';
        html +='<tr><td style="width: 15%"><input type="text" class="form-control" readonly name="config['+progress+'][progress]" value="'+progress+'"></td>';
        var coinsArr = {1:"coins01",2:"coins02",3:"coins03",4:"coins04",5:"coins05",6:"coins06"};
        html +='<td style="width: 30%"><select class="form-control" name="config['+progress+'][coins]">';
        for(var j=1;j<=6;j++){
            var tStr = "";
            var coins= coinsArr[j];
            if(coins == data['coins']){
                tStr = "selected";
            }
            html += '<option '+tStr+' value="'+coins+'">'+coins+'</option>';
        }
        html +='</select></td>';
        html +='<td><input type="text" class="form-control" name="config['+progress+'][bet]" value="'+data['bet']+'"></td>';
        html +='<td><input type="text" class="form-control" name="config['+progress+'][n]" value="'+data['n']+'"></td>';
        html +='</tr>';
        $("#table_body5").append(html);
    }

    function getSteelSafeLimitHtml() {
        var html ='';
        html +='<div class="col-sm-8"><div class="form-group">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">限时触发配置(积分)</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>进度</th><th>触发进度</th><th>延时(秒)</th><th>持续时间(秒)</th><th>积分区间(下线)</th><th>积分区间(上线)</th></thead>' ;
        html +='<tbody id="table_SteelSafePoint">';
        html +='</tbody><tr><td colspan="6"><div class="text-center"><botton class="btn btn-primary" onclick="addSteelSafeLimitTr()">添加</botton><botton class="btn btn-danger del-tr" onclick="delSteelSafeLimitTr()">删除</botton></div></td></tr>';
        html +='</table></div></div>';
        return html;
    }

    function getSteelSafeLimitTr(data){
        steel_safelimit_tr ++;
        var id = data['id'];
        var html ='';
        html +='<tr><td style="display: none"><input type="text" class="form-control" name="limit['+id+'][id]" value="'+id+'"></td>';
        html +='<td><input type="text" class="form-control" name="limit['+id+'][progress]" value="'+data['progress']+'"></td>';
        html +='<td><input type="text" class="form-control" name="limit['+id+'][percent]"  value="'+data['percent']+'"></td>';
        html +='<td><input type="text" class="form-control" name="limit['+id+'][delay]"    value="'+data['delay']+'"></td>';
        html +='<td><input type="text" class="form-control" name="limit['+id+'][duration]" value="'+data['duration']+'"></td>';
        html +='<td><input type="text" class="form-control" name="limit['+id+'][pointMin]" value="'+data['pointMin']+'"></td>';
        html +='<td><input type="text" class="form-control" name="limit['+id+'][pointMax]" value="'+data['pointMax']+'"></td>';
        html +='</tr>';
        $("#table_SteelSafePoint").append(html);
    }

    function addSteelSafeLimitTr() {
        console.log(steel_safelimit_tr);
        var conf = {"id":steel_safelimit_tr,"progress":1,"percent":1,"delay":1,"pointMin":1,"pointMax":1,"duration":1};
        getSteelSafeLimitTr(conf);
    }

    function delSteelSafeLimitTr() {
        $("#table_SteelSafePoint").children("tr:last-child").remove();
        steel_safelimit_tr--;
    }

    function getSteelSafeLimitRewardHtml() {
        var html ='';
        html +='<div class="col-sm-12"><div class="form-group">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">限时触发配置(奖励)</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>奖励ID</th><th>进度1概率</th><th>进度2概率</th><th>进度3概率</th><th>奖励</th><th>操作</th></thead>' ;
        html +='<tbody id="table_SteelSafeLimitReward">';
        html +='</tbody><tr><td colspan="6"><div class="text-center"><botton class="btn btn-primary" onclick="addSteelSafeLimitReward()">添加</botton><botton class="btn btn-danger del-tr" onclick="delSteelSafeLimitReward()">删除</botton>';
        html +='</div></td></tr></table></div>';
        return html;
    }

    function getSteelSafeLimitRewardTr(data){
        var id = data['id'];
        var reward = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var reward_show_arr = JSON.parse(reward);
        reward = escape(reward);

        var html ='';
        html+='<tr id="safeLimitInfo_'+id+'">';
        html +='<td style="width: 5%;"><input type="text" class="form-control" name="safeLimit['+id+'][id]" value="'+id+'" readonly></td>';
        html +='<td style="width: 10%;"><input type="text" class="form-control" name="safeLimit['+id+'][pro0]" value="'+data['pro0']+'"></td>';
        html +='<td style="width: 10%;"><input type="text" class="form-control" name="safeLimit['+id+'][pro1]" value="'+data['pro1']+'"></td>';
        html +='<td style="width: 10%;"><input type="text" class="form-control" name="safeLimit['+id+'][pro2]" value="'+data['pro2']+'"></td>';
        html +='<td class="showSafeLimitPrize_'+id+'">';
        if(reward_show_arr.length>0){
            for(var j=0;j<reward_show_arr.length;j++){
                html+= chestPropsHtml(reward_show_arr[j]);
            }
        }
        html +='</td>';
        html +='<input type="hidden" name="safeLimit['+id+'][prize]" value="'+reward+'">';
        html +='<td style="width: 15%;"><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+id+',6)">奖励配置</button></td>';
        html +='</tr>';
        return html;
    }

    function addSteelSafeLimitReward() {
        steel_safelimit_limit++;
        var data ={"id":steel_safelimit_limit,"pro0":1,"pro1":1,"pro2":1};
        var html = getSteelSafeLimitRewardTr(data);
        $("#table_SteelSafeLimitReward").append(html);
    }

    function delSteelSafeLimitReward() {
        $("#table_SteelSafeLimitReward").children("tr:last-child").remove();
        steel_safelimit_limit--;
    }


    /** -------------金币大爆炸---------------*/
    function getCoinCfgHtml(data) {
        var html='';
        var names = {"steal":"偷","attack":"打","slot":"旋转老虎机"};
        for(var i=0;i<data.length;i++){
            html+='<div class="row"><div class="form-group">';
            html+='<div class="col-sm-2"><input type="hidden" placeholder="" name="reward['+i+'][type]" value="'+data[i]['type']+'" class="form-control"></div>';
            html+='<label class="col-sm-2 control-label">'+names[data[i]['type']]+'-奖励倍数:</label>';
            html+='<div class="col-sm-2"><input type="text" placeholder="奖励倍数" name="reward['+i+'][bet]" value="'+data[i]['bet']+'" class="form-control"></div>';
            html+='</div></div>';
        }
        return html;
    }
    function getSteelSafeNHtml(n) {
        var html = '';
        html +='<div aria-hidden="true" id="SteelSafeN">';
        html +='<div class="form-group">';
        html +='<label class="col-sm-1 control-label">金币系数:</label><div class="col-sm-1"><input type="text"  name="steelSafeN" value="'+n+'" class="form-control"></div>';
        html +='</div>';
        html+='</div>';
        return html;
    }

    /** ------------- premium ---------------*/
    function getPremiumHtml(spins) {
        var html = '';
        html +='<div aria-hidden="true">';
        html +='<div class="form-group">';
        html +='<label class="col-sm-1 control-label">消耗体力:</label><div class="col-sm-1"><input type="text"  name="premiumSpins" value="'+spins+'" class="form-control"></div>';
        html +='</div>';
        html +='</div>';
        html +='<div class="form-group" id="premium_table">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">用户分组</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>序号</th><th>分组</th></tr></thead>' ;
        html +='<tbody id="table_body_premium">';
        html +='</tbody><tr><td colspan="6"><div class="text-center"><botton class="btn btn-primary" onclick="addPremium()">添加</botton><botton class="btn btn-danger del-tr" onclick="delPremium()">删除</botton>';
        html +='</div></td></tr></table></div>';
        return html;
    }

    function addPremium() {
        premium_limit++;
        var data ={"id":premium_limit};
        var html = premiumTR(data);
        $("#table_body_premium").append(html);
    }

    function delPremium() {
        if(premium_limit>0){
            $("#table_body_premium").children("tr:last-child").remove();
            premium_limit--;
        }
    }

    function premiumTR(data) {
        var id = data['id'];
        var html ='';
        html+='<tr id="premium_'+id+'">';
        html +='<td style="width: 20%"><input type="text" class="form-control" name="premium['+id+'][id]" value="'+id+'"></td>';
        var arr = '<?php echo json_encode($userGroup3);?>';
        arr = JSON.parse(arr);
        html +='<td><select class="form-control" name="premium['+id+'][gid]">';
        for(let i in arr){
            var tStr = "";
            if(i == data['gid']){
                tStr = "selected";
            }
            html += '<option '+tStr+' value="'+i+'">'+arr[i]+'</option>';
        }
        html +='</select></td>';
        html +='</tr>';
        return html;
    }

    function getTrafficPermitBetHtml(n) {
        var html = '';
        html +='<div aria-hidden="true">';
        html +='<div class="form-group">';
        html +='<label class="col-sm-1 control-label">经验倍率:</label><div class="col-sm-1"><input type="number" onchange="checkTrafficPermitBet(this,this.value)" name="trafficPermitBet" value="'+n+'" class="form-control"></div>';
        html +='</div>';
        html+='</div>';
        return html;
    }

    function checkTrafficPermitBet(obj,val) {
        if(val > 5 || val < 2){
            alert("倍率范围：2-5");
            $(obj).val(2);
        }
    }

    //********************** 2 选 1 礼包 *******************/
    function ChooseOne() {
        var html = '';
        html +='<div class="form-group">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">商品</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>商品ID</th><th>商品价格</th><th>商品SKU</th><th>折扣（显示1-当前值）</th><th>奖励</th><th>操作</th></tr></thead>' ;
        html +='<tbody id="table_body_ChooseOne">';
        html +='</tbody></table></div>';
        return html;
    }

    function addChooseOneBtn(n) {
        chooseOne++
        var gid      = n == 1 ? 1810 : 1811;
        var sku      = n == 1 ? "com.unioncity.crazycoin.0.99" : "com.unioncity.crazycoin.2.99";
        var price    = n == 1 ? 0.99 : 2.99;
        var discount = n == 1 ? 1 : 1;
        var data ={"gid":gid,"gsku":sku,"gprice":price,"gdiscount":discount};
        $("#table_body_ChooseOne").append(ChooseOneTR(data));
    }

    //奖励阶段行数据html
    function ChooseOneTR(data){
        var prize = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var prize_show_arr = JSON.parse(prize);
        prize = escape(prize);
        var html ='';
        html+='<tr id="rewardInfo_'+chooseOne+'">';
        html +='<td><input readonly type="text" class="form-control" name="chooseOne['+chooseOne+'][gid]"    value="'+data['gid']+'"></td>';
        html +='<td><input type="text" class="form-control" name="chooseOne['+chooseOne+'][gprice]" value="'+data['gprice']+'"></td>';
        html +='<td><input type="text" class="form-control" name="chooseOne['+chooseOne+'][gsku]"   value="'+data['gsku']+'"></td>';
        html +='<td><input type="text" class="form-control" name="chooseOne['+chooseOne+'][gdiscount]"   value="'+data['gdiscount']+'"></td>';
        html +='<td class="chooseOnePrize_'+chooseOne+'">';
        if(prize_show_arr.length>0){
            for(var j=0;j<prize_show_arr.length;j++){
                html+= chestPropsHtml(prize_show_arr[j]);
            }
        }
        html+='</td>';
        html +='<input type="hidden" name="chooseOne['+chooseOne+'][prize]" value="'+prize+'">';
        html +='<td><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+chooseOne+',7)">奖励配置</button></td>';
        html +='</tr>';
        return html;
    }

    //********************** 基金活动 *******************/
    function Fund() {
        var html = '';
        html +='<div class="form-group">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">商品</h5></div>';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>天数</th><th>奖励</th><th>操作</th></tr></thead>' ;
        html +='<tbody id="table_body_Fund">';
        html +='</tbody></table></div>';
        return html;
    }

    function FundPriceGroupHtml(data){
        html = '<div class="col-sm-12""><div class="form-group"><div class="col-sm-4 col-sm-offset-2">';
        html += '<botton class="btn btn-primary" onclick="addFundPrice()">添加</botton>';
        html += '<botton class="btn btn-danger del-tr" onclick="delFundPrice()">删除</botton></div></div></div>';
	    $("#reward_info").prepend(html);
        var html = '';
        html += '<div id="fundProducts">';
        if(data == undefined){
            html += FundPriceHtml({}, 0);
        } else {
            for(var i in data){
                for(var j in data[i].gid){
                    scoreCGGidArr.push(data[i].gid[j]);
                }
                html += FundPriceHtml(data[i], parseInt(i));
            }
        }
        html += '</div>';
	    $("#reward_info").prepend(html);
    }

    function addFundPrice() {
        $("#fundProducts").append(FundPriceHtml({}, $(".fundGroup").length));
    }

    function delFundPrice() {
        $("#fundProducts").children(".fundGroup:last-child").remove();
    }

    //基金发恩组收购,续购,补签价格
    function FundPriceHtml(data, index) {
        var html ='';
        var str = '商品分组'+(index+1);
        var group = (data === undefined || data.gid === undefined) ? {} : data.gid;
        var d = (data === undefined || data.data === undefined) ? {} : data.data;

        html +='<div class="fundGroup">';
        html +='<div class="form-group">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">'+str+'</h5></div>';
        html +='</div>';

        html +='<div class="ibox-content">';
        html += '<div class="form-group">';
        html += ChooseRFMGroup({"gid": group}, index, 0); //rfm分组
        html += '</div>';

        var products = {1812: "首购", 1813: "续购", 1832: "补签"};
        for(var i in products) {
            var price = (d[i] === undefined || d[i].gprice === undefined)?'':d[i].gprice;
            var sku = (d[i] === undefined || d[i].gsku === undefined)?'':d[i].gsku;
            var discount = (d[i] === undefined || d[i].gdiscount === undefined)?'':d[i].gdiscount;
            html +='<div class="form-group">';
            html +='<label class="col-sm-1 control-label m-b">'+products[i]+'价格</label>';
            html +='<div class="col-sm-2">';
            html +='<input type="text" class="form-control" name="reward_conf['+index+']['+i+'][gprice]" value="'+price+'"></div>';
            html += '<label class="col-sm-1 control-label m-b">'+products[i]+'sku</label><div class="col-sm-3">';
            html +='<input type="text" class="form-control" name="reward_conf['+index+']['+i+'][gsku]" value="'+sku+'"></div>';
            html += '<label class="col-sm-2 control-label m-b">'+products[i]+'折扣（显示1-当前值）</label><div class="col-sm-2">';
            html +='<input type="text" class="form-control" name="reward_conf['+index+']['+i+'][gdiscount]" value="'+discount+'"></div>';
            html +='</div>';
        }
        html += '</div>';
        return html;
    }

    function FundHtml(data) {
        for(var i=0;i<data.length;i++){
            $("#table_body_Fund").append(FundTR(data[i]));
        }
    }

    //奖励阶段行数据html
    function FundTR(data){
        var id    = data['id'];
        var prize = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var prize_show_arr = JSON.parse(prize);
        prize = escape(prize);
        var html ='';
        html+='<tr id="rewardInfo_'+id+'">';
        html +='<td style="width: 10%"><input readonly type="text" class="form-control" name="fund['+id+'][id]" value="'+data['id']+'"></td>';
        html +='<td class="fundPrize_'+id+'">';
        if(prize_show_arr.length>0){
            for(var j=0;j<prize_show_arr.length;j++){
                html+= chestPropsHtml(prize_show_arr[j]);
            }
        }
        html+='</td>';
        html +='<input type="hidden" name="fund['+id+'][prize]" value="'+prize+'">';
        html +='<td style="width: 10%"><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+id+',8)">奖励配置</button></td>';
        html +='</tr>';
        return html;
    }
    //--------------四选一 star------------------
    var easterGiftStage=0;
    function addEasterGift(){
        easterGiftStage++;
        var d = {"stage":easterGiftStage,"bet":1,"prize":1.9,"sku":"com.unioncity.crazycoin.1.99"};
        $("#table_body").append(easterGiftLine(d));
    }

    function delEasterGift() {
        if(easterGiftStage>1){
            $("#table_body").children("tr:last-child").remove();
            easterGiftStage--;
        }
    }
    //复活礼包table
    function easterGiftTable(data){
        var html ='';
        html+='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">复活礼包配置</h5></div>';
        html +='<table class="table table-bordered scoreCGRewardTable" id="reward_table">';
        html +='<thead><tr><td colspan="4"><div class="form-group"></div></thead>';
        html +='<tr><th>阶段</th><th>倍率</th><th>价格/sku</th></tr>';
        html +='<tbody id="table_body">';
        $.each(data,function (k,v) {
           html+=easterGiftLine(v);
            easterGiftStage++;
        });
        html +='</tbody><tr><td colspan="4"><div class="text-center"><botton class="btn btn-primary" onclick="addEasterGift()">添加</botton><botton class="btn btn-danger del-tr" onclick="delEasterGift()">删除</botton>';
        html +='</div></td></tr></table>';
        return html;
    }
    //复活礼包行tr
    function easterGiftLine(data){

        var html = '';
        html += '<tr id="rewardInfo_' + data['stage'] + '">';
        html += '<td><input type="text" class="form-control" readonly name="extraData[' + data['stage'] + '][stage]" value="' + data['stage'] + '"></td>';
        html += '<td><input type="text" class="form-control" name="extraData[' + data['stage'] + '][bet]" value="' + data['bet'] + '"></td>';
        html += '<td>价格:<select class="form-control m-b selPrice" name="extraData[' + data['stage'] + '][price]">';
        $.each(goodSku, function (k, v) {
            if (data["price"] == v["price"]) {
                sel = "selected";
            } else {
                sel = "";
            }
            html += '<option value="' + v["price"] + '" ' + sel + '>' + v["price"] + '</option>';
        });
        html +='</select>sku:<input class="form-control t_sku" type="text" name="extraData['+data['stage']+'][sku]" value="'+data['sku']+'"></td></td>';
        html +="</tr>";
        return html;
    }
    //-----------------end------------------------

    //********************** 好友召回活动 *******************/
    function callBackCfg(data){
        var html='';
        html +='<div class="form-group"><label class="col-sm-2 control-label m-b">召回固定积分<span style="color: #ff0000;">注：必填</span></label><div class="col-sm-3 input-group">';
        html +='<input type="text" style="text-align: center" class="form-control" name="extra_reward[score]" value="'+data.score+'">';
        html +='</div></div>';
        html +='<div class="form-group"><label class="col-sm-2 control-label m-b">被召回可任务天数<span style="color: #ff0000;">注：默认配置需要>=1天,且小于结束时间-领奖时间(天数)</span></label><div class="col-sm-3 input-group">';
        html +='<input type="text" style="text-align: center" class="form-control" name="extra_reward[days]" value="'+data.days+'">';
        html +='</div></div>';
        return html;
    }

    //创建表格式html
    function callbackCondTb(){
        var html ='';
        var cols = 4;
        index = $('#callback_cond_body').find('table').length+1;
        html +='<table class="table table-bordered spinRankTable">';
        html +='<tbody id="callback_cond_body">';
        html +='</tbody><tr><td colspan="'+cols+'"><div class="text-center"><botton class="btn btn-primary" onclick="addCallbackCondNum('+index+')">添加</botton><botton class="btn btn-danger del-tr" onclick="delCallbackCondNum()">删除</botton>';
        html +='</div></td></tr></table></div>';
        return html;
    }

    function addCallbackCondNum(index = 0) {
        var condition = {
            level: {'start':'', 'end':''}, //等级区间
            lastDays: 1, //不在线时间范围
            score: 0, //召回成功一个奖励积分数
            gid: [], //已选的rfm分组
            extraScore:2,
        };
        index = $('#callback_cond_body').find('table.spinRankTable').length+1;
        var html = friendCallbackCond(condition, index);
        $('#callback_cond_body').append(html);
    }

    function delCallbackCondNum(index) {
        index = $('#callback_cond_body').find('table').length;
        if(index > 0){
            $('#callback_cond_body').children("table.spinRankTable:last-child").remove();
        }
    }

    //可找回玩家条件赛选
    function friendCallbackCond(data, index=0) {
        data['lastDays'] = data['lastDays']==undefined?1:data['lastDays'];
        var html ='';
        var str = '对象分组'+index;
        html +='<table class="table table-bordered spinRankTable">';

        html +='<thead><tr><td colspan="4">';
        html +='<div class="form-group" id="callbackCond_table">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">'+str+'</h5></div>';
        html +='</div></div></td></tr>';
        html += ChooseRFMGroup(data, index); //rfm分组
        html +='<thead><tr><td colspan="4">';
        html +='<input type="hidden"  class="form-control" name="cond['+index+'][id]" value="'+index+'">';
        html +='<div class="form-group"><label class="col-sm-2 control-label m-b">等级区间 <span style="color: #ff0000;">注:必填</span></label><div class="col-sm-3 input-group">';
        html +='<input type="text" style="text-align: center" class="form-control" name="cond['+index+'][level][start]" value="'+data.level['start']+'">';
        html +='<span class="input-group-addon">-</span>';
        html +='<input type="text" style="text-align: center" class="form-control" name="cond['+index+'][level][end]" value="'+data.level['end']+'">';
        html +='</div></div></td></tr>';

        html +='<tr><td colspan="4">';
        html +='<div class="form-group"><label class="col-sm-2 control-label m-b">不在线天数 <span style="color: #ff0000;">注：默认配置需要>=1天</span></label><div class="col-sm-3 input-group">';
        html +='<input type="text" style="text-align: center" class="form-control" name="cond['+index+'][lastDays]" value="'+data['lastDays']+'"></div>';
        //<label class="col-sm-2 control-label m-b" style="color:red">注：默认配置需要>=1天</label>

        // html +='<tr><td colspan="4">';
        // html +='<div class="form-group"><label class="col-sm-2 control-label m-b">召回固定积分</label><div class="col-sm-3 input-group">';
        // html +='<input type="text" style="text-align: center" class="form-control" name="cond['+index+'][score]" value="'+data.score+'">';
        // html +='</div></div></td></tr>';

        html +='<tr><td colspan="4">';
        html +='<div class="form-group"><label class="col-sm-2 control-label m-b">召回额外积分</label><div class="col-sm-3 input-group">';
        html +='<input type="text" style="text-align: center" class="form-control" name="cond['+index+'][extraScore]" value="'+data.extraScore+'">';
        html +='</div></div></td></tr></thead>';
        html +='<tbody>';
        html += callbackCondSignTb(index);
        html +='</tbody></div></td></tr></table>';
        return html;
    }

    function callbackCondSignTb(index = 0){
        var html ='';
        html +='<tr><td colspan="4">';
        html +='<div class="col-sm-12"><div class="form-group">';
        html +='<table class="table table-bordered">';
        html +='<thead><tr><th>编号</th><th>累计签到天数</th><th>对应积分</th></thead>';
        html +='<tbody id="table_callback_sign_cond_'+index+'">';
        html +='</tbody><tr><td colspan="6"><div class="text-center"><botton class="btn btn-primary" onclick="addCallbackSign('+index+')">添加</botton><botton class="btn btn-danger del-tr" onclick="delCallbackSign('+index+')">删除</botton>';
        html +='</div></td></tr></table></div>';
        html += '</td></tr>';
        return html;
    }

    //累计签到天数积分奖励配置
    function callbackSignTR(data, index) {
        var day = data['day'] == undefined?1:data['day'];
        var score = data['score'] == undefined?1:data['score'];
        var stage = $('#table_callback_sign_cond_'+index).find('tr').length+1;
        var html ='';
        html+='<tr>';
        html +='<td style="width: 5%;"><input type="text" class="form-control" name="cond['+index+'][sign]['+stage+'][id]" value="'+stage+'"></td>';
        html +='</select></td>';
        html +='<td><input type="text" class="form-control" name="cond['+index+'][sign]['+stage+'][day]" value="'+day+'"></td>';
        html +='<td><input type="text" class="form-control" name="cond['+index+'][sign]['+stage+'][score]" value="'+score+'"></td>';
        html +='</tr>';
        $('#table_callback_sign_cond_'+index).append(html);
    }

    //添加召回活动任务列
    function addCallbackSign(index = 0) {
        var stage = $('#table_callback_sign_cond_'+index).find('tr').length+1;
        var html ='';
        html+='<tr>';
        html +='<td style="width: 5%;"><input type="text" class="form-control" name="cond['+index+'][sign]['+stage+'][id]" value="'+stage+'"></td>';
        html +='</select></td>';
        html +='<td><input type="text" class="form-control" name="cond['+index+'][sign]['+stage+'][day]" value="1"></td>';
        html +='<td><input type="text" class="form-control" name="cond['+index+'][sign]['+stage+'][score]" value="1"></td>';
        html +='</tr>';
        $('#table_callback_sign_cond_'+index).append(html);
    }

    //删除召回活动每日签到列表
    function delCallbackSign(index = 0) {
        var length = $('#table_callback_sign_cond_'+index).find('tr').length;
        if(length > 0){
            $('#table_callback_sign_cond_'+index).children("tr:last-child").remove();
        }
    }

    //删除召回任务列
    function delFriendCallbackTask() {
        if(callbackTask_limit>0){
            $("#callback_task").children("tr:last-child").remove();
            callbackTask_limit--;
        }
    }

    function friendCallbackTaskTb() {
        var html ='';
        html +='<div class="col-sm-12"><div class="form-group">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">活动任务配置<span style="color: #ff0000;">注：每个类型只能配一个</span></h5></div>';
        html +='<table class="table table-bordered">';
        //html +='<thead><tr><th>任务ID</th><th>任务类型</th><th>任务次数</th><th>任务参数</th><th>可获得积分</th></thead>';
        html +='<thead><tr><th>任务ID</th><th>任务类型</th><th>任务次数/数量</th><th>可获得积分</th></thead>';
        html +='<tbody id="callback_task">';
        html +='</tbody><tr><td colspan="6"><div class="text-center"><botton class="btn btn-primary" onclick="addFriendCallbackTask()">添加</botton><botton class="btn btn-danger del-tr" onclick="delFriendCallbackTask()">删除</botton>';
        html +='</div></td></tr></table></div>';
        return html;
    }

    //添加召回玩家任务列表
    function addFriendCallbackTask() {
        callbackTask_limit++;
        var data ={"id":callbackTask_limit,"score":1,"num":1};
        var html = callbackTaskTR(data);
        $("#callback_task").append(html);
    }

    //添加召回活动任务列
    function callbackTaskTR(data) {
        var stage = data['id'];
        var html ='';
        html+='<tr id="treasureInfo_'+stage+'">';
        html +='<td style="width: 5%;"><input type="text" class="form-control" name="callback_task['+stage+'][id]" value="'+stage+'"></td>';
        var taskTypeArr = {1:"偷金币",2:"攻击岛",3:"消耗体力",4:"签到",5:"分享",6:"fb邀请",7:"召回分享",8:"建造完成",9:"赠送体力",10:"赠送金币",11:"赠送卡片"};
        html +='<td style="width: 15%;"><select class="form-control seltask" name="callback_task['+stage+'][type]">';
        for(var j=1;j<=11;j++){
            var tStr = "";
            if(j == data['type']){
                tStr = "selected";
            }
            html += '<option '+tStr+' value="'+j+'">'+taskTypeArr[j]+'</option>';
        }
        html +='</select></td>';
        html +='<td><input type="text" class="form-control" name="callback_task['+stage+'][num]" value="'+data['num']+'"></td>';
        html +='<td><input type="text" class="form-control" name="callback_task['+stage+'][score]" value="'+data['score']+'"></td>';
        html +='</tr>';
        return html;
    }

    //删除召回任务列
    function delFriendCallbackTask() {
        if(callbackTask_limit>0){
            $("#callback_task").children("tr:last-child").remove();
            callbackTask_limit--;
        }
    }

    //奖励阶段行数据html
    function callbackRewardTableTR(data){
        // console.log(data);
        var stage = data['stage'];
        var prize = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var prize_show_arr = JSON.parse(prize);
        prize = escape(prize);
        var html ='';
        html+='<tr id="rewardInfo_'+data['stage']+'">';
        html +='<td><input type="text" class="form-control" name="reward['+data['stage']+'][stage]" value="'+data['stage']+'"></td>';
        html +='<td><input type="text" class="form-control" name="reward['+data['stage']+'][stepnum]" value="'+data['stepnum']+'"></td>';

        html +='<td class="showStagePrize_'+data['stage']+'">';
        if(prize_show_arr.length>0){
            for(var j=0;j<prize_show_arr.length;j++){
                html+= chestPropsHtml(prize_show_arr[j]);
            }
        }
        html+='</td>';
        html +='<input type="hidden" name="reward['+data['stage']+'][prize]" value="'+prize+'">';
        html +='<td><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+',1)">奖励配置</button></td>';// data-toggle="modal"
        html +='</tr>';
        return html;
    }
    //-----------------end------------------------
    //---------------小玩法收集 star---------------
    var collectChangeItem=[{"name":"地雷","value":1}];//{"name":"金矿钩子","value":2}
    function collectChangeSel(data){
        console.log(collectChangeItem.length,collectChangeItem[1]);
        var html='';
        html +='<div class="form-group" ><label class="col-sm-2 control-label m-b">收集物:</label><div class="col-sm-3 input-group">';
        html +='<select class="form-control" name="reward_conf[item]">';
        for(var j=0;j<collectChangeItem.length;j++){
            var tStr = "";
            if(collectChangeItem[j]['value'] == data['item']){
                tStr = "selected";
            }
            html += '<option '+tStr+' value="'+collectChangeItem[j]['value']+'">'+collectChangeItem[j]['name']+'</option>';
        }
        html +='</select></div></div>';
        return html;
    }
    //----------------- end ---------------------
</script>
<script>
    //======================超级气球==star========================
    //添加气球bet_table
    $(document).on('click', '#addBalloonBetBtn', function(e) {
        betStage++;
        var d ={"star":0,"end":0};
        html2 = balloonBetTable(betStage,d);
        $("#balloon_table").append(html2);
    });
    //删除气球bet_table
    $(document).on('click', '#delBalloonBetBtn', function(e) {
        if(betStage>1){
            $("#balloon_table").children(".balloonBetTable:last-child").remove();
            betStage--;
        }
    });
    function addBalloonTR(index){
        if(!balloon_bet_limit[index]){
            balloon_bet_limit[index] =1;
        }else{
            balloon_bet_limit[index]++;
        }
        console.log('分组：阶段-',index,balloon_bet_limit[index]);
        var data ={"stage":balloon_bet_limit[index],"weight":100,"imgType":1};
        var html = balloonTableTRHtml(index,data);
        $("#table_body3_"+index).append(html);
    }
    //删除排行奖励行
    function delBalloonTR(index){
        if(balloon_bet_limit[index]>0){
            $("#table_body3_"+index).children("tr:last-child").remove();
            balloon_bet_limit[index]--;
        }
    }
    function setBalloonStyleHtml(data) {
        var html ='';
        html +='<div class="form-group"><label class="col-sm-2 control-label">移动方式：</label>';
        html +='<div class="col-sm-4"><select class="form-control m-b" name="moveType">';
        var arr={1:"向上飘",2:"向下落"};
        for(let i in arr){
            var tStr = "";
            if(i == data['moveType']){
                tStr = "selected";
            }
            html += '<option '+tStr+' value="'+i+'">'+arr[i]+'</option>';
        }
        html +='</select></div></div>';
        html +='<div class="form-group"><label class="col-sm-2 control-label">移动速度：</label>';
        html +='<div class="col-sm-4"><input type="text"  name="speed" value="'+data['speed']+'" class="form-control"></div>';
        html +='</div>';
        html +='<div class="form-group"><label class="col-sm-2 control-label">转到金币出现概率：</label>';
        html +='<div class="col-sm-4"><input type="text"  name="showPv" value="'+data['showPv']+'" class="form-control"></div>';
        html +='</div>';
        html +='<div class="form-group"><label class="col-sm-2 control-label">气球产出权重：</label>';
        html +='<label class="col-xs-1 control-label">1个:</label><div class="col-sm-1"><input type="text"  name="outPut[1]" value="'+data['outPut'][1]+'" class="form-control"></div>';
        html +='<label class="col-xs-1 control-label">2-3个:</label><div class="col-sm-1"><input type="text"  name="outPut[2]" value="'+data['outPut'][2]+'" class="form-control"></div>';
        html +='<label class="col-xs-1 control-label">4-6个:</label><div class="col-sm-1"><input type="text"  name="outPut[3]" value="'+data['outPut'][3]+'" class="form-control"></div>';
        html +='</div>';
        return html;
    }
    function balloonTable() {
        var html ='';
        html +='<hr style=" height:2px;border:none;border-top:2px dotted #0b0;"><div class="form-group" id="balloon_table">';
        html +='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">气球bet区间掉落配置</h5></div>';

        html +='</div>';
        html +='<div class="form-group"><div class="col-sm-4 col-sm-offset-2">';
        html += '<button class="btn btn-primary" id="addBalloonBetBtn" type="button">添加</button>';
        html +='<button class="btn btn-white"   id="delBalloonBetBtn" type="button">删除</button>';
        html +='</div></div><hr style=" height:2px;border:none;border-top:2px dotted #0b0;">';
        return html;
    }
    function balloonBetTable(index,data){
        var html ='';
        html +='<table class="table table-bordered balloonBetTable">';
        html +='<thead><tr><td colspan="5">';
        html +='<div class="form-group"><label class="col-sm-2 control-label m-b">Bet区间 </label><div class="col-sm-3 input-group">';
        html +='<input type="text" style="text-align: center" class="form-control" name="spinStage['+index+'][star]" value="'+data['star']+'">';
        html +='<span class="input-group-addon">-</span>';
        html +='<input type="text" style="text-align: center" class="form-control" name="spinStage['+index+'][end]" value="'+data['end']+'">';
        html +='</div></div></td></tr>';
        html +='<tr><th>stage</th><th>飘落物品</th><th>权重</th><th>奖励</th><th>奖励配置</th></tr></thead>' ;
        html +='<tbody id="table_body3_'+index+'">';

        html +='</tbody><tr><td colspan="5"><div class="text-center"><botton class="btn btn-primary"  onclick="addBalloonTR('+index+')">添加</botton><botton class="btn btn-danger del-tr" onclick="delBalloonTR('+index+')">删除</botton>';
        html +='</div></td></tr></table>';
        return html;
    }
    function balloonTableTRHtml(index,data) {
        var stage = data['stage'];
        var prize = data['prize']!=undefined?JSON.stringify(data['prize']):'[]';
        var prize_show_arr = JSON.parse(prize);
        prize = escape(prize);
        var html ='';
        html+='<tr id="rewardInfo_'+data['stage']+'">';
        html +='<td><input type="text" class="form-control" name="rewardnew['+index+']['+data['stage']+'][stage]" value="'+data['stage']+'"></td>';
        var arr={1:"物品1",2:"物品2",3:"物品3",4:"物品4"};
        html +='<td><select class="form-control" name="rewardnew['+index+']['+data['stage']+'][imgType]">';
        for(let i in arr){
            var tStr = "";
            if(i == data['imgType']){
                tStr = "selected";
            }
            html += '<option '+tStr+' value="'+i+'">'+arr[i]+'</option>';
        }
        html +='</select></td>';
        html +='<td><input type="text" class="form-control" name="rewardnew['+index+']['+data['stage']+'][weight]" value="'+data['weight']+'"></td>';
        html +='<td class="showStagePrize_'+index+'_'+data['stage']+'">';
        if(prize_show_arr.length>0){
            for(var j=0;j<prize_show_arr.length;j++){
                html+= chestPropsHtml(prize_show_arr[j]);
            }
        }
        html+='</td>';
        html +='<input type="hidden" name="rewardnew['+index+']['+data['stage']+'][prize]" value="'+prize+'">';
        html +='<td><button type="button" class="btn btn-outline btn-success" onclick="setPrize('+stage+',1,'+index+')">奖励配置</button></td>';// data-toggle="modal"
        html +='</tr>';

        return html;
    }
    //========================= end ==============================
</script>
<script>
    var commonLineTitles={};
    var commonLineNum =0;
    function addCommonLine() {
        var html='';
        var d;
        commonLineNum++;
        if(act_type=='easter_egg'){
            d = {"id":commonLineNum,"limit":commonLineNum,"bet":1,"ce":1};
        }else if(act_type=='treasure'){
            d = {"id":commonLineNum,"pro":1,"fix":1,};
        }
        html +=commonLine(d);
        $('#commonLine').append(html);
    }
    function delCommonLine() {
        if(commonLineNum>1){
            $("#commonLine").children(".row")[commonLineNum-1].remove();
            commonLineNum--;
        }
    }
    function commonInput(data) {
        var html='';
        html += '<div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;"><div class="form-group" >';
        var zs ='';
        if(act_type=='speed_spins'){
            zs ='<span style="color: #ff0000;">*(只能取2,3,4,5)</span>';
        }
        $.each(commonLineTitles,function(key,val) {
            html += '<label class="col-sm-2 control-label">'+val['tname']+zs+'</label><div class="col-sm-1"><input type="text" class="form-control"  name="reward_conf['+val['vname']+']" value="' + data[val['vname']] + '"></div>';
        });
        html += '</div></div>';
        return html;
    }
    function commonTable(title) {
        var html='';
        html+='<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">'+title+'</h5></div>';
        // html+='<div class="col-sm-8"></div>';
        // html+='</div>';
        html+='<div class="text-center" id="commonLine">';
        html+='</div><botton class="btn btn-primary" id="addCommonLine" onclick="addCommonLine()">添加</botton><botton class="btn btn-danger del-tr" onclick="delCommonLine()">删除</botton></div>';
        // html +='<hr style=" height:2px;border:none;border-top:2px dotted #0b0;"><div class="form-group" id="balloon_table">';
        return html;
    }
    function  commonLine(data) {
        var html='';
        var i = data["id"];
        html += '<div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;"><div class="form-group" >';
        html += '<input type="hidden" class="form-control" readonly name="common_conf['+i+'][id]" value="'+data["id"]+'">';
        $.each(commonLineTitles,function(key,val) {
            html += '<label class="col-sm-1 control-label">'+val['tname']+'</label><div class="col-sm-1"><input type="text" class="form-control"  name="common_conf[' + i + ']['+val['vname']+']" value="' + data[val['vname']] + '"></div>';
        });
        html += '</div></div>';
        return html;
    }
    function commIboxTable(title) {
       return '<div class="ibox-title" style="border-top: 0;"><h5 style="font-weight: bold">'+title+'</h5></div>';
    }
</script>
<script>
    var prize_num = 0;//奖品行数
    var prize_stage = 0;//奖品所属奖励类id
    var prize_type =0;//奖品所属奖励类
    //保持进度行奖品配置
    //奖品行html

    function chestPropsHtml(data) {
        if(data['type'] == 23){
            var dv = ' => '+reward_type[23].data[data['num']];
            var dc = 'btn-primary'
        }else if($.inArray(parseInt(data['type']),actPropArr)!= -1){
            var dv = "分钟";
            var dc = "btn-danger";
        }else{
            if(data['type'] == 13){
                var dv = data['rtype']==1?' 固定金卡':(data['rtype']==2?'随机金卡':'固定金卡反面');
            }else{
                var dv = data['rtype']==1?'个':'倍';
            }
            var dc = data['rtype']==1?'btn-primary':'btn-danger';
        }
        if("is_ts" in data){
            data['is_ts']==1?dv +='(限)':true;
            data['is_ts']==1?dc ='btn-warning':true;
        }
        if(chestPropsArr.indexOf(data['type'] * 1) >= 0){
            if('skin' in data){
                var skin = data['skin'];
            }else{
                var defArr = {19:1};
                var skin   = defArr[data['type']]
            }
            var html ='<span class="btn btn-outline '+dc+'">'+chestArr[skin]+':'+data['num']+dv+'</span>';
        }else{
            var html ='<span class="btn btn-outline '+dc+'">'+reward_type_arr[data['type']]['name']+':'+data['num']+dv+'</span>';
        }
        return html;
    }
    function prizeInfoTR(data,index=0){
        var w ='';
        if(index>0){
            var w = 'style="width: 100%"';
        }
        var html='';
        var sel2 ='';
        var sel3 ='';
        var sel4='';
        var sel5='';
        html+='<tr id="prize_'+data["prize"]['id']+'">';
        html+='<input type="hidden" name="id" value="'+data["prize"]['id']+'">';
        html +='<td><select class="form-control" onchange="prizeInfoTRChange(this,this.value)" name="type">';//prize['+data['prize']['id']+']
        $.each(reward_type,function(k,v){
            if(act_type == "daily_chest" && v.id != 19){
                return true;
            }
            if(data["prize"]['type']==v["id"]){
                sel = "selected";
            }else{
                sel = "";
            }
            html +='<option value="'+v["id"]+'" '+sel+'>'+v["name"]+'</option>';
        });
        html +='</select></td>';
        html +='<td><select class="form-control" name="rtype">';
        if(data["prize"]['rtype']==1){
            sel2 = "selected";
        }else if(data["prize"]['rtype']==2){
            sel3 = "selected";
        }else{
            sel4 = "selected";
        }
        if(data["prize"]['type']==13){
            html +='<option value="1" '+sel2+'>固定金卡</option>';
            html +='<option value="2" '+sel3+'>随机金卡</option>';
            if(act_type=='rank'){
                html +='<option value="3" '+sel4+'>固定金卡反面</option>';
            }
        }else{
            html +='<option value="1" '+sel2+'>固定值</option>';
            html +='<option value="2" '+sel3+'>等级取值</option>';
        }
        html +='</select></td>';
        if(data["prize"]['type'] == 23){
            html +='<td><select class="form-control" name="num">';
            $.each(reward_type[23].data,function(k,v){
                if(data["prize"]['num']==k){
                    sel5 = "selected";
                }else{
                    sel4 = "";
                }
                html +='<option value="'+k+'" '+sel4+'>'+v+'</option>';
            });
            html +='</select></td>';
        }else{
            html +='<td><input type="text" class="form-control" name="num" value="'+data["prize"]['num']+'" '+w+'></td>';
        }
        if((act_type=='collect' || act_type=='collect_only'|| act_type=='super_collect')&&index>0){
            html +='<td><select class="form-control" name="is_ts">';
            if(data["prize"]['is_ts']==1){
                sel5 = "selected";
            }else{
                sel4 = "selected";
            }
            html +='<option value="0" '+sel4+'>否</option>';
            html +='<option value="1" '+sel5+'>是</option>';
            html +='</select></td>';
            html +='<td><input type="text" class="form-control" name="ts" value="'+data["prize"]['ts']+'" '+w+'></td>';
        }else if(act_type=='super_balloon'){
            // html +='<td><input type="text" class="form-control" name="weight" value="'+data["prize"]['weight']+'" '+w+'></td>';
        }
        html +='<td><select class="form-control" name="skin">';

        var skinArr = {}
        if(chestPropsArr.indexOf(data["prize"]['type'] * 1) >= 0 || act_type == "daily_chest"){
            skinArr = chestArr
        }
        $.each(skinArr,function(k,v){
            if(data["prize"]['skin']==k){
                var sel = "selected";
            }else{
                var sel = "";
            }
            html +='<option '+sel+' value="'+k+'">'+v+'</option>';
        });
        html +='</select></td>';

        html +='</tr>';
        return html;
    }

    function prizeInfoTRChange(obj , value) {
        var selObj = $(obj).parent().next().children();
        selObj[0].options.length=0;
        if(value == 14){
            $(selObj).append('<option value="1" selected>固定值</option>');
            $(selObj).append('<option value="2">等级取值</option>');
        }else if(value == 13){
            $(selObj).append('<option value="1" selected>固定金卡</option>');
            $(selObj).append('<option value="2">随机金卡</option>');
            if(act_type=='rank'){
                $(selObj).append('<option value="3">固定金卡反面</option>');
            }
        }else{
            $(selObj).append('<option value="1" selected>固定值</option>');
        }
        var selObj2 = $(obj).parent().next().next();
        if(value == 23){
            var html ='<select class="form-control" name="num">';
            $.each(reward_type[23].data,function(k,v){
                html +='<option value="'+k+'">'+v+'</option>';
            });
            html +='</select>';
            selObj2.html(html)
        }else if(chestPropsArr.indexOf(value * 1) >= 0){
            value = value * 1;
            var defArr = {19:1};
            var def    = defArr[value]
            var html ='<select class="form-control" name="skin">';
            $.each(chestArr,function(k,v){
                var sel = "";
                if(def == k){
                    sel = "selected";
                }
                html +='<option '+sel+' value="'+k+'">'+v+'</option>';
            });
            html +='</select>';
            $(obj).parent().parent().children("td:last-child").html(html)
        }else{
            selObj2.html('<input type="text" class="form-control" name="num" value="1">')
            $(obj).parent().parent().children("td:last-child").html('<select class="form-control" name="skin"></select>')
        }
    }
    function scheduleSubmit() {
        var str = '';
        // console.log(prize_num);
        for(var i=1;i<=prize_num;i++){
            data = serializeForm("prize_"+i);
            // console.log(data);
            str +=data+",";
        }
        str="["+str.slice(0,str.length-1)+"]";

        var prize_show_arr = JSON.parse(str);
        var htmls = '';
        for(var j=0;j<prize_show_arr.length;j++){
            res = propSelVersion(prize_show_arr[j]['type']);
            if(!res){
                return false;
            }
            if(prize_show_arr[j]['num']<1){
                alert('数量必须大于1');
                return false;
            }
            console.log('道具类型:',prize_show_arr[j]['type']);
            if(prize_show_arr[j]['rtype']==2){
                if(prize_show_arr[j]['type']==14&&prize_type==2&&act_type=='rank'){
                    alert('排名奖励金币只能配固定金币值');
                    return false;
                }else if(prize_show_arr[j]['type']!=14&&prize_show_arr[j]['type']!=13){
                    alert('只有金币能够配等级取倍数');
                    return false;
                }else if(prize_show_arr[j]['num']>100){
                    var ret =window.confirm('当前倍率取值超过100倍,确定这么操作么');
                    if(!ret){
                        return false;
                    }
                }
            }
            if($.inArray(parseInt(prize_show_arr[j]['type']),[1,2,3,4.10,11,12,13,18,19,20,21,29,30])!= -1&&prize_show_arr[j]['num']>1){
                alert('宝箱,金卡等只支持一条一个');
                return false;
            }
            if(parseInt(prize_show_arr[j]['type'])==13){
                alert('金卡配置需谨慎操作,看清楚再配');
                if($.inArray(act_type,["rank","accumulated_pay","treasure"])){
                    alert('只有排行榜,累冲,宝藏,能配金卡');
                    return false;
                }
            }
            htmls += chestPropsHtml(prize_show_arr[j]);
        }

        str = escape(str);
        if(this_index>0){
            if(prize_type==1){
                $('input[name="rewardnew['+this_index+']['+prize_stage+'][prize]"]').val(str);
                $(".showStagePrize_"+this_index+'_'+prize_stage).html(htmls);
            }else if(prize_type==2){
                $('input[name="rank['+this_index+']['+prize_stage+'][prize]"]').val(str);
                $(".showRankStagePrize_"+this_index+'_'+prize_stage).html(htmls);
            }else if(prize_type==15){
                $('input[name="reward'+this_index+'['+prize_stage+'][prize]"]').val(str);
                $(".showStagePrize_"+this_index+'_'+prize_stage).html(htmls);
            }

        }else{
            if(prize_type==1){
                $('input[name="reward['+prize_stage+'][prize]"]').val(str);
                $(".showStagePrize_"+prize_stage).html(htmls);
            }else if(prize_type==2){
                // $('input[name="rank['+prize_stage+'][prize]"]').val(str);
                // $(".showRankStagePrize_"+prize_stage).html(htmls);
            }else if(prize_type==3){
                $('input[name="treasure['+prize_stage+'][prize]"]').val(str);
                $(".showTreasurePrize_"+prize_stage).html(htmls);
            }else if(prize_type==4){
                $('input[name="trafficPermit['+prize_stage+'][prize]"]').val(str);
                $(".showTrafficPermitPrize_"+prize_stage).html(htmls);
            }else if(prize_type==5){
                $('input[name="trafficPermit['+prize_stage+'][specialPrize]"]').val(str);
                $(".showTrafficPermitSpecial_"+prize_stage).html(htmls);
            }else if(prize_type==6){
                $('input[name="safeLimit['+prize_stage+'][prize]"]').val(str);
                $(".showSafeLimitPrize_"+prize_stage).html(htmls);
            }else if(prize_type==7){
                $('input[name="chooseOne['+prize_stage+'][prize]"]').val(str);
                $(".chooseOnePrize_"+prize_stage).html(htmls);
            }else if(prize_type==8){
                $('input[name="fund['+prize_stage+'][prize]"]').val(str);
                $(".fundPrize_"+prize_stage).html(htmls);
            }
        }


        closePrize();
        // console.log(JSON.stringify(data));
        // console.log(getElements("prize_from"));
    }
    function closePrize() {
        $('#myModal5').removeClass('in');
        $('#myModal5').hide();
    }

    function setPrize(stage,t,index=0) {
        this_index = index;
        // console.log(stage,t);
        prize_type = t;
        prize_stage = stage;
        var prize =[];
        prize_num =0;
        if(index>0&&(act_type=='collect' || act_type == 'collect_only'|| act_type == 'super_collect')){
            var ht = '<th>奖励类型</th><th>是否固定</th><th>奖励值</th><th>是否是限时奖励</th><th>限时长（分钟）</th><th>皮肤</th>';
            $('#tds').attr('colspan',6);
        }
        // else if(act_type=='super_balloon'){
        //     var ht ='<th>奖励类型</th><th>是否固定</th><th>奖励值</th><th>权重值</th>';
        //     $('#tds').attr('colspan',4);
        // }
        else{
            var ht ='<th>奖励类型</th><th>是否固定</th><th>奖励值</th><th>皮肤</th>';
            $('#tds').attr('colspan',4);
        }
        $('.ths').html(ht);
        $('#myModal5').addClass('in');
        $('#myModal5').show();
        $('#prize_body').children("tr").remove();//清空行
        if(index>0){
            if(t==1){
                var str = $('input[name="rewardnew['+index+']['+prize_stage+'][prize]"]').val();
            }else if(t==2){
                var str = $('input[name="rank['+index+']['+prize_stage+'][prize]"]').val();
            }else if(t == 15){
                var str = $('input[name="reward'+index+'['+prize_stage+'][prize]"]').val();
            }
        }else{
            if(t==1){
                var str = $('input[name="reward['+prize_stage+'][prize]"]').val();
            }else if(t==2){
                // var str = $('input[name="rank['+prize_stage+'][prize]"]').val();
            }else if(t==3){
                var str = $('input[name="treasure['+prize_stage+'][prize]"]').val();
            }else if(t==4){
                var str = $('input[name="trafficPermit['+prize_stage+'][prize]"]').val();
            }else if(t==5){
                var str = $('input[name="trafficPermit['+prize_stage+'][specialPrize]"]').val();
            }else if(t==6){
                var str = $('input[name="safeLimit['+prize_stage+'][prize]"]').val();
            }else if(t==7){
                var str = $('input[name="chooseOne['+prize_stage+'][prize]"]').val();
            }else if(t==8){
                var str = $('input[name="fund['+prize_stage+'][prize]"]').val();
            }else if(t == 15){
                var str = $('input[name="reward'+index+'['+prize_stage+'][prize]"]').val();
            }
        }

        str =  unescape(str);
        console.log(str);
        if(str.length>0&&str!="undefined"){
            prize = JSON.parse(str);
            // console.log(prize);
        }
        if(prize.length>0){
            for(var i=0;i<prize.length;i++){
                prize_num++;
                d = {"stage":stage,"prize":prize[i]};
                // console.log(prize[i]);
                var html = prizeInfoTR(d,index);
                $("#prize_body").append(html);
            }
        }
    }
    function addPrize() {
        stage = prize_type==1?reward_limit:rank_limit;
        prize_num++;
        if((act_type=='collect' || act_type=='collect_only' || act_type=='super_collect' )&&this_index>0){
            var data ={"stage":stage,"prize":{"id":prize_num,"type":0,"num":1,"rtype":1,"ts":0,"ts_type":0,"ts_rtype":1,"ts_num":0}};
        }
        // else if(act_type=='super_balloon'){
        //     var data ={"stage":stage,"prize":{"id":prize_num,"type":0,"num":0,"rtype":1,"weight":1}};
        // }
        else{
            var data ={"stage":stage,"prize":{"id":prize_num,"type":0,"num":1,"rtype":1}};
        }
        console.log(stage);
        var html = prizeInfoTR(data,this_index);
        $("#prize_body").append(html);
    }
    function delPrize() {
        if(prize_num>0){
            // console.log(prize_num);
            $("#prize_body").children("tr:last-child").remove();
            prize_num--;
        }
    }
</script>

<script>
    var date1 = new Date(parseInt('<?php echo $info['start_time']??time();?>')*1000);
    var date2 = new Date(parseInt('<?php echo $info['end_time']??time();?>')*1000);
    var date3 = new Date(parseInt('<?php echo $info['reward_time']??time();?>')*1000);
    var date4 = new Date(parseInt('<?php echo $info['lock_time']??time();?>')*1000);
    laydate.render({
        elem: '#test',
        type: 'datetime',
        range: true
    });
    laydate.render({
        elem: '#test1',
        type: 'datetime',
    });
</script>

<script type="text/javascript">

    //获取指定form中的所有的<input>对象
    function getElements(formId) {
        var form = document.getElementById(formId);
        var elements = new Array();
        var tagElements = form.getElementsByTagName('input');
        var tagElements2 = form.getElementsByTagName('select');
        for (var j = 0; j < tagElements.length; j++){
            elements.push(tagElements[j]);
        }
        for (var i = 0; i < tagElements2.length; i++){
            elements.push(tagElements2[i]);
        }
        return elements;
    }

    //获取单个input中的【name,value】数组
    function inputSelector(element) {
        if (element.checked)
            return [element.name, element.value];
    }

    function input(element) {
        switch (element.type.toLowerCase()) {
            case 'submit':
            case 'hidden':
            case 'password':
            case 'text':
                return [element.name, element.value];
            case 'checkbox':
            case 'select-one':
                return [element.name, element.value];
            case 'radio':
                return inputSelector(element);
        }
        return false;
    }

    //组合URL
    function serializeElement(element) {
        var parameter = input(element);

        if (parameter) {
            var key = encodeURIComponent(parameter[0]);
            if (key.length == 0) return;

            if (parameter[1].constructor != Array)
                parameter[1] = [parameter[1]];

            var values = parameter[1];
            var results ='';
            for (var i=0; i<values.length; i++) {
                results +='"'+parameter[0]+'":"'+encodeURIComponent(values[i])+'",';
                // results[parameter[0]] = encodeURIComponent(values[i]);
            }
            return results;

        }
    }

    //调用方法
    function serializeForm(formId) {
        var elements = getElements(formId);
        // var queryComponents = new Array();
        var queryComponents ='';
        for (var i = 0; i < elements.length; i++) {
            var queryComponent = serializeElement(elements[i]);
            if (queryComponent)
                queryComponents += queryComponent;
            // queryComponents.push(queryComponent);
        }
        queryComponents = queryComponents.slice(0,queryComponents.length-1);
        queryComponents = '{'+queryComponents+'}';
        return queryComponents;
    }

    //判别版本
    function toNum(a){
        var a=a.toString();
        //也可以这样写 var c=a.split(/\./);
        var c=a.split('.');
        var num_place=["","0","00","000","0000"],r=num_place.reverse();
        for (var i=0;i<c.length;i++){
            var len=c[i].length;
            c[i]=r[len]+c[i];
        }
        var res= c.join('');
        return res;
    }
    

</script>
