106 lines
3.7 KiB
Lua
106 lines
3.7 KiB
Lua
local RechargeView = {}
|
|
function RechargeView:New(gameObject)
|
|
local b = {}
|
|
b.gameObject = gameObject
|
|
b.transform = gameObject.transform
|
|
setmetatable(b, { __index = RechargeView })
|
|
return b
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function RechargeView:AddListener()
|
|
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function RechargeView:RemoveListener()
|
|
|
|
end
|
|
|
|
function RechargeView:InitComponent()
|
|
self.spLoader = SpriteLoader.New()
|
|
self.shopViewRoot = Util.GetGameObject(self.gameObject, "root")
|
|
-- 显示特权信息
|
|
self.vipInfoPart = Util.GetGameObject(self.gameObject, "VipInfoPart")
|
|
self.vipChargeRoot = Util.GetGameObject(self.vipInfoPart, "textGrid")
|
|
self.chargeNum = Util.GetGameObject(self.vipInfoPart, "textGrid/num"):GetComponent("Text")
|
|
self.moneyIcon = Util.GetGameObject(self.vipInfoPart, "textGrid/icon/Image"):GetComponent("Image")
|
|
self.vipLevelTip = Util.GetGameObject(self.vipInfoPart, "textGrid/end"):GetComponent("Text")
|
|
self.vipIconLevel = Util.GetGameObject(self.vipInfoPart, "vipIcon/num"):GetComponent("Text")
|
|
self.vipHeroStar = Util.GetGameObject(self.vipInfoPart, "reward/Text"):GetComponent("Image")
|
|
|
|
-- 进度
|
|
self.vipProgress = Util.GetGameObject(self.vipInfoPart, "Slider/fill"):GetComponent("Image")
|
|
self.vipDetailBtn = Util.GetGameObject(self.vipInfoPart, "btnDetail")
|
|
self.progressText = Util.GetGameObject(self.vipInfoPart, "Slider/value"):GetComponent("Text")
|
|
self.vipRedPoint = Util.GetGameObject(self.vipDetailBtn, "redPoint")
|
|
self.vipInfoPart:SetActive(false)
|
|
BindRedPointObject(RedPointType.VIP_SHOP_DETAIL, self.vipRedPoint)
|
|
|
|
if not self.shopView then
|
|
self.shopView = SubUIManager.Open(SubUIConfig.ShopView, self.shopViewRoot.transform)
|
|
-- 修改商品栏的位置
|
|
self.shopView:SetItemContentPosition(Vector3.New(0, 710, 0))
|
|
end
|
|
end
|
|
function RechargeView:BindEvent()
|
|
-- 打开特权详情
|
|
Util.AddClick(self.vipDetailBtn, function ()
|
|
UIManager.OpenPanel(UIName.VipPanelV2)
|
|
end)
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function RechargeView:OnOpen(_activityConfig,_index,parent)
|
|
self.actConfig = _activityConfig
|
|
self.pageIndex = _index
|
|
self.parent = parent
|
|
end
|
|
|
|
function RechargeView:OnSortingOrderChange()
|
|
end
|
|
|
|
function RechargeView:OnShow(_sortingOrder)
|
|
self.gameObject:SetActive(true)
|
|
self.sortingOrder = _sortingOrder
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, self.SetVipPartInfo, self)
|
|
self.shopView:ShowShop(SHOP_TYPE.SOUL_STONE_SHOP, self.sortingOrder)
|
|
self:SetVipPartInfo()
|
|
end
|
|
|
|
-- 设置特权面板数据
|
|
function RechargeView:SetVipPartInfo()
|
|
local need, nextLevelNeed = VipManager.GetNextLevelNeed()
|
|
--self.vipChargeRoot:SetActive(need > 0)
|
|
self.chargeNum.text = need
|
|
self.moneyIcon.sprite = SetIcon(self.spLoader, 15)
|
|
local nextLevel = VipManager.GetVipLevel() + 1
|
|
nextLevel = nextLevel > VipManager.GetMaxVipLevel() and VipManager.GetMaxVipLevel() or nextLevel
|
|
|
|
self.vipLevelTip.text = nextLevel
|
|
self.vipIconLevel.text = VipManager.GetVipLevel()
|
|
self.vipHeroStar.sprite = self.spLoader:LoadSprite(VIP_LEVEL_REWARD[nextLevel])
|
|
self.vipProgress.fillAmount = VipManager.GetChargedNum() / nextLevelNeed
|
|
self.progressText.text = VipManager.GetChargedNum() .. "/" .. nextLevelNeed
|
|
end
|
|
|
|
function RechargeView:OnClose()
|
|
self.gameObject:SetActive(false)
|
|
end
|
|
|
|
function RechargeView:OnDestroy()
|
|
self.spLoader:Destroy()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, self.SetVipPartInfo, self)
|
|
if self.shopView then
|
|
SubUIManager.Close(self.shopView)
|
|
self.shopView = nil
|
|
end
|
|
ClearRedPointObject(RedPointType.VIP_SHOP_DETAIL, self.vipRedPoint)
|
|
end
|
|
|
|
|
|
|
|
return RechargeView
|
|
|