This commit is contained in:
YZ\249929363 2025-08-01 16:35:43 +08:00
commit 101417464b
3 changed files with 17 additions and 21 deletions

View File

@ -15940,7 +15940,7 @@
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"zoomScale": 1.1,
"clickEvents": [
{
"__id__": 350
@ -15948,8 +15948,8 @@
],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$transition": 3,
"transition": 3,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,

View File

@ -884,37 +884,28 @@ export default class JiaZai extends cc.Component {
}
//获取月卡有效期距离今天的天数
getMonthlyCardValidityDays() {
getMonthlyCardValidityDays(): Promise<number> {
return new Promise((resolve, reject) => {
Utils.getMonthlyCard((data) => {
if (data.code === 1) {
const validityTime = data.data.monthCardTime; // 后端返回的到期时间戳(毫秒)
// 获取今天的零点时间戳
const today = new Date();
today.setHours(0, 0, 0, 0);
const todayMidnight = today.getTime();
// 获取到期日的零点时间戳
const expiryDate = new Date(validityTime);
expiryDate.setHours(0, 0, 0, 0);
const expiryMidnight = expiryDate.getTime();
// 计算两个零点时间戳之间的毫秒差
const diffMs = expiryMidnight - todayMidnight;
// 将毫秒差转换为完整的天数
const days = Math.floor(diffMs / 86400000); // 86400000 = 24 * 60 * 60 * 1000
// 确保天数不为负数
const days = Math.floor(diffMs / 86400000);
const remainingDays = Math.max(0, days);
cc.fx.GameConfig.GM_INFO.monthTime = remainingDays;
// console.log('月卡剩余天数 (零点刷新):', cc.fx.GameConfig.GM_INFO.monthTime );
resolve(remainingDays);
} else {
resolve(0); // 或 reject(data) 根据需要
}
});
}
});
}
//获取有没有分享信息
getShareInfo() {
@ -963,6 +954,7 @@ export default class JiaZai extends cc.Component {
}
}
onCardReward() {
this.getcard.active = false;
cc.fx.GameTool.changeCoin(500);
this.updateCoin();
const dataTemp = {

View File

@ -182,12 +182,16 @@ export default class NewClass extends cc.Component {
// cc.fx.GameTool.changeCoin(6000);
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
const jiazaiComp = jiazaiNode.getComponent(JiaZai);
jiazaiComp.getMonthlyCardValidityDays().then(days => {
cc.fx.GameConfig.GM_INFO.monthTime = days;
NumberToImage.numberToImageNodes(days, 35, 20, "month_", this.monthCardTime, true);
});
if (jiazaiComp) {
setTimeout(() => {
jiazaiComp.setHealthInfo(false);
jiazaiComp.startTimeCutDown();
jiazaiComp.updateCoin();
jiazaiComp.getMonthlyCardValidityDays();
}, 300);
} else {
console.log("无法获取JiaZai组件");
@ -247,7 +251,7 @@ export default class NewClass extends cc.Component {
shopComp.openShop();
}
}
this.init();
}
})
// update (dt) {}