源战役客户端
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

252 строки
8.8 KiB

1 месяц назад
  1. -- <*
  2. -- @Author: Saber
  3. -- @Description: 社团主界面
  4. -- *>
  5. GuildMainView = GuildMainView or BaseClass(BaseView)
  6. local GuildMainView = GuildMainView
  7. GuildMainView.Tab_List = {
  8. {id = Config.ConfigGuild.TabId.Apply, name = "申请", module_id = 400, open_lv = 0, open_task = 0},
  9. {id = Config.ConfigGuild.TabId.MainInfo, name = "主页", module_id = 400, open_lv = 0, open_task = 0},
  10. {id = Config.ConfigGuild.TabId.List, name = "列表", module_id = 400, open_lv = 0, open_task = 0},
  11. {id = Config.ConfigGuild.TabId.Active, name = "活跃", module_id = 400, sub_id = 2},
  12. {id = Config.ConfigGuild.TabId.Order, name = "拼单", module_id = 400, sub_id = 3},
  13. {id = Config.ConfigGuild.TabId.Shop, name = "商城", module_id = 400, sub_id = 4},
  14. {id = Config.ConfigGuild.TabId.Event, name = "活动", module_id = 400, sub_id = 5},
  15. }
  16. function GuildMainView:__init()
  17. self.base_file = "guild"
  18. self.layout_file = "GuildMainView"
  19. self.layer_name = "UI"
  20. self.destroy_imm = true
  21. self.view_list = {} -- 子界面列表
  22. self.change_scene_close = true --是否切换场景时关闭(弹出界面使用)
  23. self.append_to_ctl_queue = true --是否要添加进界面堆栈
  24. --self.need_show_money = false --是否要显示顶部的金钱栏
  25. self.tab_index = 1 -- 当前页签id
  26. self.hide_maincancas = true
  27. self.is_set_zdepth = true
  28. self.use_background = G_USING_BG
  29. self.blur_activity_bg = true
  30. self.use_show_anim = true
  31. self.use_hide_anim = true
  32. self.is_trigger_guide = false
  33. self.model = GuildModel:getInstance()
  34. self.load_callback = function ()
  35. self:LoadSuccess()
  36. self:AddEvent()
  37. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40005)
  38. self:UpdateTabRed()
  39. end
  40. self.open_callback = function ( )
  41. self:OpenSuccess()
  42. end
  43. self.switch_callback = function(index)
  44. self:SwitchTab(index, true)
  45. end
  46. self.destroy_callback = function ( )
  47. self:DestroySuccess()
  48. end
  49. end
  50. function GuildMainView:Open(tab_index)
  51. --self.data = data
  52. self.tab_index = tab_index or 1
  53. BaseView.Open(self)
  54. end
  55. function GuildMainView:LoadSuccess()
  56. local nodes = {
  57. "container",
  58. }
  59. self:GetChildren(nodes)
  60. local function select_callback(index)
  61. self:SwitchTab(index)
  62. end
  63. local function close_callback()
  64. self:Close()
  65. end
  66. local tab_list = self:GetGuildTabData()
  67. self.tabWindowComponent = UITabWindow.New(self.transform, tab_list, select_callback, close_callback, self.background_wnd, nil, UITabWindow.SizeSmallHall, nil, nil, true)
  68. self.tabWindowComponent:SetTitleText("社团")
  69. self.tabWindowComponent:ChangeShowFlag("Guild")
  70. self:AddToStageHandler()
  71. end
  72. function GuildMainView:AddEvent()
  73. local function update_red(view_type)
  74. self:UpdateTabRed(view_type)
  75. end
  76. self:BindEvent(self.model, GuildModel.UPDATE_RED_DOT_BY_TYPE, update_red)
  77. local function update_tab_list()
  78. self:RefreshGuildTabData(true) -- true代表协议刷新,不要出现手动跳转页签时会出现的飘字
  79. end
  80. self:BindEvent(self.model, GuildModel.RefreshGuildInfoEvt, update_tab_list)
  81. local function onGuideTrigger()
  82. self:AddToStageHandler()
  83. end
  84. self:BindEvent(GlobalEventSystem, EventName.TRIGGER_GUIDE_TYPE, onGuideTrigger)
  85. end
  86. function GuildMainView:OpenSuccess()
  87. self:SwitchTab(self.tab_index)
  88. end
  89. function GuildMainView:GetGuildTabData( )
  90. local guild_info = self.model:GetGuildBaseInfo()
  91. self.last_cache_guild_id = self.last_cache_guild_id or guild_info.guild_id or nil
  92. self.is_joined_guild = guild_info.guild_id and guild_info.guild_id ~= 0 or false
  93. self.tab_index = self.is_joined_guild and self.tab_index or Config.ConfigGuild.TabId.Apply -- 未加入社团的只能看第一个页签
  94. local tab_list = {}
  95. for k, v in ipairs(GuildMainView.Tab_List) do
  96. if v.id == Config.ConfigGuild.TabId.Apply then
  97. if not self.is_joined_guild then
  98. tab_list[#tab_list+1] = v
  99. end
  100. elseif v.id == Config.ConfigGuild.TabId.MainInfo then
  101. if self.is_joined_guild then
  102. tab_list[#tab_list+1] = v
  103. end
  104. else
  105. tab_list[#tab_list+1] = v
  106. end
  107. end
  108. return tab_list
  109. end
  110. function GuildMainView:RefreshGuildTabData(hide_msg)
  111. local guild_info = self.model:GetGuildBaseInfo()
  112. local cur_guild_id = guild_info.guild_id or 0
  113. if self.tabWindowComponent and (not self.last_cache_guild_id or self.last_cache_guild_id ~= cur_guild_id) then
  114. self.hide_tips_msg = hide_msg
  115. local new_tab_list = self:GetGuildTabData()
  116. self.tab_index = self.is_joined_guild and Config.ConfigGuild.TabId.MainInfo or Config.ConfigGuild.TabId.Apply -- 强制刷新页签
  117. self.tabWindowComponent:RefeshTabbar(new_tab_list, nil, nil, true)
  118. self.last_cache_guild_id = guild_info.guild_id
  119. self:UpdateTabRed()
  120. end
  121. end
  122. function GuildMainView:UpdateView()
  123. if self.tab_index == Config.ConfigGuild.TabId.Apply then -- 申请界面
  124. if not self.view_list[self.tab_index] then
  125. self.view_list[self.tab_index] = GuildApplyView.New(self.container, nil, self.layer_name)
  126. end
  127. self.tabWindowComponent:SetBackgroundRes("guild_apply_bg")
  128. elseif self.tab_index == Config.ConfigGuild.TabId.MainInfo then -- 主信息界面
  129. if not self.view_list[self.tab_index] then
  130. self.view_list[self.tab_index] = GuildInfoView.New(self.container, nil, self.layer_name)
  131. end
  132. self.tabWindowComponent:SetBackgroundRes("guild_info_bg")
  133. elseif self.tab_index == Config.ConfigGuild.TabId.List then -- 列表界面
  134. if not self.view_list[self.tab_index] then
  135. self.view_list[self.tab_index] = GuildListView.New(self.container, nil, self.layer_name)
  136. end
  137. self.tabWindowComponent:SetBackgroundRes("guild_list_bg")
  138. elseif self.tab_index == Config.ConfigGuild.TabId.Active then -- 社团活跃界面
  139. if not self.view_list[self.tab_index] then
  140. self.view_list[self.tab_index] = GuildActiveView.New(self.container, nil, self.layer_name)
  141. end
  142. self.tabWindowComponent:SetBackgroundRes("guild_active_bg")
  143. elseif self.tab_index == Config.ConfigGuild.TabId.Order then -- 社团派单界面
  144. if not self.view_list[self.tab_index] then
  145. self.view_list[self.tab_index] = GuildSpellListView.New(self.container, nil, self.layer_name)
  146. end
  147. self.tabWindowComponent:SetBackgroundRes("default_bg_6")
  148. elseif self.tab_index == Config.ConfigGuild.TabId.Shop then -- 社团商城界面
  149. if not self.view_list[self.tab_index] then
  150. self.view_list[self.tab_index] = GuildShopView.New(self.container, nil, self.layer_name)
  151. end
  152. -- 如果存在商城红点,进入页签后销毁红点
  153. if self.model:GetGuildRedDotCache(Config.ConfigGuild.TabId.Shop) then
  154. self.model.show_guild_shop_red = false
  155. self.model:CheckGuildRedDot(Config.ConfigGuild.TabId.Shop, true)
  156. end
  157. self.tabWindowComponent:SetBackgroundRes("default_bg_6")
  158. elseif self.tab_index == Config.ConfigGuild.TabId.Event then -- 社团活动界面
  159. if not self.view_list[self.tab_index] then
  160. self.view_list[self.tab_index] = GuildEventView.New(self.container, nil, self.layer_name)
  161. end
  162. self.tabWindowComponent:SetBackgroundRes("default_bg_6")
  163. end
  164. -- 判断是否在社团拼单界面
  165. self.model._is_in_guild_spelllist_view = self.tab_index == Config.ConfigGuild.TabId.Order
  166. self:PopUpChild(self.view_list[self.tab_index])
  167. end
  168. -- show_msg:提醒加入社团飘字
  169. function GuildMainView:SwitchTab( index )
  170. if self.is_joined_guild then
  171. if index == Config.ConfigGuild.TabId.Apply then
  172. self.tab_index = Config.ConfigGuild.TabId.MainInfo
  173. else
  174. self.tab_index = index
  175. end
  176. else
  177. if index ~= Config.ConfigGuild.TabId.Apply then
  178. self.tab_index = Config.ConfigGuild.TabId.Apply
  179. if not self.hide_tips_msg then
  180. Message.show("请先加入社团")
  181. else
  182. self.hide_tips_msg = false
  183. end
  184. end
  185. end
  186. --设置页签索引值切换主页面
  187. if self.tabWindowComponent then
  188. self.tabWindowComponent:SetTabBarIndex(self.tab_index)
  189. end
  190. self:UpdateView()
  191. end
  192. function GuildMainView:UpdateTabRed( view_type )
  193. local red_cache = self.model:GetGuildRedDotCache(view_type)
  194. if view_type then
  195. self.tabWindowComponent:ShowRedPoint(view_type, red_cache)
  196. else
  197. for k, v in pairs(Config.ConfigGuild.TabId) do
  198. self.tabWindowComponent:ShowRedPoint(v, red_cache[v] or false)
  199. end
  200. end
  201. end
  202. function GuildMainView:DestroySuccess( )
  203. for k, v in pairs(self.view_list) do
  204. v:DeleteMe()
  205. v = nil
  206. end
  207. self.view_list = {}
  208. if self.tabWindowComponent then
  209. self.tabWindowComponent:DeleteMe()
  210. self.tabWindowComponent = nil
  211. end
  212. end
  213. function GuildMainView:AddToStageHandler()
  214. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_GUILD,3)
  215. if not helpVo then return end
  216. local help_type = helpVo.help_type
  217. if (help_type == HelpType.TYPE_GUILD) then
  218. local step = helpVo.step
  219. local button = false
  220. if (help_type == HelpType.TYPE_GUILD) and step == 3 then
  221. self.is_trigger_guide = true
  222. end
  223. end
  224. end
  225. function GuildMainView:Close( )
  226. if self.is_trigger_guide then
  227. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK)
  228. end
  229. BaseView.Close(self)
  230. -- 重置变量
  231. self.model._is_in_guild_spelllist_view = false
  232. end