miduo_client/Assets/ManagedResources/~Lua/Modules/Recharge/View/RechargeView.lua

88 lines
3.3 KiB
Lua
Raw Normal View History

2020-08-06 17:52:32 +08:00
local RechargeView = quick_class("RechargeView")
2020-05-15 16:52:35 +08:00
function RechargeView:ctor(rootView, gameObject)
self.rootView = rootView
self.gameObject = gameObject
self:InitComponent(gameObject)
self:BindEvent()
self.ItemList = {}
self.NoviceItemList={}
end
function RechargeView:InitComponent(gameObject)
self.shopViewRoot = Util.GetGameObject(gameObject, "root")
-- 显示特权信息
self.vipInfoPart = Util.GetGameObject(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")
2020-05-25 19:16:23 +08:00
self.vipInfoPart:SetActive(false)
2020-05-15 16:52:35 +08:00
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 ()
2020-05-25 19:16:23 +08:00
UIManager.OpenPanel(UIName.VipPanelV2)
2020-05-15 16:52:35 +08:00
end)
end
function RechargeView:OnShow()
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, self.SetVipPartInfo, self)
self.shopView:ShowShop(SHOP_TYPE.SOUL_STONE_SHOP, self.rootView.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(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 = Util.LoadSprite(VIP_LEVEL_REWARD[nextLevel])
self.vipProgress.fillAmount = VipManager.GetChargedNum() / nextLevelNeed
self.progressText.text = VipManager.GetChargedNum() .. "/" .. nextLevelNeed
end
function RechargeView:OnSortingOrderChange(cursortingOrder)
if self.shopView then
self.shopView:SetSortLayer(cursortingOrder)
end
end
function RechargeView:OnHide()
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, self.SetVipPartInfo, self)
end
function RechargeView:OnDestroy()
-- 销毁shopview
if self.shopView then
SubUIManager.Close(self.shopView)
self.shopView = nil
end
ClearRedPointObject(RedPointType.VIP_SHOP_DETAIL, self.vipRedPoint)
end
---------------------
2020-06-23 18:36:24 +08:00
return RechargeView