SafeDepositBoxData.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 = null
  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. console.log("--------------");
  86. this.freshQipao = true;
  87. }
  88. //福利银行教学
  89. if(gData.gameData.richBankTeachTag){
  90. gData.gameData.richBankTeachTag = false;
  91. let isOpenRichBankUI = mk.ui.isPopPanel();
  92. let times = gData.gameData.getProp(GameProp.cashTimes);
  93. console.log(`=========${isOpenRichBankUI}===${times}=====${this.cashRecordData.length}====${this.cashRecordDataLength}`);
  94. if(gData.gameData.funOpenData[13] == "1" && !isOpenRichBankUI && times >=gData.gameData.showRichBankIconLimit){
  95. if(this.cashRecordData.length >= this.cashRecordDataLength){
  96. this.cashRecordDataLength = this.cashRecordData.length;
  97. this.isTeach = mk.guide.open(13);
  98. }
  99. }
  100. }
  101. }
  102. setCashRecordDataLength(){
  103. if(this.cashRecordData){
  104. this.cashRecordDataLength = this.cashRecordData.length;
  105. console.log(`setCashRecordDataLength==========${this.cashRecordDataLength}`);
  106. }else{
  107. this.cashRecordDataLength = 0;
  108. }
  109. }
  110. /**
  111. * 当前时间和目标时间是否是同一天
  112. * @param targetTime 记录的时间戳
  113. */
  114. checkSameDay(targetTime: number): boolean {
  115. let currentDay = new Date().getDate()
  116. let lastData = new Date(targetTime).getDate()
  117. if (currentDay == lastData) {
  118. return true
  119. }
  120. return false
  121. }
  122. addJGTags(){
  123. JsbSystem.addJGTags("富翁银行完成当天的任务");
  124. gData.gameData.setProp(GameProp.finishRichBankTodayTask, Date.now() + "");
  125. }
  126. deleteJGTags(){
  127. if(this.richBankDailyVideoTimes < this.richBankDailyTotelVideoTimes && this.isStartBankTask > 0){
  128. let time = gData.gameData.getProp(GameProp.finishRichBankTodayTask);
  129. if(time){
  130. let same = gData.safeDepositBoxData.checkSameDay(new Number(time).valueOf())
  131. if(!same){
  132. JsbSystem.deleteTags("富翁银行完成当天的任务");
  133. gData.gameData.setProp(GameProp.finishRichBankTodayTask, Date.now() + "");
  134. }
  135. }
  136. }
  137. }
  138. }