local UIOACommonGiftDetailBase = UIViewClass() function UIOACommonGiftDetailBase:OnOpened(context) self.activityType = context.activityType self.activityId = context.activityId self.giftType = context.giftType self:InitView() end function UIOACommonGiftDetailBase:InitView() self:SetRewardDetail() end function UIOACommonGiftDetailBase:SetRewardDetail() for _, v in MDL.OperationActivity.DirectGiftData[self.activityType]:GetEnumeratorByActivityID(self.activityId) do if v.HotPackageType == self.giftType then self.detailScroll:AddData(v, 0) end end end function UIOACommonGiftDetailBase:ShowRewardDetailCell(cellTable, data) -- 折扣 local giftRewardData = MDL.OperationActivity.CommonGiftReward:GetDataByID(data.GiftID) -- txt_Num UIUtils.SetLabel(cellTable.txt_Num, UTL.String.GetDiscountStrByIdsId(giftRewardData.Rebate)) -- 奖励 local rewardTable = giftRewardData.Reward_Table for i, rewardData in ipairs(rewardTable) do local contentItem = cellTable.Content[i] if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, cellTable.cell_Item.gameObject) end UTL.Item.SetItemCell(contentItem.Item, rewardData.RewardID, rewardData.RewardNum) UIUtils.SetActive(contentItem.gameObject, true) end for i = #rewardTable + 1, #cellTable.Content do UIUtils.SetActive(cellTable.Content[i].gameObject, false) end -- 价格 if data.IsFree then UIUtils.SetLabelText(cellTable.txt_Prices, Const_IDS.IDS_Gift_Receive) else UIUtils.SetLabel(cellTable.txt_Prices, MDL.Currency.GetFullyIAPPriceByIapID(giftRewardData.IapID)) end -- 限购 if data.LimitType == LuaConst.LimitBuyType.NoLimit then UIUtils.SetActive(cellTable.txt_RemainNum, false) else UIUtils.SetActive(cellTable.txt_RemainNum, true) local titleLimit = data.LimitType == LuaConst.LimitBuyType.Forever and UIUtils.GetLocalizedTxt(Const_IDS.IDS_GoldHeroActivity_Store_LimitBuyHint) or CTL.PayMall.GetLimitedTitleText(data.LimitType) local hasBuyCount = MDL.DirectGift.GetGiftBuyingCount(self.activityId, data.HotPackageID) local limitNumText = data.TimesLimit - hasBuyCount if hasBuyCount < data.TimesLimit then limitNumText = UTL.Color.FormatGreenColor(limitNumText) else limitNumText = UTL.Color.FormatRedColor(limitNumText) end UIUtils.SetLabel(cellTable.txt_RemainNum, titleLimit .. limitNumText .. "/" .. data.TimesLimit) end end function UIOACommonGiftDetailBase:OnButtonClicked(comp) if comp == self.event_Bottom then self:CloseView() end end function UIOACommonGiftDetailBase:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.detailScroll then self:ShowRewardDetailCell(cellTable, data) end end function UIOACommonGiftDetailBase:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.detailScroll then for i, v in ipairs(cellTable.Content) do if v.Item.event_Click == target then local giftRewardData = MDL.OperationActivity.CommonGiftReward:GetDataByID(data.GiftID) local rewardTable = giftRewardData.Reward_Table UTL.ItemTips.ShowCommonTipsById(rewardTable[i].RewardID) break end end end end return UIOACommonGiftDetailBase