--充值有礼 local UIOACommonGiftBase = require("View/OperationActivity/OACommonBase/UIOACommonGiftBase") local UICommandTheWorldRecharge = UIViewClass(UIOACommonGiftBase) local TimeColorCode = "FFFFFF" function UICommandTheWorldRecharge:Init(context) self.activityId = context.activityId self.activityType = context.activityType self:RegistSystemEvent(EventID.UI_DirectGift_GiftInfoUpdate, self.UpdatePage) self.playSound = true UTL.Item.SetLocalizationImage(self.PackagePanel.loc_Title, self.PackagePanel.img_Title, "hltxtc_msz_xslb.png") self:RefreshPage() self:SetCdTimerStr() self:RefreshGiftTime() self:StartRepeatFunc(self.CheckNeedClose, 1, -1) if MDL.CommandTheWorld.IsSingleSerActivity() then UIUtils.SetLabelText(self.txt_Tip, Const_IDS.IDS_BattlefieldMuster_WarZoneRankTips_Single) else UIUtils.SetLabelText(self.txt_Tip, Const_IDS.IDS_BattlefieldMuster_WarZoneRankTips) end end --战区排行结算前10分钟关闭礼包界面 function UICommandTheWorldRecharge:CheckNeedClose() if not CTL.CommandTheWorld.IsCanShowGift() then self:StopRepeatFunc(self.CheckNeedClose) self:CloseView() end end function UICommandTheWorldRecharge:RefreshPage() local dataArray = {} for _, v in MDL.DirectGift.GetDirectGiftEnumerator(MDL.DirectGift.DirectGiftType.Base, self.activityId) do table.insert(dataArray,v) end self.PackagePanel.GiftScroll:ReloadAll(dataArray) --无礼包时的显示 UIUtils.SetActive(self.group_Empty,self.PackagePanel.GiftScroll.Count == 0) end function UICommandTheWorldRecharge:UpdatePage() self:RefreshPage() end function UICommandTheWorldRecharge:RefreshGiftTime() if not self:IsActivityOpen() then self.PackagePanel.group_Time:EndTimer() self:ActivityCloseFunc() else local endTime = CTL.CommandTheWorld.GetShowGiftEndTime() local leftTimes = endTime - UTL.Time.GetServerTimestamp() self.PackagePanel.group_Time:ResetAndBeginCustomTimer(false, leftTimes, 0, nil) end end function UICommandTheWorldRecharge:SetCdTimerStr() local timeStr_1 = string.FormatByIdsKey("IDS_Monopoly_LastTime", string.FormatByIdsKey("IDS_HorseActivity_TimeWithColor_1", TimeColorCode)) local timeStr_2 = string.FormatByIdsKey("IDS_Monopoly_LastTime", string.FormatByIdsKey("IDS_HorseActivity_TimeWithColor_2", TimeColorCode, TimeColorCode, TimeColorCode)) local timeStr_3 = string.FormatByIdsKey("IDS_Monopoly_LastTime", string.FormatByIdsKey("IDS_HorseActivity_TimeWithColor_4", TimeColorCode, TimeColorCode)) local timeStr_4 = string.FormatByIdsKey("IDS_Monopoly_LastTime", string.FormatByIdsKey("IDS_HorseActivity_TimeWithColor_4", TimeColorCode, TimeColorCode)) self.PackagePanel.group_Time:SetDHMSStr(timeStr_1, timeStr_2, timeStr_3, timeStr_4) end function UICommandTheWorldRecharge:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.PackagePanel.GiftScroll then self:ShowGiftCell(cellTable, data) end end function UICommandTheWorldRecharge:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.PackagePanel.GiftScroll then if target == cellTable.btn_Buy or target == cellTable.btn_Get then self:OnClickBuyInGiftCell(data) else for i, v in ipairs(cellTable.Content) do if v.event_Click == target then local giftRewardData = MDL.OperationActivity.CommonGiftReward:GetDataByID(data.data.GiftID) local rewardTable = giftRewardData.Reward_Table UTL.ItemTips.ShowCommonTipsById(rewardTable[i].RewardID) break end end end end end function UICommandTheWorldRecharge:IsActivityOpen() -- 先判断服务器开启状态GM if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.CommandTheWorld) then return false end local info = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) return info and CTL.OperationActivity.IsOperationActivityOpen(info) end --是否检测活动时间 ,用于领取的额外判断 function UICommandTheWorldRecharge:IsCheckActivityTime() if CTL.CommandTheWorld.IsBattleAreaEnd() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ActivityItem_NotAtActivityTime) CTL.CommandTheWorld.ShowHonourShowPanel() self:CloseView() return false else return true end end function UICommandTheWorldRecharge:ActivityCloseFunc() self:CloseView() end return UICommandTheWorldRecharge