月卡时间

This commit is contained in:
computer\尼卡 2025-08-01 15:20:21 +08:00
parent 8d2d21e19c
commit 83d32aa5dd
3 changed files with 60 additions and 83 deletions

View File

@ -197,8 +197,8 @@ export default class JiaZai extends cc.Component {
// //打开heath弹窗 // //打开heath弹窗
// this.openHeath(); // this.openHeath();
this.uploadToCloud(cc.fx.GameConfig.GM_INFO.level + 1); this.uploadToCloud(cc.fx.GameConfig.GM_INFO.level + 1);
this.rewarded();
this.getMonthlyCardValidityDays(); this.getMonthlyCardValidityDays();
this.rewarded();
console.log('月卡剩余天数 (零点刷新):', cc.fx.GameConfig.GM_INFO.monthTime); console.log('月卡剩余天数 (零点刷新):', cc.fx.GameConfig.GM_INFO.monthTime);
Utils.getMonthlyCard((data) => { Utils.getMonthlyCard((data) => {
if (data.code == 1) { if (data.code == 1) {
@ -765,7 +765,6 @@ export default class JiaZai extends cc.Component {
//打开界面 //打开界面
openMonthCard() { openMonthCard() {
this.openMonthlyCard(); this.openMonthlyCard();
this.monthlyCardNode.getComponent("monthlyCard").home = 1;
// this.monthCard.active = true; // this.monthCard.active = true;
// Utils.getMonthlyCard((data) => { // Utils.getMonthlyCard((data) => {
// if (data.msg == "不在有效期") { // if (data.msg == "不在有效期") {
@ -778,49 +777,49 @@ export default class JiaZai extends cc.Component {
// } // }
// }) // })
} }
//关闭界面 // //关闭界面
closeMonthCard() { // closeMonthCard() {
Utils.getMonthlyCard((data) => { // Utils.getMonthlyCard((data) => {
if (data.msg == "不在有效期") { // if (data.msg == "不在有效期") {
this.monthCardBtn.active = true; // this.monthCardBtn.active = true;
this.monthCardBtn2.active = false; // this.monthCardBtn2.active = false;
} else { // } else {
this.monthCardBtn.active = false; // this.monthCardBtn.active = false;
this.monthCardBtn2.active = true; // this.monthCardBtn2.active = true;
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); // NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true);
} // }
}) // })
this.monthCard.active = false; // this.monthCard.active = false;
this.rewarded(); // this.rewarded();
} // }
//购买月卡 // //购买月卡
buyMonthCard() { // buyMonthCard() {
Utils.setMonthlyCard(0, (data) => { // Utils.setMonthlyCard(0, (data) => {
console.log("购买月卡'✅ ", data.code); // console.log("购买月卡'✅ ", data.code);
if (data.code == 1) { // if (data.code == 1) {
let rewardData = [ // let rewardData = [
{ type: "coin", count: 6000 }, // { type: "coin", count: 6000 },
] // ]
cc.fx.GameConfig.GM_INFO.hp_Max = 7; // cc.fx.GameConfig.GM_INFO.hp_Max = 7;
cc.fx.GameConfig.GM_INFO.hp = 7; // cc.fx.GameConfig.GM_INFO.hp = 7;
cc.fx.GameTool.changeCoin(6000); // cc.fx.GameTool.changeCoin(6000);
setTimeout(() => { // setTimeout(() => {
this.updateCoin(); // this.updateCoin();
this.setHealthInfo(false); // this.setHealthInfo(false);
this.startTimeCutDown(); // this.startTimeCutDown();
this.openRewardWindow(rewardData, 1); // this.openRewardWindow(rewardData, 1);
}, 300); // }, 300);
cc.fx.GameTool.setUserHealth(0, (data) => { // cc.fx.GameTool.setUserHealth(0, (data) => {
cc.fx.GameTool.getHealth(null); // cc.fx.GameTool.getHealth(null);
}) // })
this.monthCardBtn.active = false; // this.monthCardBtn.active = false;
this.monthCardBtn2.active = true; // this.monthCardBtn2.active = true;
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true); // NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true);
} // }
}) // })
} // }
rewarded() { rewarded() {
Utils.monthGetReward((data) => { Utils.monthGetReward((data) => {
@ -862,8 +861,6 @@ export default class JiaZai extends cc.Component {
compensate: false compensate: false
} }
cc.fx.GameTool.shushu_Track("resource_get", dataTemp); cc.fx.GameTool.shushu_Track("resource_get", dataTemp);
} }
}) })
} }

View File

@ -45,6 +45,7 @@ export default class NewClass extends cc.Component {
//@ts-ignore //@ts-ignore
wx.onShow(this.onShowListener); wx.onShow(this.onShowListener);
} }
this.home = 0;
} }
onShow() { onShow() {
@ -142,11 +143,6 @@ export default class NewClass extends cc.Component {
} }
start() { start() {
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
const jiazaiComp = jiazaiNode.getComponent(JiaZai);
if (jiazaiComp) {
jiazaiComp.getMonthlyCardValidityDays();
}
Utils.getMonthlyCard((data) => { Utils.getMonthlyCard((data) => {
if (data.msg == "不在有效期") { if (data.msg == "不在有效期") {
this.monthCardBtn.active = true; this.monthCardBtn.active = true;
@ -161,23 +157,14 @@ export default class NewClass extends cc.Component {
} }
init() { init() {
this.btn_Touch = true; this.btn_Touch = true;
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点 if (cc.fx.GameConfig.GM_INFO.hp_Max == 7) {
const jiazaiComp = jiazaiNode.getComponent(JiaZai); this.monthCardBtn.active = false;
if (jiazaiComp) { this.monthCardBtn2.active = true;
setTimeout(() => { NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true);
jiazaiComp.getMonthlyCardValidityDays(); } else {
}, 300); 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.GameTool.shopBuy(id, false);
cc.fx.GameConfig.GM_INFO.hp_Max = 7; cc.fx.GameConfig.GM_INFO.hp_Max = 7;
cc.fx.GameConfig.GM_INFO.hp = 7; cc.fx.GameConfig.GM_INFO.hp = 7;
this.home = 1;
// cc.fx.GameTool.changeCoin(6000); // cc.fx.GameTool.changeCoin(6000);
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点 const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
const jiazaiComp = jiazaiNode.getComponent(JiaZai); const jiazaiComp = jiazaiNode.getComponent(JiaZai);
@ -284,9 +272,10 @@ export default class NewClass extends cc.Component {
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点 const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
const jiazaiComp = jiazaiNode.getComponent(JiaZai); 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; this.home = 0;
jiazaiComp.rewarded(); jiazaiComp.rewarded();
console.log("123iiiii222")
} }
this.node.active = false; this.node.active = false;
} }

View File

@ -681,26 +681,17 @@ export default class NewClass extends cc.Component {
} }
} }
this.monthCard = true; this.monthCard = true;
Utils.getMonthlyCard((data) => { this.updateIcon()
if (data.msg == "不在有效期") {
this.monthCardTime.active = false;
} else {
this.monthCardTime.active = true;
}
})
NumberToImage.numberToImageNodes(25, 35, 15, "button_", this.monthCardTime.children[1], true);
} }
//更新图标 //更新图标
updateIcon() { updateIcon() {
Utils.getMonthlyCard((data) => { if (cc.fx.GameConfig.GM_INFO.hp_Max == 7) {
if (data.msg == "不在有效期") { this.monthCardTime.active = true;
this.monthCardTime.active = false;
} else { } else {
this.monthCardTime.active = true; this.monthCardTime.active = false;
}
}) }
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 15, "button_", this.monthCardTime.children[1], true); NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 15, "button_", this.monthCardTime.children[1], true);
} }