local UIOACommonGiftBase = require("View/OperationActivity/OACommonBase/UIOACommonGiftBase") local UIGoldHeroReprintRecharge = UIViewClass(UIOACommonGiftBase) local TimeColorCode = "FFFFFF" function UIGoldHeroReprintRecharge:Init(context) self.activityType = context.activityType self.activityTypeInfo = MDL.GoldHeroReprint.GetGoldHeroReprintActivityInfo() self.activityId = context.activityId self:RegistSystemEvent(EventID.UI_DirectGift_GiftInfoUpdate, self.UpdatePage) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self.playSound = true self:RefreshPage() self:SetCdTimerStr() self:RefreshGiftTime() local timer = self.activityTypeInfo.endTime - UTL.Time.GetServerTimestamp() self:StartRepeatFunc(self.CheckNeedClose, timer) end -- 活动结束关闭界面 function UIGoldHeroReprintRecharge:CheckNeedClose() self:CloseView() end function UIGoldHeroReprintRecharge: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 UIGoldHeroReprintRecharge:UpdatePage() self:RefreshPage() end function UIGoldHeroReprintRecharge:RefreshGiftTime() if not self:IsActivityOpen() then self.PackagePanel.group_Time:EndTimer() self:ActivityCloseFunc() else local endTime = self.activityTypeInfo.endTime local leftTimes = endTime - UTL.Time.GetServerTimestamp() self.PackagePanel.group_Time:ResetAndBeginCustomTimer(false, leftTimes, 0, nil) end end function UIGoldHeroReprintRecharge: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 UIGoldHeroReprintRecharge:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.PackagePanel.GiftScroll then self:ShowGiftCell(cellTable, data) end end function UIGoldHeroReprintRecharge: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 UIGoldHeroReprintRecharge:IsActivityOpen() -- 先判断服务器开启状态GM if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GoldHeroReprint) then return false end local info = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) return info and CTL.OperationActivity.IsOperationActivityOpen(info) end --是否检测活动时间 ,用于领取的额外判断 function UIGoldHeroReprintRecharge:IsCheckActivityTime() return MDL.GoldHeroReprint.IsActivityInFuncTime() end function UIGoldHeroReprintRecharge:ActivityCloseFunc() self:CloseView() end function UIGoldHeroReprintRecharge:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseSubViews() self:CloseView(true) end end end function UIGoldHeroReprintRecharge:SetDiscount(cellTable, giftRewardData) -- txt_Num UIUtils.SetActive(cellTable.group_Discount, giftRewardData.Rebate ~= 0) UIUtils.SetLabelText(cellTable.lab_Discount, Const_IDS.IDS_Monopoly_GiftBag_OnSale) UIUtils.SetActive(cellTable.lab_Discount, Localization.IsAllChinese()) local numStr = UTL.String.GetDiscountStrByIdsId(giftRewardData.Rebate) if cellTable.loc_Discount.CurState == 1 then local index = string.find(numStr, "%", 1, true) if index and index > 0 then numStr = numStr:sub(1,index + 1)..'\n '..numStr:sub(index+2) end end UIUtils.SetLabel(cellTable.txt_Num, numStr) end return UIGoldHeroReprintRecharge