ext+mvc2.0登录面板

来源:互联网 发布:linux 硬盘的dd命令 编辑:程序博客网 时间:2024/05/18 01:37

 

jackAccess.Login = function() {
    var winFormPanel, formPanel, box, view, hasStutus = false;
    box = new Ext.BoxComponent({
        style: 'padding:2 2 2 2', autoEl: { tag: 'img', src: '/content/images/header.jpg' }
    });

    function Login() {
        if (formPanel.form.isValid()) {
            formPanel.form.submit({ url: "Rsb_AdminInfo/LogOn", waitmsg: "正在登录...", method: "get",params:{},
                success: function(form, action) {
                    if (action.result.flag) {
                        if (view == null) {
                            view = new jackAccess.ViewIndex();
                        }
                        view.shoMainPanel(); winFormPanel.hide();
                    }
                    else { Ext.MessageBox.alert("警告!", "错误的用户名或密码"); }
                },
                failure: function() { Ext.MessageBox.alert("警告!", "链接服务器失败"); }
            });
        }
    }
    function Check() {
        if (winFormPanel.hidden) {

            Ext.Ajax.request({ url: "rsb_admininfo/CheckLogOn", success: function(res, config) {
                var result = Ext.util.JSON.decode(res.responseText);
                if (result.flag) {
                    if (view == null) {
                        view = new jackAccess.ViewIndex();
                    }
                    view.shoMainPanel();
                } else {
                    winFormPanel.show();

                }
            }, failure: function() { Ext.MessageBox.alert("警告!", "链接服务器失败"); winFormPanel.show(); }
            });
        }

    }

    function CheckLogOn() {
        Ext.TaskMgr.start({
            run: Check,
            interval: 5000
        });
    }
    formPanel = new Ext.FormPanel({
        labelWidth: 40, frame: true,
        items: [{ layout: "column", items: [box, { layout: "form",
            items: [{ xtype: "textfield", fieldLabel: " 账号", labelWidth: 40, name: "UserName", allowBlank: false },
                        { xtype: "textfield", inputType: "password", fieldLabel: " 密码", labelWidth: 40, name: "Password", allowBlank: false },
                        { xtype: "checkbox", boxLabel: "记住密码", name: "RememberMe", labelWidth: 55}]}]}]
        });

        var json = { UserName: '', Password: '', RememberMe: '' };
        json.UserName = Ext.util.Cookies.get('UserName');
        json.Password = Ext.util.Cookies.get('Password');
        json.RememberMe = Ext.util.Cookies.get('RememberMe');
       
        if (json.RememberMe == "on") {
           
            formPanel.getForm().setValues(json);
        }

        winFormPanel = new Ext.Window({ title: "登录系统", resizable: false, iconCls: "logon", closable: false,
            width: 300, modal: true, buttonAlign: "center", closeAction: "hide",
            items: formPanel,
            buttons: [{ text: "登录", handler: function() { Login(); } }, { text: "取消", handler: function() { } }]
        });
        return { Checking: function() { CheckLogOn(); } }
    }

 

原创粉丝点击