/** 富翁银行数据类 */ import JsbSystem from "../../../mk/system/JsbSystem"; import { GameProp } from "../GameData"; import { StorageKey } from "../StorageData"; const { ccclass } = cc._decorator; @ccclass export default class SafeDepositBoxData { /** 保险箱配置信息 */ richBankConfig = null /** 银行存入金额 */ richBankCashAmount = 0 /** 当前任务的id,也就是index字段 */ currentRichBankCashTaskIndex = null /** 开始银行任务后 每日观看的视频数 */ richBankDailyVideoTimes = 0 /** 开始银行任务后 连续登录数 */ richbankLoginDays = 0 /** 开始银行任务后 今日需要视频总次数 */ richBankDailyTotelVideoTimes = 0 /** 开始银行任务后 今日需要登陆总次数 */ richBankTotelLoginDays = 0; //富翁银行正在进行过的档位 addRichBankFinishIndex = 0; //是否开启任务 isStartBankTask = 0; qipaoType = -1; freshQipao = false; cashRecordData = null; cashRecordDataLength = 0; isTeach = false; /** 现金进入富翁银行动画 */ creatPacketAnim(type) { this.qipaoType = type; } /** * 检查在哪个段位 */ getBankTaskIndex(next = false): any { mk.console.logSingle("getBankTaskIndex addRichBankFinishIndex:", gData.safeDepositBoxData.addRichBankFinishIndex) let configInfo = gData.safeDepositBoxData.richBankConfig if (configInfo == null || configInfo == undefined) { return } let curIndex = gData.safeDepositBoxData.addRichBankFinishIndex if (next) { curIndex += 1; } if (curIndex < 1) { curIndex = 1; } if (curIndex > configInfo.length) { return configInfo[configInfo.length - 1] } for (let entry of configInfo) { if (entry.index == curIndex) { return entry } } } getBankTaskIndexExtra(isMinusOne = false){ let configInfo = gData.safeDepositBoxData.richBankConfig if (configInfo == null || configInfo == undefined) { return } let curIndex = gData.safeDepositBoxData.currentRichBankCashTaskIndex; if(isMinusOne) { curIndex -= 1; } if (curIndex > configInfo.length) { return configInfo[configInfo.length - 1] } for (let entry of configInfo) { if (entry.index == curIndex) { return entry } } } async updateQipao() { await mk.time.WaitForSeconds(1); //let response = await mk.http.sendData('richbank/getCashRecord', {}); let response = await mk.http.sendData('newrichbank/getCashRecord', {}); if (response && response.errcode == 0) { this.cashRecordData = response.data; console.log("--------------"); this.freshQipao = true; } //福利银行教学 if(gData.gameData.richBankTeachTag){ gData.gameData.richBankTeachTag = false; if(mk.guide.isGuideComplete()){ return; } mk.ui.closeAllUI(); let times = gData.gameData.getProp(GameProp.cashTimes); //let times = gData.gameData.playerProp.orderData.overTimes; console.log(`=========${times}=====${this.cashRecordData.length}====${this.cashRecordDataLength}`); if(gData.gameData.funOpenData[13] == "1" && times >=gData.gameData.showRichBankIconLimit){ this.isTeach = mk.guide.open(13); } } } setCashRecordDataLength(){ if(this.cashRecordData){ this.cashRecordDataLength = this.cashRecordData.length; console.log(`setCashRecordDataLength==========${this.cashRecordDataLength}`); }else{ this.cashRecordDataLength = 0; } } /** * 当前时间和目标时间是否是同一天 * @param targetTime 记录的时间戳 */ checkSameDay(targetTime: number): boolean { let currentDay = new Date().getDate() let lastData = new Date(targetTime).getDate() if (currentDay == lastData) { return true } return false } addJGTags(){ JsbSystem.addJGTags("富翁银行完成当天的任务"); gData.gameData.setProp(GameProp.finishRichBankTodayTask, Date.now() + ""); } deleteJGTags(){ if(this.richBankDailyVideoTimes < this.richBankDailyTotelVideoTimes && this.isStartBankTask > 0){ let time = gData.gameData.getProp(GameProp.finishRichBankTodayTask); if(time){ let same = gData.safeDepositBoxData.checkSameDay(new Number(time).valueOf()) if(!same){ JsbSystem.deleteTags("富翁银行完成当天的任务"); gData.gameData.setProp(GameProp.finishRichBankTodayTask, Date.now() + ""); } } } } }