源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
4.6 KiB

  1. GodActivityBaseView = GodActivityBaseView or BaseClass(BaseItem)
  2. local GodActivityBaseView = GodActivityBaseView
  3. function GodActivityBaseView:__init(parent_wnd,prefab_asset,layer_name)
  4. self.base_file = "godActivity"
  5. self.layout_file = "GodActivityBaseView"
  6. self.layer_name = layer_name
  7. self.model = GodModel:getInstance()
  8. self.activity_type = GodConst.ActivityType.Limit
  9. self.type_name = {
  10. [GodConst.ActivityType.Common] = "普通召唤",
  11. [GodConst.ActivityType.Limit] = "限时召唤",
  12. }
  13. self.full_screen = true
  14. self.ani_left = -200
  15. self:Load()
  16. end
  17. function GodActivityBaseView:Load_callback()
  18. self.nodes = {
  19. "left:obj",
  20. "left/img_tab_1:obj:img", "left/lb_tab_2:tmp", "container", "left/img_tab_2:obj:img", "left/lb_tab_1:tmp",
  21. "left/lb_tab_1_up:tmp", "left/lb_tab_2_up:tmp", "left/red_1:obj", "left/red_2:obj", "left/lb_time:tmp",
  22. }
  23. self:GetChildren(self.nodes)
  24. self.left_obj:SetActive(false)
  25. self:AddEvents()
  26. if self.need_refreshData then
  27. self:UpdateView()
  28. end
  29. end
  30. function GodActivityBaseView:AddEvents( )
  31. local function call_back( target )
  32. if self.model.draw_ing then
  33. Message.show("抽奖中,请稍后")
  34. return
  35. end
  36. if target == self.img_tab_1_obj then
  37. self.activity_type = GodConst.ActivityType.Limit
  38. self:UpdateView()
  39. else
  40. self.activity_type = GodConst.ActivityType.Common
  41. self:UpdateView()
  42. end
  43. end
  44. AddClickEvent(self.img_tab_1_obj,call_back,false)
  45. AddClickEvent(self.img_tab_2_obj,call_back,false)
  46. local function on_update_red_dot( )
  47. self:RefreshRed()
  48. end
  49. self:BindEvent(self.model, GodConst.UpdateRedDot, on_update_red_dot)
  50. local function ANS_ACTIVITY_LIMIT_INFO( )
  51. self:UpdateTime()
  52. end
  53. self:BindEvent(self.model, GodConst.ANS_ACTIVITY_LIMIT_INFO, ANS_ACTIVITY_LIMIT_INFO)
  54. end
  55. function GodActivityBaseView:RefreshRed( )
  56. if self.is_loaded then
  57. self.red_1_obj:SetActive(self.model:IsActivityLimitRed())
  58. --宠物生活技能 每日免费抽奖一次
  59. local left_free_draw_times = self.model:GetGodLeftFreeDrawTimes()
  60. local free_red = left_free_draw_times > 0
  61. self.red_2_obj:SetActive(self.model:IsActivityCommonRed() or free_red)
  62. end
  63. end
  64. function GodActivityBaseView:UpdateView( )
  65. self:UpdateTabList()
  66. if self.activity_type == GodConst.ActivityType.Common then
  67. if self.view_limit then
  68. self.view_limit:SetVisible( false,true )
  69. end
  70. self.view_common = self.view_common or self:CreateItem(GodActivityCommonView, self.container, self.layer_name)
  71. self.view_common:SetVisible( true,true )
  72. else
  73. if self.view_common then
  74. self.view_common:SetVisible( false,true )
  75. end
  76. self.view_limit = self.view_limit or self:CreateItem(GodActivityLimitView, self.container, self.layer_name)
  77. self.view_limit:SetVisible( true,true )
  78. self.view_limit:RefreshModel(true)
  79. end
  80. self:RefreshRed()
  81. if self.switch_call then
  82. self.switch_call(self.activity_type)
  83. end
  84. self:UpdateTime()
  85. end
  86. function GodActivityBaseView:SetSwitchCall( call_back )
  87. self.switch_call = call_back
  88. if self.activity_type and self.switch_call then
  89. self.switch_call(self.activity_type)
  90. end
  91. end
  92. function GodActivityBaseView:UpdateTabList( )
  93. if self.activity_type == GodConst.ActivityType.Limit then
  94. lua_resM:setImageSprite(self, self.img_tab_1_img, "godActivity_asset", "godActivity_di_8",true)
  95. lua_resM:setImageSprite(self, self.img_tab_2_img, "godActivity_asset", "godActivity_di_9",true)
  96. self.lb_tab_1_tmp.text = ""
  97. self.lb_tab_1_up_tmp.text = self.type_name[GodConst.ActivityType.Limit]
  98. self.lb_tab_2_tmp.text = self.type_name[GodConst.ActivityType.Common]
  99. self.lb_tab_2_up_tmp.text = ""
  100. else
  101. lua_resM:setImageSprite(self, self.img_tab_1_img, "godActivity_asset", "godActivity_di_9",true)
  102. lua_resM:setImageSprite(self, self.img_tab_2_img, "godActivity_asset", "godActivity_di_8",true)
  103. self.lb_tab_1_tmp.text = self.type_name[GodConst.ActivityType.Limit]
  104. self.lb_tab_1_up_tmp.text = ""
  105. self.lb_tab_2_tmp.text = ""
  106. self.lb_tab_2_up_tmp.text = self.type_name[GodConst.ActivityType.Common]
  107. end
  108. end
  109. function GodActivityBaseView:UpdateTime( )
  110. if not self.is_loaded then return end
  111. local base_data = self.model:GetActivityLimitInfo()
  112. if not base_data then return end
  113. local stime_str = TimeUtil:timeConversion(base_data.begin_time, "mm.dd")
  114. local etime_str = TimeUtil:timeConversion(base_data.end_time, "mm.dd")
  115. self.lb_time_tmp.text = stime_str .. "~" .. etime_str
  116. end
  117. function GodActivityBaseView:SetData( activity_type )
  118. self.activity_type = activity_type or self.activity_type
  119. if self.is_loaded then
  120. self.need_refreshData = false
  121. self:UpdateView()
  122. else
  123. self.need_refreshData = true
  124. end
  125. end
  126. function GodActivityBaseView:NeedChangeMoneyFlag( )
  127. return
  128. end
  129. function GodActivityBaseView:__delete( )
  130. end