local UIDirectionalGiftCommon = UIViewClass() local ADJUST_NUM = 4 local BaseTitleName = "tylb_msz_01.png" -- 请检查 以下为这个界面必须要导出的节点 -- loc_Title -- img_Title -- loop_Rewards -- txt_Time -- cdTimer -- btn_Price -- txt_Price -- txt_Integral -- txt_Discount -- txt_DiscountNum -- loc_Discount -- txt_PackageName \ txt_Name 这两个不是强制导出 -- -------------------- function UIDirectionalGiftCommon:OnOpened(context) self:SetGiftData(context.giftData) self.parentView = context.parentView self.giftBackGroundData = context.giftBackGroundData self:RefreshPanel() UIUtils.SetActive(self.btn_Price, not MDL.Currency.IsNotShowRechargeButton()) end function UIDirectionalGiftCommon:OnButtonClicked(comp) if comp == self.btn_Price then if self.giftData then local info = MDL.OperationActivity.PushGiftData:GetDataByActivityID_ID(self.giftData.activityId, self.giftData.giftId) local reward = MDL.OperationActivity.CommonGiftReward:GetDataByID(info.RewardId) local iap for _, v in DataSheetManager.IAP:GetEnumerator() do if v.IapID == reward.IapID then iap = v.Index break end end if iap then MDL.Currency.GetOrderIDReq(iap, MDL.Currency.PayType.PushGift, self.giftData.giftId, self.giftData.activityId, MDL.OperationActivity.ActivityType.PushGift) else logging.error(LTAG.ERROR, "iap not found", reward.IapID) end else --过期了,直接关闭界面 self.parentView:CloseView() end end end function UIDirectionalGiftCommon:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Rewards then UTL.Item.SetItemCell(cellTable.item, data.RewardID, data.RewardNum) end end function UIDirectionalGiftCommon:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Rewards then UTL.ItemTips.ShowCommonTipsById(data.RewardID) end end -------------------- function UIDirectionalGiftCommon:RefreshPanel() local info = MDL.OperationActivity.PushGiftData:GetDataByActivityID_ID(self.giftData.activityId, self.giftData.giftId) if info then local reward = MDL.OperationActivity.CommonGiftReward:GetDataByID(info.RewardId) -- 折扣显示 local count = UTL.String.GetDiscountNum(reward.Rebate) if self.loc_Discount.CurState == 0 then self.txt_Discount.text = count else self.txt_DiscountNum.text = string.format("%s%%", count) self.txt_DiscountNumVN.text = string.format("%s%%", count) end -- 道具 self.loop_Rewards:ReloadAll(reward.Reward_Table) if self.txt_PackageName then UIUtils.SetLabel(self.txt_PackageName, reward.Name) end if self.txt_Name then UIUtils.SetLabel(self.txt_Name, info.PushTabName) end UIUtils.AdjustLoopScrollAlignment(self.loop_Rewards, ADJUST_NUM) UIUtils.SetLabel(self.txt_Price, MDL.Currency.GetFullyIAPPriceByIapID(reward.IapID)) local amount = MDL.Currency.GetIAPRewardAmountBy(reward.IapID) UIUtils.SetActive(self.txt_Integral, amount and true or false) if amount then UIUtils.SetLabel(self.txt_Integral, string.FormatByIdsId(Const_IDS.IDS_TotalTopUp_Score_Tips_Giftbag, amount)) end -- 设置标题 if self.img_Title ~= nil and self.loc_Title.CurState == 0 then if self.giftBackGroundData then UIUtils.SetLocalizationImage(self.img_Title, self.giftBackGroundData.Title) else UIUtils.SetLocalizationImage(self.img_Title, BaseTitleName) end end end -- 剩余时间 local offset = self.giftData.endTime - UTL.Time.GetServerTimestamp() if offset > UTL.Time.TotalSecondsOneDay then self.cdTimer:SetCustomString(UIUtils.GetLocalizedTxt(Const_IDS.IDS_7DayActivity_Hint_2) .. UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Time2), 1, 1) self.cdTimer:ResetAndBeginTimer(false, offset, 0) else self.cdTimer:SetCustomString(UIUtils.GetLocalizedTxt(Const_IDS.IDS_PushGift_RemainingTime), 1, 2) self.cdTimer:ResetAndBeginCustomTimer(false, offset, 0, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PushGift_RemainingTime), 1) end end function UIDirectionalGiftCommon:SetGiftData(giftData) self.giftData = giftData end function UIDirectionalGiftCommon:SetTimeEnd() self.cdTimer:EndTimer() UIUtils.SetLabelText(self.txt_Time, Const_IDS.IDS_PushGift_TimeOver) end return UIDirectionalGiftCommon