<style>
.elput{width: 20%;margin-left: 428px;}
.sdiv{margin-top:18px;}
.dianm{margin-top: 0px}
.ssele{width: 91%}
.slable{margin-left:0px}
.reset_bg{margin-top: 50px;}
.t-e img {
    width: 16px;
    margin-left: 10px;
}

.t-e span {
    color: #ADADAD;
    vertical-align: middle;
    padding-left: 5px;
    font-size: 12px;
}

.reward_box {
    margin-left: 30px;
    width: 700px;
    overflow: hidden;
}
</style>

<div class="col-md-10" role="main">
    <nav class="breadcrumb"></i> 客户端功能配置<span class="c-gray en">&gt;</span>积分设置</nav>
    <div class="title-box">
        <p class="t-p" style="font-size: 28px; color: #7d7d7d;vertical-align: middle; padding-top: 15px; padding-bottom: 15px;">积分设置</p>
        <div class="t-e">
            <img src="<?php echo asset_url('images/explain.png')?>" alt="">
            <span>说明：用于控制分享任务获得的积分数量与积分种类。</span>
        </div>
    </div>


        <div class="reset_bg">
            <form action="<?php echo site_url('mocuzfun/client_fun/saveinte')?>" method="post" class="registerForm regiswidth" enctype="multipart/form-data">
                
                <div class="reward_box">
                    <div class="form-group" >
                        <span class="dianm biu_tle">分享获得积分功能：</span>
                        <input type="hidden" value="<?php echo $integral_share_switch['value'];?>" name="integral_share_switch">
                        <div class="biu_rdo rew_rdo">
                            <img src="<?php echo asset_url('images/unchoice.png');?>" alt="" class="biu_rdo_img " isc="0" sid="1"> <span>开启</span>
                            <img src="<?php echo asset_url('images/unchoice.png');?>" alt="" class="biu_rdo_img left_rdo" isc="0" sid="0"> <span>关闭</span>
                        </div>
                    </div>
                    
                    <div class="form-group" style="margin-top:60px;">
                        <span class="dianm biu_tle">分享帖子到朋友圈，奖励积分数量</span>
                        <input type="text" class="biu_ipt" name="share_integral" maxlength="6" placeholder="0" value="<?php echo $share_integral['score'];?>" style="margin-top:0px;">
                    </div>

                    <div class="form-group gn_set rewaed_jf_bxbtm" >
                        <span class="dianm biu_tle">奖励类型：</span>
                        <div style="float: right;">
                            <div class="gn_jf_type">
                                <p class="reward_je_p"></p> 
                                <img src="<?php echo asset_url('images/triangle.png');?>" alt="" class="sel_down">              
                            </div>
                            <input type="hidden" value="<?php echo $share_integral['type']?>" name="share_integral_type">
                             <ul isn="0" style="position: absolute;background-color: #FFF;">
                                    <li class="<?php !$share_integral['type']?'on_jf_type':'';?>" vid="0">请选择分类</li>
                                <?php
                                    foreach ($extcredits as $id => $value)
                                    {
                                        if($value['available']){
                                ?>
                                        <li class="<?php if($id == $share_integral['type']){echo "on_jf_type";}?>" vid="<?php echo $id;?>"><?php echo empty($value['title']) ? 'extcredit'.$id : $value['title']; ?></li>
                                <?php
                                        }
                                    }
                                ?>
                            </ul>
                        </div>
                    </div>

                     <button class="edit_btn" id="save">保存修改</button>
                </div>
            </form>    
        </div>
    </div>

