源战役客户端
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.

242 line
8.6 KiB

  1. --[[@------------------------------------------------------------------
  2. @description:
  3. @author:HWR
  4. ----------------------------------------------------------------------]]
  5. FuliMainView = FuliMainView or BaseClass(BaseView)
  6. FuliMainView.TAB_DATA = {
  7. {id = FuliConst.TAB_ID.SIGN,name = "每日签到",light_res = "icon_bb1_1",dark_res = "icon_bb1_2", open_lv = Config.Modulesub["160@1"].open_lv, open_day = Config.Modulesub["160@1"].open_day },
  8. {id = FuliConst.TAB_ID.AI,name = "在线奖励",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["160@2"].open_lv, open_day = Config.Modulesub["160@2"].open_day},
  9. {id = FuliConst.TAB_ID.LEVEL,name = "冲级大礼",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["160@3"].open_lv, open_day = Config.Modulesub["160@3"].open_day},
  10. {id = FuliConst.TAB_ID.NOTICE,name = "游戏公告",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["160@1"].open_lv, open_day = Config.Modulesub["160@1"].open_day},
  11. {id = FuliConst.TAB_ID.DOWNLOAD,name = "资源礼包",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["160@4"].open_lv, open_day = Config.Modulesub["160@4"].open_day},
  12. {id = FuliConst.TAB_ID.CDK,name = "邀请礼包",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["160@5"].open_lv, open_day = Config.Modulesub["160@5"].open_day},
  13. }
  14. function FuliMainView:__init()
  15. self.base_file = "fuli"
  16. self.layout_file = "FuliBaseView"
  17. self.layer_name = "UI"
  18. self.use_background = true
  19. self.hide_maincancas = true
  20. self.close_mode = CloseMode.CloseDestroy
  21. self.destroy_imm = true
  22. self.append_to_ctl_queue = true
  23. self.is_set_zdepth = false
  24. self.close_fog = true
  25. self.model = FuliModel:getInstance()
  26. self.model:Fire(FuliConst.REQ_FULI_SCMD, 16001)
  27. self.model:Fire(FuliConst.REQ_FULI_SCMD, 16003)
  28. self.model:Fire(FuliConst.REQ_FULI_SCMD, 16005)
  29. self.mainRoleVo = RoleManager.Instance.mainRoleInfo
  30. self.current_index = nil
  31. self.sub_view_list = {}
  32. self.fire_change_visible_event = true
  33. self.show_tab_conf = {}
  34. local can_show = true
  35. for k,v in ipairs(FuliMainView.TAB_DATA) do
  36. table.insert( self.show_tab_conf, v )
  37. end
  38. -------------------------
  39. --万物宝典
  40. if GetModuleIsOpen(331,74) then
  41. local temp_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.CONTRACT)
  42. for i,v in pairs(temp_list or {}) do
  43. local id = 33100000 + CustomActivityModel.CustomActBaseType.CONTRACT * 1000 + v.sub_type
  44. -------------------------
  45. local temp_conf = {id = id,name = v.name,light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Modulesub["331@74"].open_lv, open_day = Config.Modulesub["331@74"].open_day}
  46. table.insert( self.show_tab_conf,1, temp_conf )
  47. end
  48. end
  49. -------------------------
  50. self.load_callback = function ()
  51. self:LoadSuccess()
  52. self:InitEvent()
  53. end
  54. self.open_callback = function ()
  55. self.tabWindowComponent:SetTabBarIndex(self.cur_index or self:GetFirstRedIndex())
  56. self:UpdateRedDot()
  57. end
  58. self.close_callback = function ()
  59. self:Remove()
  60. end
  61. end
  62. function FuliMainView:GetFirstRedIndex( )
  63. --获取列表里的第一个红点页签
  64. local red_data = self.model:GetAllFuliRedDot()
  65. for k,v in ipairs(self.show_tab_conf) do
  66. if red_data[v.id] == true then
  67. return v.id
  68. end
  69. end
  70. return self.show_tab_conf[1] and self.show_tab_conf[1].id or 1
  71. end
  72. function FuliMainView:Open(index, type_id)
  73. self.cur_index = index
  74. self.type_id = type_id
  75. BaseView.Open(self)
  76. end
  77. function FuliMainView:Remove()
  78. if self.tabWindowComponent then
  79. self.tabWindowComponent:DeleteMe()
  80. self.tabWindowComponent = nil
  81. end
  82. for i,v in pairs(self.sub_view_list) do
  83. v:DeleteMe()
  84. v = nil
  85. end
  86. self.sub_view_list = {}
  87. end
  88. function FuliMainView:LoadSuccess()
  89. self.container
  90. = GetChildTransforms(self.transform,
  91. {
  92. "container",
  93. })
  94. if self.tabWindowComponent == nil then
  95. local select_callback = function(index)
  96. self:SeletedTabbar(index)
  97. end
  98. local close_callback = function()
  99. self:Close()
  100. end
  101. self.tabWindowComponent = UITabWindow.New(self.transform, self.show_tab_conf, select_callback, close_callback, self.background_wnd, nil, UITabWindow.SizeSmallHall, false, nil, true)
  102. self.tabWindowComponent:SetTitleText("福利")
  103. end
  104. local function bg_back_func( ... )
  105. if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
  106. self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
  107. end
  108. if self.tabWindowComponent and self.tabWindowComponent.win_bg then
  109. self:MoveUIToBack(self.tabWindowComponent.win_bg)
  110. end
  111. end
  112. if self.background_wnd then
  113. bg_back_func()
  114. else
  115. self.bg_back_func = bg_back_func
  116. end
  117. end
  118. function FuliMainView:InitEvent()
  119. local function on_ans_update_red_dot( tab_id,bool )--设置红点的状态注意此处的协议是从model那边发过来的
  120. self:UpdateRedDot()
  121. end
  122. self.on_ans_update_red_dot_id = self.model:Bind(FuliConst.ANS_UPDATE_FULI_RED_DOT, on_ans_update_red_dot)
  123. local function CLICK_TASK_ITEM( )
  124. self:Close()
  125. end
  126. self:BindEvent(ContractModel:getInstance(), ContractConst.CLICK_TASK_ITEM, CLICK_TASK_ITEM)
  127. local function MOVE_UI_TO_BACK( node_image )
  128. if node_image then
  129. self:MoveUIToBack(node_image)
  130. end
  131. end
  132. self:BindEvent(self.model, FuliConst.MOVE_UI_TO_BACK, MOVE_UI_TO_BACK)
  133. end
  134. function FuliMainView:SeletedTabbar(index)
  135. if self.current_index == index then
  136. return
  137. elseif index == FuliConst.TAB_ID.NOTICE then
  138. local data = LoginModel:getInstance():GetNoticeData("fuli_view")
  139. if TableSize(data) == 0 then
  140. Message.show("暂无公告哦")
  141. self.tabWindowComponent:SetTabBarIndex(self.current_index)
  142. return
  143. end
  144. end
  145. if self.current_index ~= nil then
  146. self.is_changeIndex = true
  147. end
  148. local current_index = self.tabWindowComponent:GetCurrentSelectIndex()
  149. self:SwitchView(index)
  150. self.current_index = index
  151. end
  152. function FuliMainView:SwitchView(index)
  153. local is_contract = false--是否是万物宝典
  154. local contract_index_start = 33100000 + CustomActivityModel.CustomActBaseType.CONTRACT * 1000
  155. if index > contract_index_start and index <= (contract_index_start + 999) then
  156. is_contract = index - contract_index_start
  157. end
  158. local bg_res = "default_bg_6"
  159. local is_online_ai = index == FuliConst.TAB_ID.AI
  160. if is_contract or is_online_ai then
  161. LuaViewManager:getInstance():SetBackCameraShow(true)
  162. else
  163. LuaViewManager:getInstance():SetBackCameraShow(false)
  164. end
  165. -------------------------
  166. if index == FuliConst.TAB_ID.SIGN then
  167. self.model:Fire(FuliConst.REQ_FULI_SCMD, 16001)
  168. if self.sub_view_list[index] == nil then
  169. self.sub_view_list[index] = FuliSignView.New(self.container)
  170. end
  171. elseif index == FuliConst.TAB_ID.AI then
  172. if self.sub_view_list[index] == nil then
  173. self.sub_view_list[index] = FuliAIView.New(self.container)
  174. end
  175. self.model:Fire(FuliConst.REQ_FULI_SCMD, 16003)
  176. bg_res = "fuli_ai_bg"
  177. elseif index == FuliConst.TAB_ID.LEVEL then
  178. self.model:Fire(FuliConst.REQ_FULI_SCMD, 16005)
  179. if self.sub_view_list[index] == nil then
  180. self.sub_view_list[index] = FuliLevelView.New(self.container)
  181. end
  182. bg_res = "fuli_level_bg"
  183. elseif index == FuliConst.TAB_ID.NOTICE then
  184. if self.sub_view_list[index] == nil then
  185. self.sub_view_list[index] = FuliNoticeView.New(self.container)
  186. end
  187. bg_res = "fuli_notice_bg"
  188. elseif index == FuliConst.TAB_ID.DOWNLOAD then
  189. self.model:Fire(FuliConst.REQ_FULI_SCMD, 16007)
  190. if self.sub_view_list[index] == nil then
  191. self.sub_view_list[index] = FuliDownloadView.New(self.container)
  192. end
  193. bg_res = "fuli_download_bg"
  194. elseif index == FuliConst.TAB_ID.CDK then
  195. if self.sub_view_list[index] == nil then
  196. self.sub_view_list[index] = FuliCDKView.New(self.container)
  197. end
  198. elseif is_contract then
  199. if self.sub_view_list[index] == nil then
  200. self.sub_view_list[index] = ContractSubView.New(self.container,nil,self.layer_name,is_contract)
  201. self.contract_view = self.contract_view or self.sub_view_list[index]
  202. else
  203. self.sub_view_list[index]:JumpToDefaultPos()
  204. end
  205. end
  206. self.tabWindowComponent:SetBackgroundRes(bg_res)
  207. self:PopUpChild(self.sub_view_list[index])
  208. self.sub_view_list[index]:SetData(index, self.type_id)
  209. if self.contract_view then
  210. self.contract_view:ShowBg(is_contract)
  211. end
  212. end
  213. function FuliMainView:UpdateRedDot()
  214. if self.tabWindowComponent then
  215. local red_data = self.model:GetAllFuliRedDot()
  216. for k,v in pairs(red_data) do
  217. self.tabWindowComponent:ShowRedPoint(k,v)
  218. end
  219. end
  220. end
  221. function FuliMainView:ReOpen(index, sub_index, param_list )
  222. self.cur_index = index or 1
  223. self.sub_index = sub_index
  224. self.param_list = param_list
  225. if self.is_loaded then
  226. self:SeletedTabbar(self.cur_index)
  227. end
  228. end