Compare commits

..

No commits in common. "d161e193e42bfa824fd92b00642d70f4e107fc42" and "c566f28150380f145ec88b8eaa2f25bef45d8f08" have entirely different histories.

3 changed files with 19 additions and 42 deletions

View File

@ -241,8 +241,8 @@ export default class GameManager extends cc.Component {
const MAX_RETRIES = 15; const MAX_RETRIES = 15;
// 延迟时间数组,按照 1 秒 3 次、2 秒 5 次、5 秒 6 次、15 秒 5 次的规则生成 // 延迟时间数组,按照 1 秒 3 次、2 秒 5 次、5 秒 6 次、15 秒 5 次的规则生成
const delays = [ const delays = [
...Array(3).fill(2000), ...Array(3).fill(1000),
...Array(5).fill(3000), ...Array(5).fill(2000),
...Array(6).fill(5000), ...Array(6).fill(5000),
...Array(5).fill(15000) ...Array(5).fill(15000)
]; ];
@ -251,7 +251,7 @@ export default class GameManager extends cc.Component {
Utils.getUserInfo((data) => { Utils.getUserInfo((data) => {
if (data.code == 1) { // 假设返回数据中有 success 字段表示成功 if (data.code == 1) { // 假设返回数据中有 success 字段表示成功
//console.log("登录成功时间耗时:", Date.now() - this.nowTime); //console.log("登录成功时间耗时:", Date.now() - this.nowTime);
// //console.log("111登陆成功_____________"); // console.log("111登陆成功_____________");
console.log("登錄", data); console.log("登錄", data);
//console.log("uid", data.data.onlyId); //console.log("uid", data.data.onlyId);
if (data.data._id) { if (data.data._id) {
@ -270,10 +270,10 @@ export default class GameManager extends cc.Component {
//console.log("______________________________有未发放奖励", cc.fx.GameConfig.GM_INFO.allOutTradeNo); //console.log("______________________________有未发放奖励", cc.fx.GameConfig.GM_INFO.allOutTradeNo);
} }
if (data.data.shareLv) { if (data.data.shareLv) {
//console.log("有分享信息", data.data.shareLv) console.log("有分享信息", data.data.shareLv)
if (data.data.shareLv.length > 0) { if (data.data.shareLv.length > 0) {
//console.log(data.data.shareLv[0]); console.log(data.data.shareLv[0]);
//console.log("设置分享等级", data.data.shareLv[0].lv); console.log("设置分享等级", data.data.shareLv[0].lv);
cc.fx.GameConfig.GM_INFO.helpLevel = data.data.shareLv[0].lv; cc.fx.GameConfig.GM_INFO.helpLevel = data.data.shareLv[0].lv;
} }
} }
@ -395,7 +395,7 @@ export default class GameManager extends cc.Component {
// //console.log("没有等级信息,从用户接口拿到数据"); // //console.log("没有等级信息,从用户接口拿到数据");
if (levelInfo.level) { if (levelInfo.level) {
cc.fx.GameConfig.GM_INFO.level = levelInfo.level; cc.fx.GameConfig.GM_INFO.level = levelInfo.level;
//console.log(cc.fx.GameConfig.GM_INFO.helpLevel, "___________________", cc.fx.GameConfig.GM_INFO.level); console.log(cc.fx.GameConfig.GM_INFO.helpLevel, "___________________", cc.fx.GameConfig.GM_INFO.level);
if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) { if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) {
cc.fx.GameConfig.GM_INFO.level += 1; cc.fx.GameConfig.GM_INFO.level += 1;
if ((cc.fx.GameConfig.GM_INFO.level) > 323) { if ((cc.fx.GameConfig.GM_INFO.level) > 323) {
@ -421,7 +421,7 @@ export default class GameManager extends cc.Component {
if (levelInfo.level) { if (levelInfo.level) {
//console.log("以游戏前端等级为准", data.result.data); //console.log("以游戏前端等级为准", data.result.data);
cc.fx.GameConfig.GM_INFO.level = levelInfo.level; cc.fx.GameConfig.GM_INFO.level = levelInfo.level;
//console.log(cc.fx.GameConfig.GM_INFO.helpLevel, "___________________", cc.fx.GameConfig.GM_INFO.level); console.log(cc.fx.GameConfig.GM_INFO.helpLevel, "___________________", cc.fx.GameConfig.GM_INFO.level);
if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) { if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) {
cc.fx.GameConfig.GM_INFO.level += 1; cc.fx.GameConfig.GM_INFO.level += 1;
if ((cc.fx.GameConfig.GM_INFO.level) > 323) { if ((cc.fx.GameConfig.GM_INFO.level) > 323) {
@ -867,7 +867,7 @@ export default class GameManager extends cc.Component {
else if (data.result.code == 200) { else if (data.result.code == 200) {
//console.log("有等级信息,从关卡接口拿到数据", data.result.data); //console.log("有等级信息,从关卡接口拿到数据", data.result.data);
cc.fx.GameConfig.GM_INFO.level = data.result.data; cc.fx.GameConfig.GM_INFO.level = data.result.data;
//console.log(cc.fx.GameConfig.GM_INFO.helpLevel, "___________________", cc.fx.GameConfig.GM_INFO.level); console.log(cc.fx.GameConfig.GM_INFO.helpLevel, "___________________", cc.fx.GameConfig.GM_INFO.level);
if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) { if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) {
cc.fx.GameConfig.GM_INFO.level += 1; cc.fx.GameConfig.GM_INFO.level += 1;
if ((cc.fx.GameConfig.GM_INFO.level) > 323) { if ((cc.fx.GameConfig.GM_INFO.level) > 323) {

View File

@ -13,37 +13,18 @@ export default class Utils {
wx.login({ wx.login({
success(res) { success(res) {
console.log("微信login成功"); console.log("微信login成功");
console.log(res.code); console.log(res);
if (res.code) { if (res.code) {
// 延迟时间数组,可按需调整 Utils.POST("login", { code: res.code }, ret => {
const delays = [1000, 2000, 3000, 4000, 5000]; console.log("请求结果:", res);
let attempt = 0; // 轮询次数 console.log(ret);
Utils.openid = ret.data.openid;
const poll = () => { Utils.session_key = ret.data.session_key;
if (attempt >= delays.length) { Utils.uid = ret.data._id;
console.log('登录请求轮询超时'); callBack(ret);
callBack({ code: 0, data: { openid: "登录失败" }, message: '轮询超时' }); })
return;
}
Utils.POST("login", { code: res.code }, ret => {
console.log("请求结果:", ret);
if (ret.code === 1) { // 假设返回 code 为 1 表示成功
Utils.openid = ret.data.openid;
Utils.session_key = ret.data.session_key;
Utils.uid = ret.data._id;
callBack(ret);
} else {
attempt++;
setTimeout(poll, delays[attempt - 1]);
}
});
};
poll();
} else { } else {
console.log('登录失败!' + res.errMsg) console.log('登录失败!' + res.errMsg)
callBack({ code: 0, data: { openid: "登录失败" }, message: res.errMsg });
} }
} }
}) })
@ -388,7 +369,6 @@ export default class Utils {
*/ */
public static POST(url, param: object | any, callback) { public static POST(url, param: object | any, callback) {
var xhr = cc.loader.getXMLHttpRequest(); var xhr = cc.loader.getXMLHttpRequest();
xhr.timeout = 5000;//超时时间
let dataStr = ''; let dataStr = '';
Object.keys(param).forEach(key => { Object.keys(param).forEach(key => {
dataStr += key + '=' + encodeURIComponent(param[key]) + '&'; dataStr += key + '=' + encodeURIComponent(param[key]) + '&';
@ -401,9 +381,6 @@ export default class Utils {
xhr.open("POST", url, true); xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
console.log("请求readyState结果");
console.log(xhr.readyState);
console.log(xhr.status);
if (xhr.readyState === 4) { if (xhr.readyState === 4) {
let response: any = xhr.responseText; let response: any = xhr.responseText;
if (xhr.status >= 200 && xhr.status < 300) { if (xhr.status >= 200 && xhr.status < 300) {

View File

@ -1,5 +1,5 @@
{ {
"last-module-event-record-time": 1754302048063, "last-module-event-record-time": 1753696850285,
"group-list": [ "group-list": [
"default", "default",
"Map" "Map"