ActivityDailyComulativeRechargeBTItem.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. local ActivityDailyComulativeRechargeBTItem = class('ActivityDailyComulativeRechargeBTItem', require('Activities/ActivityTypeItem'))
  2. local ActivityTaskItem = require("Activities/ActivityTaskItem")
  3. function ActivityDailyComulativeRechargeBTItem:ctor()
  4. self.curDay = 0
  5. self.curDayEndTime = 0
  6. self.dayTaskList = nil
  7. self.redPointType = Enum.RPNotifyType.DailyRechargeBT
  8. end
  9. function ActivityDailyComulativeRechargeBTItem:SyncSrvData(serverData, curDayEndTime)
  10. if not self.dayTaskList then
  11. self.dayTaskList = {}
  12. end
  13. local curDay = serverData.cur_day
  14. if self.curDay ~= curDay then
  15. self.curDay = curDay
  16. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Activity_Day_Change,self.actId)
  17. end
  18. self.curDayEndTime = tonumber(tostring(curDayEndTime / 1000))
  19. local taskList = serverData.bt_zhenjia_recharge_task_list
  20. for i = 1, #taskList do
  21. local taskData = taskList[i]
  22. local task = self:GetTaskById(taskData.task_id)
  23. if not task then
  24. task = ActivityTaskItem:new(taskData.task_id)
  25. self.dayTaskList[#self.dayTaskList+1] = task
  26. end
  27. task:SyncServerData(taskData)
  28. end
  29. self:SortTask(self.dayTaskList)
  30. end
  31. function ActivityDailyComulativeRechargeBTItem:SortTask(taskList)
  32. if taskList == nil or #taskList < 2 then
  33. return
  34. end
  35. table.sort(
  36. taskList,
  37. function(a, b)
  38. if a.showPriority < b.showPriority then
  39. return true
  40. elseif a.showPriority > b.showPriority then
  41. return false
  42. else
  43. return a.taskId < b.taskId
  44. end
  45. end
  46. )
  47. end
  48. function ActivityDailyComulativeRechargeBTItem:GetTaskById(id)
  49. for i = 1, #self.dayTaskList do
  50. if self.dayTaskList[i].taskId == id then
  51. return self.dayTaskList[i]
  52. end
  53. end
  54. return nil
  55. end
  56. function ActivityDailyComulativeRechargeBTItem:GetDayTaskList()
  57. return self.dayTaskList
  58. end
  59. function ActivityDailyComulativeRechargeBTItem:HasRedPoint()
  60. if self.dayTaskList == nil then
  61. return false
  62. end
  63. for i = 1, #self.dayTaskList do
  64. local task = self.dayTaskList[i]
  65. if task:HasRedPoint() then
  66. return true
  67. end
  68. end
  69. return false
  70. end
  71. function ActivityDailyComulativeRechargeBTItem:GetDayLeftTime()
  72. local leftTime = self.curDayEndTime - ManagerContainer.LuaTimerMgr:GetTimeSecond()
  73. if leftTime < 0 then
  74. leftTime = 0
  75. end
  76. return leftTime
  77. end
  78. return ActivityDailyComulativeRechargeBTItem