$scope.login = function()

in src/main/resources/static/src/login.js [19:44]


    $scope.login = function () {
        if (!$("#username").val()) {
            alert("用户名不能为空");
            return;
        }
        if (!$("#password").val()) {
            alert("密码不能为空");
            return;
        }

        $http({
            method: "POST",
            url: "login/login.do",
            params: {username: $("#username").val(), password: $("#password").val()}
        }).success(function (resp) {
            if (resp.status == 0) {
                Notification.info({message: 'Login successful, redirect now', delay: 2000});
                $window.sessionStorage.setItem("username", resp.data.loginUserName);
                $window.sessionStorage.setItem("userrole", resp.data.loginUserRole);
                window.location = resp.data.contextPath;
                initFlag = false;
            } else {
                Notification.error({message: resp.errMsg, delay: 2000});
            }
        });
    };