Merge branch 'main' of https://git.sparkus.cn/yangzhao/cb
This commit is contained in:
commit
101417464b
|
@ -15940,7 +15940,7 @@
|
||||||
"_normalMaterial": null,
|
"_normalMaterial": null,
|
||||||
"_grayMaterial": null,
|
"_grayMaterial": null,
|
||||||
"duration": 0.1,
|
"duration": 0.1,
|
||||||
"zoomScale": 1.2,
|
"zoomScale": 1.1,
|
||||||
"clickEvents": [
|
"clickEvents": [
|
||||||
{
|
{
|
||||||
"__id__": 350
|
"__id__": 350
|
||||||
|
@ -15948,8 +15948,8 @@
|
||||||
],
|
],
|
||||||
"_N$interactable": true,
|
"_N$interactable": true,
|
||||||
"_N$enableAutoGrayEffect": false,
|
"_N$enableAutoGrayEffect": false,
|
||||||
"_N$transition": 0,
|
"_N$transition": 3,
|
||||||
"transition": 0,
|
"transition": 3,
|
||||||
"_N$normalColor": {
|
"_N$normalColor": {
|
||||||
"__type__": "cc.Color",
|
"__type__": "cc.Color",
|
||||||
"r": 255,
|
"r": 255,
|
||||||
|
|
|
@ -884,37 +884,28 @@ export default class JiaZai extends cc.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取月卡有效期距离今天的天数
|
//获取月卡有效期距离今天的天数
|
||||||
getMonthlyCardValidityDays() {
|
getMonthlyCardValidityDays(): Promise<number> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
Utils.getMonthlyCard((data) => {
|
Utils.getMonthlyCard((data) => {
|
||||||
if (data.code === 1) {
|
if (data.code === 1) {
|
||||||
const validityTime = data.data.monthCardTime; // 后端返回的到期时间戳(毫秒)
|
const validityTime = data.data.monthCardTime; // 后端返回的到期时间戳(毫秒)
|
||||||
|
|
||||||
// 获取今天的零点时间戳
|
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
today.setHours(0, 0, 0, 0);
|
today.setHours(0, 0, 0, 0);
|
||||||
const todayMidnight = today.getTime();
|
const todayMidnight = today.getTime();
|
||||||
|
|
||||||
// 获取到期日的零点时间戳
|
|
||||||
const expiryDate = new Date(validityTime);
|
const expiryDate = new Date(validityTime);
|
||||||
expiryDate.setHours(0, 0, 0, 0);
|
expiryDate.setHours(0, 0, 0, 0);
|
||||||
const expiryMidnight = expiryDate.getTime();
|
const expiryMidnight = expiryDate.getTime();
|
||||||
|
|
||||||
// 计算两个零点时间戳之间的毫秒差
|
|
||||||
const diffMs = expiryMidnight - todayMidnight;
|
const diffMs = expiryMidnight - todayMidnight;
|
||||||
|
const days = Math.floor(diffMs / 86400000);
|
||||||
// 将毫秒差转换为完整的天数
|
|
||||||
const days = Math.floor(diffMs / 86400000); // 86400000 = 24 * 60 * 60 * 1000
|
|
||||||
|
|
||||||
// 确保天数不为负数
|
|
||||||
const remainingDays = Math.max(0, days);
|
const remainingDays = Math.max(0, days);
|
||||||
|
|
||||||
cc.fx.GameConfig.GM_INFO.monthTime = remainingDays;
|
cc.fx.GameConfig.GM_INFO.monthTime = remainingDays;
|
||||||
// console.log('月卡剩余天数 (零点刷新):', cc.fx.GameConfig.GM_INFO.monthTime );
|
resolve(remainingDays);
|
||||||
} else {
|
} else {
|
||||||
|
resolve(0); // 或 reject(data) 根据需要
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//获取有没有分享信息
|
//获取有没有分享信息
|
||||||
getShareInfo() {
|
getShareInfo() {
|
||||||
|
@ -963,6 +954,7 @@ export default class JiaZai extends cc.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onCardReward() {
|
onCardReward() {
|
||||||
|
this.getcard.active = false;
|
||||||
cc.fx.GameTool.changeCoin(500);
|
cc.fx.GameTool.changeCoin(500);
|
||||||
this.updateCoin();
|
this.updateCoin();
|
||||||
const dataTemp = {
|
const dataTemp = {
|
||||||
|
|
|
@ -182,12 +182,16 @@ export default class NewClass extends cc.Component {
|
||||||
// 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);
|
||||||
|
jiazaiComp.getMonthlyCardValidityDays().then(days => {
|
||||||
|
cc.fx.GameConfig.GM_INFO.monthTime = days;
|
||||||
|
NumberToImage.numberToImageNodes(days, 35, 20, "month_", this.monthCardTime, true);
|
||||||
|
});
|
||||||
if (jiazaiComp) {
|
if (jiazaiComp) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
jiazaiComp.setHealthInfo(false);
|
jiazaiComp.setHealthInfo(false);
|
||||||
jiazaiComp.startTimeCutDown();
|
jiazaiComp.startTimeCutDown();
|
||||||
jiazaiComp.updateCoin();
|
jiazaiComp.updateCoin();
|
||||||
jiazaiComp.getMonthlyCardValidityDays();
|
|
||||||
}, 300);
|
}, 300);
|
||||||
} else {
|
} else {
|
||||||
console.log("无法获取JiaZai组件");
|
console.log("无法获取JiaZai组件");
|
||||||
|
@ -247,7 +251,7 @@ export default class NewClass extends cc.Component {
|
||||||
shopComp.openShop();
|
shopComp.openShop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.init();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// update (dt) {}
|
// update (dt) {}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user