2021-04-21 13:12:04 +08:00
|
|
|
|
|
2021-03-30 10:48:34 +08:00
|
|
|
|
local GrowthGiftPage = {}
|
|
|
|
|
local sortingOrder = 0
|
2020-06-08 13:57:30 +08:00
|
|
|
|
local rewardNameConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)--读取奖励名称信息
|
|
|
|
|
local GlobalActivity = ConfigManager.GetConfig(ConfigName.GlobalActivity)
|
2021-03-30 10:48:34 +08:00
|
|
|
|
local actRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
|
|
|
|
|
local rechargeConfigs = ConfigManager.GetAllConfigsDataByKey(ConfigName.RechargeCommodityConfig,"Type",GoodsTypeDef.GrowthReward)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
local giftList = {
|
|
|
|
|
[101] = 6,--表内没有礼包id(101、102、103、104、105)和ActivityId的对应关系,
|
|
|
|
|
[102] = 7,
|
|
|
|
|
[103] = 8,--自定义本表建立对应关系
|
|
|
|
|
[104] = 9,
|
|
|
|
|
[105] = 16,
|
|
|
|
|
}
|
2021-03-30 10:48:34 +08:00
|
|
|
|
function GrowthGiftPage:New(gameObject)
|
|
|
|
|
local b = {}
|
|
|
|
|
b.gameObject = gameObject
|
|
|
|
|
b.transform = gameObject.transform
|
|
|
|
|
setmetatable(b, { __index = GrowthGiftPage })
|
|
|
|
|
return b
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-03-30 10:48:34 +08:00
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function GrowthGiftPage:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.spLoader = SpriteLoader.New()
|
2020-06-08 13:57:30 +08:00
|
|
|
|
--定义头部文字和按钮
|
2021-03-30 10:48:34 +08:00
|
|
|
|
self.bg = Util.GetGameObject(self.gameObject, "rzyBg")
|
2021-03-30 18:26:10 +08:00
|
|
|
|
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")
|
|
|
|
|
|
2021-03-30 10:48:34 +08:00
|
|
|
|
self.btnInvest = Util.GetGameObject(self.gameObject, "rzyBg/bg/btnInvest")
|
|
|
|
|
self.btnInvestText = Util.GetGameObject(self.gameObject, "rzyBg/bg/btnInvest/Text"):GetComponent("Text")
|
2021-03-30 18:26:10 +08:00
|
|
|
|
|
2020-06-08 13:57:30 +08:00
|
|
|
|
--滚动条和预设
|
2021-03-30 10:48:34 +08:00
|
|
|
|
self.scrollItem = Util.GetGameObject(self.gameObject, "rzyBg/scrollItem")
|
|
|
|
|
self.itemPre = Util.GetGameObject(self.gameObject, "rzyBg/ItemPre")
|
2022-09-15 16:48:56 +08:00
|
|
|
|
self.btn_qmfl=Util.GetGameObject(self.gameObject, "rzyBg/bg/btn_qmfl")
|
2022-12-16 17:04:19 +08:00
|
|
|
|
self.red_qmfl=Util.GetGameObject(self.gameObject, "rzyBg/bg/btn_qmfl/red")
|
|
|
|
|
self.red_qmfl:SetActive(false)
|
2022-09-15 16:48:56 +08:00
|
|
|
|
self.btn_qmfl:GetComponent("Image").sprite=self.spLoader:LoadSprite("GM_qmfl_botton_zh")
|
2020-06-08 13:57:30 +08:00
|
|
|
|
--设置滚动条
|
|
|
|
|
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
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-03-30 10:48:34 +08:00
|
|
|
|
--绑定事件(用于子类重写)
|
2021-03-30 18:26:10 +08:00
|
|
|
|
function GrowthGiftPage:BindEvent()
|
2021-03-30 10:48:34 +08:00
|
|
|
|
Util.AddOnceClick(self.btnInvest,function()
|
|
|
|
|
self:OnBtnInvestClicked()
|
|
|
|
|
end)
|
2022-09-15 16:48:56 +08:00
|
|
|
|
|
|
|
|
|
Util.AddClick(self.btn_qmfl,function()
|
|
|
|
|
--LogGreen(this.helpPosition.x.."+"..this.helpPosition.y)
|
|
|
|
|
UIManager.OpenPanel(UIName.QuanMinFLPanel,self.curActiId)
|
|
|
|
|
end)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
2020-05-25 19:16:23 +08:00
|
|
|
|
|
2021-03-30 10:48:34 +08:00
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function GrowthGiftPage:AddListener()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-03-30 10:48:34 +08:00
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function GrowthGiftPage:RemoveListener()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-03-30 10:48:34 +08:00
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function GrowthGiftPage:OnOpen(_activityConfig,_index,parent)
|
|
|
|
|
self.actConfig = _activityConfig
|
|
|
|
|
self.pageIndex = _index
|
|
|
|
|
self.parent = parent
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
|
2022-12-16 17:04:19 +08:00
|
|
|
|
function GrowthGiftPage:OnFocus()
|
|
|
|
|
self.red_qmfl:SetActive(RecruitTreasureManager.GetQuanMinRed(self.curActiId))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2021-06-01 20:02:48 +08:00
|
|
|
|
function GrowthGiftPage:OnSortingOrderChange()
|
|
|
|
|
end
|
|
|
|
|
|
2021-03-30 10:48:34 +08:00
|
|
|
|
-- 打开,重新打开时回调
|
|
|
|
|
function GrowthGiftPage:OnShow(_sortingOrder)
|
2021-04-02 11:24:59 +08:00
|
|
|
|
VipManager.SetGrowthPackagePointStatus()--成长礼包
|
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
2021-03-30 10:48:34 +08:00
|
|
|
|
self.gameObject:SetActive(true)
|
2021-03-30 18:26:10 +08:00
|
|
|
|
if _sortingOrder then
|
|
|
|
|
sortingOrder = _sortingOrder
|
|
|
|
|
end
|
2022-09-15 16:48:56 +08:00
|
|
|
|
|
2021-03-30 10:48:34 +08:00
|
|
|
|
self.curActiId = self.actConfig.ActId
|
2022-09-15 16:48:56 +08:00
|
|
|
|
self.btn_qmfl:SetActive(ActivityGiftManager.GetActivityInfoByType(10502)~=nil and ActivityGiftManager.CheckIsHaveHaveQMFL(ActivityTypeDef.GrowthReward,self.curActiId) )
|
2021-03-30 10:48:34 +08:00
|
|
|
|
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
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2021-03-30 22:19:54 +08:00
|
|
|
|
end
|
2022-12-16 17:04:19 +08:00
|
|
|
|
LogError("self.curActiId:=="..self.curActiId)
|
|
|
|
|
self.red_qmfl:SetActive(RecruitTreasureManager.GetQuanMinRed(self.curActiId))
|
2021-04-21 16:36:12 +08:00
|
|
|
|
--LogGreen("self.curActiId:"..self.curActiId)
|
2021-03-30 18:26:10 +08:00
|
|
|
|
if self.actConfig.Icon[3] and self.actConfig.Icon[3] ~= "" then
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.titleBgIma.sprite = self.spLoader:LoadSprite(self.actConfig.Icon[3])
|
2021-03-30 18:26:10 +08:00
|
|
|
|
end
|
|
|
|
|
if self.actConfig.Icon[4] and self.actConfig.Icon[4] ~= "" then
|
|
|
|
|
self.titleIma.gameObject:SetActive(true)
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.titleIma.sprite = self.spLoader:LoadSprite(self.actConfig.Icon[4])
|
2021-03-30 18:26:10 +08:00
|
|
|
|
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
|
2021-04-07 16:38:26 +08:00
|
|
|
|
local str = string.split(GetLanguageStrById(self.actConfig.TitleText),"|")
|
2021-03-30 18:26:10 +08:00
|
|
|
|
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)
|
2021-04-02 11:24:59 +08:00
|
|
|
|
end
|
2021-04-15 16:25:00 +08:00
|
|
|
|
self:RefreshData(true,true)
|
2021-03-30 10:48:34 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-04-15 16:25:00 +08:00
|
|
|
|
function GrowthGiftPage:RefreshData(isTop,isAni)
|
2021-03-30 18:26:10 +08:00
|
|
|
|
if self.actType == ActivityTypeDef.GrowthReward then
|
|
|
|
|
self:SetBtnInvestState()
|
|
|
|
|
self.clickFun = self.GrowthGiftPageOnClick
|
|
|
|
|
end
|
2021-04-15 16:25:00 +08:00
|
|
|
|
self:RefreshGiftData(isTop,isAni)
|
2021-03-30 10:48:34 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--设置投资按钮初始状态
|
|
|
|
|
function GrowthGiftPage:SetBtnInvestState()
|
2021-04-02 11:24:59 +08:00
|
|
|
|
self.curGiftsId = GlobalActivity[self.curActiId].CanBuyRechargeId[1]
|
2021-03-30 10:48:34 +08:00
|
|
|
|
self.gift = OperatingManager.GetGiftGoodsInfo(GoodsTypeDef.GrowthReward, self.curGiftsId)
|
2021-11-15 15:44:02 +08:00
|
|
|
|
if self.gift and self.gift.isBought == 0 then
|
2021-03-30 10:48:34 +08:00
|
|
|
|
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
|
2021-04-09 12:26:35 +08:00
|
|
|
|
self.btnInvestText.text = Language[10514]
|
2021-03-30 10:48:34 +08:00
|
|
|
|
Util.SetGray(self.btnInvest, true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2021-03-30 10:48:34 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-04-15 16:25:00 +08:00
|
|
|
|
function GrowthGiftPage:RefreshGiftData(isTop,isAni)
|
2021-03-30 18:26:10 +08:00
|
|
|
|
self.mission = DynamicActivityManager.GetMissionDataByActId(self.curActiId)
|
2021-03-30 10:48:34 +08:00
|
|
|
|
if not self.missionPre then
|
|
|
|
|
self.missionPre = {}
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
2021-03-30 10:48:34 +08:00
|
|
|
|
|
2021-03-30 18:26:10 +08:00
|
|
|
|
self.scrollView:ForeachItemGO(function (index, go)
|
|
|
|
|
go.gameObject:SetActive(false)
|
|
|
|
|
end)
|
2021-03-30 10:48:34 +08:00
|
|
|
|
|
2021-03-30 18:26:10 +08:00
|
|
|
|
self.scrollView:SetData(self.mission, function(index, item)
|
|
|
|
|
self:RefreshShowData(item, self.mission[index])
|
2021-04-15 16:25:00 +08:00
|
|
|
|
end,not isTop,not isAni)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--刷新每一条item
|
|
|
|
|
function GrowthGiftPage:RefreshShowData(item, data)
|
2021-03-30 10:48:34 +08:00
|
|
|
|
if not self.missionPre[item] then
|
2021-03-30 18:26:10 +08:00
|
|
|
|
local config = SubUIConfig[self.actConfig.UIName[2]]
|
|
|
|
|
self.missionPre[item] = SubUIManager.Open(config,item.transform)
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
2021-03-30 18:26:10 +08:00
|
|
|
|
item.gameObject:SetActive(true)
|
2021-05-10 10:06:53 +08:00
|
|
|
|
self.missionPre[item]:SetData(data,self,sortingOrder,nil,nil,self.clickFun)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-03-30 10:48:34 +08:00
|
|
|
|
--检测是否全部已领取
|
|
|
|
|
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
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-03-30 10:48:34 +08:00
|
|
|
|
return 1
|
2020-06-08 13:57:30 +08:00
|
|
|
|
end
|
2021-03-30 22:19:54 +08:00
|
|
|
|
function GrowthGiftPage.GrowthGiftPageOnClick(data,curActiId,self)
|
2021-03-30 18:26:10 +08:00
|
|
|
|
if data.state == -1 then
|
2021-04-09 12:26:35 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11372])
|
2021-03-30 18:26:10 +08:00
|
|
|
|
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)
|
2021-03-30 22:19:54 +08:00
|
|
|
|
if self:CheckAllGet(curActiId,data.missionId) == 0 then
|
2021-03-30 18:26:10 +08:00
|
|
|
|
self:RefreshGiftData(false)
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-03-31 17:25:11 +08:00
|
|
|
|
if(curActiId == 16)then--16是最后一个礼包的ActivityId
|
2021-04-09 12:26:35 +08:00
|
|
|
|
MsgPanel.ShowOne(Language[11370])
|
2021-03-31 17:25:11 +08:00
|
|
|
|
self:RefreshGiftData(true)
|
2021-03-30 18:26:10 +08:00
|
|
|
|
else
|
2021-04-09 12:26:35 +08:00
|
|
|
|
MsgPanel.ShowOne(Language[11371])
|
2021-03-30 18:26:10 +08:00
|
|
|
|
self:OnShow(sortingOrder)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
elseif data.state ~= 1 then
|
2021-04-09 12:26:35 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[11369])
|
2021-03-30 18:26:10 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-25 19:16:23 +08:00
|
|
|
|
|
2020-06-08 13:57:30 +08:00
|
|
|
|
--点击进行投资购买礼包
|
2020-05-09 13:31:21 +08:00
|
|
|
|
function GrowthGiftPage:OnBtnInvestClicked()
|
2022-11-18 17:35:05 +08:00
|
|
|
|
--self.btnInvest:GetComponent("Button").enabled = false
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self:RequestBuy()
|
|
|
|
|
end
|
|
|
|
|
function GrowthGiftPage:RequestBuy()
|
2021-03-30 10:48:34 +08:00
|
|
|
|
local giftGoodsInfo = OperatingManager.GetGiftGoodsInfo(GoodsTypeDef.GrowthReward, self.curGiftsId)
|
2021-06-21 17:37:34 +08:00
|
|
|
|
PayManager.Pay(giftGoodsInfo.goodsId, function(id)
|
|
|
|
|
-- 检测月卡激活是否需要拍脸
|
2021-10-18 16:22:11 +08:00
|
|
|
|
MonthCardManager.CheckMonthCardPatFace()
|
2020-09-09 18:47:17 +08:00
|
|
|
|
self:RefreshStatus()
|
|
|
|
|
end)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GrowthGiftPage:RefreshStatus()
|
2020-05-25 19:16:23 +08:00
|
|
|
|
-- 添加已经购买的物品
|
2021-03-30 10:48:34 +08:00
|
|
|
|
OperatingManager.SetHadBuyGoodsId({self.curGiftsId})
|
2020-05-25 19:16:23 +08:00
|
|
|
|
-- 增加充值金额
|
2021-03-30 10:48:34 +08:00
|
|
|
|
FirstRechargeManager.RefreshAccumRechargeValue(self.curGiftsId)
|
2020-05-25 19:16:23 +08:00
|
|
|
|
-- 检测红点状态
|
2020-05-09 13:31:21 +08:00
|
|
|
|
RedpotManager.CheckRedPointStatus(RedPointType.GrowthGift)
|
2020-05-25 19:16:23 +08:00
|
|
|
|
-- 刷新当前界面显示
|
2021-04-15 16:25:00 +08:00
|
|
|
|
self:RefreshData(false,false)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-03-30 10:48:34 +08:00
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function GrowthGiftPage:OnClose()
|
2021-04-02 11:41:50 +08:00
|
|
|
|
VipManager.SetGrowthPackagePointStatus()--成长礼包
|
|
|
|
|
CheckRedPointStatus(RedPointType.GrowthPackage)
|
2021-03-30 10:48:34 +08:00
|
|
|
|
self.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function GrowthGiftPage:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
self.spLoader:Destroy()
|
2021-03-30 10:48:34 +08:00
|
|
|
|
for k,v in pairs(self.missionPre) do
|
|
|
|
|
SubUIManager.Close(v)
|
|
|
|
|
end
|
|
|
|
|
self.missionPre = {}
|
|
|
|
|
end
|
2020-06-08 13:57:30 +08:00
|
|
|
|
return GrowthGiftPage
|