zoukankan      html  css  js  c++  java
  • js前端登录js脚本

    html部分

    <div class="col-md-6">
    	<div class="ibox-content">
    		<div class="m-t login_wrap">
    			<div class="form-group text-center">
    				<h2 class="font-bold">登录</h2>
    			</div>
    			<div class="form-group">
    				<input type="text" name="login_name" class="form-control" placeholder="请输入登录用户名">
    			</div>
    			<div class="form-group">
    				<input type="password" name="login_pwd" class="form-control" placeholder="请输入登录密码">
    			</div>
    			<button type="button" class="btn btn-primary block full-width m-b do-login">登录</button>
    		</div>
    	</div>
    </div>
    

    js部分

    • js文件开头用分号";"的原因:为了多个JS文件合并压缩的时候防止文件之间没有;分隔导致错误
    ;
    let user_login_ops = {
        init: function () {
            this.eventBind();
        },
        eventBind: function () {
            $(".login_wrap .do-login").click(function () {
                let login_name = $(".login_wrap input[name=login_name]").val();
                let login_pwd = $(".login_wrap input[name=login_pwd]").val();
    
                if (login_name == undefined || login_name.length < 1) {
                    common_ops.alert("请输入正确的登录用户名");
                    return;
                }
                if (login_pwd == undefined || login_pwd.length < 1) {
                    common_ops.alert("请输入正确的密码");
                    return;
                }
    
                $.ajax({
                    url: common_ops.buildUrl("/user/login"),
                    type: 'POST',
                    data: {'login_name': login_name, 'login_pwd': login_pwd},
                    dataType: 'json',
                    success: function (res) {
                        btn_target.removeClass("disabled");
                        let callback = null;
                        if (res.code == 200) {
                            callback = function () {
                                window.location.href = common_ops.buildUrl("/");
                            }
                        }
                        common_ops.alert(res.msg, callback);
                    }
                });
            });
        }
    };
    
    $(document).ready(function () {
        user_login_ops.init();
    });
    
    Hole yor life get everything if you never give up.
  • 相关阅读:
    Educational Codeforces Round 81 (Rated for Div. 2) A-E
    SEERC 2018 I
    manjaro linux java环境配置
    Pangu and Stones HihoCoder
    Linux下 vim 的配置
    C++内存管理技术
    Interview_C++_day27
    Interview_C++_day26
    Interview_C++_day25
    Interview_数据库_day24
  • 原文地址:https://www.cnblogs.com/1fengchen1/p/15617336.html
Copyright © 2011-2022 走看看