SafeDepositBoxData.ts 5.2 KB

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