Compare commits

...

2 Commits

Author SHA1 Message Date
YZ\249929363 d161e193e4 Merge branch 'main' of https://git.sparkus.cn/yangzhao/cb 2025-08-04 19:00:18 +08:00
YZ\249929363 185708c192 暂存 2025-08-04 19:00:11 +08:00
3 changed files with 42 additions and 19 deletions

View File

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

View File

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

View File

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