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");
|
console.log("________________1");
|
||||||
this.getMonthlyCardValidityDays();
|
this.getMonthlyCardValidityDays();
|
||||||
this.rewarded();
|
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) {
|
if (cc.fx.GameConfig.GM_INFO.level >= 16 && JiaZai.cachedMonthlyCardPrefab) {
|
||||||
this.monthH();
|
this.monthH();
|
||||||
};
|
};
|
||||||
|
@ -989,7 +1007,6 @@ export default class JiaZai extends cc.Component {
|
||||||
|
|
||||||
//获取月卡有效期距离今天的天数
|
//获取月卡有效期距离今天的天数
|
||||||
getMonthlyCardValidityDays(): Promise<{ days: number, time: number }> {
|
getMonthlyCardValidityDays(): Promise<{ days: number, time: number }> {
|
||||||
|
|
||||||
console.log("________________2");
|
console.log("________________2");
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Utils.getMonthlyCard((data) => {
|
Utils.getMonthlyCard((data) => {
|
||||||
|
@ -1092,24 +1109,7 @@ export default class JiaZai extends cc.Component {
|
||||||
cc.fx.GameTool.shushu_Track("resource_get", dataTemp);
|
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() {
|
checkShare() {
|
||||||
|
|
|
@ -1437,8 +1437,32 @@ var GameTool = {
|
||||||
else {
|
else {
|
||||||
return false;
|
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本地缓存小于等于服务器存储
|
//返回true本地缓存大于服务器存储,false本地缓存小于等于服务器存储
|
||||||
// compareLevel() {
|
// compareLevel() {
|
||||||
|
|
|
@ -141,18 +141,17 @@ export default class NewClass extends cc.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
Utils.getMonthlyCard((data) => {
|
let isExpired = cc.fx.GameTool.checkExpiration();
|
||||||
if (data.msg == "不在有效期") {
|
if (isExpired == false) {
|
||||||
this.monthCardBtn.active = true;
|
this.monthCardBtn.active = true;
|
||||||
this.monthCardBtn2.active = false;
|
this.monthCardBtn2.active = false;
|
||||||
} else {
|
} else {
|
||||||
this.monthCardBtn.active = false;
|
this.monthCardBtn.active = false;
|
||||||
this.monthCardBtn2.active = true;
|
this.monthCardBtn2.active = true;
|
||||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true);
|
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 20, "month_", this.monthCardTime, true);
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
init() {
|
init() {
|
||||||
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
|
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
|
||||||
// 定义监听函数
|
// 定义监听函数
|
||||||
|
@ -250,9 +249,8 @@ export default class NewClass extends cc.Component {
|
||||||
//jiazai
|
//jiazai
|
||||||
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
|
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
|
||||||
const jiazaiComp = jiazaiNode.getComponent(JiaZai);
|
const jiazaiComp = jiazaiNode.getComponent(JiaZai);
|
||||||
|
let isExpired = cc.fx.GameTool.checkExpiration();
|
||||||
if (jiazaiComp && this.home == 1 && cc.fx.GameConfig.GM_INFO.hp_Max == 7) {
|
if (jiazaiComp && this.home == 1 && isExpired) {
|
||||||
|
|
||||||
this.home = 0;
|
this.home = 0;
|
||||||
jiazaiComp.rewarded();
|
jiazaiComp.rewarded();
|
||||||
console.log("123iiiii222")
|
console.log("123iiiii222")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user