//设置当前公用域 //try {document.domain = "qingdao.gov.cn";} catch (e) {} //全局变量 var global_go_url=''; var global_callback = null; var global_param = null; var global_target = '_self'; //ucweb地址 var _ucUrl = "http://login.qingdao.gov.cn"; //注销后将去向何处 var _logoutUrl = "http://www.qingdao.gov.cn"; //document.write(''); var _loadJs = function(jsUrl,cb,async){//加载js文件的方法 var script = document.createElement( "script" ); script.async = "async"; script.src = jsUrl; head.insertBefore( script, head.firstChild ); } head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; _loadJs(_ucUrl+'/skins/js/messenger.js'); function _closeLoginDlg(){ var o1 = document.getElementById("is_login_iframe"); var o2 = document.getElementById("uc_login_dlg"); if(o1){ document.body.removeChild(o1); } if(o2){ document.body.removeChild(o2); } return false; } var _winWidth = 0; var _winHeight = 0; function getDimensions() //函数:获取尺寸 { //获取窗口宽度 if (window.innerWidth) _winWidth = window.innerWidth; else if ((document.body) && (document.body.clientWidth)) _winWidth = document.body.clientWidth; //获取窗口高度 if (window.innerHeight) _winHeight = window.innerHeight; else if ((document.body) && (document.body.clientHeight)) _winHeight = document.body.clientHeight; //通过深入Document内部对body进行检测,获取窗口大小 if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth){ _winHeight = document.documentElement.clientHeight; _winWidth = document.documentElement.clientWidth; } } var loginDlg = { initCallBack:function(param){ if(typeof(param)=="undefined"){ param = window.location.href; } global_param=param; switch(typeof param){ case "function":{ //传回调函数 global_callback = param; global_go_url = _ucUrl+"/login/login.do?method=loginJump";//第三方登陆用到 break; } case "string":{ //传url global_go_url = param; global_callback = function(url){ if(url == ''){ window.location.reload(); }else{ window.location.href = url; } } break; } case "object": { if(typeof param.url != "undefined") { global_go_url = param.url; global_target = param.target?param.target:"_self"; if(global_target == "_blank") { global_callback = function(url) { if(document.getElementById("Dlg-jump-a")) document.body.removeChild(document.getElementById("Dlg-jump-a")); var dlg_jump_a = document.createElement("a"); dlg_jump_a.id = "Dlg-jump-a"; dlg_jump_a.href = url; dlg_jump_a.target = "_blank"; document.body.appendChild(dlg_jump_a); setTimeout(function(){ var evt = document.createEvent('MouseEvents'); evt.initEvent('click', true, true); dlg_jump_a.dispatchEvent(evt); },100); } } else { global_callback = function(url){ if(url == ''){ window.location.reload(); }else{ window.location.href = url; } } } } else { return; } } default :return; } }, poplogin : function(param){ var $this = this; var doOpertaion = function(){ _closeLoginDlg(); $this.initCallBack(param); var iframe = document.createElement('iframe'); iframe.id="is_login_iframe" ; iframe.style.display="none"; iframe.src = _ucUrl+'/login/login.do?method=isLoginForDlg'; document.body.appendChild(iframe); var isLoginMessenger = Messenger.initInParent(document.getElementById('is_login_iframe')); isLoginMessenger.onmessage = function (data) { data = data.replace(/(^\s*)|(\s*$)/g, ""); if(data == "nologined"){ $this.doPoplogin(global_param); } else if(data == "islogined") { if(typeof global_param == "function"){ global_callback(); } else { if(global_go_url.indexOf('?') == -1){ global_go_url = global_go_url+"?uclogin=1"; } else { if(global_go_url.indexOf('uclogin=1') == -1){ global_go_url = global_go_url+"&uclogin=1"; } } global_callback(global_go_url); } } }; }; var msgMgr = function(){ if(typeof Messenger == "undefined" || !(document.body)){ setTimeout(function(){ msgMgr(); },1000); } else { doOpertaion(); } } msgMgr(); }, //传参:function 或 url doPoplogin: function(param){ if(document.getElementById("uc_login_dlg"))return; var body = document.body; getDimensions(); var overLayerStyle = "position:fixed;" + "_position:absolute;" + "top:0;" + "left:0;" + "width:"+_winWidth+"px;" + "height:"+_winHeight+"px;" +//ie6下100%高度、宽度有问题很小 "padding:0;" + "margin:0;" + "border:0;" + "background:#000;" + "opacity:0.5;" + "vertical-align:center;" + "filter:alpha(opacity=50);" + "z-index:9999999 !important;" + "zoom:1;" ; var iframeStyle = "position:fixed;" + "_position:absolute;" + "top:0;" + "left:0;" + "width:575px;" + "height:370px;" + "padding:0;" + "margin:0;" + "border:0;" + "background:transparent;" + "z-index:9999999;" + "zoom:1;"; var closeBtnStyle = "z-index:9999999;" + "position:fixed;" + "_position:absolute;" + "top:0px;" + "left:0px;" + "width:14px;" + "height:13px;" ; var closeBtnSpanStyle= "text-indent: -9999px;" + "width: 16px;" + "display: block;" + "background: url("+_ucUrl+"/skins/images/login/btns_login.png) 1px -159px;" + "height: 16px;" + "overflow: hidden;"; var global_go_url_enc = encodeURIComponent(global_go_url); var overLayer = '
'; var iframe = ''; var closeBtn = 'close'; var div = document.createElement("div"); div.setAttribute("id","uc_login_dlg"); div.innerHTML = overLayer + iframe +closeBtn; body.appendChild(div); var overLayerDom = document.getElementById("login_iframe_overLayer"); var iframeDom = document.getElementById("login_iframe"); var closeBtnDom = document.getElementById("login_iframe_close_btn"); iframeDom.style.left = (overLayerDom.clientWidth-iframeDom.clientWidth)/2 + "px"; iframeDom.style.top = (overLayerDom.clientHeight-iframeDom.clientHeight)/2+ "px"; closeBtnDom.style.left = (overLayerDom.clientWidth+iframeDom.clientWidth)/2 - closeBtnDom.clientWidth -15+ "px"; closeBtnDom.style.top = (overLayerDom.clientHeight-iframeDom.clientHeight)/2 + 5+ "px"; var messenger = Messenger.initInParent(document.getElementById('login_iframe')); messenger.onmessage = function (data) { var gotoUrl = ''; data = data.replace(/(^\s*)|(\s*$)/g, ""); if(typeof param == "function"){ //第三方登陆或普通登陆成功 //不支持跳转完善资料页面 if(data == "execCallback"||data == "loginok"||data.indexOf('goto:')>=0){ _closeLoginDlg(); global_callback(); } }else if(typeof param == "string"){ //第三方登陆或普通登陆成功 if(data == "execCallback"||data == "loginok"){ //global_go_url = decodeURIComponent(global_go_url); if(global_go_url.indexOf('?') == -1){ global_go_url = global_go_url+"?uclogin=1" }else{ if(global_go_url.indexOf('uclogin=1') == -1){ global_go_url = global_go_url+"&uclogin=1" } } gotoUrl = global_go_url; global_callback(gotoUrl); }else { //登录成功后跳转完善资料页面 var index = data.indexOf('goto:'); if(index >= 0){ gotoUrl = decodeURIComponent(data.substring(index+5)); global_callback(gotoUrl); } } } return; }; } } function LoginDlg_doLogin(callback_url) { if(typeof callback_url == "object") { if(callback_url[0] == "undefined") { callback_url = ""; } else { callback_url = callback_url[0]; } } callback_url = callback_url || window.location.href; if(typeof(loginDlg) != "undefined"){ loginDlg.poplogin(callback_url); } } function LoginDlg_doLogout(callback_url) { if(typeof callback_url == "object") { if(callback_url[0] == "undefined") { callback_url = ""; } else { callback_url = callback_url[0]; } } var logout_url = _ucUrl+"/index/index.do?method=logoutAll"; callback_url = callback_url || _logoutUrl; window.location.href = logout_url+"&callback_url="+callback_url; return false; }