| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- local UIVipLvUpView = require("UIVip/UIVipLvUpView_Generate")
- function UIVipLvUpView:OnAwake(data)
- self.controller = require("UIVip/UIVipLvUpCtr"):new()
- self.controller:Init(self)
- self.controller:SetData(data)
- end
- function UIVipLvUpView:AddEventListener()
- end
- function UIVipLvUpView:FillContent(data, uiBase)
- self.uiBase = uiBase
- local gameObject = self.uiBase:GetRoot()
- if gameObject ~= nil then
- self.gameObject = gameObject
- self.transform = gameObject.transform
- end
- self:InitGenerate(self.transform, data)
- self:Init()
- end
- function UIVipLvUpView:Init()
- self.gainList.loopListView:InitListView(0, function(loopListView, itemIndex)
- return self:GetItemByIndex(loopListView, itemIndex)
- end)
- self:InitView()
- end
- function UIVipLvUpView:RemoveEventListener()
- ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
- end
- function UIVipLvUpView:AddUIEventListener()
- self.uiBase:AddButtonUniqueEventListener(self.AnyBtn.button, self, self.OnClickCloseBtn)
- end
- function UIVipLvUpView:OnHide()
- end
- function UIVipLvUpView:OnShow(data)
- self.controller:SetData(data)
- end
- function UIVipLvUpView:OnClose()
- end
- function UIVipLvUpView:OnDispose()
- self.canClose = nil
- if self.animTimer then
- self.animTimer:Stop()
- self.animTimer = nil
- end
- if self.closeTimer then
- self.closeTimer:Stop()
- self.closeTimer = nil
- end
- self.gainList.loopListView:Dispose()
- self.reward.loopHorizontalScrollRect:ClearCells()
- self.controller:OnDispose()
- end
- function UIVipLvUpView:OnPageInEnd()
- self.super.OnPageInEnd(self)
- self:StartVipAnim()
- end
- function UIVipLvUpView:OnClickCloseBtn()
- if not self.canClose then return end
- local isNext = self.controller:RefreshNextChange()
- if not isNext then
- self:UIClose()
- return
- end
- self:InitView()
- self:StartVipAnim()
- end
- function UIVipLvUpView:InitView()
- self.canClose = false
- local lastLv, curLv = self.controller:GetInfo()
- local lastVipCfg = ManagerContainer.CfgMgr:GetVipCfgById(lastLv)
- local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(curLv)
- self:RefreshView(lastVipCfg)
- if self.animTimer then
- self.animTimer:Stop()
- self.animTimer = nil
- end
- self.animTimer = Timer.New(function()
- self:RefreshView(vipCfg)
- end, 1)
- if self.closeTimer then
- self.closeTimer:Stop()
- self.closeTimer = nil
- end
- local duration = GlobalConfig.Instance:GetConfigFloatValue(250)
- if duration <= 0 then
- duration = 4
- end
- self.closeTimer = Timer.New(function()
- self:StopVipAnim()
- end, duration)
- self.godSeal.animator:Play('VipKeep', -1, 0)
- self.godSeal.animator:Update(0)
- self.gainList.loopListView:SetListItemCount(0)
- CommonUtil.LoopGridViewEleCreateNew(self, self.reward.loopHorizontalScrollRect, nil, {}, 0, self, self.UpdateRewardItem)
- end
- function UIVipLvUpView:StartVipAnim()
- self.godSeal.animator:Play('VipLevelUp', -1, 0)
- self.godSeal.animator:Update(0)
- if self.animTimer then
- self.animTimer:Start()
- end
- if self.closeTimer then
- self.closeTimer:Start()
- end
- end
- function UIVipLvUpView:StopVipAnim()
- self.canClose = true
- local _, curLv = self.controller:GetInfo()
- local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(curLv)
- if not vipCfg then
- self.gainList.loopListView:SetListItemCount(0)
- CommonUtil.LoopGridViewEleCreateNew(self, self.reward.loopHorizontalScrollRect, nil, {}, 0, self, self.UpdateRewardItem)
- return
- end
- self.gainList.loopListView:SetListItemCount(0)
- self.gainList.loopListView:SetListItemCount(vipCfg.UnlockDes and #vipCfg.UnlockDes or 0)
- self.gainList.loopListView:RefreshAllShownItem()
- CommonUtil.LoopGridViewEleCreateNew(self, self.reward.loopHorizontalScrollRect, nil, vipCfg.Reward and vipCfg.Reward or {}, 0, self, self.UpdateRewardItem)
- end
- function UIVipLvUpView:RefreshView(vipCfg)
- self.vipIcon.image.sprite = nil
- self.vipIcon.image.enabled = false
- self.vipFrame.image.sprite = nil
- self.vipFrame.image.enabled = false
- if vipCfg then
- self.curVipNameTxt.text.text = string.formatbykey(vipCfg.Name)
- CommonUtil.LoadIcon(self, vipCfg.BigIcon, function(sprite)
- if sprite then
- self.vipIcon.image.sprite = sprite
- self.vipIcon.image.enabled = true
- end
- end)
- CommonUtil.LoadIcon(self, vipCfg.BigFrame, function(sprite)
- if sprite then
- self.vipFrame.image.sprite = sprite
- self.vipFrame.image.enabled = true
- end
- end)
- else
- self.curVipNameTxt.text.text = ''
- end
- end
- function UIVipLvUpView:GetItemByIndex(loopListView, itemIndex)
- local _, vipLv = self.controller:GetInfo()
- local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(vipLv)
- if not vipCfg then return nil end
- if not vipCfg.UnlockDes then return nil end
- local unlockDes = vipCfg.UnlockDes[itemIndex + 1]
- if not unlockDes then return nil end
- local item = loopListView:NewListViewItem('VipUnlockDesItem')
- local isNew = unlockDes[1] or 0
- local itemLua = CommonUtil.BindGridViewItem2Lua(self, 'VipUnlockDesItem', item.gameObject)
- if itemLua then
- itemLua.exist:SetActive(isNew ~= 1)
- itemLua.new:SetActive(isNew == 1)
- local params = {}
- local langKey = unlockDes[2]
- for i = 3, #unlockDes do
- params[#params + 1] = tostring(unlockDes[i])
- end
- itemLua.desTxt.text.text = string.formatbykey(langKey, unpack(params))
- end
- ManagerContainer.LuaUIMgr:ForceRebuildLayoutImmediate(item.CachedRectTransform)
- return item
- end
- function UIVipLvUpView:RefreshBottomView()
- local _, vipLv = self.controller:GetInfo()
- local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(vipLv)
- if not vipCfg then
- self.vipNameTxt.text.text = ''
- self.gainList.loopListView:SetListItemCount(0)
- CommonUtil.LoopGridViewEleCreateNew(self, self.reward.loopHorizontalScrollRect, nil, {}, 0, self, self.UpdateRewardItem)
- return
- end
- self.vipNameTxt.text.text = string.formatbykey(vipCfg.Name)
- self.gainList.loopListView:SetListItemCount(vipCfg.UnlockDes and #vipCfg.UnlockDes or 0)
- self.gainList.loopListView:RefreshAllShownItem()
- CommonUtil.LoopGridViewEleCreateNew(self, self.reward.loopHorizontalScrollRect, nil, vipCfg.Reward and vipCfg.Reward or {}, 0, self, self.UpdateRewardItem)
- end
- function UIVipLvUpView:UpdateRewardItem(itemLua, itemIdx, itemData)
- if not itemLua or not itemData then return end
- CommonUtil.UpdateItemPrefab(self, itemLua.iconItem, {cfgId = itemData[1], num = itemData[2]}, Enum.ItemIEnterType.Bag, self, self.ShowItemTips)
- itemLua.check:SetActive(false)
- end
- function UIVipLvUpView:ShowItemTips(button, params)
- ManagerContainer.LuaUIMgr:OpenTips(params[0])
- end
- return UIVipLvUpView
|