在登录时只需在原系统登录时以ajax登录上报表系统,使报表系统处于登录状态
<html>
<head>
<script src='finereport.js'></script>
<script src='jquery.js'></script>
<script>
function cjkEncode(text) {
if (text == null) {
return "";
}
var newText = "";
for (var i = 0; i < text.length; i++) {
var code = text.charCodeAt (i);
if (code >= 128 || code == 91 || code == 93) { //91 is "[", 93 is "]".
newText += "[" + code.toString(16) + "]";
} else {
newText += text.charAt(i);
}
}
return newText;
}
function op(){
var username ='admin'//document.getElementById("username").value;
var password ='123456'//document.getElementById("password").value;
jQuery.ajax({
url:"http://localhost:8075/WebReport/ReportServer?op=fs_load&cmd=sso",//单点登录的报表服务器
dataType:"jsonp",//跨域采用jsonp方式
data:{"fr_username":username,"fr_password":password},
jsonp:"callback",
timeout:5000,//超时时间(单位:毫秒)
success:function(data) {
if (data.status === "success") {
alert("success"); //登录成功
window.location=data.url;//登录成功,直接跳转到平台系统页面
window.location=cjkEncode('http://localhost:8075/WebReport/ReportServer?reportlet=/培训/demo3.cpt&part=华东');
}else if (data.status === "fail"){
alert("fail");//登录失败(用户名或密码错误)
}
},
error:function(){
alert("error"); // 登录失败(超时或服务器其他错误)
}
});
}
</script>
</head>
<body>
<button onclick='op()'>切换页面</button>
</body>
</html>