miduo_client/Assets/ManagedResources/~Lua/Modules/Operating/ShenzunPrivilegePage.lua

112 lines
3.8 KiB
Lua

local ShenzunPrivilegePage = {}
local this = ShenzunPrivilegePage
local rechargeConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, 1000)
local qaConfig = ConfigManager.GetConfigData(ConfigName.QAConfig, 130)
local sortingOrder = 0
local activityId = 9901
function this:New(gameObject)
local b = {}
b.gameObject = gameObject
b.transform = gameObject.transform
setmetatable(b, { __index = ShenzunPrivilegePage })
return b
end
--初始化组件(用于子类重写)
function this:InitComponent()
this.rewardGrid = Util.GetGameObject(self.gameObject, "layout/rewardGrid")
this.getBtn = Util.GetGameObject(self.gameObject, "layout/getBtn")
this.getBtnText = Util.GetGameObject(self.gameObject, "layout/getBtn/Text"):GetComponent("Text")
this.des = Util.GetGameObject(self.gameObject, "layout/des"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function this:BindEvent()
Util.AddOnceClick(this.getBtn, function()
local activityData = ActivityGiftManager.GetActivityInfoByType(activityId)
if activityData.value == 0 then
PayManager.Pay(rechargeConfig.Id, function()
this.SetBtnGray()
activityData.value = 2
end)
elseif activityData.value == 1 then
NetManager.GetActivityRewardRequest(0, activityId, function(drop)
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1)
this.SetBtnGray()
activityData.value = 2
CheckRedPointStatus(RedPointType.ZhongShenKa)
end)
end
end)
end
--添加事件监听(用于子类重写)
function this:AddListener()
end
--移除事件监听(用于子类重写)
function this:RemoveListener()
end
--界面打开时调用(用于子类重写)
function this:OnOpen()
local str = GetLanguageStrById(qaConfig.content)
str = string.gsub(str, "{", "<color=#E6BC85>")
str = string.gsub(str, "}", "</color>")
str = string.gsub(str, "|", "\n") --换行
this.des.text = str
local activityData = ActivityGiftManager.GetActivityInfoByType(activityId)
LogGreen("~~~~~~~~~~~~~~~~~~~~~~~~~``" .. activityData.value)
if activityData.value == 0 then
this.getBtnText.text = MoneyUtil.GetMoney(rechargeConfig.Price) .. Language[10497]
for i = 1, #rechargeConfig.BaseReward do
local itemInfo = SubUIManager.Open(SubUIConfig.ItemView, this.rewardGrid.transform)
itemInfo:OnOpen(false, rechargeConfig.BaseReward[i], 1)
if i == 1 then
Util.GetGameObject(itemInfo.gameObject, "PreciousShow").gameObject:SetActive(true)
Util.GetGameObject(itemInfo.gameObject, "PreciousShow/Text"):GetComponent("Text").text = Language[12021]
end
end
elseif activityData.value == 1 then
this.getBtnText.text = Language[10018]
for i = 1, #rechargeConfig.ExtraReward do
local itemInfo = SubUIManager.Open(SubUIConfig.ItemView, this.rewardGrid.transform)
itemInfo:OnOpen(false, rechargeConfig.ExtraReward[i], 1)
end
else
this.SetBtnGray()
for i = 1, #rechargeConfig.ExtraReward do
local itemInfo = SubUIManager.Open(SubUIConfig.ItemView, this.rewardGrid.transform)
itemInfo:OnOpen(false, rechargeConfig.ExtraReward[i], 1)
end
end
end
function this.SetBtnGray()
Util.SetGray(this.getBtn, true)
this.getBtnText.text = Language[10025]
end
function this:OnSortingOrderChange()
end
-- 打开,重新打开时回调
function this:OnShow(_sortingOrder)
self.gameObject:SetActive(true)
sortingOrder = _sortingOrder
end
--界面关闭时调用(用于子类重写)
function this:OnClose()
self.gameObject:SetActive(false)
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
end
return this