| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>接口服务登录</title>
- <link href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
- <script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
- <script src="//cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- <style type="text/css">
- .login-box {
- width: 360px;
- padding: 30px 20px;
- background: #fff;
- margin: auto;
- margin-top: 170px;
- }
- .login-box-body h3 {
- display: block;
- font-weight: 500;
- line-height: 1.1;
- color: inherit;
- font-size: 24px;
- text-align: center;
- padding-top: 20px;
- padding-bottom: 20px;
- }
- </style>
- </head>
- <body style="background: #d2d6de;">
- <div class="login-box">
- <!-- /.login-logo -->
- <div class="login-box-body">
- <!--<div class="logo"><img src="images/logo.png"></div>-->
- <h3>接口服务登录</h3>
- <div>
- <div class="form-group has-feedback">
- <input id="userName" type="text" class="form-control" name="account" placeholder="用户名">
- <span class="glyphicon glyphicon-user form-control-feedback"></span>
- </div>
- <div class="form-group has-feedback">
- <input id="password" type="password" class="form-control" name="pwd" placeholder="密码">
- <span class="glyphicon glyphicon-lock form-control-feedback"></span>
- </div>
- <div style="margin-left: -18px;text-align: center">
- <button id="loginBtn" type="submit" class="btn btn-primary" style="width: 310px;">登录</button>
- </div>
- </div>
- <!-- /.login-box-body -->
- </div>
- </div>
- <script type="text/javascript">
- $(function () {
- $("#loginBtn").click(function () {
- login();
- });
- $(document).keydown(function (event) {
- if (event.keyCode == 13) {
- $("#loginBtn").click();
- }
- });
- });
- //登录方法
- function login() {
- $("#loginBtn").html("登陆中...");
- var srcurl = window.location.href;
- var url="/user/login";
- if (srcurl.indexOf("apis") != -1) {
- url="/apis/user/login";
- }
- var account=$("#userName").val();
- var password=$("#password").val();
- if(account ==""){
- alert("用户名不能为空");
- return;
- }
- if(password==""){
- alert("请输入密码");
- return;
- }
- var data={
- "account":account,
- "password":password
- };
- $.ajax({
- url:url,
- type:'post',
- data: {
- "user": JSON.stringify(data)
- },
- dataType:'json',
- contentType : 'application/json',
- success:function (res) {
- if(res.httpCode == 200){
- $("#loginBtn").html("登陆成功");
- var destUrl="/xdoc/index";
- if (srcurl.indexOf("apis") != -1) {
- destUrl="/apis/xdoc/index";
- }
- window.location.href=destUrl;
- }
- else{
- $("#loginBtn").html("登陆");
- alert(res.msg);
- }
- },
- error:function (res) {
- alert(res.msg);
- }
- })
- }
- </script>
- </body>
- </html>
|