|
--[[@------------------------------------------------------------------
|
|
@description:市场主界面
|
|
@author:wyb
|
|
----------------------------------------------------------------------]]
|
|
MarketView = MarketView or BaseClass(BaseView)
|
|
MarketView.TAB_DATA = {
|
|
{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 },
|
|
{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},
|
|
{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},
|
|
{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},
|
|
{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},
|
|
}
|
|
function MarketView:__init()
|
|
self.base_file = "market"
|
|
self.layout_file = "MarketView"
|
|
self.layer_name = "UI"
|
|
self.use_background = true
|
|
self.close_mode = CloseMode.CloseDestroy
|
|
self.blur_activity_bg = true
|
|
self.hide_maincancas = true
|
|
self.destroy_imm = true
|
|
self.append_to_ctl_queue = true
|
|
self.is_set_zdepth = true
|
|
|
|
self.model = MarketModel:getInstance()
|
|
self.mainRoleVo = RoleManager.Instance.mainRoleInfo
|
|
self.sub_view_list = {}
|
|
self.event_list = {}
|
|
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:InitEvent()
|
|
end
|
|
self.open_callback = function ()
|
|
self.tabWindowComponent:SetTabBarIndex(self.cur_index or 1)
|
|
end
|
|
self.close_callback = function ()
|
|
|
|
end
|
|
self.destroy_callback = function ()
|
|
self:Remove()
|
|
end
|
|
end
|
|
|
|
function MarketView:Open(index, sub_index, param_list )
|
|
self.cur_index = index or 1
|
|
self.sub_index = sub_index
|
|
self.param_list = param_list
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function MarketView:ReOpen(index, sub_index, param_list )
|
|
self.cur_index = index or 1
|
|
self.sub_index = sub_index
|
|
self.param_list = param_list
|
|
self.tabWindowComponent:SetTabBarIndex(self.cur_index)
|
|
end
|
|
|
|
function MarketView:Remove()
|
|
for _, v in pairs(self.event_list) do
|
|
self.model:UnBind(v)
|
|
v = nil
|
|
end
|
|
self.event_list = {}
|
|
for _, v in pairs(self.sub_view_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.sub_view_list = {}
|
|
if self.tabWindowComponent then
|
|
self.tabWindowComponent:DeleteMe()
|
|
self.tabWindowComponent = nil
|
|
end
|
|
self.model:SetMarketAuctionRed(false)
|
|
end
|
|
|
|
function MarketView:LoadSuccess()
|
|
self.container
|
|
= GetChildTransforms(self.transform,
|
|
{
|
|
"container",
|
|
})
|
|
if self.tabWindowComponent == nil then
|
|
local select_callback = function(index)
|
|
self:SeletedTabbar(index)
|
|
end
|
|
local close_callback = function()
|
|
self:Close()
|
|
end
|
|
self.tabWindowComponent = UITabWindow.New(self.transform, MarketView.TAB_DATA, select_callback, close_callback, self.background_wnd, self.winCon, UITabWindow.SizeSmallHall, false, nil, true)
|
|
-- self.tabWindowComponent:SetTitleRes("market_asset", "market_title_text1") --标题
|
|
self.tabWindowComponent:SetBackgroundRes("default_bg_6")
|
|
self.tabWindowComponent:SetTitleText( "拍卖" )
|
|
end
|
|
self:ShowTabRedPointState()
|
|
self.model:SetMarketAuctionRed(false)
|
|
|
|
--距离上次打开界面超过10分钟,购买页签要显示新品角标
|
|
local last_open_view_timestamp = self.model:GetOpenViewTimestamp() or 0
|
|
if TimeUtil:getServerTime() - last_open_view_timestamp > 600 then
|
|
self.tabWindowComponent:SetSpeacialImg(MarketConst.TabId.BuyHall, 2)
|
|
end
|
|
end
|
|
|
|
function MarketView:InitEvent()
|
|
local function onRefreshTabDot()
|
|
self:ShowTabRedPointState()
|
|
end
|
|
self:BindEvent(self.model, MarketModel.ANS_MARKET_TAB_RED_DOT , onRefreshTabDot)
|
|
end
|
|
|
|
function MarketView:ShowTabRedPointState()
|
|
local red_data = self.model:GetMarketRedData()
|
|
self.tabWindowComponent:ShowRedPoint(MarketConst.TabId.BuyHall, red_data.guild_red)
|
|
self.tabWindowComponent:ShowRedPoint(MarketConst.TabId.SalesHall, red_data.down_red or red_data.can_up_shelves_red)
|
|
end
|
|
|
|
function MarketView:SeletedTabbar(index)
|
|
if index == MarketConst.TabId.BuyHall then
|
|
if self.sub_view_list[index] == nil then
|
|
self.sub_view_list[index] = MarketBuyHallView.New(self.container,nil,self.layer_name)
|
|
self.sub_view_list[index]:SetData(self.sub_index, self.param_list)
|
|
else
|
|
self.sub_view_list[index]:RefreshData()
|
|
end
|
|
self.sub_index = nil
|
|
self.param_list = nil
|
|
self.model:ResetOpenViewTimestamp()
|
|
elseif index == MarketConst.TabId.Focus then
|
|
self.model:Fire(MarketModel.REQUEST_CCMD_EVENT, 15512)
|
|
if self.sub_view_list[index] == nil then
|
|
self.sub_view_list[index] = MarketFocusView.New(self.container,nil,self.layer_name)
|
|
end
|
|
self.sub_view_list[index]:SetData()
|
|
elseif index == MarketConst.TabId.SalesHall then
|
|
self.model:Fire(MarketModel.REQUEST_CCMD_EVENT, 15503)
|
|
if self.sub_view_list[index] == nil then
|
|
self.sub_view_list[index] = MarketSalesHallView.New(self.container,nil,self.layer_name)
|
|
end
|
|
self.sub_view_list[index]:SetData(self.sub_index, self.param_list)
|
|
self.param_list = nil
|
|
self.sub_index = nil
|
|
elseif index == MarketConst.TabId.Record then
|
|
if self.sub_view_list[index] == nil then
|
|
self.sub_view_list[index] = MarketRecordView.New(self.container,nil,self.layer_name)
|
|
end
|
|
self.sub_view_list[index]:SetData()
|
|
elseif index == MarketConst.TabId.Attention then
|
|
self.model:Fire(MarketModel.REQUEST_CCMD_EVENT, 15505)
|
|
if self.sub_view_list[index] == nil then
|
|
self.sub_view_list[index] = MarketAttentionView.New(self.container,nil,self.layer_name)
|
|
end
|
|
self.sub_view_list[index]:SetData()
|
|
end
|
|
|
|
self:PopUpChild(self.sub_view_list[index])
|
|
self.sub_index = nil
|
|
end
|