From 0118f2bd907fde5f3acd63f2f13ac3e4908879c2 Mon Sep 17 00:00:00 2001 From: "YZ\\249929363" <249929363@qq.com> Date: Fri, 8 Aug 2025 19:57:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9C=88=E5=8D=A1=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Script/JiaZai.ts | 88 ++++++++++++++++++++++++++----- assets/Script/module/Pay/Utils.ts | 1 + assets/Script/monthlyCard.ts | 6 ++- assets/shop/script/shop.ts | 11 ++-- 4 files changed, 86 insertions(+), 20 deletions(-) diff --git a/assets/Script/JiaZai.ts b/assets/Script/JiaZai.ts index c310041..48cf2fe 100644 --- a/assets/Script/JiaZai.ts +++ b/assets/Script/JiaZai.ts @@ -176,11 +176,13 @@ export default class JiaZai extends cc.Component { //console.log("音乐开关", cc.fx.GameConfig.GM_INFO.musicOpen); AudioManager._instance.playMusicGame(); // this.openMonthCard(); + console.log("3333333333"); this.onGames(); } //监听后台 onGames() { if (typeof wx !== 'undefined') { + console.log("从这里开始进入监听了————————————————————"); this.onShowListener = null; this.onHideListener = null; // 定义监听函数 @@ -200,32 +202,45 @@ export default class JiaZai extends cc.Component { } onGameHide() { console.log("执行onGameHide", cc.fx.GameConfig.GM_INFO.min_Time); - this.isFirstLaunch = false; - this.stopHeathTimeCutDown(); - this.stopTimeCutDown(); - this.stopPowerTime(); + if (this.isFirstLaunch != null && this.isFirstLaunch != undefined) this.isFirstLaunch = false; + if (this) { + if (this.node) { + this.stopHeathTimeCutDown(); + this.stopTimeCutDown(); + this.stopPowerTime(); + } + } + } onGameShow() { console.log("执行开始游戏gameshow") cc.fx.GameTool.getHealth((data) => { - NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true); - NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); + if (this.level) { + NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true); + } + if (this.coin) { + NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); + } this.setHealthInfo(true); }); console.log("执行on", cc.fx.GameConfig.GM_INFO.min_Time); - if (this.node.getChildByName("heathpop")) { - if (this.node.getChildByName("heathpop").active == true) { - const heathComponent = this.node.getChildByName("heathpop").getComponent("heathnum"); - if (heathComponent && heathComponent.timeNode && - cc.fx.GameConfig.GM_INFO.hp < cc.fx.GameConfig.GM_INFO.hp_Max) { - this.startHeathTimeCutDown(heathComponent.timeNode); + if (this) { + if (this.node) { + if (this.node.getChildByName("heathpop")) { + if (this.node.getChildByName("heathpop").active == true) { + const heathComponent = this.node.getChildByName("heathpop").getComponent("heathnum"); + if (heathComponent && heathComponent.timeNode && + cc.fx.GameConfig.GM_INFO.hp < cc.fx.GameConfig.GM_INFO.hp_Max) { + this.startHeathTimeCutDown(heathComponent.timeNode); + } + } } } - } + } start() { @@ -797,13 +812,15 @@ export default class JiaZai extends cc.Component { cc.fx.GameConfig.GM_INFO.doubleCoin = 2; cc.fx.GameConfig.GM_INFO.hp_Max = 7; cc.fx.GameConfig.GM_INFO.hp = 7; + this.openLoad(); + this.buyMonthCard(productId); } else if (order.itemid == "reborn_Gift") { coinTemp = 1000; } let title = "充值补发奖励金币:" + coinTemp; // MiniGameSdk.API.showToast(title); - cc.fx.GameTool.shopBuy(productId, true); + if (order.itemid != "month_Card") cc.fx.GameTool.shopBuy(productId, true); console.log("充值成功获得金币"); } else { MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放"); @@ -1126,5 +1143,48 @@ export default class JiaZai extends cc.Component { } } + + //购买月卡 + buyMonthCard(id) { + Utils.setMonthlyCard(0, (data) => { + console.log("购买月卡", data.code); + if (data.code == 1) { + // let rewardData = [ + // { type: "coin", count: 6000 }, + // ] + cc.fx.GameTool.shopBuy(id, false); + cc.fx.GameConfig.GM_INFO.hp_Max = 7; + cc.fx.GameConfig.GM_INFO.hp = 7; + + cc.fx.GameTool.getMonthlyCardValidityDays().then(days => { + cc.fx.GameConfig.GM_INFO.monthTime = days.days; + //本地储存当前服务器时间 + let dateStr = new Date(days.time); + cc.fx.StorageMessage.setStorage("mCardDate", dateStr); + }); + // cc.fx.GameTool.changeCoin(6000); + const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点 + const jiazaiComp = jiazaiNode.getComponent(JiaZai); + if (jiazaiComp) { + console.log("获取到JiaZai组件", jiazaiComp); + setTimeout(() => { + jiazaiComp.setHealthInfo(false); + jiazaiComp.startTimeCutDown(); + jiazaiComp.updateCoin(); + + }, 300); + } else { + console.log("无法获取JiaZai组件"); + } + cc.fx.GameConfig.GM_INFO.doubleCoin = 2; + cc.fx.GameTool.setUserHealth(0, (data) => { + cc.fx.GameTool.getHealth(null); + }) + } + this.closeLoad(); + }) + // update (dt) {} + } + // update (dt) {} } diff --git a/assets/Script/module/Pay/Utils.ts b/assets/Script/module/Pay/Utils.ts index 2d4f115..d17c59d 100644 --- a/assets/Script/module/Pay/Utils.ts +++ b/assets/Script/module/Pay/Utils.ts @@ -171,6 +171,7 @@ export default class Utils { /**跳转客服*/ static GoKEFu(iosPayInfo, callBack) { + console.log("创建新的订单,清空老订单"); cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null; cc.fx.GameConfig.GM_INFO.iosOutTradeNo = `wcx_` + Math.round(Math.random() * 10 ** 13) + Date.now(); const data = { diff --git a/assets/Script/monthlyCard.ts b/assets/Script/monthlyCard.ts index b499b43..9c9c00d 100644 --- a/assets/Script/monthlyCard.ts +++ b/assets/Script/monthlyCard.ts @@ -52,7 +52,7 @@ export default class NewClass extends cc.Component { this.btn_Touch = true; Utils.getIosPayInfo(iosOutTradeNo, (data) => { - console.log("获得轮训结果:", data); + console.log("月卡获得轮训结果:", data); const iosID = data.data?.payment_name || this.iosProductId; let iosAmount = data.data?.goodsPrice || this.iosPrice; iosAmount = parseInt(iosAmount); @@ -133,6 +133,7 @@ export default class NewClass extends cc.Component { } this.btn_Touch = true; + console.log("月卡自己置空订单号"); cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null; }) } @@ -256,8 +257,9 @@ export default class NewClass extends cc.Component { console.log("123iiiii222") } if (jiazaiComp) { + console.log("22222222") jiazaiComp.onGames(); - console.log("1222") + } this.node.active = false; diff --git a/assets/shop/script/shop.ts b/assets/shop/script/shop.ts index 0e996f5..e29520a 100644 --- a/assets/shop/script/shop.ts +++ b/assets/shop/script/shop.ts @@ -186,6 +186,7 @@ export default class NewClass extends cc.Component { const wincoin1 = winCOIN.getComponent(JiaZai); if (wincoin1) { if (wincoin1) { + console.log("111111111"); wincoin1.onGames(); wincoin1.rewarded(); } @@ -203,18 +204,19 @@ export default class NewClass extends cc.Component { if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null && cc.fx.GameConfig.GM_INFO.iosOutTradeNo != "") { console.log("有苹果订单号,开始轮训"); const iosOutTradeNo = cc.fx.GameConfig.GM_INFO.iosOutTradeNo; - cc.fx.GameConfig.GM_INFO.iosOutTradeNo = ""; + // cc.fx.GameConfig.GM_INFO.iosOutTradeNo = ""; // this.closeLoad(); // this.openLoad(); this.btn_Touch = true; Utils.getIosPayInfo(iosOutTradeNo, (data) => { - console.log("获得轮训结果:", data); + console.log("商城获得轮训结果:", data); const iosID = data.data?.payment_name || this.iosProductId; let iosAmount = data.data?.goodsPrice || this.iosPrice; iosAmount = parseInt(iosAmount); if (iosID == "reborn_Gift" || iosID == "month_Card") { + console.log("商城检测到是月卡返回"); return; } if (data.code == 1) { @@ -298,7 +300,8 @@ export default class NewClass extends cc.Component { } this.closeLoad(); this.btn_Touch = true; - cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null; + // console.log("商城置空订单号"); + // cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null; }) } else { @@ -491,7 +494,7 @@ export default class NewClass extends cc.Component { } else { console.log("客服回话失败"); - cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null; + // cc.fx.GameConfig.GM_INFO.iosOutTradeNo = null; this.closeLoad(); } });