<script type="text/javascript">
$(function(){
    //表单提交
    $("#save").on('click',function(event) {
        event.preventDefault();
        /* Act on the event */
        var integral_share_switch = $('input[name=integral_share_switch]').val();
        var share_integral_type = $('input[name=share_integral_type]').val();

        if(integral_share_switch == 1)
        {
            if(share_integral_type == 0)
            {
                alert('请选择积分种类');
                return false;
            }
            var regExp1 = /^[1-9]\d*$/;

            if(!regExp1.test($('input[name=share_integral]').val()))
            {
                alert('请输入正确分值');
                return false;
            }
        }
        $('form').submit();
    });    
    //初始化选择
    var integral_share_switch = $('input[name=integral_share_switch]').val();
    $('.biu_rdo_img').each(function(){
     if($(this).attr('sid') == integral_share_switch)
     {
        $(this).attr('src','<?php echo asset_url("images/choice.png");?>');
        $(this).attr('isc',1);
     }
    });
    //初始化下拉框
    $('.gn_set ul li').each(function(index) {
        if($(this).attr('vid') == <?php echo empty($share_integral['type'])?0:$share_integral['type'];?>)
        {
            $('.gn_jf_type p').text($(this).text());
        }
    });     
    // 模拟下拉框
    $('.gn_jf_type,.sel_down').click(function(e){
        e.stopPropagation();
        var isn=$('.gn_set ul').attr('isn');
        if(isn==0){
            $('.gn_set ul').show();
            $('.gn_set ul').attr('isn','1');
        }else{
            $('.gn_set ul').hide();
            $('.gn_set ul').attr('isn','0');
        }
    })

    $('.gn_set ul li').mouseover(function(){
        $(this).addClass('on_jf_type');
        $(this).siblings().removeClass('on_jf_type');
    })

    $('.gn_set ul li').click(function(){
        var vid = $(this).attr('vid');
        $("input[name=share_integral_type]").val(vid);
        $('.gn_set ul').hide();
        $('.gn_set ul').attr('isn','0');
        var text=$(this).text();
        $('.gn_jf_type p').text(text);
    })

     // 单选按钮切换
    $('.biu_rdo img').click(function(){
        var sval = $(this).attr('sid');
        $('input[name=integral_share_switch]').val(sval); 
        var isc=$(this).attr('isc');
        if(isc==0){
            $(this).attr('src','<?php echo asset_url("images/choice.png");?>');
            $(this).attr('isc','1');
            $(this).siblings('img').attr('src','<?php echo asset_url("images/unchoice.png")?>');
            $(this).siblings('img').attr('isc','0');
        }
    })
})    
</script>

<script type="text/javascript">
// $(function(){
//     $('.registerForm').bootstrapValidator({
//         message: 'This value is not valid',
//         feedbackIcons: {
//             valid: 'glyphicon glyphicon-ok',
//             invalid: 'glyphicon glyphicon-remove',
//             validating: 'glyphicon glyphicon-refresh',
//             excluded : ':disabled'
//         },
//         fields: {
//             share_integral: {
//                 message: '积分数量',
//                 validators: {
//                     regexp: {
//                         regexp: /^\d+$/,
//                         message: '请输入正确积分数量',
//                     }
//                 }
//             },
//             invite_integral: {
//                 message: '积分数量',
//                 validators: {
//                     regexp: {
//                         regexp: /^\d+$/,
//                         message: '请输入正确积分数量',
//                     }
//                 }
//             }
//         }
//     })
//     .on('success.form.bv',function(e){
//         e.preventDefault();         
//         var form = this;
//         var share_switch = $('input[name=integral_share_switch]:checked').val();
//         var invite_switch = $('input[name=integral_invite_switch]:checked').val();

//         if (share_switch != 0 && invite_switch == 0)
//         {
//             if($('select[name=share_integral_type]').val() == 0)
//             {
//                 alert('请选择增加积分种类');
//                 return false;
//             }                
//         }
//         if (share_switch == 0 && invite_switch != 0)
//         {
//             if($('select[name=invite_integral_type]').val() == 0)
//             {
//                 alert('请选择增加积分种类');
//                 return false;
//             }                
//         }
//         form.submit();
  
//     })
// })    
</script>