Merge branch 'main' of https://git.sparkus.cn/yangzhao/cb
This commit is contained in:
commit
13f5d08d4d
|
@ -1005,41 +1005,7 @@ export default class JiaZai extends cc.Component {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取月卡有效期距离今天的天数
|
|
||||||
getMonthlyCardValidityDays(): Promise<{ days: number, time: number }> {
|
|
||||||
console.log("________________2");
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
Utils.getMonthlyCard((data) => {
|
|
||||||
console.log("月卡返回时间:", data);
|
|
||||||
if (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);
|
|
||||||
const remainingDays = Math.max(0, days);
|
|
||||||
cc.fx.GameConfig.GM_INFO.monthTime = remainingDays;
|
|
||||||
let obj = {
|
|
||||||
days: remainingDays,
|
|
||||||
time: validityTime,
|
|
||||||
}
|
|
||||||
resolve(obj);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// resolve(0); // 或 reject(data) 根据需要
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// resolve(0); // 或 reject(data) 根据需要
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取有没有分享信息
|
//获取有没有分享信息
|
||||||
getShareInfo() {
|
getShareInfo() {
|
||||||
|
|
|
@ -1460,8 +1460,43 @@ var GameTool = {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
//获取月卡有效期距离今天的天数
|
||||||
|
getMonthlyCardValidityDays(): Promise<{ days: number, time: number }> {
|
||||||
|
console.log("________________2");
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
Utils.getMonthlyCard((data) => {
|
||||||
|
console.log("月卡返回时间:", data);
|
||||||
|
if (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);
|
||||||
|
const remainingDays = Math.max(0, days);
|
||||||
|
cc.fx.GameConfig.GM_INFO.monthTime = remainingDays;
|
||||||
|
let obj = {
|
||||||
|
days: remainingDays,
|
||||||
|
time: validityTime,
|
||||||
|
}
|
||||||
|
resolve(obj);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// resolve(0); // 或 reject(data) 根据需要
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// resolve(0); // 或 reject(data) 根据需要
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//判断本地缓存关卡等级是否大于服务器存储
|
//判断本地缓存关卡等级是否大于服务器存储
|
||||||
//返回true本地缓存大于服务器存储,false本地缓存小于等于服务器存储
|
//返回true本地缓存大于服务器存储,false本地缓存小于等于服务器存储
|
||||||
|
|
|
@ -186,20 +186,19 @@ export default class NewClass extends cc.Component {
|
||||||
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;
|
this.home = 1;
|
||||||
|
cc.fx.GameTool.getMonthlyCardValidityDays().then(days => {
|
||||||
|
cc.fx.GameConfig.GM_INFO.monthTime = days.days;
|
||||||
|
//本地储存当前服务器时间
|
||||||
|
let dateStr = new Date(days.time);
|
||||||
|
cc.fx.StorageMessage.setStorage("mCardDate", dateStr);
|
||||||
|
NumberToImage.numberToImageNodes(days.days, 35, 20, "month_", this.monthCardTime, true);
|
||||||
|
|
||||||
|
});
|
||||||
// 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);
|
||||||
|
|
||||||
if (jiazaiComp) {
|
if (jiazaiComp) {
|
||||||
console.log("获取到JiaZai组件", jiazaiComp);
|
console.log("获取到JiaZai组件", jiazaiComp);
|
||||||
jiazaiComp.getMonthlyCardValidityDays().then(days => {
|
|
||||||
cc.fx.GameConfig.GM_INFO.monthTime = days.days;
|
|
||||||
//本地储存当前服务器时间
|
|
||||||
let dateStr = new Date(days.time);
|
|
||||||
cc.fx.StorageMessage.setStorage("mCardDate", dateStr);
|
|
||||||
NumberToImage.numberToImageNodes(days.days, 35, 20, "month_", this.monthCardTime, true);
|
|
||||||
|
|
||||||
});
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
jiazaiComp.setHealthInfo(false);
|
jiazaiComp.setHealthInfo(false);
|
||||||
jiazaiComp.startTimeCutDown();
|
jiazaiComp.startTimeCutDown();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user