");var n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)"),o=n.exec(t);return o?o[2]?decodeURIComponent(o[2].replace(/\+/g," ")):"":null}function n(e){var t=document.location.search||document.location.hash;if(t){if("?"===t[0]&&(t=t.slice(1)),null===e)return decodeURIComponent(t);for(var n=t.split("&"),o=0,i=n.length;o=1-(Number(i)||.1)&&((new Image).src="https://support.weixin.qq.com/cgi-bin/mmsupportmeshnodelogicsvr-bin/cube?biz=3512&label=connect.qrconnect&"+n+"="+o+"&msg="+e("appid")+"&idx1="+e("scope")+"&idx2="+encodeURIComponent(encodeURIComponent(t("redirect_uri"))))}function i(e){var t=document.getElementsByTagName("head")[0];if(t&&("auto"===e||"dark"===e||"light"===e)){var n=document.createElement("meta");n.name="color-scheme",n.content="auto"===e?"light dark":e,t.appendChild(n)}}function s(){G=!0,c()}function c(){v&&1!==E||T?$(".js_qrcode_img").attr("src","https://res.wx.qq.com/t/fed_upload/46a73b115c002aa8d49ae255da18c592/qrcode_expired.jpg"):($(".js_refresh_qrcode").show(),$(".js_refresh_qrcode_mask").show())}function r(e){loadScript({type:"GET",url:U+"/connect/l/qrconnect?uuid="+F+(e?"&last="+e:""),dataType:"script",cache:!1,timeout:3e4,success:function(){o("action","connect_qrconnect_longpull_success",.01);var e=window.wx_errcode;switch(e){case 405:o("action","connect_qrconnect_longpull_success_405",.01);var t="/qrcallback.aspx";if(t=t.replace(/&/g,"&"),t+=(t.indexOf("?")>-1?"&":"?")+"code="+wx_code+"&state=ad13060bb32345c69a1523b0e6ad9419",console.log("扫码redirect_uri: ",t),v)if("true"!==N&&"false"!==N)try{document.domain="qq.com";var n=window.top.location.host.toLowerCase();n&&(window.location=t)}catch(e){window.top.location=t}else if("true"===N)try{window.location=t}catch(e){window.top.location=t}else window.top.location=t;else window.location=t;break;case 404:o("action","connect_qrconnect_longpull_success_404",.01),jQuery(".js_status").hide(),jQuery(".js_qr_img").hide(),jQuery(".js_wx_after_scan").show(),setTimeout(r,100,e);break;case 403:o("action","connect_qrconnect_longpull_success_403",.01),jQuery(".js_status").hide(),jQuery(".js_qr_img").hide(),jQuery(".js_wx_after_cancel").show(),setTimeout(r,2e3,e);break;case 402:o("action","connect_qrconnect_longpull_success_402",.01),s();break;case 500:o("action","connect_qrconnect_longpull_success_500",.01),setTimeout(function(){ window.location.reload()},200);break;case 408:o("action","connect_qrconnect_longpull_success_408",.01),z&&0!==R||setTimeout(r,2e3);break;default:o("action","connect_qrconnect_longpull_success_others",.01)}},error:function(){s(),o("action","connect_qrconnect_longpull_error",.01);var e=window.wx_errcode;408==e?o("action","connect_qrconnect_longpull_error_408",.01):o("action","connect_qrconnect_longpull_error_others",.01)}})}function a(e,t){var n,o,i=screen.width,s=screen.height,c=window.outerWidth||document.documentElement.clientWidth||document.body.clientWidth,r=window.outerHeight||document.documentElement.clientHeight||document.body.clientHeight,a=window.screenX||window.screenLeft||0,l=window.screenY||window.screenTop||0,d=window.screen.availLeft||0,_=window.screen.availTop||0;return window.top!=window?void 0===window.screen.availLeft?(n=a+c/2-e/2,o=l+r/2-t/2,console.log("availLeft undefined && centerX: ",n)):(n=i/2-e/2+d,o=s/2-t/2+_,console.log("centerX: ",n)):(n=a+c/2,o=l+r/2,n=0===d?Math.min(Math.max(n-e/2,0),i+d-e):Math.min(Math.max(n-e/2,d),i+d-e),o=0===_?Math.min(Math.max(o-t/2,0),s+_-t):Math.min(Math.max(o-t/2,_),s+_-t)),{x:n,y:o}}function l(e,t,n,o,i,s,c){return c||(c=jQuery.Deferred()),0===e.length?($(".js_quick_login").hide(),$(".js_normal_login").show(),$(".js_switchToFast_wrp").hide(),$(".js_web_qrcode_tips_fast").hide(),$(".js_web_qrcode_tips_normal").show(),z=!1,console.log("所有端口均无法连接"),c.resolve(),c.promise()):(console.log("当前port: ",e[0]),$.ajax({url:"https://localhost.weixin.qq.com:"+e[0]+t,type:n,cache:!1,contentType:"application/json",data:JSON.stringify(o),success:function(t){i&&i(t),c.resolve(t,e[0])},error:function(r,a,d){console.log("端口"+e[0]+"连接失败,尝试下一个端口"),e.length>1?l(e.slice(1),t,n,o,i,s,c):(s&&s(),c.resolve(!1))}}),c.promise())}function d(n){return console.log("checklogin post redirect_uri",t("redirect_uri")),l(n,"/api/check-login","POST",{apiname:"qrconnectchecklogin",jsdata:{appid:e("appid"),scope:e("scope"),redirect_uri:t("redirect_uri"),state:t("state")||""}},function(e){o("action","connect_qrconnect_checkLogin_succ",1)},function(){o("action","connect_qrconnect_checkLogin_fail",1)})}function _(e){var t=e.errcode;switch(t){case 10057:console.log("此应用仅支持扫一扫登录"),$("#quick_login_unsupport_toast").fadeIn(300,function(){var e=this;setTimeout(function(){$(e).fadeOut(300)},1e3)}),o("action","connect_qrconnect_fastLogin_fail_unsupport",1)}return!(0!==t||!L)}function u(e,t){if(e){var n=JSON.parse(e);return console.log("登录状态检查成功",n),J=t,console.log("连通port: ",J),Y=n.jsdata&&n.jsdata.authorize_uuid||"",_(n)}return!1}function A(e,t){if(t)var n=JSON.parse(t);e?(o("action","connect_qrconnect_fastLogin_show",1),$(".js_quick_login").show(),$(".js_normal_login").hide(),$(".js_switchToFast_wrp").show(),$(".js_web_qrcode_tips_fast").show(),$(".js_web_qrcode_tips_normal").hide(),$(".js_quick_login_nickname").text(n.jsdata&&n.jsdata.nickname||""),$(".js_quick_login_avatar").attr("src",n.jsdata&&n.jsdata.headimgurl||"https://res.wx.qq.com/t/fed_upload/937b4aa0-2cc5-42ec-81d7-e641da427fff/avatar_default.svg")):($(".js_quick_login").hide(),$(".js_normal_login").show(),$(".js_switchToFast_wrp").hide(),$(".js_web_qrcode_tips_fast").hide(),$(".js_web_qrcode_tips_normal").show())}function p(e,t){for(var n=!1,o=0,i=0;i=.99&&(n(o),t(o))}var i=!1;$(".js_qrcode_img").each(function(){function t(){if(n.off("load",t),!i&&this.src.indexOf("open.weixin.qq.com/connect/qrcode")>-1){h("status","wxQRcodeReady");var s=Number(e("ts"))||window.pageStartTime||0,c=s?Date.now()-s:0;console.log("qrcode loaded, duration: ",c),o({duration:c}),i=!0}}var n=$(this);n.on("load",t),this.complete&&0!==this.naturalWidth&&0!==this.width&&t.call(this)})}function b(){var e=jQuery.Deferred();return setTimeout(function(){e.resolve()},1e3),jQuery(window).load(function(){e.resolve()}),e.promise()}"undefined"==typeof console?console={log:function(){},error:function(){}}:("undefined"==typeof console.log&&(console.log=function(){}),"undefined"==typeof console.error&&(console.error=function(){})),jQuery(".js_web_qrcode_reload").click(function(){window.location.reload()});var v=window.top!=window,y=n("self_redirect")||n("style")||n("href")||n("oldstyle"),j=parseInt(e("styletype"),10),x=NaN,k="",E=parseInt(t("stylelite"),10),T=!1,Q=t("color_scheme");if(1!==j&&0!==j&&1===x&&(j=0),1!==E&&1!==j&&0!==j&&k){T=!0,o("action","connect_qrconnect_css_href");var C=document.createElement("link");C.rel="stylesheet",C.href=k.replace(new RegExp("javascript:","gi"),""),document.getElementsByTagName("head")[0].appendChild(C)}if(1===E&&(jQuery("#tpl_old_iframe").hide(),jQuery("#tpl_iframe").show()),v){o("action","connect_qrconnect_iframe"),document.body.className+=" web_qrcode_type_iframe","auto"===Q?(i(Q),document.body.className+=" auto_color_scheme"):"dark"===Q?(i(Q),document.body.setAttribute("data-weui-theme","dark")):"light"===Q&&(i(Q),document.body.setAttribute("data-weui-theme","light"));var O="";"white"!=O&&(document.body.style.color="#373737"),jQuery("#tpl_for_iframe").show()}else{o("action","connect_qrconnect_page"),document.getElementsByClassName||(document.getElementsByClassName=function(e){for(var t=[],n=new RegExp("(^| )"+e+"( |$)"),o=document.getElementsByTagName("*"),i=0,s=o.length;i