<nav class="breadcrumb"> 客户端界面设置 <span class="c-gray en">&gt;</span> 首页内容配置 </nav>
<style>
    .ediv{padding-bottom:40px}  
    .elp{padding-left: 0px;}
    .elr{padding-left: 650px;padding-top: 5px;overflow: hidden;}
    .reset_bg{margin-top: 30px;}
	.edt{padding-left:30px; }
	.edr{padding-right:20px;font-size: 18px;}
	.loc{width: 33%;text-align:center;margin-top: 20px;}
	.subsy{text-align: right;border-radius: 0 0 6px 6px;box-shadow: inset 0 1px 0 #fff;margin-top: 30px;}
	.imgstyle{width:238px;box-shadow: 0px 0px 15px 8px rgba(230, 230, 230, 0.5)}
	.edit_btn {
    border: 0;
    padding: 5px 25px 6px 25px;
    background-color: #9DE149;
    color: #FFF;
    border-radius: 4px;
    float: right;
    margin-top: -20px;
    margin-right:35px;
    margin-bottom: 20px;
}


/*显示入口*/
    .show-channel{margin: 25px 30px; width: 980px;}
    .show-channel ul{overflow:hidden;width:100%;}
    .show-channel ul li{width:136px;float:left;margin: 0px 60px 40px 0px;padding: 2px;}
    .channel-icon{position: relative;width: 72px;margin: 0px auto;margin-top: 25px;border-radius: 50%;overflow: hidden;text-align:center}
    .channel-icon img{width: 100%;position: relative;cursor:pointer;}
    .channel-name{position: relative;height: 20%;text-align: center;font-size: 15px;color:#e5e5e5;margin-top: 14px;  margin-bottom: 15px;}
    .channel-name span{margin-top: -3%;position: relative;display: block;color: #333}
    .channel-del{position: relative;  height: 44px;text-align: center;font-size: 16px;width: 100%;background-color: #F3FAFD;cursor:pointer;border-top: 1px solid #e5e5e5;}
    .channel-del:hover{background-color: #E8F0F0;}
    .channel-del span{display: block;margin-top: 9px; color:#7D7D7D;}
    .ediv{padding-bottom:20px}
    .edt{padding-left:30px;}
    .edr{padding-right:20px;}
    .elp{padding-left: 0px;padding-top: 20px;padding-bottom: 20px;}
    .modal.fade.in{top: 11%;bottom:12%;}
    .mt10{margin-top: 10px;}

     /*添加按钮*/
    #channel-add-i{padding: 0;}
    .channel-add{position: relative;cursor: pointer;text-align: center;background-color: #f5f5f5;width: 80%;margin: 0px auto;border: 1px solid #e5e5e5;border-radius: 3px;padding: 3px 0px;}
    .channel-add:hover{background-color: #EAEAEA;}
    .channel-add span{color:#7D7D7D;font-size: 15px;}

    /*弹窗添加*/
     .add-text{display: block;font-size: 16px;margin-left: 42px;margin-bottom: 5px}
     .channel-input{height:30px;width:80%;border: 1px solid #dfdfdf;}
     .channel-div{text-align: center}
     .add-icon{width:80%;margin-left: 42px;} 
     .add-icon ul{overflow:hidden;width:90%;margin-left: 4.5%;padding:10px 0px 5px;;position: relative;}
     .add-icon ul li{width:19%;float:left;height: 57px;border: 2px solid #ccc;margin-left: 1%;margin-bottom: 1%;}
     .add-icon ul li:hover{border: 2px solid #6BB5C1;cursor:pointer;}
     .add-icon ul li img{width: 100%;position: relative;}   
     .t-e {margin-left: 30px; margin-bottom: 15px; margin-top: 5px; overflow: hidden;}


     /*增加排序功能*/
     .channelmain{border: 1px solid #e5e5e5;}
     .channelsort{margin-top:10px;}
     .channelsort span{padding-left:20px;padding-right:5px}
     .channelsort input{width:40%;border-radius:5px;border:1px solid #e5e5e5;text-align:center}


    .sy_pz_type_on{-webkit-box-shadow:0 0px 1px rgba(0, 0, 0, .4);
  -moz-box-shadow:0 0px 1px rgba(0, 0, 0, .4);box-shadow:0 0px 1px rgba(0, 0, 0, .4);}
    .reward_je_p{margin-top: 4px!important;}
    .on_rk_type{color: #FFF!important;background-color: #58CAF5!important;}
     .sy_pz_type{width: 100%;margin-bottom: 20px;border: 1px solid #e5e5e5;font-size: 14px;border-radius: 4px;height: 32px;text-align: center;cursor: pointer;position: relative;}
     .sy_select{position: relative;}
     .sy_select ul{position: absolute;background-color: #FFF;-webkit-box-shadow:0 2px 4px rgba(0, 0, 0, .4);
  -moz-box-shadow:0 2px 4px rgba(0, 0, 0, .4);box-shadow:0 2px 4px rgba(0, 0, 0, .4);top: 31px;z-index: 9;display: none;}
  .sy_select ul li{width: 100%!important;margin: 0!important;text-align: center;color: #000;padding: 3px 0px;}
</style>
<div class="col-md-10" role="main">

		<div style="width:100%;border-bottom: 1px solid #e5e5e5;"><li class="edt" style="font-size: 28px; color: #7d7d7d;vertical-align: middle; padding-top: 15px; padding-bottom: 15px;">首页内容配置</div>
        <div>
            <p class="mt10 edt edr">首页入口配置</p>
            <div class="t-e">
                    <img src="<?php echo asset_url('images/explain.png');?>" alt="">
                    <span style="width: 800px;vertical-align: middle;">说明：① 请在此处对首页首屏图标入口进行编辑，最多可添加5个；② 页面最多展示5个图标入口，IPHONE4、5可展示4个；③ 可选择爆炸贴并在页面显示，如HOT、NEW、热、新。</span>
            </div>
        </div>
        
		<div class="reset_bg" style="width:980px;">
             <div class="show-channel">
                <ul id="ul_channel">
                <?php
                    foreach ($channel as $k => $v) {
                ?>
                <li>

                   <div class="sy_select">
                            <div class="sy_pz_type">
                                <p class="reward_je_p"><?php echo !empty($v['flag']) ? $hot_flag[$v['flag']] : '请选择';?></p>
                                <img src="<?php echo asset_url('images/triangle.png'); ?>" alt="" class="sel_down">
                            </div>
                            <input type="hidden" value="" name="share_integral_type">
                            <ul isn="0" channel_id="<?php echo $v['id']?>">
                                    <li vid="new">NEW</li>
                                    <li vid="hot">HOT</li>
                                    <li vid="xin">最新</li>
                                    <li vid="re">热门</li>
                                    <li vid="no">无</li>
                            </ul>
                        </div> 

                  <div class="channelmain"> 
                  <div class="channel-icon"><img style="width: 72px !important;height: 72px !important;vertical-align: middle;text-align: center;"  mid="<?php echo $v['id'];?>" xdl="<?php echo $v['requiredlogin'];?>" src="<?php echo asset_url('images/channel_img/'.$v['icon']);?>" alt=""></div>
                  <div class="channel-name"><span><?php echo $v['title'];?></span></div>
                  <div data-target="#delModal" data-toggle="modal" class="channel-del"><span>删除</span></div>  
                  </div>
                  <div class="channelsort"><span>序号</span><input type="text" name="ordernum[<?php echo $v['id']?>]" sid="<?php echo $v['id']?>" value="<?php echo $v['ordernum']?>"></div>
                </li>                
                <?php
                    }
                ?>
                <li id="channel-add-i" <?php if(count($channel) > 4):?>style="display:none"<?php endif;?>>
                    <div class="channel-add"><span>新增入口＋</span></div>
                </li>

                </ul>
<!--                 <button class="edit_btn" id="save" style="margin-right: 75px;">保存修改</button> -->
            </div>

            <button class="edit_btn" id="order">保存排序</button>




				<form id="form1" action="<?php echo site_url('mocuz/client/save')?>" method="post" class=" regiswidth" enctype="multipart/form-data">
				<div class="form-group ediv">
                    <span class="dianm edt edr">热点新闻区块</span>
                   
                        <input type="hidden" name="index_hot_block" value="<?php echo $index_hot_block['value'];?>">
                        <div class="biu_rdo" style="margin-top: 14px;margin-right: 59px;">           
                            <img src="<?php echo asset_url('images/unchoice.png');?>" alt="" class="biu_rdo_img " isc="0" vid="1"> <span style="font-size: 14px;">显示</span>
                            <img src="<?php echo asset_url('images/unchoice.png');?>" alt="" class="biu_rdo_img left_rdo" isc="0" vid="0"> <span style="font-size: 14px;">隐藏</span>
                        </div>
                    
                </div> 
                <div class="form-group ediv">
                    <span class="dianm edt edr">热点新闻数据调用</span>
                    
                        <input type="text" class="form-control elput" style="width: 180px;float: right;  margin-right: 59px;margin-top: 3px;" value="<?php echo $index_hot_news['value']?>" name="index_hot_news">
                       
                        <div class="t-e biu_e" style="margin-bottom:0px!important; margin-left:30px!important;">
                            <img src="<?php echo asset_url('images/explain.png');?>" alt="">
                            <span>说明：请在此处输入首页热点新闻区块调用的DIY模块，如已配置妥当，请尽量不要修改，以免出现数据错乱等问题。</span>
                        </div>
                    
                </div>
		
                <div class="form-group ediv">
                    <span class="dianm edt edr">新鲜事区块<span style="font-size:14px!important;color:#ADADAD;">(论坛新贴流)</span></span>
                   
                        <input type="hidden" name="index_last_news" value="<?php echo $index_last_news['value'];?>">
                        <div class="biu_rdo" style="margin-top: 14px;margin-right: 59px;">           
                            <img src="<?php echo asset_url('images/unchoice.png');?>" alt="" class="biu_rdo_img " isc="0" sid="1"> <span style="font-size: 14px;">显示</span>
                            <img src="<?php echo asset_url('images/unchoice.png');?>" alt="" class="biu_rdo_img left_rdo" isc="0" sid="0"> <span style="font-size: 14px;">隐藏</span>
                        </div>
                        
                    
                </div> 
                <div class="form-group ediv">
                    <span class="dianm edt edr">新鲜事数据调用</span>
                    
                        <input type="text" class="form-control elput" style="width: 180px;float: right;  margin-right: 59px;margin-top: 3px;" value="<?php echo $index_block_id['value'];?>" name="index_block_id">                     
                        <div class="t-e biu_e" style="margin-bottom:0px!important; margin-left:30px!important;">
                            <img src="<?php echo asset_url('images/explain.png');?>" alt="">
                            <span>说明：此处填写版块ID，以半角“，” 分割。例如：想要同时调用版块ID为30和45的新帖数据，则填写30,45。</span>
                        </div>
                    
                </div>   

			     <div class="form-group ediv" style="clear:both">
                    <span class="dianm edt edr" style="width: 100%;">效果展示</span>
 			
					<div style="float:left;text-align:center;margin: 20px;padding-left: 10px;">   
                                <p style="font-size: 14px;  margin-bottom: 20px; ">两个区块同时启用效果</p>
                                <img class="imgstyle" src="<?php echo asset_url('images/bothshow.jpg')?>" alt="">
                     </div>
										
					<div style="float:left;text-align:center;margin: 20px;">   
                                <p style="font-size: 14px;  margin-bottom: 20px;">只显示热点新闻区块效果</p>
                                <img class="imgstyle" src="<?php echo asset_url('images/news.jpg')?>" alt="">
                     </div>
					
					<div style="float:left;text-align:center;margin: 20px;">   
                                <p style="font-size: 14px;  margin-bottom: 20px;">只显示新鲜事区块效果</p>
                                <img class="imgstyle" src="<?php echo asset_url('images/novelty.jpg')?>" alt="">
                     </div>
                </div> 
               
                   <button class="edit_btn" id="save">保存修改</button>					
                     <div class="t-e biu_e" style="text-align: right;padding-right: 35px;">
                            <img src="<?php echo asset_url('images/explain.png');?>" alt="">
                            <span>提示：保存前，请至少选择显示一个区块。</span>
                    </div>
            </form>    
        </div>
    </div>

        <!--添加弹框-->
    <div class="modal fade equity" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="position: fixed; width:453px;">
        <div class="modal-dialog" style="margin:0; ">
            <form id="level_form" action="" class="registerdate">
                <input type="hidden" name="icon" value=""> 
                <!--默认添加操作-->

                <input type="hidden" name="id" value=""> 
                <div class="form-group">
                    <span class="add-text">入口名称</span>
                    <div class="channel-div">
                        <input type="text"  class="channel-input" maxlength="5" name="title" value="" style="text-indent: 10px;margin:8px 0px;"/>
                    </div>
                </div>
                <div class="form-group">
                    <span class="add-text">跳转类别</span>
                    <div class="channel-div">
                        <select name="cid" class="channel-input" style="  text-indent: 10px;margin:8px 0px;">
                            <option value="0">请选择</option>
                            <?php foreach ($goto as $key => $value) {
                            ?>
                            <option value="<?php echo $key?>" ><?php echo $value;?></option>
                            <?php
                            }?>
                        </select>
                    </div>
                </div>
                <div id="goto_value" class="form-group" style="display:none">
                    <span class="add-text"></span>
                    <div class="channel-div">
                        <input type="text" class="channel-input" name="goto_value" value="" style="  text-indent: 10px;margin:8px 0px;"/>
                    </div>
                </div>
                <div class="form-group"  style="height: 200px;overflow: scroll;overflow-x: hidden;">
                    <span class="add-text">图标</span>
                    <div class="add-icon">
                        <ul>
                            <?php
                            foreach ($iconlist as $k => $v) {
                            ?>
                            <li class="mark-choose"><img  src="<?php echo asset_url('images/channel_img').'/'.$v;?>" alt=""></li>
                            <?php
                            }
                            ?>
                        </ul>
                    </div>
                </div>
                <div class="form-group ediv">
                    <span class="dianm" style="margin-left:42px;   font-size: 16px;">是否要求登录</span>

                    <input type="hidden" name="requiredlogin" value="1">
                    <div class="biu_rdo" style="  margin-top: 10px; margin-right: 40px;">                         
                            <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="equity-button" style="width:100%;  padding-left: 42px;">
                    <button type="submit" class="h5a-btn btn  btn-primary equitycof" id="edit_opt">确定</button>
                    <button type="button" class="h5a-btn btn  btn-default equityclose" data-dismiss="modal" style="float:right;margin-right: 40px;">取消</button>
                </div>
            </form>
        </div>  
    </div>


    <!--确认删除弹出框-->
    <input type="hidden" name="channelId" value="">
    <div class="modal fade equity" id="delModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="width: 360px; height: 190px; border-radius: 0px; top: 20%;">
        <div class="modal-dialog" style="  width: 100%!important;margin: 0">
            <p class="delete-title">确定要删除该入口？</p>
            <div class="equity-button">
                <button type="button" class="h5a-btn btn  btn-primary equitycof" id='optdel'>确定</button>
                <button type="button" class="h5a-btn btn  btn-default equityclose" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>

<!--    保存成功按钮-->
    <div class="ok_popup">
        <img src="<?php echo asset_url('images/save_success.png')?>" alt="">
    </div>

 <script type="text/javascript">
$(function(){
    //初始化
    var index_hot_block = $('input[name=index_hot_block]').val();
    var index_last_news = $('input[name=index_last_news]').val();
    $('.biu_rdo img').each(function(){
     if($(this).attr('vid') == index_hot_block || $(this).attr('sid') == index_last_news)
     {
        $(this).attr('src','<?php echo asset_url("images/choice.png");?>');
        $(this).attr('isc',1);
     }
    });
    // 单选按钮切换
    $('.biu_rdo img').click(function(){

        var isc=$(this).attr('isc');
        if(typeof($(this).attr('vid')) != "undefined")
        {
            var subval = $(this).attr('vid');
            $('input[name=index_hot_block]').val(subval);

        }
        if(typeof($(this).attr('sid')) != "undefined")
        {
            var pval = $(this).attr('sid');
            $('input[name=index_last_news]').val(pval); 
        }

        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(){   
    $('#save').on('click',function(event) {
        event.preventDefault();
        /* Act on the event */
        var hot_block = $("input[name='index_hot_block']").val();
        var last_news = $("input[name='index_last_news']").val(); 
               
        var hot_news = $("input[name='index_hot_news']").val();
        var block_id = $("input[name='index_block_id']").val();

        var regExp1 = /^\d+$/;
        var regExp2 = /^\d+(,\d+)*$/;
        if(hot_block == 1 && last_news == 1)
        {
            if(regExp1.test(hot_news) == false)
            {
                alert('请填写正确热点新闻ID');
                return false;
            }
            if(regExp2.test(block_id) == false)
            {
                alert('请填写正确板块数据');
                return false;
            }    
        }
        if (hot_block == 1 && last_news == 0)
        {
            if(regExp1.test(hot_news) == false)
            {
                alert('请填写正确热点新闻ID');
                return false;
            }
            
        }
        if (hot_block == 0 && last_news == 1)
        {
            if(regExp2.test(block_id) == false)
            {
                alert('请填写正确板块数据');
                return false;
            }
        }            
        if(hot_block == 0 && last_news == 0)
        {
            alert('至少要显示一个区块');
            return false;
        }
        $('#form1').submit();     
    });
})
</script>
<script>
        jQuery(document).ready(function($) {
            $('#order').on('click',  function(event) {
                event.preventDefault();
                /* Act on the event */
                var formObj={};
                var contr = '';
                var rege = /^\+?[0-9]+$/;
                $("[name^=ordernum]").each(function(){
                    n = $.trim($(this).val());
                    if(n !== '' && !rege.test(n))
                    {
                        alert('请输入正确序号');
                        contr = 1;
                        return false;
                    }
                    formObj[($(this).attr("sid"))]=n;
                });
                if(contr==1)
                {
                    return false;
                }
                $.post(
                    "<?php echo site_url('mocuz/client/sort_home_channel')?>",
                    {ordernum: formObj},
                    function(data) {
                        popup_saveSuccess();
                        location.href="<?php echo site_url('mocuz/client/index')?>";
                    },
                    'json');
                console.log(formObj);
            });
        });
    </script>
<script type="text/javascript">
$(function(){
    // 单选按钮切换
    $('.biu_rdo img').click(function(){
        var subval = $(this).attr('sid');
        $('input[name=requiredlogin]').val(subval);
        var isc=$(this).attr('isc');
        if(isc==0){
            $(this).attr('src','<?php echo asset_url("images/choice.png");?>');
            $(this).attr('isc','1');
            $(this).siblings().attr('src','<?php echo asset_url("images/unchoice.png");?>');
            $(this).siblings().attr('isc','0');
        }
    })
})    
</script>

    
<script type="text/javascript">
    //初始化
    function init()
    {
        //将第一个图标默认为显示的图标
        var obj = $('.add-icon').find('li').eq(0);
        obj.addClass('colorOn');
        var first_icon = obj.children('img').attr('src');
        var first_icon_src = first_icon.split("images/channel_img/");
        $('input[name=icon]').val(first_icon_src[1]);
        $('input[name=id]').val("");
        $('input[name=title]').val("");
        $('#goto_value').css('display','none'); 
        $('input[name=goto_value]').val("");
        $('select[name=cid] option').each(function() {
            if($(this).val() == 0)
            {

                $(this).attr('selected',true);
            }else{

                $(this).attr('selected',false);
            }
        });     
        $('input[name=requiredlogin]').val(1);
        $('img[sid=1]').attr('src','<?php echo asset_url("images/choice.png");?>');
        $('img[sid=1]').attr('isc','1');
        $('img[sid=0]').attr('src','<?php echo asset_url("images/unchoice.png");?>');
        $('img[sid=0]').attr('isc','0');
    }


    /*添加/编辑 图标样式显示*/
    function showIcon(icon)
    {
        $(".mark-choose").each(function(){
            var icon_src = $(this).children('img').attr('src');

            var icon_src_last = icon_src.split("images/channel_img/");
            if(icon_src_last[1] == icon)
            {
                $(this).addClass('colorOn');
                $(this).siblings().removeClass('colorOn');
                return true;
            }
        });        
    }

    //保存成功
    function popup_saveSuccess(){
        $('.ok_popup').show();
        setTimeout(function(){ $('.ok_popup').fadeOut(2000);},1000);
    }

    /*单击编辑操作*/
    $(document).on('click', '.channel-icon img', function(event) {
        event.preventDefault();
        /* Act on the event */
        init();
        var id = $(this).attr('mid');
        $.ajax({
            url: "<?php echo site_url('mocuz/client/get_home_channel')?>",
            type: 'POST',
            dataType: 'json',
            data: {id: id},
            success:function(data)
            {
                $('input[name=icon]').val(data.icon);
                $('input[name=title]').val(data.title);
                if(data.cid == 2018)
                {
                    $('#goto_value').children('span').text('帖子ID');
                }
                if(data.cid == 1003)
                {
                    $('#goto_value').children('span').text('版块ID');
                }
                if(data.cid == 1001)
                {
                    $('#goto_value').children('span').text('地址');
                }
                if(data.cid == 1003 || data.cid == 1001 || data.cid == 2018)
                {
                    $('#goto_value').show();
                }             
                showIcon(data.icon);
                $('input[name=goto_value]').val(data.goto_value);
                $('input[name=id]').val(data.id);

                $('input[name=requiredlogin]').val(data.requiredlogin);

                $('.biu_rdo img').each(function(){
                 if($(this).attr('sid') == data.requiredlogin)
                 {
                    $(this).attr('src','<?php echo asset_url("images/choice.png");?>');
                    $(this).attr('isc',1);
                 }else{
                    $(this).attr('src','<?php echo asset_url("images/unchoice.png");?>');
                    $(this).attr('isc',0);                    
                 }
                }); 


                $('select[name=cid] option').each(function() {
                                //限定必须登录的 选项
                    if(data.cid == 2019  || data.cid == 2020 || data.cid == 2011)
                    {
                        $('img[sid=0]').hide();
                        $('img[sid=0]').next('span').hide();
                    }
                    else{
                        $('img[sid=0]').show();
                        $('img[sid=0]').next('span').show();               
                    }
                     if($(this).val() == data.cid)
                     {
                        $(this).attr('selected',true);
                     }
                     else{
                        $(this).attr('selected',false);
                     }
                });

                $("#myModal").modal();
            }
        });
        
        

    });
    /*图片icon选择*/
    $(document).on('click', '.mark-choose', function(event) {
        event.preventDefault();
        /* Act on the event */
        $(this).addClass('colorOn');
        $(this).siblings().removeClass('colorOn');
        var src = $(this).children('img').attr('src');
        var icon = src.split("images/channel_img/");
        $('input[name=icon]').val(icon[1]);
    });

    $(document).ready(function() {
        $('select[name=cid]').change(function(event) {
            /* Act on the event */
            var cid = $(this).val();
            var rege = /^10.*$/;
            if(rege.test(cid))
            {
                $("#goto_value").show();
                if(cid == '1003')
                {
                    $("#goto_value").children('span').text('版块ID');
                    $("input[name=goto_value]").attr('placeholder','0');
                }
                else
                {
                    $("#goto_value").children('span').text('地址');
                    $("input[name=goto_value]").attr('placeholder','http://xxx.com');
                }
            }
            else
            {
                $("#goto_value").show();
                if(cid == '2018')
                {
                    $("#goto_value").children('span').text('帖子ID');
                    $("input[name=goto_value]").attr('placeholder','0');
                }else{
                    $("#goto_value").hide();
                    $("#goto_value").children('span').text('地址');                    
                }                

            }

            //限定必须登录的 选项
            if(cid == 2019  || cid == 2020 || cid == 2011)
            {
                $('img[sid=0]').hide();
                $('img[sid=0]').next('span').hide();
                $('input[name=requiredlogin]').val(1);
                $('img[sid=1]').attr('src','<?php echo asset_url("images/choice.png");?>');
                $('img[sid=1]').attr('isc','1');               
            }
            else{
                $('img[sid=0]').show();
                $('img[sid=0]').next('span').show();
                $('input[name=requiredlogin]').val(1);
                $('img[sid=1]').attr('src','<?php echo asset_url("images/choice.png");?>');
                $('img[sid=1]').attr('isc','1');   
                $('img[sid=0]').attr('src','<?php echo asset_url("images/unchoice.png");?>');
                $('img[sid=0]').attr('isc','0');               
            }
        });

        //弹窗隐藏 初始化
        $('#myModal').on('hide.bs.modal', function () {
            init();
        })

        //表单提交
        $("#edit_opt").on('click',function(event) {
            event.preventDefault();
            /* Act on the event */
            var regExp1 = /^(\w|-|[\u4e00-\u9fa5]){1,6}$/;
            var regExp2 = /^\d+$/;
            var regExp3 = /^[a-zA-z]+:\/\/[^\s]*$/;
            var title = $("input[name=title]").val();

            var cid = $("select[name=cid]").val();
            var icon = $("input[name=icon]").val();

            var goto_value = $("input[name=goto_value]").val();
            if(regExp1.test(title) == false)
            {
                alert("请输入正确版块名");
                return false;
            }
            if(parseInt(cid) == 0)
            {
                alert("请选择正确跳转分类");
                return false;
            }
            /*论坛版块 只能填数*/
            if(cid == '1003' && ! regExp2.test(goto_value))
            {
                alert("请填写正确版块ID");
                return false;
            }
            /*论坛版块 只能填数*/
            if(cid == '2018' && ! regExp2.test(goto_value))
            {
                alert("请填写正确帖子ID");
                return false;
            }       
            /*外部地址填写格式*/
            if(cid == '1001' && ! regExp3.test(goto_value))
            {
                alert("请填写正确外部链接地址");
                return false;
            }

            var mode ="";
            if($('input[name=id]').val())
            {
                mode = "/"+$('input[name=id]').val();
            }
            var requiredlogin = $('input[name=requiredlogin]').val();
            $.ajax({
                url: "<?php echo site_url('mocuz/client/save_home_channel"+mode+"')?>",
                type: 'POST',
                dataType: 'json',
                data: {title: title,cid:cid,goto_value:goto_value,icon:icon,requiredlogin:requiredlogin},
                success:function(data)
                {
                    if(data.code != 1)
                    {
                        alert(data.msg);
                        return false;
                    }
                    location.href="<?php echo site_url('mocuz/client/index')?>";
                    
                }
            })
        });
        //删除操作
        $(document).on('click', '.channel-del', function(event) {
            event.preventDefault();
            /* Act on the event */           
            $("input[name=channelId]").val($(this).prev('div').prev('div').children('img').attr('mid'));
        });
        $("#optdel").on('click', function(event) {
            event.preventDefault();
            var id = $("input[name=channelId]").val();
            $.ajax({
                url: '<?php echo site_url("mocuz/client/del_home_channel");?>',
                type: 'POST',
                dataType: 'json',
                data: {id: id},
                success:function(data){
                    if(data.code==1)
                    {
                        $("#delModal").modal('hide');
                        var obj = $('img[mid='+id+']');
                        obj.parent("div").parent("div").parent('li').remove();
                        $("#channel-add-i").show();
                    }
                }
            })
        });  
        //添加操作      
        $(".channel-add").on('click',function(event) {
            event.preventDefault();
            /* Act on the event */
            //初始化
            init();
            $("#myModal").modal();
        });



            // 模拟下拉框
    $('.sy_pz_type').click(function(e){
        e.stopPropagation();
        var isn=$(this).siblings('ul').attr('isn');
        if(isn==0){
            $(this).siblings('ul').show();
            $(this).siblings('ul').attr('isn','1');
            $(this).addClass('sy_pz_type_on');
            $('.sy_pz_type').not($(this)).siblings('ul').hide();
            $('.sy_pz_type').not($(this)).siblings('ul').attr('isn','0');
            $('.sy_pz_type').not($(this)).removeClass('sy_pz_type_on');
        }else{
            $(this).siblings('ul').hide();
            $(this).siblings('ul').attr('isn','0');
            $(this).removeClass('sy_pz_type_on');
        }
    })

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

    $('.sy_select ul li').click(function(){
        var vid = $(this).attr('vid'),
            channel_id = $(this).parent().attr('channel_id');
//        $("input[name=share_integral_type]").val(vid);
        $(this).parent().hide();
        $(this).parent().siblings('.sy_pz_type').removeClass('sy_pz_type_on');
        $(this).parent().attr('isn','0');
        var text=$(this).text();
        $(this).parent().siblings('.sy_pz_type').find('p').text(text);
        $.ajax({
            url: '<?php echo site_url("mocuz/client/save_home_channel_flag");?>',
            type: 'POST',
            dataType: 'json',
            data: {id: channel_id, flag: vid},
            success:function(data){
                if(data.code==1)
                {
//                    alert('已保存')
                }
            }
        })
    })

    });         
</script>