var qqUrl = "https://ui.ptlogin2.qq.com/cgi-bin/login?style=9&appid=563027201&daid=37&s_url=" + encodeURIComponent(window.location.href) + "&low_login=0&hln_autologin=0" window.isActivityEnd = false; window.isGetTaskEnd = false; // var curDate = new Date(); // var endDate = new Date('2021/02/01 00:00'); // console.log('curDate', curDate); // console.log('endDate', endDate); // if (curDate > endDate) { // window.isActivityEnd = true; // } window.getDefaultRole = function (callback) { var noRoleCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; //判断是否游戏 var cookie_msdk_uid = Cookie.get("msdk_uid"); var cookie_msdk_skey = Cookie.get("msdk_skey"); var ua = navigator.userAgent.toLowerCase(); var isGHelper = ua.indexOf('gamehelper') != -1; var curopenid = ""; $.ajax({ url: cgiDomain + "/pvp/comm/report/stat_daily_number" + msdkSuffix(), dataType: "json", type: "post", xhrFields: { withCredentials: true }, data: { plat: (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1) ? 2 : 1, merc_id: "gamematch", module_id: 10006, oper_id: 100, gid: 331, sresv1: "kpljc", iresv2: 1 }, success: function (data) { if (data.r != 0 && (data.r == 100000 || data.retcode == 100000)) { //需要登录,跳转返回的登录链接 loginHandle(data.url); return; } }, complete: function (data) { var url_report = "https://a.igame.qq.com/merc.merccgi.merc.comm/Report" + msdkSuffix() if(window.location.origin.indexOf("test.igame.qq.com")!=-1){ var url_report = "https://atest.igame.qq.com/merc.merccgi.merc.comm/Report" + msdkSuffix() } $.ajax({ url: url_report, dataType: "json", contentType: 'application/json;charset=UTF-8', type: "post", xhrFields: { withCredentials: true }, data: JSON.stringify({ report_id: "60002" }), success: function (data) { if (data.r != 0 && (data.r == 100000 || data.retcode == 100000)) { //需要登录,跳转返回的登录链接 loginHandle(data.url); return; } } }); } }); if (cookie_msdk_uid != null && cookie_msdk_skey != null || getUrlParam("msdkEncodeParam") != null && getUrlParam("sig") != null || isGHelper) { //无默认角色,游戏内,设置角色大区cookie if (isGHelper) { var selectArea = getUrlParam("serverId"); var openid = getUrlParam("gameOpenid"); curopenid = openid; Cookie.set(openid + "_subarea", selectArea, 24 * 60 * 60, ".igame.qq.com"); //设置cookie callback(openid); } else { var selectArea = getUrlParam("partition"); var openid = getUrlParam("openid"); curopenid = openid; Cookie.set(openid + "_subarea", selectArea, 24 * 60 * 60, ".igame.qq.com"); //设置cookie callback(openid); } } else { //无默认角色,非游戏内,设置角色大区cookie $.ajax({ url: cgiDomain + "/pvp/kpl/get_role_list", dataType: "json", type: "post", xhrFields: { withCredentials: true }, data: {}, success: function (data) { if (data.r != 0 && (data.r == 100000 || data.retcode == 100000)) { //需要登录,跳转返回的登录链接 loginHandle(data.url); return; } if (data.r != 0) { showDia("tipNoRole"); if (noRoleCallback != null) noRoleCallback(); return; } if (data.r == 0) { if (data.role_list.length <= 0) { showDia("tipNoRole"); if (noRoleCallback != null) noRoleCallback(); return; } else { //有角色,选择第一个 var selectArea = data.role_list[0].subarea; var openid = data.role_list[0].gopenid; //本地有角色的,优先选用本地的角色 if (Cookie.get(openid + "_subarea")) { callback(openid); return; } curopenid = openid; Cookie.set(openid + "_subarea", selectArea, 24 * 60 * 60, ".igame.qq.com"); callback(openid); } } else { $("#tipdialogtext").text("目前竞猜参与火爆,系统繁忙请稍后再试"); showDia("tipdialog"); } }, error: function () { $("#tipdialogtext").text("目前竞猜参与火爆,系统繁忙请稍后再试"); showDia("tipdialog"); } }); } window.isTiYanFu = Cookie.get(curopenid + "_subarea") == "6011" || Cookie.get(curopenid + "_subarea") == "7011"; } window.msdkSuffix = function () { //判断是否游戏 var cookie_msdk_uid = Cookie.get("msdk_uid"); var cookie_msdk_skey = Cookie.get("msdk_skey"); var ua = navigator.userAgent.toLowerCase(); var isGHelper = ua.indexOf('gamehelper') != -1; if (cookie_msdk_uid != null && cookie_msdk_skey != null || getUrlParam("msdkEncodeParam") != null && getUrlParam("sig") != null || isGHelper) { return window.location.search; } return ""; } window.loginHandle = function (url) { if (typeof url != undefined) qqUrl = url; var env = {}; env.ua = navigator.userAgent.toLowerCase(); env.isWeixin = env.ua.indexOf('micromessenger') != -1; env.isQQ = env.ua.indexOf(' qq/') != -1; env.isApp = env.ua.indexOf(' igameapp/') != -1; env.isAndroid = env.ua.indexOf('android') != -1; env.isIos = (env.ua.indexOf('iphone') != -1) || (env.ua.indexOf('ipad') != -1); if (env.isQQ || env.isWeixin) { window.location.href = url; return; } else if (env.isApp) { return; } else if (msdkSuffix() != "") { return; } else { showDia("selectLogin"); return; } } window.loginWX = function () { // var ua = navigator.userAgent.toLowerCase(); //获取判断用的对象 // if (ua.match(/WeiBo/i) == "weibo") { $("#tipdialogtext").html("请复制链接到微信打开"); showDia("tipdialog"); return; // } // window.location.href = "https://game.weixin.qq.com/cgi-bin/comm/openlink?noticeid=90230566&appid=wx95a3a4d7c627e07d&url=https%3A%2F%2Figame.qq.com%2Fnewcss%2Fpvp%2Fkpl%2Findex.html"; } window.loginQQ = function () { var actUrl = window.location.href.split('?')[0]; var ua = navigator.userAgent.toLowerCase(); //获取判断用的对象 if (ua.indexOf('gamehelper') != -1) { window.location.href = "https://ui.ptlogin2.qq.com/cgi-bin/login?style=9&appid=563027201&daid=37&s_url=" + encodeURIComponent(actUrl) + "&low_login=0&hln_autologin=0"; } else { window.location.href = qqUrl; } } function getUrlParam(name) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == name) { return pair[1]; } } return null; } var Cookie = new Object(); Cookie.get = function (sName, sDefaultValue) { var sRE = "(?:; |^)" + sName + "=([^;]*);?"; var oRE = new RegExp(sRE); if (oRE.test(document.cookie)) { return unescape(RegExp["$1"]); } else { return sDefaultValue || null; } }; Cookie.set = function (sName, sValue, iExpireSec, sDomain, sPath, bSecure) { if (!sName) { return; } if (!sValue) { sValue = ""; } var str = sName + "=" + escape(sValue) + "; "; if (!isNaN(iExpireSec)) { var oDate = new Date(); oDate.setTime(oDate.getTime() + iExpireSec * 1000); str += "expires=" + oDate.toGMTString() + "; "; } if (sDomain) { str += "domain=" + sDomain + "; "; } if (sPath) { str += "path=" + sPath + "; "; } else { str += "path=/; "; } if (bSecure) { str += "secure"; } document.cookie = str; }; //处理特殊情况,返回true的话,外面需要接上return; window.handleActivity = function (banTy, banAe, banTask) { // if(banTy && window.isTiYanFu){ // $("#tipdialogtext").text("抢先服暂不支持竞猜,正在修复中。"); // showDia("tipdialog"); // return true; // } if (banAe && window.isActivityEnd) { //活动结束提示 showDia('tipEndDialog'); return true; } if (banTask && window.isGetTaskEnd) { showDia("tipEndTaskDialog"); return true; } return false; }