<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;
    }
    .noshow{
        display: none;
    }
</style>

<div class="container-fluid" style="background-color: #f3f3f4;margin-bottom: 0">
    <div class="row">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <button class="btn btn-primary submitBtn">提交</button>
            </div>
        </div>
    </div>

</div>
<div class="row">
    <div class="col-sm-12">
        <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'];?>配置</a></li>
            </ul>
            <div class="tab-content">
                <form id="form">
                    <div class="greatMemoriesLostDaysWrap" id="greatMemoriesLostDaysWrap_${rewardIdx}" data-idx="${greatMemoriesSSCnt}" style="margin:10px;padding:5px;">
                        <table class="table table-bordered" >
                            <thead>
                            <tr>
                                <th>红包类型</th>
                                <th>红包触发类型</th>
                                <th>过关等级，多个等级用英文逗号,分割</th>
                                <th>开关</th>
                                <th>奖励</th>
                                <th>奖励设置</th>
                            </tr>
                            </thead>
                            <tbody id="redPacketsRewards"> </tbody>
                            <tr>
                                <td colspan="5">
                                    <div class="text-center">
                                        <botton class="btn btn-primary addGreatMemoriesRewardTrBtn" onclick="addGreatMemoriesRewardTr(this)">添加</botton>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </form>
            </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;">
                <!--                <from id="prize_from">-->
                <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>

                    <tr>
                        <td colspan="3" id="tds">
                            <div class="text-center">
                                <botton class="btn btn-primary" id="addPrize" onclick="addPrize()">添加</botton>
                                <botton class="btn btn-danger del-tr" onclick="delPrize()">删除</botton>
                            </div>
                        </td>
                    </tr>
                </table>
                <!--                </from>-->
            </div>
            <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>

<style>
    .prizesSpan{
        text-align: center;
    }
