源战役客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

157 rindas
5.8 KiB

pirms 4 nedēļām
  1. --[[@------------------------------------------------------------------
  2. @description:
  3. @author:wyb
  4. ----------------------------------------------------------------------]]
  5. MarketView = MarketView or BaseClass(BaseView)
  6. MarketView.TAB_DATA = {
  7. {id = MarketConst.TabId.BuyHall,name = "拍卖大厅",light_res = "icon_bb1_1",dark_res = "icon_bb1_2", open_lv = Config.Moduleid[155].open_lv, open_day = Config.Moduleid[155].open_day },
  8. {id = MarketConst.TabId.Focus,name = "我的关注",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Moduleid[155].open_lv, open_day = Config.Moduleid[155].open_day},
  9. {id = MarketConst.TabId.SalesHall,name = "出售大厅",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Moduleid[155].open_lv, open_day = Config.Moduleid[155].open_day},
  10. {id = MarketConst.TabId.Record,name = "购买记录",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Moduleid[155].open_lv, open_day = Config.Moduleid[155].open_day},
  11. {id = MarketConst.TabId.Attention,name = "入库提醒",light_res = "icon_ck1_1",dark_res = "icon_ck1_2", open_lv = Config.Moduleid[155].open_lv, open_day = Config.Moduleid[155].open_day},
  12. }
  13. function MarketView:__init()
  14. self.base_file = "market"
  15. self.layout_file = "MarketView"
  16. self.layer_name = "UI"
  17. self.use_background = true
  18. self.close_mode = CloseMode.CloseDestroy
  19. self.blur_activity_bg = true
  20. self.hide_maincancas = true
  21. self.destroy_imm = true
  22. self.append_to_ctl_queue = true
  23. self.is_set_zdepth = true
  24. self.model = MarketModel:getInstance()
  25. self.mainRoleVo = RoleManager.Instance.mainRoleInfo
  26. self.sub_view_list = {}
  27. self.event_list = {}
  28. self.load_callback = function ()
  29. self:LoadSuccess()
  30. self:InitEvent()
  31. end
  32. self.open_callback = function ()
  33. self.tabWindowComponent:SetTabBarIndex(self.cur_index or 1)
  34. end
  35. self.close_callback = function ()
  36. end
  37. self.destroy_callback = function ()
  38. self:Remove()
  39. end
  40. end
  41. function MarketView:Open(index, sub_index, param_list )
  42. self.cur_index = index or 1
  43. self.sub_index = sub_index
  44. self.param_list = param_list
  45. BaseView.Open(self)
  46. end
  47. function MarketView:ReOpen(index, sub_index, param_list )
  48. self.cur_index = index or 1
  49. self.sub_index = sub_index
  50. self.param_list = param_list
  51. self.tabWindowComponent:SetTabBarIndex(self.cur_index)
  52. end
  53. function MarketView:Remove()
  54. for _, v in pairs(self.event_list) do
  55. self.model:UnBind(v)
  56. v = nil
  57. end
  58. self.event_list = {}
  59. for _, v in pairs(self.sub_view_list) do
  60. v:DeleteMe()
  61. v = nil
  62. end
  63. self.sub_view_list = {}
  64. if self.tabWindowComponent then
  65. self.tabWindowComponent:DeleteMe()
  66. self.tabWindowComponent = nil
  67. end
  68. self.model:SetMarketAuctionRed(false)
  69. end
  70. function MarketView:LoadSuccess()
  71. self.container
  72. = GetChildTransforms(self.transform,
  73. {
  74. "container",
  75. })
  76. if self.tabWindowComponent == nil then
  77. local select_callback = function(index)
  78. self:SeletedTabbar(index)
  79. end
  80. local close_callback = function()
  81. self:Close()
  82. end
  83. self.tabWindowComponent = UITabWindow.New(self.transform, MarketView.TAB_DATA, select_callback, close_callback, self.background_wnd, self.winCon, UITabWindow.SizeSmallHall, false, nil, true)
  84. -- self.tabWindowComponent:SetTitleRes("market_asset", "market_title_text1") --标题
  85. self.tabWindowComponent:SetBackgroundRes("default_bg_6")
  86. self.tabWindowComponent:SetTitleText( "拍卖" )
  87. end
  88. self:ShowTabRedPointState()
  89. self.model:SetMarketAuctionRed(false)
  90. --距离上次打开界面超过10分钟,购买页签要显示新品角标
  91. local last_open_view_timestamp = self.model:GetOpenViewTimestamp() or 0
  92. if TimeUtil:getServerTime() - last_open_view_timestamp > 600 then
  93. self.tabWindowComponent:SetSpeacialImg(MarketConst.TabId.BuyHall, 2)
  94. end
  95. end
  96. function MarketView:InitEvent()
  97. local function onRefreshTabDot()
  98. self:ShowTabRedPointState()
  99. end
  100. self:BindEvent(self.model, MarketModel.ANS_MARKET_TAB_RED_DOT , onRefreshTabDot)
  101. end
  102. function MarketView:ShowTabRedPointState()
  103. local red_data = self.model:GetMarketRedData()
  104. self.tabWindowComponent:ShowRedPoint(MarketConst.TabId.BuyHall, red_data.guild_red)
  105. self.tabWindowComponent:ShowRedPoint(MarketConst.TabId.SalesHall, red_data.down_red or red_data.can_up_shelves_red)
  106. end
  107. function MarketView:SeletedTabbar(index)
  108. if index == MarketConst.TabId.BuyHall then
  109. if self.sub_view_list[index] == nil then
  110. self.sub_view_list[index] = MarketBuyHallView.New(self.container,nil,self.layer_name)
  111. self.sub_view_list[index]:SetData(self.sub_index, self.param_list)
  112. else
  113. self.sub_view_list[index]:RefreshData()
  114. end
  115. self.sub_index = nil
  116. self.param_list = nil
  117. self.model:ResetOpenViewTimestamp()
  118. elseif index == MarketConst.TabId.Focus then
  119. self.model:Fire(MarketModel.REQUEST_CCMD_EVENT, 15512)
  120. if self.sub_view_list[index] == nil then
  121. self.sub_view_list[index] = MarketFocusView.New(self.container,nil,self.layer_name)
  122. end
  123. self.sub_view_list[index]:SetData()
  124. elseif index == MarketConst.TabId.SalesHall then
  125. self.model:Fire(MarketModel.REQUEST_CCMD_EVENT, 15503)
  126. if self.sub_view_list[index] == nil then
  127. self.sub_view_list[index] = MarketSalesHallView.New(self.container,nil,self.layer_name)
  128. end
  129. self.sub_view_list[index]:SetData(self.sub_index, self.param_list)
  130. self.param_list = nil
  131. self.sub_index = nil
  132. elseif index == MarketConst.TabId.Record then
  133. if self.sub_view_list[index] == nil then
  134. self.sub_view_list[index] = MarketRecordView.New(self.container,nil,self.layer_name)
  135. end
  136. self.sub_view_list[index]:SetData()
  137. elseif index == MarketConst.TabId.Attention then
  138. self.model:Fire(MarketModel.REQUEST_CCMD_EVENT, 15505)
  139. if self.sub_view_list[index] == nil then
  140. self.sub_view_list[index] = MarketAttentionView.New(self.container,nil,self.layer_name)
  141. end
  142. self.sub_view_list[index]:SetData()
  143. end
  144. self:PopUpChild(self.sub_view_list[index])
  145. self.sub_index = nil
  146. end