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

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

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

        .upimg {
            cursor: pointer;
        }

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

</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12">
            <aside>
                <header><i class="fa fa-fw fa-file"></i>修改活动</header>
                <hr/>
                <section>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <input type="hidden" value="/Activity/uploadImg" id="uploadUrl"/>
                                <input type="hidden" value="<?php echo $baseUrl;?>" id="baseUrl"/>
                                <?php if($id == 0){?>
                                    <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data"  id="uploadForm" action="#">
                                        <div class="form-group" id="uploadImg">
                                            <label class="col-sm-2 control-label">活动图片</label>
                                            <?php foreach ($langList as $k => $v){ ?>
                                                <div class="col-sm-1 thumbnail div-lang" >
                                                    <img src="<?php echo '/images/default_img.png';?>"  class="upimg default-img <?php if(!empty($info['img'])) {echo 'hide';}?>" name="<?php echo $k;?>" alt=""  style="height: 90px;width: 90px;"  />
                                                    <img src="<?php echo $info['img'][$k];?>" class="upimg  uploaded-img <?php if(empty($info['img'])) {echo 'hide';}?>" alt=""  name="<?php echo $k;?>" id="<?php echo $k;?>" onerror="javascript:this.src='<?php echo '/images/default_img.png';?>'"  style="height: 90px;width: 90px;"  />
                                                    <input type="file" name="imgfile_<?php echo $k;?>" id="imgfile_<?php echo $k;?>" class="imgfile hide"/>
                                                    <span class="lang-name"><?php echo $v;?></span>
                                                </div>
                                            <?php }?>
                                        </div>
                                    </form>
                                <?}?>
                                <form class="form-horizontal" role="form" method="post"  enctype="multipart/form-data" id="editForm">
                                    <?php foreach ($langList as $k => $v) { ?>
                                        <input type="hidden" value="<?php echo $info['img_'.$k];?>" id="uplang_<?php echo $k;?>" name="uplang[<?php echo $k;?>]"/>
                                    <?php }?>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">活动ID*: </label>
                                        <div class="col-sm-2">
                                            <input type="text" readonly class="form-control"  name="id" value="<?php echo $id;?>">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label" style="line-height: 7px;">包:</label>
                                        <div class="an-checkbox-div col-sm-9 android-package">
                                            <label>
                                                <input type="checkbox" id="android-checkall"> 【全选】
                                            </label>
                                            <?php foreach ($androidPackageList as $k => $v) { ?>
                                                <label>
                                                    <input type="checkbox" class="android-check" name="package[]" value="<?php echo $k;?>" <?php if(in_array($k, $packageList)) {echo 'checked'; }?> > <?php echo '安卓'.$v;?>
                                                </label>
                                            <?php }?>
                                            <br/>
                                            <br/>
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <?php foreach ($iosPackageList as $k => $v) { ?>
                                                <label>
                                                    <input type="checkbox" class="android-check" name="package[]" value="<?php echo $k;?>"  <?php if(in_array($k, $packageList)) {echo 'checked'; }?>> <?php echo '苹果'.$v;?>
                                                </label>
                                            <?php }?>
                                        </div>

                                    </div>


                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">标题*: </label>
                                        <?php
                                        $tNum = 0;
                                        foreach ($langList as $k => $v) {
                                            if($tNum != 0 && $tNum % 4 == 0){?>
                                                <label class="col-sm-3 control-label"></label>
                                            <?php }
                                            ?>
                                            <div class="col-sm-2">
                                                <input type="text" class="form-control" placeholder="<?php echo $v?>" name="title[<?php echo $k;?>]" value="<?php echo $info['title_name_'.$k] ?? '';?>">
                                            </div>
                                            <?php
                                            $tNum++;
                                        }?>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">是否显示按钮*:</label>
                                        <div class="col-sm-3">
                                            <label class="radio-inline">
                                                <input type="radio" name="actType"  value="1" <?php if($info['actType'] == 1) {?>checked <?php }?>/> 显示
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="actType"  value="0"  <?php if($info['actType'] != 1) {?>checked <?php }?>/> 隐藏
                                            </label>

                                        </div>
                                    </div>

                                    <div class="form-group btn-show">
                                        <label class="col-sm-2 control-label">按钮名称*: </label>
                                        <?php
                                        $bNum = 0;
                                        foreach ($langList as $k => $v) {
                                            if($bNum != 0 && $bNum % 4 == 0) { ?>
                                                <label class="col-sm-3 control-label"></label>
                                            <?php }
                                            ?>
                                            <div class="col-sm-2">
                                                <input type="text" class="form-control" placeholder="<?php echo $v?>" name="bname[<?php echo $k;?>]" value="<?php echo $info['bname_'.$k];?>">
                                            </div>
                                            <?php
                                            $bNum++;
                                        }?>
                                    </div>

                                    <div class="form-group btn-show">
                                        <label class="col-sm-2 control-label">按钮颜色:</label>
                                        <div class="col-sm-2">
                                            <!--                                                    <input type="text" class="form-control" placeholder="颜色" name="bcolor" value="--><?php //echo $info['bcolor'];?><!--">-->
                                            <select class="form-control" name="bcolor" id="bcolor">
                                                <option value="2" <?php if($info['bcolor'] == 2) echo 'selected'; ?>>绿色</option>
                                                <option value="1" <?php if($info['bcolor'] == 1) echo 'selected'; ?>>蓝色</option>
                                                <option value="3" <?php if($info['bcolor'] == 3) echo 'selected'; ?>>黄色</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">开始时间:</label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control datepicker stime" value="<?php echo date('Y-m-d', $info['start_time']);?>" placeholder="开始时间" name="stime" />
                                        </div>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control datetimepicker stime-hour" value="<?php echo date('H:i', $info['start_time']);?>" placeholder="开始时间" name="stimeHour" />
                                        </div>
                                    </div>


                                    <?php if(in_array($id,[13])){?>
                                        <div class="form-group date-hour" >
                                            <label class="col-sm-2 control-label">领奖时间:</label>
                                            <div class="col-sm-2">
                                                <input type="text" class="form-control datepicker rtime" value="<?php echo date('Y-m-d', $info['reward_time']);?>" placeholder="领奖时间" name="rtime" />
                                            </div>
                                            <div class="col-sm-2">
                                                <input type="text" class="form-control datetimepicker rtime-hour" value="<?php echo date('H:i', $info['reward_time']);?>" placeholder="领奖时间" name="rtimeHour" />
                                            </div>
                                        </div>
                                    <?php }?>


                                    <div class="form-group date-hour" >
                                        <label class="col-sm-2 control-label">结束时间:</label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control datepicker etime" value="<?php echo date('Y-m-d', $info['end_time']);?>" placeholder="结束时间" name="etime" />
                                        </div>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control datetimepicker etime-hour" value="<?php echo date('H:i', $info['end_time']);?>" placeholder="结束时间" name="etimeHour" />
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">显示排序<span class="fa fa-question-circle "   data-toggle="tooltip" title="数字越大顺序越后"></span>:</label>
                                        <div class="col-sm-1">
                                            <input type="text" class="form-control" placeholder="显示排序" name="sort" value="<?php echo $info['sort'];?>">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">最低开放等级<span class="fa fa-question-circle "   data-toggle="tooltip" title=""></span>:</label>
                                        <div class="col-sm-1">
                                            <input type="text" class="form-control" placeholder="最低开放等级" name="openlv" value="<?php echo $info['openlv'];?>">
                                        </div>
                                    </div>

                                    <?php if(in_array($id,[2,3,6,7,13,14,15,16])){?>
                                        <div class="form-group btn-show">
                                            <label class="col-sm-2 control-label">活动类型:</label>
                                            <div class="col-sm-1">
                                                <select class="form-control" onchange="changeImgName()" name="img" id="img">
                                                    <?php if($id == 2){?>
                                                        <option <?php if($img == 1){ echo 'selected';}?> value="1">金蛋</option>
                                                        <option <?php if($img == 2){ echo 'selected';}?> value="2">玫瑰</option>
                                                        <option <?php if($img == 3){ echo 'selected';}?> value="3">万圣节</option>
                                                        <option <?php if($img == 4){ echo 'selected';}?> value="4">感恩节</option>
                                                        <option <?php if($img == 5){ echo 'selected';}?> value="5">情人节</option>
                                                        <option <?php if($img == 6){ echo 'selected';}?> value="6">四叶草节</option>
                                                        <option <?php if($img == 7){ echo 'selected';}?> value="7">四选一</option>
                                                        <option <?php if($img == 8){ echo 'selected';}?> value="8">世界环境日</option>
                                                        <option <?php if($img == 9){ echo 'selected';}?> value="9">独立日</option>
                                                        <option <?php if($img == 10){ echo 'selected';}?> value="10">红酒</option>
                                                        <option <?php if($img == 11){ echo 'selected';}?> value="11">冰淇淋</option>
                                                        <option <?php if($img == 12){ echo 'selected';}?> value="12">沙滩排球</option>
                                                    <?php }else if($id == 6){?>
                                                        <option <?php if($img == 1){ echo 'selected';}?> value="1">偷</option>
                                                        <option <?php if($img == 2){ echo 'selected';}?> value="2">打</option>
                                                    <?php }else if($id == 3){?>
                                                        <option <?php if($img == 1){ echo 'selected';}?> value="1">气球</option>
                                                        <option <?php if($img == 2){ echo 'selected';}?> value="2">感恩节</option>
                                                    <?php }else if($id == 7){?>
                                                        <option <?php if($img == 1){ echo 'selected';}?> value="1">圣诞节</option>
                                                    <?php }else if($id == 13){?>
                                                        <option <?php if($img == 1){ echo 'selected';}?> value="1">钻石</option>
                                                        <option <?php if($img == 2){ echo 'selected';}?> value="2">独立日</option>
                                                        <option <?php if($img == 3){ echo 'selected';}?> value="3">相遇</option>
                                                    <?php }else if($id == 14){?>
                                                        <option <?php if($img == 1){ echo 'selected';}?> value="1">体力加速</option>
                                                    <?php }else if($id == 15){?>
                                                        <option <?php if($img == 1){ echo 'selected';}?> value="1">连环礼包</option>
                                                        <option <?php if($img == 2){ echo 'selected';}?> value="2">独立日</option>
                                                        <option <?php if($img == 3){ echo 'selected';}?> value="3">浪漫法国</option>
                                                        <option <?php if($img == 4){ echo 'selected';}?> value="4">奇幻假日</option>
                                                        <option <?php if($img == 5){ echo 'selected';}?> value="5">丛林</option>
                                                        <option <?php if($img == 6){ echo 'selected';}?> value="6">冲浪</option>
                                                    <?php }else if($id == 16){?>
                                                        <option <?php if($img == 1){ echo 'selected';}?> value="1">宝藏活动</option>
                                                    <?php }?>
                                                </select>
                                            </div>
                                            <label class="col-sm-1 control-label">资源名称:</label>
                                            <div class="col-sm-2">
                                                <input type="text" class="form-control" name="imgName" id="imgName" value="<?php echo $imgName[$img];?>">
                                            </div>
                                        </div>
                                        <?php if($id == 2){?>
                                            <div class="form-group btn-show">
                                                <label class="col-sm-2 control-label">标题字体颜色:</label>
                                                <div class="col-sm-1">
                                                    <input type="text" class="form-control" name="textColor[]" id="textColorTitle" value="<?php echo $textColor[$img][0];?>">
                                                </div>
                                                <label class="col-sm-1 control-label">内容字体颜色</label>
                                                <div class="col-sm-2">
                                                    <input type="text" class="form-control" name="textColor[]" id="textColorContent" value="<?php echo $textColor[$img][1];?>">
                                                </div>
                                            </div>
                                        <?php }?>
                                    <?php }?>

                                    <?php if($id == 3 || $id == 2 || $id == 6 || $id == 7){?>
                                        <div class="form-group btn-show">
                                            <label class="col-sm-2 control-label">循环启动时间(小时):</label>
                                            <div class="col-sm-1">
                                                <input type="text"  class="form-control" name="action_time" id="action_time" value="<?php echo $action_time;?>">
                                            </div>
                                            <label class="col-sm-1 control-label">关闭时间:</label>
                                            <div class="col-sm-1">
                                                <input type="text" class="form-control" name="lock_time" id="lock_time" value="<?php echo $lock_time;?>">
                                            </div>
                                        </div>
                                    <?php }?>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">活动状态*:</label>
                                        <div class="col-sm-2">
                                            <label class="radio-inline">
                                                <input type="radio" name="online"  value="1" <?php if($info['is_online'] == 1) { ?>checked <?php }?> /> 上线
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="online"  value="0" <?php if($info['is_online'] != 1) { ?>checked <?php }?> /> 下线
                                            </label>
                                        </div>
                                    </div>

                                    <div class="form-group"  <?php if(!in_array($id,[2,7,13,6])){ echo 'style="display: none"'; }?>>
                                        <label class="col-sm-2 control-label">概率调整:</label>
                                        <div class="col-sm-8">
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>攻击</span>
                                                <input type="text" class="form-control" name="pro[1]" value="<?php echo $pro[1]??0;?>">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>偷袭</span>
                                                <input type="text" class="form-control" name="pro[2]" value="<?php echo $pro[2]??0;?>">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>体力</span>
                                                <input type="text" class="form-control" name="pro[3]" value="<?php echo $pro[3]??0;?>">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>护盾</span>
                                                <input type="text" class="form-control" name="pro[4]" value="<?php echo $pro[4]??0;?>">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>1个金币</span>
                                                <input type="text" class="form-control" name="pro[5]" value="<?php echo $pro[5]??0;?>">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>2个金币</span>
                                                <input type="text" class="form-control" name="pro[6]" value="<?php echo $pro[6]??0;?>">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>3个金币</span>
                                                <input type="text" class="form-control" name="pro[7]" value="<?php echo $pro[7]??0;?>">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>1个钱袋</span>
                                                <input type="text" class="form-control" name="pro[8]" value="<?php echo $pro[8]??0;?>">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>2个钱袋</span>
                                                <input type="text" class="form-control" name="pro[9]" value="<?php echo $pro[9]??0;?>">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>3个钱袋</span>
                                                <input type="text" class="form-control" name="pro[10]" value="<?php echo $pro[10]??0;?>">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>没有奖励</span>
                                                <input type="text" class="form-control" name="pro[11]" value="<?php echo $pro[11]??0;?>">
                                            </div>
                                            <div class="col-sm-1" style="text-align: center">
                                                <span>活动</span>
                                                <input type="text" class="form-control" name="pro[12]" value="<?php echo $pro[12]??0;?>">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <div class="col-sm-offset-2 col-sm-3">
                                            <button type="button" class="btn btn-info goback">返回</button>
                                            <button type="button" class="btn btn-primary" id="submitBtn">提交</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </section>
            </aside>
        </div>
    </div>
