52,792
社区成员




if (cmd == "login")
{
context.Response.Write("{success:true}");
}
}
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>华中电力科技开发公司电网事业二部短信群发平台</title>
</head>
<body background="images/webroot/login_backgroud.jpg">
<link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
<script type="text/javascript" src="scripts/ext/ext-base.js"></script>
<script type="text/javascript" src="scripts/ext/ext-all.js"></script>
<script>
// sets default ExtJS blank image
Ext.BLANK_IMAGE_URL = "resources/images/default/s.gif";
Ext.QuickTips.init();
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
Ext.onReady(function(){
formWindow = new Ext.Window({
id:'formWindow',
title:'用户登录',
layout :"fit",
closable : false, // 禁止关闭登录页面
draggable : false, // 设置页被面不能拖动
resizable:false, // 不能拖动其大小
width:330,
height : 145,
items:[
new Ext.form.FormPanel({
id:'formTest',
// url:"index.jsp",
bodyStyle:'padding:10px',
border:false,
labelWidth:70,
items:[
new Ext.form.TextField({
id:'userName',
fieldLabel:'用户名',
//autoWidth: true,
width : 200,
allowBlank :false,
autoHeight: true
}),
new Ext.form.TextField({
id:'userPwd',
fieldLabel:'密码',
// autoWidth: true,
width : 200,
autoHeight: true,
allowBlank :false,
inputType:'password'
// vtype:'email' //设定此文本框输入的格式为 email 的格式
})],
buttons:[
new Ext.Button({
text:'登录',
type:'submit',
onSubmit : Ext.emptyFn,
listeners:{
click:function(){
if(formTest.getForm().isValid()){
Ext.MessageBox.show({
id : "refBox1",
title: '提示',
msg: '正在初始化,请稍后...',
progressText: 'Initialization...',
width : 300,
wait:true,
waitConfig: {interval:200}
});
setTimeout(function(){
Ext.MessageBox.hide();
Ext.example.msg('Done', 'Done Refresh!');
},50000);
// 实现AJAX提交表单
formTest.form.doAction('submit',{
url:'<%=path%>/login.do',
method:'post',
// 根据回调的 json 数据判断是 success 还是 failure
success:function(form,action){
document.location='index.jsp';
},
//提交失败的回调函数
failure:function(){
Ext.Msg.alert('错误','服务器出现错误请稍后再试!');
}
})
}
}
}
}),
new Ext.Button({
text:'取消',
type:'reset',
listeners:{
click:function(){formTest.form.reset()}
}
})
]
})],
contentEl:'formWindowEl'
});
})
</script>
<div class="x-hide-display" id="formWindowEl"></div>
<script>
Ext.onReady(function(){
try {
formWindow = Ext.getCmp('formWindow');
formTest = Ext.getCmp('formTest');
} catch(e){};
});
</script>
<script>
Ext.onReady(function(){
formWindow.show();
});
</script>
</body>
</html>
Ext.onReady(function()
{
Ext.QuickTips.init();
LoginWindow=Ext.extend(Ext.Window,{
title : '登陆系统',
width : 265,
height : 170,
collapsible : true,
defaults : {
border : false
},
buttonAlign : 'center',
createFormPanel :function() {
return new Ext.form.FormPanel( {
bodyStyle : 'padding-top:6px',
defaultType : 'textfield',
labelAlign : 'right',
labelWidth : 55,
labelPad : 0,
frame : true,
defaults : {
allowBlank : false,
width : 158
},
items : [{
cls : 'user',
name : 'username',
fieldLabel : '帐号',
blankText : '帐号不能为空'
}, {
cls : 'key',
name : 'password',
fieldLabel : '密码',
blankText : '密码不能为空',
inputType : 'password'
}, {
cls : 'key',
name:'randCode',
id:'randCode',
fieldLabel:'验证码',
width:80,
blankText : '验证码不能为空'
}]
});
},
login:function() {
this.fp.form.submit({
waitMsg : '正在登录......',
url : 'login.ashx?cmd=login',
success : function(form, action) {
//alert(action.response.responseText)
//window.location.href = 'default.aspx';
},
failure : function(form, action) {
form.reset();
if (action.failureType == Ext.form.Action.SERVER_INVALID)
Ext.MessageBox.alert('警告', action.result.errors.msg);
}
});
},
initComponent : function(){
LoginWindow.superclass.initComponent.call(this);
this.fp=this.createFormPanel();
this.add(this.fp);
this.addButton('登陆',this.login,this);
this.addButton('重置', function(){this.fp.form.reset();},this);
}
});
var win=new LoginWindow();
win.show();
var bd = Ext.getDom('randCode');
var bd2 = Ext.get(bd.parentNode);
bd2.createChild({tag: 'img', src: 'checkcode.aspx',align:'absbottom'});
}
);