<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>增加/编辑系统字段设置</title>
<link rel="stylesheet" href="__STATIC__/layui/css/layui.css" media="all">
<script src="__STATIC__/layui/layui.js"></script>
</head>
<body style="background-color: #FFFFFF;">
<div class="layui-fluid" style="margin-top: 20px;" lay-filter="test1">
<form class="layui-form" action="{:url('system_add',['id'=>$id])}" method="post">
<div class="layui-form-item">
<label class="layui-form-label">类型</label>
<div class="layui-input-block">
<input type="radio" name="type" value="0" title="简短文本" {empty name="$rs.type"}checked{/empty}>
<input type="radio" name="type" value="1" title="图片" {if $rs.type == 1 }checked{/if}>
<input type="radio" name="type" value="2" title="文件" {if $rs.type == 2 }checked{/if}>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">标题</label>
<div class="layui-input-inline">
<input type="text" name="title" id="title" value="{$rs.title}" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">字段</label>
<div class="layui-input-inline">
<input type="text" name="field" value="{$rs.field}" required lay-verify="required" placeholder="只能输入英文" autocomplete="off" class="layui-input">
</div>
<div class="layui-form-mid layui-word-aux">例子:live_username</div>
</div>
</div>
<!--文本-->
<div class="layui-form-item" id="type0">
<label class="layui-form-label">值</label>
<div class="layui-input-block">
<input type="text" name="value" value="{$rs.value}" placeholder="" autocomplete="off" class="layui-input">
</div>
</div>
<!--图片-->
<div class="layui-form-item" id="type1">
<label class="layui-form-label">图片</label>
<div class="layui-input-block">
<input type="file" name="image[]" />
{if $rs.value }
<a href="/Uploads/{$rs.value}" target="_blank"><img style="float:left;" src="/Uploads/{$rs.value}" width="30" height="30px"></a>
{/if}
</div>
</div>
<!--文件-->
<div class="layui-form-item" id="type2">
<label class="layui-form-label">文件</label>
<div class="layui-input-block">
<input type="file" name="image[]" />
{if $rs.value }
<a href="/Uploads/{$rs.value}" target="_blank"><img style="float:left;" src="/Uploads/{$rs.value}" width="30" height="30px"></a>
{/if}
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">提示文字</label>
<div class="layui-input-block">
<textarea name="placeholder" placeholder="请输入提示内容" class="layui-textarea">{$rs.placeholder}</textarea>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">
<input type="text" name="sort" value="{$rs.sort}" placeholder="越大越前面" autocomplete="off" class="layui-input" value="1">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</form>
</div>
<script>
layui.use(['form', 'jquery'], function(){
var form = layui.form
,$= layui.$;
form.on('radio', function(data){
//console.log(data.elem); //得到radio原始DOM对象
//console.log(data.value); //被点击的radio的value值
if(data.value==1){
console.log('111');
}else if (data.value==2) {
console.log('2222');
}
});
layer.ready(function(){
$("#type0").show();
$("#type1").hide();
$("#type2").hide();
});
});
</script>
</body>
</html>
选中单选框,执行对应的事件