</div>

</body>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script src="<?php echo base_url();?>public/plugins/validate/jquery.validate-1.15.0.min.js"></script>
<script src="<?php echo base_url();?>public/plugins/validate/jaquery.validate.messages_zh.js"></script>
<script src="<?php echo base_url();?>public/js/common.js"></script>
<script src="<?php echo base_url();?>public/js/activity/edit.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/timepicker/timepicker.min.js"></script>
<!-- Select2 -->
<script src="<?php echo base_url();?>public/js/vendor/select2/select2.full.min.js"></script>

</html>
<script type="text/javascript">
    var time = '<?php echo time();?>';
    //选择日期
    $('.stime,.etime,.rtime').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });

    $(".select2").select2();

    controllGoto();

    function changeImgName(){
        var id = $('#img').val();
        var imgName = new Array();
        <?php foreach ($imgName as $key=>$row){
            echo "imgName[{$key}] = '{$row}';";
        } ?>
        $('#imgName').val(imgName[id]);

        var textColor = new Array();
        <?php
        if($id == 2){
            foreach ($textColor as $key=>$row){
                echo "textColor[{$key}] = ['{$row[0]}','{$row[1]}'];";
            }
        }
        ?>
        <?php if($id == 2){?>
            $('#textColorTitle').val(textColor[id][0]);
            $('#textColorContent').val(textColor[id][1]);
        <?php }?>
    }


    //选择时间段
    $('.datetimepicker').timepicker({
        timeFormat:'HH:mm'
    });


    $('.goback').click(function(){
        history.go(-1);
    });

    //跳转链接
    $('#goto').change(function () {
        controllGoto();
    });
    //控制跳转
    function controllGoto() {
        var value = $('#goto option:selected').val();
        var gotoLevel = $('.goto-level');
        if(value == 5) {
            gotoLevel.removeClass('hide');
        }else {
            gotoLevel.addClass('hide');
        }

        var goodsType = $('.goods-type'),
            payType = $('.pay-type');
        if(value == 12) {//打开商城
            goodsType.removeClass('hide');
            payType.removeClass('hide');
        }else {
            goodsType.addClass('hide');
            payType.addClass('hide');
        }
    }



    //是否选择时间段
    $('#isChooseDateHour').change(function () {
        var state = $(this).val();
        if(state === '1'){
            $('.date-hour').removeClass('hide');
        }else {
            $('.date-hour').addClass('hide');
        }
    });


    //全选/全不选
    $('#android-checkall').change(function () {
        if($(this).is(':checked')) {//已经是全选的状态
            $('.android-check').prop('checked', true);
        }else {
            $('.android-check').prop('checked', false);
        }
    });
</script>