SafeDepositBoxData.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /** 富翁银行数据类 */
  2. import JsbSystem from "../../../mk/system/JsbSystem";
  3. import { GameProp } from "../GameData";
  4. import { StorageKey } from "../StorageData";
  5. const { ccclass } = cc._decorator;
  6. @ccclass
  7. export default class SafeDepositBoxData {
  8. /** 保险箱配置信息 */
  9. richBankConfig = null
  10. /** 银行存入金额 */
  11. richBankCashAmount = 0
  12. /** 当前任务的id,也就是index字段 */
  13. currentRichBankCashTaskIndex = 0
  14. /** 开始银行任务后 每日观看的视频数 */
  15. richBankDailyVideoTimes = 0
  16. /** 开始银行任务后 连续登录数 */
  17. richbankLoginDays = 0
  18. /** 开始银行任务后 今日需要视频总次数 */
  19. richBankDailyTotelVideoTimes = 0
  20. /** 开始银行任务后 今日需要登陆总次数 */
  21. richBankTotelLoginDays = 0;
  22. //富翁银行正在进行过的档位
  23. addRichBankFinishIndex = 0;
  24. //是否开启任务
  25. isStartBankTask = 0;
  26. qipaoType = -1;
  27. freshQipao = false;
  28. cashRecordData = null;
  29. cashRecordDataLength = 0;
  30. isTeach = false;
  31. /** 现金进入富翁银行动画 */
  32. creatPacketAnim(type) {
  33. this.qipaoType = type;
  34. }
  35. /**
  36. * 检查在哪个段位
  37. */
  38. getBankTaskIndex(next = false): any {
  39. mk.console.logSingle("getBankTaskIndex addRichBankFinishIndex:", gData.safeDepositBoxData.addRichBankFinishIndex)
  40. let configInfo = gData.safeDepositBoxData.richBankConfig
  41. if (configInfo == null || configInfo == undefined) {
  42. return
  43. }
  44. let curIndex = gData.safeDepositBoxData.addRichBankFinishIndex
  45. if (next) {
  46. curIndex += 1;
  47. }
  48. if (curIndex < 1) {
  49. curIndex = 1;
  50. }
  51. if (curIndex > configInfo.length) {
  52. return configInfo[configInfo.length - 1]
  53. }
  54. for (let entry of configInfo) {
  55. if (entry.index == curIndex) {
  56. return entry
  57. }
  58. }
  59. }
  60. getBankTaskIndexExtra(isMinusOne = false){
  61. let configInfo = gData.safeDepositBoxData.richBankConfig
  62. if (configInfo == null || configInfo == undefined) {
  63. return
  64. }
  65. let curIndex = gData.safeDepositBoxData.currentRichBankCashTaskIndex;
  66. if(isMinusOne)
  67. {
  68. curIndex -= 1;
  69. }
  70. if (curIndex > configInfo.length) {
  71. return configInfo[configInfo.length - 1]
  72. }
  73. for (let entry of configInfo) {
  74. if (entry.index == curIndex) {
  75. return entry
  76. }
  77. }
  78. }
  79. async updateQipao() {
  80. await mk.time.WaitForSeconds(1);
  81. //let response = await mk.http.sendData('richbank/getCashRecord', {});
  82. let response = await mk.http.sendData('newrichbank/getCashRecord', {});
  83. if (response && response.errcode == 0) {
  84. this.cashRecordData = response.data;
  85. this.freshQipao = true;
  86. }
  87. //福利银行教学
  88. if(gData.gameData.richBankTeachTag){
  89. gData.gameData.richBankTeachTag = false;
  90. let isOpenRichBankUI = mk.ui.getCurOnPanel("SafeDepositBox");
  91. if(gData.gameData.funOpenData[13] == "1" && !isOpenRichBankUI){
  92. if(this.cashRecordData.length > this.cashRecordDataLength){
  93. this.cashRecordDataLength = this.cashRecordData.length;
  94. this.isTeach = mk.guide.open(13);
  95. }
  96. }
  97. }
  98. }
  99. setCashRecordDataLength(){
  100. if(this.cashRecordData){
  101. this.cashRecordDataLength = this.cashRecordData.length;
  102. }else{
  103. this.cashRecordDataLength = 0;
  104. }
  105. }
  106. /**
  107. * 当前时间和目标时间是否是同一天
  108. * @param targetTime 记录的时间戳
  109. */
  110. checkSameDay(targetTime: number): boolean {
  111. let currentDay = new Date().getDate()
  112. let lastData = new Date(targetTime).getDate()
  113. if (currentDay == lastData) {
  114. return true
  115. }
  116. return false
  117. }
  118. addJGTags(){
  119. JsbSystem.addJGTags("富翁银行完成当天的任务");
  120. gData.gameData.setProp(GameProp.finishRichBankTodayTask, Date.now() + "");
  121. }
  122. deleteJGTags(){
  123. if(this.richBankDailyVideoTimes < this.richBankDailyTotelVideoTimes && this.isStartBankTask > 0){
  124. let time = gData.gameData.getProp(GameProp.finishRichBankTodayTask);
  125. if(time){
  126. let same = gData.safeDepositBoxData.checkSameDay(new Number(time).valueOf())
  127. if(!same){
  128. JsbSystem.deleteTags("富翁银行完成当天的任务");
  129. gData.gameData.setProp(GameProp.finishRichBankTodayTask, Date.now() + "");
  130. }
  131. }
  132. }
  133. }
  134. }