<input name="{$switchName}" id="{$switchName}" <?php echo $switchChecked ?> value="<?php echo $switchValue?>" lay-skin="switch" lay-filter="{$switchFilter}" lay-text="{$switchTitle}" type="checkbox">
<script>
layui.use(['form'], function(){
	var form = layui.form,
		$ = layui.$;

	// 初始化
    var hidden = "{$switchHidden}";
    if ("<?php echo $switchValue?>" == 1) {
        if (hidden != "") {
            $("."+hidden).removeClass("layui-hide");
        }
        $("#{$switchName}").attr('type', 'hidden').val(1);
    } else {
        if (hidden != "") {
            $("."+hidden).addClass("layui-hide");
        }
        $("#{$switchName}").attr('type', 'hidden').val(2);
    }

	form.on('switch({$switchFilter})', function(data) {
		console.log('switch开关选择状态：'+this.checked);
	    $(data.elem).attr('type', 'hidden').val(this.checked ? 1 : 2);
        // 设置隐藏域
        if (hidden != "") {
            var isSel = data.elem.checked;
            if (isSel) {
                $("."+hidden).removeClass("layui-hide");
            } else {
                $("."+hidden).addClass("layui-hide");
            }
        }
	});
});
</script>