| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- /** 富翁银行数据类 */
- 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() + "");
- }
- }
- }
- }
- }
|