(function ($) { $.getUrlParam = function (name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } })(jQuery); $(function() { document.cookie = "cas_hash=" + encodeURIComponent(window.location.hash) ; document.cookie = "accessUrl" + "=" + $.getUrlParam("service") + "; " ; try{ if(window.localStorage){ //重新登录的时候清除掉localStorage window.localStorage.clear(); } if(window.sessionStorage){ //重新登录的时候清除掉sessionStorage window.sessionStorage.clear(); } }catch(e){} var passwordhtml = document.getElementById("password_template").innerHTML; var qrcodehtml = document.getElementById("qrcode_template").innerHTML; var phonehtml = document.getElementById("phonecode_template").innerHTML; $("#login_content").html(passwordhtml); initPassWordEvent(); //手机端不显示微信登录 var userAgentInfo = navigator.userAgent; if(userAgentInfo.indexOf("Mobile")>-1){ $("#isPc").hide(); $("#isNotPc").show().find(".qq").css("margin-left","calc(50% - 33px)"); }else{ $("#isNotPc").hide(); $("#isPc").show(); } var setting = { imageWidth : 1680, imageHeight : 1050 }; var init = function() { var windowHeight = $(window).height(); var windowWidth = $(window).width(); $(".login_conatiner").css("height",windowHeight); $(".login_conatiner").css("width",windowWidth); $("#container_bg").css("height",windowHeight); $("#container_bg").css("width",windowWidth); $("#login_right_box").css("height",windowHeight); var imgW = setting.imageWidth; var imgH = setting.imageHeight; var ratio = imgH / imgW; // 图片的高宽比 imgW = windowWidth; // 图片的宽度等于窗口宽度 imgH = Math.round(windowWidth * ratio); // 图片高度等于图片宽度 乘以 高宽比 if (imgH < windowHeight) { // 但如果图片高度小于窗口高度的话 imgH = windowHeight; // 让图片高度等于窗口高度 imgW = Math.round(imgH / ratio); // 图片宽度等于图片高度 除以 高宽比 } $(".login_img_01").width(imgW).height(imgH); // 设置图片高度和宽度 }; init(); $(window).resize(function() { init(); }); //点击账号登陆 $("#password_login").click(function(){ // $("#password_login").addClass("active"); // $("#qrcode_login").removeClass("active"); // $("#login_content").html(passwordhtml); $("#password_login").addClass("active"); $("#qrcode_login").removeClass("active"); $("#phoneCode_login").removeClass("active"); $("#login_content").html(passwordhtml); initPassWordEvent(); // var search =location.search; // //跳转url // var service = getParameter(search, "service", ""); // window.location.href = decodeURIComponent(service); }); //点击扫码登陆 $("#qrcode_login").click(function(){ $("#password_login").removeClass("active"); $("#qrcode_login").addClass("active"); $("#phoneCode_login").removeClass("active"); $("#login_content").html(qrcodehtml); mxsock(); //获取token及扫码地址 /*$.ajax({ type : "get", url : "yunschoolsso", dataType : "text", cache: false , data : { "type" : "getToken" }, success : function(result) { var token = result.substring(0,result.indexOf(",")); var content = result.substring(result.indexOf(",")+1); //生成二维码 setQrcode(content); var num = 0; //扫码登录 qrcodeLogin(content, token, num); }, error : function(xhr, status, errMsg) { alert("获取token失败"); } });*/ }); $("#phoneCode_login").click(function(){ $("#password_login").removeClass("active"); $("#qrcode_login").removeClass("active"); $("#phoneCode_login").addClass("active"); $("#login_content").html(phonehtml); initErrormsg(); }); //触发如何使用360极速模式图片 // $("#open_360").mouseover(function(){ // $("#open_360_img").show(); // }).mouseout(function(){ // $("#open_360_img").hide(); // }); //如果有错误信息,则显示 if($("#errormsghide").text()){ $("#errormsg").text($("#errormsghide").text()).show(); $("#help-link").hide(); } }); function initPassWordEvent(){ //放大 //点击放大图片 comm/image/cau_qyh.png $('div[name="cleckBig"]').click(function(){ $("#qrcodBig").show(); }); $(".popup-outside-content").click(function(){ $("#qrcodBig").hide(); }); //点击记住用户名 $("#rememberName").change(function(){ if($(this).is(":checked")){ var $u = $("#un").val() ; if($.trim($u)==''){ $("#errormsg").text("账号不能为空。").show(); $("#help-link").hide(); $(this).removeAttr("checked"); }else{ //不等于空,写cookie setCookie('dlut_cas_un' , $u , 365); document.getElementById('pd').focus() } }else{ //反选之后清空cookie clearCookie('dlut_cas_un'); } }); //登录按钮触发 $("#index_login_btn").click(function(){ login(); }); $("#open_360").click(function(){ $("#open_360_img").show(); }); $("#open_360").click(function(event){ event.stopPropagation(); }); $(document).click(function(){ $("#open_360_img").hide(); }); //用户名文本域keyup事件 $("#un").keyup(function(e){ if(e.which == 13) { login(); } }).keydown(function(e){ $("#errormsg").hide(); var winW =$("body").width(); if(winW < 1024){ $("#help-link").show(); } }).focus(); //密码文本域keyup事件 $("#pd").keyup(function(e){ if(e.which == 13) { login(); } }).keydown(function(e){ $("#errormsg").hide(); var winW =$("body").width(); if(winW < 1024){ $("#help-link").show(); } }); //重新获取验证码 $("#a_changeCode").click(function(){ $("#codeImage").attr("src", "code?"+Math.random()) ; }); //获取cookie值 var cookie = getCookie('dlut_cas_un'); if(cookie){ $("#un").val(cookie); $("#rememberName").attr("checked","checked"); } var ifchecked = function(){ if($("#rememberName").is(":checked")){ document.getElementById('pd').focus() } }; ifchecked(); } function initErrormsg(){ testTTT(); $("#phone").keyup(function(e){ if(e.which == 11){ loginBtn(); } }).keydown(function(e){ $("#errormsg").hide(); }).focus(); $("#phoneCode").keyup(function(e){ if(e.which == 10){ loginBtn(); } }).keydown(function(e){ $("#errormsg").hide(); }); $("#index_login_btn_phone").click(function(){ loginBtn(); }); } function mxsock() { /*$.ajax({ type : "get", url : "yunschoolsso", dataType : "text", cache: false , data : {"cs":"cs", "type":"cs", "code" : "cs" }, success : function(result) { }, error : function(result) { window.open("www.baidu.com"); } });*/ var service = GetQueryString("service"); console.log(service); mxsoc = new mxsocket({ //自定义参数begin debug: true,//是否开启调试模式,开启调试后调试信息将以console.log的形式输出 domain: "wep.cau.edu.cn",//域名 security: true,//是否https。 appid: '200190905170208710',//开发者APPID title: '上网系统扫码登录',//当前操作名称,如XX系统扫码登录 qrcode_id: 'qrcode',//二维码所在div的ID,会自动在该DIV下生成二维码 qrcode_width: 200,//二维码宽度,单位px qrcode_height: 200,//二维码高度,单位px //自定义参数end open: function (data) { //打开websocket连接后会触发该事件 //this.send("WebSocket rocks"); }, close: function () { //websocket连接中断后触发该事件 //this.init();//关闭后重新建立websocket连接,重新生成二维码 }, confirm: function (rs) { //用户扫码后点击确认同意后会触发该事件。 //console.log(rs.find("code")); console.log(rs); console.log(rs.code); $.ajax({ type : "get", url : "yunschoolsso", dataType : "text", cache: false , data : { "type":rs.code, "code" : rs.code }, success : function(result) { //window.location="http://baidu.com" console.log(result); if(result=="login"){ if(Boolean($.cookie("accessUrl"))){ window.location.href = $.cookie("accessUrl"); }else{ window.location.href = service == "" ? "https://one.cau.edu.cn/tp_up" : service; } }else{ //$("#qrcode").hide(); $("#qrcode").html("