--------flex前端--------
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
//先获取cookie
Alert.show("正在自动登录。。。","温馨提示");
var jsFunction:String = "GetCookie";
var key:String = "LtpaToken";
var value:String
if(ExternalInterface.available)
{
//获取叫LtpaToken的cookie
var value = ExternalInterface.call(jsFunction,key);
myCookie = value;
}
if(value != null && value != ""){
currentState = "autoLogin";
}
setTimeout( function():void{ initData();},1000,null);
}
private function initData():void
{
fAppCore.fConfig.fWebServerURL="http://"+URLUtil.getServerNameWithPort(FlexGlobals.topLevelApplication.loaderInfo.url)+"/"+fAppCore.fConfig.fWebAppName;
fAppCore.fConfig.fWebChannelSet=fAppCore.fConfig.fWebServerURL+"messagebroker/amf";
/* 从其它站点自动登录 */
if(currentState == "autoLogin"){
var param:Object = new Object();
param.LtpaToken = myCookie;
//获取工号
var sJsp:HTTPService = new HTTPService();
sJsp.resultFormat = "text";
sJsp.method = "POST";
sJsp.url = fAppCore.fConfig.fWebServerURL + "/LoginClient";
sJsp.addEventListener(ResultEvent.RESULT,result_test);
sJsp.send(param);
}
}
private function result_test(event:ResultEvent):void{
var msg:String = event.message.body.toString();
if(msg != "-1"){
fAppCore.dataDeal.dataDealQueryToData("userLoginFlex","userLoginFlex","clientAutoLogin",[msg]);
fAppCore.dataDeal.remoteMethods.addEventListener(ResultEvent.RESULT,userLoginHandle);
}else{
//TAlert.show("自动登录失败,请联系管理员!","系统提示");
txt_loginInfoLose.text = "自动登录失败,请联系管理员!";
setTimeout(function():void{ autoLostTest(3);},1000,null);
}
}
private function autoLostTest(time:int):void{
txt_loginInfo.text = "还有"+time+"秒返回手动登录...";
time--;
if(time >= 0)
setTimeout(function():void{ autoLostTest(time);},1000,null);
else
currentState = "appLoginState";
}