</style>
<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>-->
<!--select2-->
<link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/select2/select2.min.css">
<script src="<?php echo base_url();?>public/js/vendor/select2/select2.full.min.js"></script>
<script>
    let config = JSON.parse('<?php echo json_encode($config);?>');
    let greatMemoriesRewardStages = 0;
    var chestPropsArr = [19];
    var actPropArr = JSON.parse('<?php echo json_encode($actPropsIds);?>');//活动道具id
    var chestArr = JSON.parse('<?php echo json_encode($chestSkin) ?>');
    var skinsArr = JSON.parse('<?php echo json_encode($skinsArr) ?>');
    var typesArray = JSON.parse('<?php echo json_encode($packetTypes) ?>');
    var triggerTypesArray = JSON.parse('<?php echo json_encode($triggerTypes) ?>');
    var statusMap = JSON.parse('<?php echo json_encode($statusMap) ?>');
    console.log(skinsArr)
    var skinsArrKeys = Object.keys(skinsArr)
    var $reward_type = '<?php echo $reward_type;?>';
    var reward_type_str = $reward_type;
    var act_type = '';
    var reward_type_arr = {};
    reward_type =JSON.parse(reward_type_str);//奖励类型
    $.each(reward_type,function(k,v){
        reward_type_arr[k]=v;
    });
    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 select2" style="width: 300px" onchange="prizeInfoTRChange(this,this.value)" name="type">';//prize['+data['prize']['id']+']
        console.log(reward_type)
        $.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  select2" 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 //随机金卡
            ||data["prize"]['type']==48//随机黑金卡
            ||data["prize"]['type']==49//随机限时金卡
            ||data["prize"]['type']==50//随机限时黑金卡
        ){
            html +='<option value="1" '+sel2+'>固定</option>';
            html +='<option value="2" '+sel3+'>随机</option>';
            if(act_type=='rank'||act_type=='rank2'){
                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 select2" 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 select2" name="skin">';

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

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

    //获取单个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 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;
    }
    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 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//随机金卡
            ||value==48//随机黑金卡
            ||value==49//随机限时金卡
            ||value==50//随机限时黑金卡
        ){
            $(selObj).append('<option value="1" selected>固定</option>');
            $(selObj).append('<option value="2">随机</option>');
            if(act_type=='rank'||act_type=='rank2'){
                $(selObj).append('<option value="3">固定金卡反面</option>');
            }
        }else{
            $(selObj).append('<option value="1" selected>固定值</option>');
        }
        var selObj2 = $(obj).parent().next().next();
        value = parseInt(value);
        if(value == 23){
            var html ='<select class="form-control select2" name="num">';
            $.each(reward_type[23].data,function(k,v){
                html +='<option value="'+k+'">'+v+'</option>';
            });
            html +='</select>';
            selObj2.html(html)
        }else if(skinsArrKeys.indexOf(value) >=0 && skinsArr[value]){
            //选择四选一活动道具
            var html ='<select class="form-control select2" name="skin">';
            $.each(skinsArr[value],function(k,v){
                var sel = "";
                html +='<option '+sel+' value="'+k+'">'+v+"(ID："+k+")"+'</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 = '';
        $.each($('#prize_body').find('tr'), function(i, o){
            data = serializeForm($(o).attr('id'));
            str +=data+",";
        })
        str="["+str.slice(0,str.length-1)+"]";

        var prize_show_arr = JSON.parse(str);
        var htmls = '';
        var nums =0;
        if('chooseYouWant' == prize_type){
            prize_show_arr = [prize_show_arr[0]];
            str = JSON.stringify(prize_show_arr)
        }
        for(var j=0;j<prize_show_arr.length;j++){
            if(prize_show_arr[j]['is_ts']==0){
                nums++;
            }
            // if(prize_show_arr[j]['num']<1){
            //     alert('数量必须大于1');
            //     return false;
            // }
            console.log('道具类型:',prize_show_arr[j]['type']);
            htmls += chestPropsHtml(prize_show_arr[j]);
        }
        // console.log(nums,act_type);
        if(nums>1&&act_type=='super_collect'){
            $('input[name="act_version[]"]:checked').each(function(){
                var selVersion = $(this).val();console.log(selVersion);
                if(toNum(selVersion)<toNum("1.9")){
                    alert('只有1.9及之后的版本才支持配两个物品');
                    return false;
                }
            });
        }
        str = escape(str);
        console.log({"prize_type":prize_type,"this_index":this_index,"this_shushuIdx":this_shushuIdx,"prize_stage":prize_stage});

        switch(prize_type){
            case 'setCommonPrize':
                $(prize_stage).parents('.commonStageRewardTr').find('.prizeInput').val(str);
                $(prize_stage).parents('.commonStageRewardTr').find('.prizeShow').html(htmls);
                break;
        }

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

    function chestPropsHtml(data) {
        if(!data || !data['type'] || isNaN(data['type']))return ''
        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//随机金卡
                ||data['type'] ==48//随机黑金卡
                ||data['type'] ==49//随机限时金卡
                ||data['type'] ==50//随机限时黑金卡
            ){
                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;
        }
        data['type'] = parseInt(data['type'] )
        if(skinsArrKeys.indexOf(data['type'] ) >= 0){
            if('skin' in data){
                var skin = data['skin'];
            }else{
                var defArr = {19:1};
                var skin   = defArr[data['type']]
            }
            console.log(skin)
            if(skinsArr[data['type']][skin] == undefined){
                var skName = reward_type_arr[data['type']]['name']+'(ID:'+skin+  ')'+'(已失效)';
                hasInvalidActProp = true;
            }else{
                var skName = skinsArr[data['type']][skin];
                if(skName.indexOf(skin)<0){
                    skName+= '(ID:'+skin+  ')'
                }
            }
            var html ='<span class="btn btn-outline '+dc+'">'+skName+':'+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 setPrize(stage,t,index=0,shushuIdx=1) {
        this_index = index;
        this_shushuIdx = shushuIdx;
        console.log(stage,t, index);
        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();//清空行

        let str = "";
        if(index>0){
            if(t==1){
                str = $('input[name="rewardnew[' + index + '][' + prize_stage + '][prize]"]').val();
            }else if(t==2){
                str = $('input[name="rank['+index+']['+prize_stage+'][prize]"]').val();
            }else if(t == 15){
                str = $('input[name="reward'+index+'['+prize_stage+'][prize]"]').val();
            }else if(t==7){
                str = $('input[name="reward['+index+']['+prize_stage+'][prize]"]').val();
            }else if(t=='treasure'){
                str = $('input[name="treasure['+stage+']['+index+'][prize]"]').val();
            }else if(t=='timelimitInvite'){
                str = $('input[name="timelimitInvite['+stage+']['+index+'][prize]"]').val();
            }else if(t=='mayaWheel'){
                str = $('input[name="mayaWheelReward['+index+'][prize]"]').val();
            }else if(t=='chooseYouWant'){
                str = $('input[name="chooseYouWantRewardConfig['+stage+']['+index+'][prize]"]').val();
            }else if(t=='rank'){
                str = $('input[name="rewardnew['+index+']['+this_shushuIdx+']['+prize_stage+'][prize]"]').val();
            } else if (['spinsMaster', 'superCollect', 'jigsaw','driftTreasure'].includes(t)) {
                str = $(stage).parents('tr').find('.prizeInput').val();
            }else if(t=='easterEgg'){
                str = $(stage).parents('.easterRewardTr').find('.prizeInput').val();
            }else if(t=='superSerial'){
                str = $(stage).parents('.serialRewardInfoTr').find('.prizeInput').val();
            }else if(t=='setCommonPrize'){
                str = $(stage).parents('.commonStageRewardTr').find('.prizeInput').val();
            } else if (t === 'luckyFox') {
                str = $(stage).parents('td').find('.prizeInput').val();
            } else if (t === 'crazyBuild_basic') {
                str = $(stage).parents('td').find('.basicPrizeInput').val();
            } else if (t === 'crazyBuild_final') {
                str = $(stage).parents('td').find('.finalPrizeInput').val();
            }
        }
        else{
            if(t==1){
                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){
                str = $('input[name="treasure['+prize_stage+'][prize]"]').val();
            }else if(t==4){
                str = $('input[name="trafficPermit['+prize_stage+'][prize]"]').val();
            }else if(t==5){
                str = $('input[name="trafficPermit['+prize_stage+'][specialPrize]"]').val();
            }else if(t==6){
                str = $('input[name="safeLimit['+prize_stage+'][prize]"]').val();
            }else if(t==7){
                str = $('input[name="reward['+index+']['+prize_stage+'][prize]"]').val();
            }else if(t==8){
                str = $('input[name="fund['+prize_stage+'][prize]"]').val();
            }else if(t == 15){
                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 = greatMemoriesRewardStages;
        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--;
        }
    }

    function getTypesSelector(array){
        let html = '<option value="">请选择</option>'
        array && $.each(array, function(i, o){
            html += `<option value="${i}">${o}</option>`
        })
        return html
    }
    // 添加进度奖行
    function addGreatMemoriesRewardTr() {
        var rIdx = ++greatMemoriesRewardStages
        var prize = '[]';
        var prize_show_arr = JSON.parse(prize);
        prize = escape(prize);
        let $typeOptionsHtml = getTypesSelector(typesArray)
        let $triggerOptionsHtml = getTypesSelector(triggerTypesArray)
        let $statusOptionsHtml = getTypesSelector(statusMap)
        var html = `
        <tr id="greatMemoriesRewardInfo_${rIdx}" data-idx="${rIdx}" class="commonStageRewardTr">
            <td>
                <select  class="form-control select2"   name="redPackets[${rIdx}][type]" >
                    ${$typeOptionsHtml}
                </select>
            </td>
            <td>
                <select  class="form-control select2"   name="redPackets[${rIdx}][triggerType]" >
                    ${$triggerOptionsHtml}
                </select>
            </td>
            <td>
                <input type="text"  class="form-control "   name="redPackets[${rIdx}][userLevelsStr]" >
            </td>
            <td>
                <select  class="form-control select2"   name="redPackets[${rIdx}][enable]" >
                    ${$statusOptionsHtml}
                </select>
            </td>
            <td class="prizeShow"></td>
            <td>
                <input type="hidden" class="prizeInput" name="redPackets[${rIdx}][prizes]" value="${prize}">
                <button type="button" class="btn btn-outline btn-success" onclick="setPrize(this,'setCommonPrize',1)">奖励配置</button>
                <button type="button" class="btn btn-outline btn-success" onclick="delReward(this,'setCommonPrize',1)">删除</button>
            </td>
        </tr>
    `;
        $('#redPacketsRewards').append(html)
    }
    function delReward(obj) {
        $(obj).parents('.commonStageRewardTr').remove()
    }

    $('.submitBtn').click(function(){
        var datas = $('#form').serializeArray();
        console.log(datas);
        $.post('/club/saveRedPacket', datas, function(res){
            if(typeof res == 'string')res = JSON.parse(res)
            alert(res.msg)
        })
    })
</script>
<script>
    config && $.each(config, function(i,o ){
        addGreatMemoriesRewardTr()
        $(`select[name="redPackets[${greatMemoriesRewardStages}][type]"]`).val(o.type)
        $(`select[name="redPackets[${greatMemoriesRewardStages}][triggerType]"]`).val(o.triggerType)
        $(`input[name="redPackets[${greatMemoriesRewardStages}][userLevelsStr]"]`).val(o.userLevelsStr)
        $(`select[name="redPackets[${greatMemoriesRewardStages}][enable]"]`).val(o.enable)
        $(`input[name="redPackets[${greatMemoriesRewardStages}][prizes]"]`).val(escape(JSON.stringify(o.prizes)))
        let prizeHtml = ''
        o.prizes && $.each(o.prizes, function(ip, op){
            prizeHtml += chestPropsHtml(op)
        })
        $(`.prizeShow:last`).html(prizeHtml)
    })
</script>
