This commit is contained in:
YZ\249929363 2025-08-01 16:33:13 +08:00
parent a7cc1e5475
commit 461612e00b
5 changed files with 90 additions and 8 deletions

View File

@ -256,10 +256,10 @@ export default class GameManager extends cc.Component {
cc.fx.GameConfig.GM_INFO.allOutTradeNo = data.data.outTradeNo;
console.log("______________________________有未发放奖励", cc.fx.GameConfig.GM_INFO.allOutTradeNo);
}
if (data.data.shareLvl) {
if (data.data.shareLv) {
if (data.data.shareLvl.length > 0) {
console.log("设置分享等级", data.data.shareLvl);
cc.fx.GameConfig.GM_INFO.helpLevel = data.data.shareLvl;
console.log("设置分享等级", data.data.shareLv);
cc.fx.GameConfig.GM_INFO.helpLevel = data.data.shareLv;
}
}
this.setUserPower(data);
@ -365,10 +365,13 @@ export default class GameManager extends cc.Component {
cc.fx.GameConfig.GM_INFO.level = levelInfo.level;
if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) {
cc.fx.GameConfig.GM_INFO.level += 1;
console.log("好友帮助通过第" + cc.fx.GameConfig.GM_INFO.helpLevel + "关");
}
}
this.load4 = true;
cc.fx.StorageMessage.setStorage("level", cc.fx.GameConfig.GM_INFO.level);
levelInfo.level = cc.fx.GameConfig.GM_INFO.level;
levelInfo.timestamp = timestamp;
cc.fx.StorageMessage.setStorage("level", levelInfo);
console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
cc.fx.GameTool.setUserLevel((data) => {
});
@ -384,8 +387,11 @@ export default class GameManager extends cc.Component {
cc.fx.GameConfig.GM_INFO.level = levelInfo.level;
if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) {
cc.fx.GameConfig.GM_INFO.level += 1;
console.log("好友帮助通过第" + cc.fx.GameConfig.GM_INFO.helpLevel + "关");
}
cc.fx.StorageMessage.setStorage("level", cc.fx.GameConfig.GM_INFO.level);
levelInfo.level = cc.fx.GameConfig.GM_INFO.level;
levelInfo.timestamp = timestamp;
cc.fx.StorageMessage.setStorage("level", levelInfo);
// console.log("等级为:",cc.fx.GameConfig.GM_INFO.level);
cc.fx.GameTool.setUserLevel((data) => {
});
@ -823,6 +829,7 @@ export default class GameManager extends cc.Component {
cc.fx.GameConfig.GM_INFO.level = data.result.data;
if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) {
cc.fx.GameConfig.GM_INFO.level += 1;
console.log("好友帮助通过第" + cc.fx.GameConfig.GM_INFO.helpLevel + "关");
}
let levelInfo = { "level": cc.fx.GameConfig.GM_INFO.level, "timestamp": timestamp };
// console.log("444444存储关卡信息:",levelInfo);

View File

@ -80,6 +80,7 @@ export default class JiaZai extends cc.Component {
// LIFE-CYCLE CALLBACKS:
onLoad() {
this.checkShare();
console.log("进入首页获取的share", cc.fx.GameConfig.GM_INFO.otherUid, cc.fx.GameConfig.GM_INFO.otherLevel);
if (cc.fx.GameConfig.GM_INFO.otherUid != "") {
this.getShareInfo();
@ -973,5 +974,48 @@ export default class JiaZai extends cc.Component {
cc.fx.GameTool.shushu_Track("resource_get", dataTemp);
}
//检测当日是否有分享行为,用不用主动获取分享关卡信息
checkShare() {
const otherInfo = cc.fx.StorageMessage.getStorage("otherLevel");
if (otherInfo && otherInfo.timeStamp && otherInfo.otherLevel) {
const currentTime = Date.now();
const timeDifference = currentTime - otherInfo.timeStamp;
const oneDayInMilliseconds = 24 * 60 * 60 * 1000;
if (timeDifference > oneDayInMilliseconds || cc.fx.GameConfig.GM_INFO.level >= otherInfo.otherLevel) {
console.log("检查分享信息过期或已获取过,清除存储信息");
cc.fx.StorageMessage.setStorage("otherLevel", null);
}
else {
if ((cc.fx.GameConfig.GM_INFO.level + 1) == otherInfo.otherLevel) {
console.log("有分享信息,并且符合条件");
Utils.getShareLevel((res) => {
if (res.code == 1) {
let title = "好友帮助通过第" + otherInfo.otherLevel + "关";
console.log(title);
MiniGameSdk.API.showToast(title);
cc.fx.GameConfig.GM_INFO.level = otherInfo.otherLevel;
const timestamp = Date.now();
const levelInfo = {
level: cc.fx.GameConfig.GM_INFO.level, // 关卡
timestamp: timestamp, // 时间戳
};
cc.fx.StorageMessage.setStorage("level", levelInfo);
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true);
cc.fx.GameTool.setUserLevel((data) => {
});
}
})
}
}
}
else {
console.log("没有分享信息");
}
}
// update (dt) {}
}

View File

@ -1581,7 +1581,10 @@ export default class MapConroler extends cc.Component {
cc.fx.GameTool.shushu_Track("resource_get", data);
let overTime = Date.now();
this.count_Time = overTime - this.count_Time;
cc.fx.GameTool.addLevel(this.count_Time, this.add_Time);
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
}
else cc.fx.GameTool.addLevel(this.count_Time, this.add_Time);
const winCOIN = cc.find("Canvas"); // 假设 Canvas 节点
if (winCOIN) {
const wincoin = winCOIN.getComponent(SceneManager);

View File

@ -142,8 +142,11 @@ export default class SceneManager extends cc.Component {
}
this.node.getChildByName("Game").getChildByName("bg").getComponent(cc.Sprite).spriteFrame = spriteFrame;
})
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true);
let levelName = (cc.fx.GameConfig.GM_INFO.level + 1);
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
levelName = cc.fx.GameConfig.GM_INFO.otherLevel;
}
NumberToImage.numberToImageNodes(levelName, 43, 15, "level_", this.level, true);
//time金币数量
NumberToImage.numberToImageNodes(1000, 25, 15, "button_", this.timeCoin, false);
}
@ -433,6 +436,12 @@ export default class SceneManager extends cc.Component {
shareFriend() {
console.log("设置分享链接");
let timeStamp = Date.now();
let otherInfo = {
timeStamp: timeStamp,
otherLevel: cc.fx.GameConfig.GM_INFO.otherLevel,
}
cc.fx.StorageMessage.setStorage("otherLevel", otherInfo);
MiniGameSdk.API.shareGame();
}

View File

@ -959,6 +959,7 @@ export default class Utils {
}
}
//设置分享成功信息,帮别人成功
static shareLevel(otherLevel, uid, callBack) {
let otheruid = uid || "";
let level = otherLevel || 0;
@ -999,6 +1000,24 @@ export default class Utils {
poll();
}
//获取分享信息
static getShareLevel(callBack) {
let data = {
uid: cc.fx.GameConfig.GM_INFO.uid
};
if (typeof wx !== 'undefined' && wx !== null) {
Utils.POST("getShareLv", data, res => {
console.log("获得shareLvSuccess数据:", res);
if (res.code === 1) {
console.log("服务器:分享帮助通过关卡数据成功", res);
if (callBack) callBack(res);
} else {
if (callBack) callBack(res);
}
});
}
}
// const propName={
//   gold_1: "金币包1",
//   gold_2: "金币包2",