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

260 lines
10 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

local GrowthGiftPage = {}
local sortingOrder = 0
local rewardNameConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)--读取奖励名称信息
local GlobalActivity = ConfigManager.GetConfig(ConfigName.GlobalActivity)
local actRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
local rechargeConfigs = ConfigManager.GetAllConfigsDataByKey(ConfigName.RechargeCommodityConfig,"Type",GoodsTypeDef.GrowthReward)
local giftList = {
[101] = 6,--表内没有礼包id101、102、103、104、105和ActivityId的对应关系
[102] = 7,
[103] = 8,--自定义本表建立对应关系
[104] = 9,
[105] = 16,
}
function GrowthGiftPage:New(gameObject)
local b = {}
b.gameObject = gameObject
b.transform = gameObject.transform
setmetatable(b, { __index = GrowthGiftPage })
return b
end
--初始化组件(用于子类重写)
function GrowthGiftPage:InitComponent()
self.spLoader = SpriteLoader.New()
--定义头部文字和按钮
self.bg = Util.GetGameObject(self.gameObject, "rzyBg")
self.titleBgIma = Util.GetGameObject(self.bg,"bg"):GetComponent("Image")
self.titleIma = Util.GetGameObject(self.bg,"titleIma"):GetComponent("Image")
self.titleTipBg = Util.GetGameObject(self.bg,"titleTipBg"):GetComponent("Image")
self.titleTip = Util.GetGameObject(self.bg,"titleTip"):GetComponent("Text")
self.btnInvest = Util.GetGameObject(self.gameObject, "rzyBg/bg/btnInvest")
self.btnInvestText = Util.GetGameObject(self.gameObject, "rzyBg/bg/btnInvest/Text"):GetComponent("Text")
--滚动条和预设
self.scrollItem = Util.GetGameObject(self.gameObject, "rzyBg/scrollItem")
self.itemPre = Util.GetGameObject(self.gameObject, "rzyBg/ItemPre")
self.btn_qmfl=Util.GetGameObject(self.gameObject, "rzyBg/bg/btn_qmfl")
self.red_qmfl=Util.GetGameObject(self.gameObject, "rzyBg/bg/btn_qmfl/red")
self.red_qmfl:SetActive(false)
self.btn_qmfl:GetComponent("Image").sprite=self.spLoader:LoadSprite("GM_qmfl_botton_zh")
--设置滚动条
local rootHight = self.scrollItem.transform.rect.height
local width = self.scrollItem.transform.rect.width
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scrollItem.transform,
self.itemPre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 0))
self.scrollView.moveTween.MomentumAmount = 1
self.scrollView.moveTween.Strength = 2
end
--绑定事件(用于子类重写)
function GrowthGiftPage:BindEvent()
Util.AddOnceClick(self.btnInvest,function()
self:OnBtnInvestClicked()
end)
Util.AddClick(self.btn_qmfl,function()
--LogGreen(this.helpPosition.x.."+"..this.helpPosition.y)
UIManager.OpenPanel(UIName.QuanMinFLPanel,self.curActiId)
end)
end
--添加事件监听(用于子类重写)
function GrowthGiftPage:AddListener()
end
--移除事件监听(用于子类重写)
function GrowthGiftPage:RemoveListener()
end
--界面打开时调用(用于子类重写)
function GrowthGiftPage:OnOpen(_activityConfig,_index,parent)
self.actConfig = _activityConfig
self.pageIndex = _index
self.parent = parent
end
function GrowthGiftPage:OnFocus()
self.red_qmfl:SetActive(RecruitTreasureManager.GetQuanMinRed(self.curActiId))
end
function GrowthGiftPage:OnSortingOrderChange()
end
-- 打开,重新打开时回调
function GrowthGiftPage:OnShow(_sortingOrder)
VipManager.SetGrowthPackagePointStatus()--成长礼包
CheckRedPointStatus(RedPointType.GrowthPackage)
self.gameObject:SetActive(true)
if _sortingOrder then
sortingOrder = _sortingOrder
end
self.curActiId = self.actConfig.ActId
self.btn_qmfl:SetActive(ActivityGiftManager.GetActivityInfoByType(10502)~=nil and ActivityGiftManager.CheckIsHaveHaveQMFL(ActivityTypeDef.GrowthReward,self.curActiId) )
self.actType = self.actConfig.ActiveType
if self.actConfig.IfBack == 1 then
if self.actConfig.ActiveType > 0 then
local id = ActivityGiftManager.IsActivityTypeOpen(self.actConfig.ActiveType)
if id and id > 0 then
self.curActiId = id
local config = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.ActivityGroups,"PageType",self.actConfig.PageType,"ActiveType",self.actConfig.ActiveType,"ActId",id)
if config then
self.actConfig = config
end
end
end
end
LogError("self.curActiId:=="..self.curActiId)
self.red_qmfl:SetActive(RecruitTreasureManager.GetQuanMinRed(self.curActiId))
--LogGreen("self.curActiId:"..self.curActiId)
if self.actConfig.Icon[3] and self.actConfig.Icon[3] ~= "" then
self.titleBgIma.sprite = self.spLoader:LoadSprite(self.actConfig.Icon[3])
end
if self.actConfig.Icon[4] and self.actConfig.Icon[4] ~= "" then
self.titleIma.gameObject:SetActive(true)
self.titleIma.sprite = self.spLoader:LoadSprite(self.actConfig.Icon[4])
self.titleIma:SetNativeSize()
self.titleIma.transform.localPosition = Vector3.New(self.actConfig.TitleImapos[1],self.actConfig.TitleImapos[2],self.actConfig.TitleImapos[3])
else
self.titleIma.gameObject:SetActive(false)
end
local str = string.split(GetLanguageStrById(self.actConfig.TitleText),"|")
if str[1] and str[1] ~= "" then
self.titleTip.text = str[1]
self.titleTip.transform.localPosition = Vector3.New((str[2] or 0),(str[3] or 0),(str[4] or 0))
self.titleTip.gameObject:SetActive(true)
else
self.titleTip.gameObject:SetActive(false)
end
self:RefreshData(true,true)
end
function GrowthGiftPage:RefreshData(isTop,isAni)
if self.actType == ActivityTypeDef.GrowthReward then
self:SetBtnInvestState()
self.clickFun = self.GrowthGiftPageOnClick
end
self:RefreshGiftData(isTop,isAni)
end
--设置投资按钮初始状态
function GrowthGiftPage:SetBtnInvestState()
self.curGiftsId = GlobalActivity[self.curActiId].CanBuyRechargeId[1]
self.gift = OperatingManager.GetGiftGoodsInfo(GoodsTypeDef.GrowthReward, self.curGiftsId)
if self.gift and self.gift.isBought == 0 then
self.btnInvest:GetComponent("Button").enabled = true
local rechargeConfig = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, self.curGiftsId)
self.btnInvestText.text = string.format(MoneyUtil.GetMoneyUnitName(),MoneyUtil.GetMoney(rechargeConfig.Price))--"$98"
Util.SetGray(self.btnInvest, false)
else
self.btnInvest:GetComponent("Button").enabled = false
self.btnInvestText.text = Language[10514]
Util.SetGray(self.btnInvest, true)
end
end
function GrowthGiftPage:RefreshGiftData(isTop,isAni)
self.mission = DynamicActivityManager.GetMissionDataByActId(self.curActiId)
if not self.missionPre then
self.missionPre = {}
end
self.scrollView:ForeachItemGO(function (index, go)
go.gameObject:SetActive(false)
end)
self.scrollView:SetData(self.mission, function(index, item)
self:RefreshShowData(item, self.mission[index])
end,not isTop,not isAni)
end
--刷新每一条item
function GrowthGiftPage:RefreshShowData(item, data)
if not self.missionPre[item] then
local config = SubUIConfig[self.actConfig.UIName[2]]
self.missionPre[item] = SubUIManager.Open(config,item.transform)
end
item.gameObject:SetActive(true)
self.missionPre[item]:SetData(data,self,sortingOrder,nil,nil,self.clickFun)
end
--检测是否全部已领取
function GrowthGiftPage:CheckAllGet(curActiId,missionId)
local aciInfo = ActivityGiftManager.GetActivityInfoByType(curActiId)
for i = 1, #aciInfo.mission do
if aciInfo.mission[i].state ~= 1 and aciInfo.mission[i].missionId ~= missionId then
return 0
end
end
return 1
end
function GrowthGiftPage.GrowthGiftPageOnClick(data,curActiId,self)
if data.state == -1 then
PopupTipPanel.ShowTip(Language[11372])
elseif data.state == 2 then
NetManager.GetActivityRewardRequest(data.missionId,curActiId, function(drop)
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1)
ActivityGiftManager.SetActivityInfo(curActiId, data.missionId, 1)
RedpotManager.CheckRedPointStatus(RedPointType.GrowthGift)
if self:CheckAllGet(curActiId,data.missionId) == 0 then
self:RefreshGiftData(false)
return
end
if(curActiId == 16)then--16是最后一个礼包的ActivityId
MsgPanel.ShowOne(Language[11370])
self:RefreshGiftData(true)
else
MsgPanel.ShowOne(Language[11371])
self:OnShow(sortingOrder)
end
end)
elseif data.state ~= 1 then
PopupTipPanel.ShowTip(Language[11369])
end
end
--点击进行投资购买礼包
function GrowthGiftPage:OnBtnInvestClicked()
--self.btnInvest:GetComponent("Button").enabled = false
self:RequestBuy()
end
function GrowthGiftPage:RequestBuy()
local giftGoodsInfo = OperatingManager.GetGiftGoodsInfo(GoodsTypeDef.GrowthReward, self.curGiftsId)
PayManager.Pay(giftGoodsInfo.goodsId, function(id)
-- 检测月卡激活是否需要拍脸
MonthCardManager.CheckMonthCardPatFace()
self:RefreshStatus()
end)
end
function GrowthGiftPage:RefreshStatus()
-- 添加已经购买的物品
OperatingManager.SetHadBuyGoodsId({self.curGiftsId})
-- 增加充值金额
FirstRechargeManager.RefreshAccumRechargeValue(self.curGiftsId)
-- 检测红点状态
RedpotManager.CheckRedPointStatus(RedPointType.GrowthGift)
-- 刷新当前界面显示
self:RefreshData(false,false)
end
--界面关闭时调用(用于子类重写)
function GrowthGiftPage:OnClose()
VipManager.SetGrowthPackagePointStatus()--成长礼包
CheckRedPointStatus(RedPointType.GrowthPackage)
self.gameObject:SetActive(false)
end
--界面销毁时调用(用于子类重写)
function GrowthGiftPage:OnDestroy()
self.spLoader:Destroy()
for k,v in pairs(self.missionPre) do
SubUIManager.Close(v)
end
self.missionPre = {}
end
return GrowthGiftPage