diff --git a/assets/Script/JiaZai.ts b/assets/Script/JiaZai.ts index a6a17ee..7434f60 100644 --- a/assets/Script/JiaZai.ts +++ b/assets/Script/JiaZai.ts @@ -828,13 +828,13 @@ export default class JiaZai extends cc.Component { } } - startGame() { cc.fx.AudioManager._instance.playEffect("anniu_Big", null); let version = cc.fx.GameTool.getWechatGameVersion(); if (cc.fx.GameTool.maxLevel()) { if (version != "开发版" && version != "体验版") { - MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + // MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + cc.fx.GameTool.requestSubscribe(); return; } @@ -864,7 +864,8 @@ export default class JiaZai extends cc.Component { cc.fx.GameConfig.GM_INFO.level = parseInt(this.custom.string) - 1; // cc.fx.StorageMessage.setStorage("level",cc.fx.GameConfig.GM_INFO.level.toString()); if (cc.fx.GameTool.maxLevel()) { - MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + // MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + cc.fx.GameTool.requestSubscribe(); return; } cc.fx.GameConfig.LEVEL_INFO_init(true, 0, false); @@ -874,7 +875,8 @@ export default class JiaZai extends cc.Component { this.node.getChildByName("zhuanchang").active = true; this.node.getChildByName("zhuanchang").getComponent(sp.Skeleton).setAnimation(1, "up", false); if (cc.fx.GameTool.maxLevel()) { - MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + // MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + cc.fx.GameTool.requestSubscribe(); return; } cc.fx.GameConfig.LEVEL_INFO_init(true, 1000, false); @@ -882,7 +884,8 @@ export default class JiaZai extends cc.Component { } else if (version == "正式版") { if (cc.fx.GameTool.maxLevel()) { - MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + // MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + cc.fx.GameTool.requestSubscribe(); return; } cc.fx.AudioManager._instance.playEffect("zhuan1", null); @@ -896,7 +899,8 @@ export default class JiaZai extends cc.Component { cc.fx.GameConfig.GM_INFO.level = parseInt(this.custom.string) - 1; // cc.fx.StorageMessage.setStorage("level",cc.fx.GameConfig.GM_INFO.level.toString()); if (cc.fx.GameTool.maxLevel()) { - MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + // MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + cc.fx.GameTool.requestSubscribe(); return; } cc.fx.GameConfig.LEVEL_INFO_init(true, 0, false); @@ -906,7 +910,8 @@ export default class JiaZai extends cc.Component { this.node.getChildByName("zhuanchang").active = true; this.node.getChildByName("zhuanchang").getComponent(sp.Skeleton).setAnimation(1, "up", false); if (cc.fx.GameTool.maxLevel()) { - MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + // MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + cc.fx.GameTool.requestSubscribe(); return; } cc.fx.GameConfig.LEVEL_INFO_init(true, 1000, false); diff --git a/assets/Script/Map.ts b/assets/Script/Map.ts index 0539051..c39816b 100644 --- a/assets/Script/Map.ts +++ b/assets/Script/Map.ts @@ -2138,7 +2138,8 @@ export default class MapConroler extends cc.Component { } if (cc.fx.GameTool.maxLevel()) { - MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + // MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + cc.fx.GameTool.requestSubscribe(); return; } cc.fx.AudioManager._instance.playEffect("zhuan1", null); diff --git a/assets/Script/module/Config/GameConfig.ts b/assets/Script/module/Config/GameConfig.ts index 54723ba..6df76de 100644 --- a/assets/Script/module/Config/GameConfig.ts +++ b/assets/Script/module/Config/GameConfig.ts @@ -352,7 +352,8 @@ export class GameConfig { if (cc.fx.GameTool.maxLevel() && otherLevel == false) { - MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + // MiniGameSdk.API.showToast("关卡每周更新,敬请期待!"); + cc.fx.GameTool.requestSubscribe(); return; } let name = "Json/level" + (cc.fx.GameConfig.GM_INFO.level + 1); diff --git a/assets/Script/module/Tool/GameTool.ts b/assets/Script/module/Tool/GameTool.ts index 684cf8e..5832c41 100644 --- a/assets/Script/module/Tool/GameTool.ts +++ b/assets/Script/module/Tool/GameTool.ts @@ -1756,6 +1756,22 @@ var GameTool = { node.children.forEach(child => this.setGray(child, gray)); }, - + requestSubscribe() { + if (cc.sys.platform === cc.sys.WECHAT_GAME) { + if (typeof wx === 'undefined') return; + wx.requestSubscribeMessage({ + tmplIds: ['BIsiZH6pcs4T9FLp0IAZ8d07zS0ELi7vX5RX8P38gN0'], + success: (res) => { + if (res['BIsiZH6pcs4T9FLp0IAZ8d07zS0ELi7vX5RX8P38gN0'] === 'accept') { + cc.log('订阅成功'); + // 可以在这里调用你的服务端接口,记录用户订阅 + } + }, + fail: (err) => { + cc.error('订阅失败:', err); + } + }); + } + } }; export { GameTool }; \ No newline at end of file