<pre name="code" class="html"><!doctype html>
<html>
<head>
<title>获取与CAS集成项目的用户信息</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="yes" name="apple-touch-fullscreen">
<meta content="telephone=no" name="format-detection">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="#ffffff" name="msapplication-TileColor">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
</head>
<body>
<div>hello</div>
<script type="text/javascript" src="js/jquery-3.1.0.min.js"></script>
<script type="text/javascript">
var username="11";
var password="111";
var ctx="http://chenyongtu.gicp.net";
var ctx_t=ctx+"/teenagers";
var ctx_c=ctx+"/cas";
var url_userinfo=ctx+"/teenagers/a/mobile/userInfoNew?mobileLogin=true"
var _services="service="+ encodeURIComponent(ctx_t+"/a/myTest/testLogin");
var casUrl=ctx_c+"/login?"+_services+"&get-lt=true&n="+new Date().getTime();
$(document).ready( function(){
//getuserinfo(url_userinfo);
getTL(casUrl);
});
function getTL(url){
$.ajax({
url:url,
type:'get',
data:'',
async : false,
error:function(){
alert('error');
},
success:function(result){
console.log(result);
var data="lt="+result.split("&")[0]+"&execution="+result.split("&")[1].replace("/\r\n/g", "").replace("/\n/g", "")+"&_eventId=submit&username="+username+"&password="+password+"&submit=%E7%99%BB%E5%BD%95";
var services="service="+encodeURIComponent(ctx_t+"/a/cas");
var url=ctx_c+"/login?"+services+"&"+data;
console.log("url"+url);
login(url);
}
});
}
function login(url){
$.ajax({
url:url,
type:'post',
data:'',
async : false,
error:function(){
alert('error');
},
success:function(data){
console.log(data);
getuserinfo(url_userinfo);
}
});
}
function getuserinfo(url){
$.get(url, function(data){
console.log(data);
});
}
</script>
</body>
</html>