This commit is contained in:
YZ\249929363 2025-08-01 15:21:53 +08:00
commit 0222378540
3 changed files with 60 additions and 83 deletions

View File

@ -201,8 +201,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) {
@ -769,7 +769,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 == "不在有效期") {
@ -782,49 +781,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) => {
@ -866,8 +865,6 @@ export default class JiaZai extends cc.Component {
compensate: false
}
cc.fx.GameTool.shushu_Track("resource_get", dataTemp);
}
})
}

View File

@ -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;
}

View File

@ -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);
}