From 83d32aa5ddb25ba9cc9d2a0354c823ace9a1a3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?computer=5C=E5=B0=BC=E5=8D=A1?= <203267346@qq.com> Date: Fri, 1 Aug 2025 15:20:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=88=E5=8D=A1=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Script/JiaZai.ts | 87 +++++++++++++++++------------------- assets/Script/monthlyCard.ts | 33 +++++--------- assets/shop/script/shop.ts | 23 +++------- 3 files changed, 60 insertions(+), 83 deletions(-) diff --git a/assets/Script/JiaZai.ts b/assets/Script/JiaZai.ts index 9d3466b..dda29eb 100644 --- a/assets/Script/JiaZai.ts +++ b/assets/Script/JiaZai.ts @@ -197,8 +197,8 @@ export default class JiaZai extends cc.Component { // //打开heath弹窗 // this.openHeath(); this.uploadToCloud(cc.fx.GameConfig.GM_INFO.level + 1); - this.rewarded(); this.getMonthlyCardValidityDays(); + this.rewarded(); console.log('月卡剩余天数 (零点刷新):', cc.fx.GameConfig.GM_INFO.monthTime); Utils.getMonthlyCard((data) => { if (data.code == 1) { @@ -765,7 +765,6 @@ export default class JiaZai extends cc.Component { //打开界面 openMonthCard() { this.openMonthlyCard(); - this.monthlyCardNode.getComponent("monthlyCard").home = 1; // this.monthCard.active = true; // Utils.getMonthlyCard((data) => { // if (data.msg == "不在有效期") { @@ -778,49 +777,49 @@ export default class JiaZai extends cc.Component { // } // }) } - //关闭界面 - closeMonthCard() { - Utils.getMonthlyCard((data) => { - if (data.msg == "不在有效期") { - this.monthCardBtn.active = true; - this.monthCardBtn2.active = false; - } else { - this.monthCardBtn.active = false; - this.monthCardBtn2.active = true; - NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); - } - }) - this.monthCard.active = false; - this.rewarded(); + // //关闭界面 + // closeMonthCard() { + // Utils.getMonthlyCard((data) => { + // if (data.msg == "不在有效期") { + // this.monthCardBtn.active = true; + // this.monthCardBtn2.active = false; + // } else { + // this.monthCardBtn.active = false; + // this.monthCardBtn2.active = true; + // NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); + // } + // }) + // this.monthCard.active = false; + // this.rewarded(); - } - //购买月卡 - buyMonthCard() { - Utils.setMonthlyCard(0, (data) => { - console.log("购买月卡'✅ ", data.code); - if (data.code == 1) { - let rewardData = [ - { type: "coin", count: 6000 }, - ] - cc.fx.GameConfig.GM_INFO.hp_Max = 7; - cc.fx.GameConfig.GM_INFO.hp = 7; - cc.fx.GameTool.changeCoin(6000); - setTimeout(() => { - this.updateCoin(); - this.setHealthInfo(false); - this.startTimeCutDown(); - this.openRewardWindow(rewardData, 1); - }, 300); - cc.fx.GameTool.setUserHealth(0, (data) => { - cc.fx.GameTool.getHealth(null); - }) - this.monthCardBtn.active = false; - this.monthCardBtn2.active = true; - NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); + // } + // //购买月卡 + // buyMonthCard() { + // Utils.setMonthlyCard(0, (data) => { + // console.log("购买月卡'✅ ", data.code); + // if (data.code == 1) { + // let rewardData = [ + // { type: "coin", count: 6000 }, + // ] + // cc.fx.GameConfig.GM_INFO.hp_Max = 7; + // cc.fx.GameConfig.GM_INFO.hp = 7; + // cc.fx.GameTool.changeCoin(6000); + // setTimeout(() => { + // this.updateCoin(); + // this.setHealthInfo(false); + // this.startTimeCutDown(); + // this.openRewardWindow(rewardData, 1); + // }, 300); + // cc.fx.GameTool.setUserHealth(0, (data) => { + // cc.fx.GameTool.getHealth(null); + // }) + // this.monthCardBtn.active = false; + // this.monthCardBtn2.active = true; + // NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); - } - }) - } + // } + // }) + // } rewarded() { Utils.monthGetReward((data) => { @@ -862,8 +861,6 @@ export default class JiaZai extends cc.Component { compensate: false } cc.fx.GameTool.shushu_Track("resource_get", dataTemp); - - } }) } diff --git a/assets/Script/monthlyCard.ts b/assets/Script/monthlyCard.ts index b7ccb91..4b282f4 100644 --- a/assets/Script/monthlyCard.ts +++ b/assets/Script/monthlyCard.ts @@ -45,6 +45,7 @@ export default class NewClass extends cc.Component { //@ts-ignore wx.onShow(this.onShowListener); } + this.home = 0; } onShow() { @@ -142,11 +143,6 @@ export default class NewClass extends cc.Component { } start() { - const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点 - const jiazaiComp = jiazaiNode.getComponent(JiaZai); - if (jiazaiComp) { - jiazaiComp.getMonthlyCardValidityDays(); - } Utils.getMonthlyCard((data) => { if (data.msg == "不在有效期") { this.monthCardBtn.active = true; @@ -161,23 +157,14 @@ export default class NewClass extends cc.Component { } init() { this.btn_Touch = true; - const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点 - const jiazaiComp = jiazaiNode.getComponent(JiaZai); - if (jiazaiComp) { - setTimeout(() => { - jiazaiComp.getMonthlyCardValidityDays(); - }, 300); + if (cc.fx.GameConfig.GM_INFO.hp_Max == 7) { + this.monthCardBtn.active = false; + this.monthCardBtn2.active = true; + NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); + } else { + this.monthCardBtn.active = true; + this.monthCardBtn2.active = false; } - Utils.getMonthlyCard((data) => { - if (data.msg == "不在有效期") { - this.monthCardBtn.active = true; - this.monthCardBtn2.active = false; - } else { - this.monthCardBtn.active = false; - this.monthCardBtn2.active = true; - NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); - } - }) } //购买月卡 @@ -191,6 +178,7 @@ export default class NewClass extends cc.Component { cc.fx.GameTool.shopBuy(id, false); cc.fx.GameConfig.GM_INFO.hp_Max = 7; cc.fx.GameConfig.GM_INFO.hp = 7; + this.home = 1; // cc.fx.GameTool.changeCoin(6000); const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点 const jiazaiComp = jiazaiNode.getComponent(JiaZai); @@ -284,9 +272,10 @@ export default class NewClass extends cc.Component { const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点 const jiazaiComp = jiazaiNode.getComponent(JiaZai); - if (jiazaiComp && this.home == 1) { + if (jiazaiComp && this.home == 1 && cc.fx.GameConfig.GM_INFO.hp == 7) { this.home = 0; jiazaiComp.rewarded(); + console.log("123iiiii222") } this.node.active = false; } diff --git a/assets/shop/script/shop.ts b/assets/shop/script/shop.ts index 4af1192..9115888 100644 --- a/assets/shop/script/shop.ts +++ b/assets/shop/script/shop.ts @@ -681,26 +681,17 @@ export default class NewClass extends cc.Component { } } this.monthCard = true; - Utils.getMonthlyCard((data) => { - if (data.msg == "不在有效期") { - this.monthCardTime.active = false; - - } else { - this.monthCardTime.active = true; - } - }) - NumberToImage.numberToImageNodes(25, 35, 15, "button_", this.monthCardTime.children[1], true); + this.updateIcon() } //更新图标 updateIcon() { - Utils.getMonthlyCard((data) => { - if (data.msg == "不在有效期") { - this.monthCardTime.active = false; + if (cc.fx.GameConfig.GM_INFO.hp_Max == 7) { + this.monthCardTime.active = true; - } else { - this.monthCardTime.active = true; - } - }) + } else { + this.monthCardTime.active = false; + + } NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 15, "button_", this.monthCardTime.children[1], true); }