layui弹出输入框

383 阅读1分钟
<script>
    layui.use('layer', function(){ //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
        var f = {$server.f};
        if(f==0){
            layer.open({
                id:1,
                type: 1,
                title:'修改密码',
                skin:'layui-layer-rim',
                area:['450px', 'auto'],
                closeBtn :0,//右上角的关闭按钮取消
                content: ' <div class="row" style="width: 420px;  margin-left:7px; margin-top:10px;">'
                +'<div class="col-sm-12">'
                +'<div class="input-group">'
                +'<span class="input-group-addon"> 新 密 码   :</span>'
                +'<input id="firstpwd" type="password" class="form-control" placeholder="请输入密码">'
                +'</div>'
                +'</div>'
                +'<div class="col-sm-12" style="margin-top: 10px">'
                +'<div class="input-group">'
                +'<span class="input-group-addon">确认密码:</span>'
                +'<input id="secondpwd" type="password" class="form-control" placeholder="请再输入一次密码">'
                +'</div>'
                +'</div>'
                +'</div>'
                ,
                btn:['保存'],
                btn1: function (index,layero) {
                    var firstpwd = $('#firstpwd').val();
                    var secondpwd = $('#secondpwd').val();
                    if(firstpwd != secondpwd){
                        layer.msg('密码不一致', {time: 1500, anim: 6});
                    }else{
                        $.post("{:url('index/edit')}", { firstpwd: firstpwd,'secondpwd':secondpwd},
                            function(data){
                                if(data.code==1){
                                    layer.msg(data.msg, {time: 1500}, function () {
                                        window.location.href = data.url;
                                    });
                                }else{
                                    layer.msg(data.msg, {time: 1500, anim: 6});
                                }
                            });
                    }
                }
            });
        }

    })
</script>