基於easyUI實現登入介面,easyUI實現登入介面

來源:互聯網
上載者:User

基於easyUI實現登入介面,easyUI實現登入介面

此文章是基於

    EasyUI+Knockout實現經典表單的查看、編輯

 

一. 準備工作

  1. 點擊此下載相關檔案,並把檔案放到 ims 工程對應的檔案夾下

 

二. 相關檔案介紹

  1. login.jsp:系統主介面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><html> <head>    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">    <title>公司資訊管理系統-登入</title>    <%@ include file="/common/basePath.jsp"%>    <link href="content/css/page/login.css" rel="stylesheet" type="text/css" /> </head>  <body>     <div class="second_body">        <form data-bind="submit:loginClick">            <div class="logo"></div>            <div class="title-zh">公司資訊管理系統</div>            <div class="title-en" style="">Enterprise Information Manage System</div>            <div class="message" data-bind="html:message"></div>            <table border="0" style="width:300px;">                <tr>                    <td style="white-space:nowrap; padding-bottom: 5px;width:55px;">使用者名稱:</td>                    <td colspan="2"><input type="text" id="userCode" class="login" data-bind="value:form.userCode" /></td>                </tr>                <tr>                    <td class="lable" style="white-space:nowrap; letter-spacing: 0.5em; vertical-align: middle">密碼:</td>                    <td colspan="2"><input type="password" id="password" class="login" data-bind="value:form.password" /></td>                </tr>                <tr>                    <td></td>                    <td colspan="2"><input type="checkbox" data-bind="checked:form.remember" /><span>系統記住我</span></td>                </tr>                <tr>                    <td colspan="3" style="text-align:center">                        <input type="submit" value="登入" class="login_button" />                        <input type="button" value="重設" class="reset_botton" data-bind="click:resetClick" />                    </td>                </tr>            </table>        </form>    </div>             <script type="text/javascript" src="content/js/jquery/jquery-1.8.1.min.js"></script>    <script type="text/javascript" src="content/js/jquery-plugin/cookie/jquery.cookie.js"></script>    <script type="text/javascript" src="content/js/core/utils.js"></script>    <script type="text/javascript" src="content/js/core/common.js"></script>     <script type="text/javascript" src="content/js/core/knockout-3.4.1.js"></script>    <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>    <script type="text/javascript" src="viewModel/login.js"></script>          <script type="text/javascript">         $(function () {             ko.applyBindings(new viewModel());         });     </script> </body></html>       
View Code

  

  2. login.js:綁定登入介面的功能按鈕

var viewModel = function () {    var self = this;    this.form = {        userCode: ko.observable(),        password: ko.observable(),        remember: ko.observable(false),        ip: null,        city: null    };    this.message = ko.observable();    this.loginClick = function (form) {        if(utils.isEmpty(self.form.password()))// 瀏覽器記住密碼 不執行knockout監聽            self.form.password($("#password").val());        if(utils.isEmpty(self.form.userCode()))            self.form.userCode($("#userCode").val());        $.ajax({            type: "POST",            url: rootPath+"/sys/login.do",            data: ko.toJSON(self.form),            dataType: "json",            contentType: "application/json",            success: function (d) {                if (d.status == 'success') {                    self.message("登陸成功正在跳轉,請稍候...");                    window.location.href = rootPath+'/';                } else {                    self.message(d.message);                }            },            error: function (e) {                self.message("登陸失敗");            },            beforeSend: function () {                $(form).find("input").attr("disabled", true);                self.message("正在登陸處理,請稍候...");            },            complete: function () {                $(form).find("input").attr("disabled", false);            }        });    };    this.resetClick = function () {        self.form.userCode("");        self.form.password("");        self.form.remember(false);    };    this.init = function () {        self.form.ip = returnCitySN.cip;        $.getJSON("http://api.map.baidu.com/location/ip?ak=F454f8a5efe5e577997931cc01de3974&callback=?", function (d) {            self.form.city = d.content.address;        });        if (top != window) top.window.location = window.location;        //判斷之前是否有設定cookie,如果有,則設定【記住我】選擇框          if(com.cookie('userCode')!=null){              self.form.remember(true);        }else{              self.form.remember(false);          }                    //讀取cookie          if(self.form.remember()){              self.form.userCode(com.cookie('userCode'));              self.form.password(com.cookie('password'));          }     };    this.init();}; 
View Code

 

三.

  1. 訪問:http://localhost:8090/ims/login.do,登入主介面

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.