{include file="common/top"/}
{include file="common/ueditor"/}

<div class="iframe_content">
	<div class="iframe_add images_box">
    	<form action="{:url('update')}" class="layui-form" name="rule" id="rule" method="post" onsubmit="return TQsubmit();">
        <input name="id" type="hidden" value="{$info.id}" />
    	<ul>
            <li><label class="layui-form-label">标　　题</label><input type="text" name="title" value="{$info.title}" placeholder="" autocomplete="off" class="layui-input"></li>
            <li><label class="layui-form-label">链　　接</label><input type="text" name="url" value="{$info.url}" placeholder="http://" autocomplete="off" class="layui-input"></li>
            <li class="images_pic_input"><label class="layui-form-label">图　　片</label>{tp:upload id="pic" name="pic" value="<?php echo $info['pic']; ?>" }</li>
            {if $info['pid']==10}
            <li class="images_pic_input"><label class="layui-form-label">附加图片</label>{tp:upload id="pic1" name="pic1" value="<?php echo $info['pic1']; ?>" }</li>
            <!--<li class="images_pic_input"><label class="layui-form-label">视　　频</label>{tp:upload_file id="sp" name="sp" value="<?php echo $info['sp']; ?>" }</li>-->
            {/if}
            <li>
                <label class="layui-form-label">是否显示</label>
                <div>
                    <input type="radio" name="is_effect" value="1" title="启用" {if $info['is_effect']==1}checked{/if}>
                    <input type="radio" name="is_effect" value="2" title="停用" {if $info['is_effect']==2}checked{/if}>
                </div>
            </li>
            <li>
                <label class="layui-form-label">跳新窗口</label>
                <div>
                    <input type="radio" name="is_new" value="1" title="否" {if $info['is_new']==1}checked{/if}>
                    <input type="radio" name="is_new" value="2" title="是" {if $info['is_new']==2}checked{/if}>
                </div>
            </li>
        </ul>
        </form>
    </div>
</div>

<div class="iframe_foot">
<input name="" type="submit" onclick="TQsubmit();" class="layui-btn TQmovesubmit" />　　
<input name="" type="button" value="关闭" onclick="open_iframe_close();" class="layui-btn layui-btn-danger" />
</div>
{include file="common/bottom"/}
<script>
function TQsubmit(){
	$('.TQmovesubmit').attr('onclick','');
	$.post('update',$("#rule").serialize(),function(data){
		console.log(data);
		if(data.type==1){
			layer.msg(data['msg'], {icon:2,time:1000});
			$('.TQmovesubmit').attr('onclick','TQsubmit();');
		}else{
			layer.msg(data['msg'], {icon:1,time:1000});
			$("body",parent.document).find('#open_iframe').val(1);
			setTimeout(function(){ window.location.reload(); },1500);
		}
    });
	return false;
}

layui.use('form', function(){
	var form = layui.form;
	form.on('select(pid)', function(data){
		var lv=$(data.elem).find("option:selected").attr('data-lv');
		var text=$.trim($('.layui-pid .layui-input').val());
		$('.layui-pid .layui-input').val(text);
		$(data.elem).find("option:selected").text(text);
	});  
});
</script>