Merge branch 'main' of https://git.sparkus.cn/yangzhao/cb
This commit is contained in:
commit
be42d3b146
|
@ -265,7 +265,25 @@ export default class JiaZai extends cc.Component {
|
|||
console.log("________________1");
|
||||
this.getMonthlyCardValidityDays();
|
||||
this.rewarded();
|
||||
this.checkExpiration();
|
||||
|
||||
//判断过期
|
||||
cc.fx.GameTool.checkExpiration();
|
||||
let isExpired = cc.fx.GameTool.checkExpiration();
|
||||
if (isExpired) {
|
||||
const validityTime = cc.fx.StorageMessage.getStorage("mCardDate"); // 后端返回的到期时间戳(毫秒)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
if (cc.fx.GameConfig.GM_INFO.level >= 16 && JiaZai.cachedMonthlyCardPrefab) {
|
||||
this.monthH();
|
||||
};
|
||||
|
@ -989,7 +1007,6 @@ export default class JiaZai extends cc.Component {
|
|||
|
||||
//获取月卡有效期距离今天的天数
|
||||
getMonthlyCardValidityDays(): Promise<{ days: number, time: number }> {
|
||||
|
||||
console.log("________________2");
|
||||
return new Promise((resolve, reject) => {
|
||||
Utils.getMonthlyCard((data) => {
|
||||
|
@ -1092,24 +1109,7 @@ export default class JiaZai extends cc.Component {
|
|||
cc.fx.GameTool.shushu_Track("resource_get", dataTemp);
|
||||
}
|
||||
|
||||
//判断过期
|
||||
checkExpiration() {
|
||||
let dateStr = cc.fx.StorageMessage.getStorage("mCardDate");
|
||||
if (dateStr) {
|
||||
//将字符串转换为时间戳
|
||||
let dateTime = new Date(dateStr).getTime();
|
||||
//当前时间转换为时间戳
|
||||
let currentTime = new Date().getTime();
|
||||
if (dateTime > currentTime) {
|
||||
cc.fx.GameConfig.GM_INFO.hp_Max = 7;
|
||||
cc.fx.GameConfig.GM_INFO.doubleCoin = 2;
|
||||
} else {
|
||||
cc.fx.GameConfig.GM_INFO.hp_Max = 5;
|
||||
cc.fx.GameConfig.GM_INFO.doubleCoin = 1;
|
||||
}
|
||||
console.log("月卡过期时间", dateTime, "当前时间", currentTime,);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//检测当日是否有分享行为,用不用主动获取分享关卡信息
|
||||
checkShare() {
|
||||
|
|
|
@ -1437,8 +1437,32 @@ var GameTool = {
|
|||
else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
//判断过期
|
||||
checkExpiration() {
|
||||
let dateStr = cc.fx.StorageMessage.getStorage("mCardDate");
|
||||
//如果过期返回 true ,没过期返回 false
|
||||
if (dateStr) {
|
||||
//将字符串转换为时间戳
|
||||
let dateTime = new Date(dateStr).getTime();
|
||||
//当前时间转换为时间戳
|
||||
let currentTime = new Date().getTime();
|
||||
// console.log("月卡过期时间", dateTime, "当前时间", currentTime,);
|
||||
if (dateTime > currentTime) {
|
||||
cc.fx.GameConfig.GM_INFO.hp_Max = 7;
|
||||
cc.fx.GameConfig.GM_INFO.doubleCoin = 2;
|
||||
return true;
|
||||
} else {
|
||||
cc.fx.GameConfig.GM_INFO.hp_Max = 5;
|
||||
cc.fx.GameConfig.GM_INFO.doubleCoin = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//判断本地缓存关卡等级是否大于服务器存储
|
||||
//返回true本地缓存大于服务器存储,false本地缓存小于等于服务器存储
|
||||
// compareLevel() {
|
||||
|
|
|
@ -141,17 +141,16 @@ export default class NewClass extends cc.Component {
|
|||
}
|
||||
|
||||
start() {
|
||||
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);
|
||||
}
|
||||
})
|
||||
let isExpired = cc.fx.GameTool.checkExpiration();
|
||||
if (isExpired == false) {
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
init() {
|
||||
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
|
||||
|
@ -250,9 +249,8 @@ export default class NewClass extends cc.Component {
|
|||
//jiazai
|
||||
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
|
||||
const jiazaiComp = jiazaiNode.getComponent(JiaZai);
|
||||
|
||||
if (jiazaiComp && this.home == 1 && cc.fx.GameConfig.GM_INFO.hp_Max == 7) {
|
||||
|
||||
let isExpired = cc.fx.GameTool.checkExpiration();
|
||||
if (jiazaiComp && this.home == 1 && isExpired) {
|
||||
this.home = 0;
|
||||
jiazaiComp.rewarded();
|
||||
console.log("123iiiii222")
|
||||
|
|
Loading…
Reference in New Issue
Block a user