local UIPushInterfaceRegression = UIViewClass() local APPPushGetRewardDay = DataSheetManager.ConstData:GetDataByID("APPPushGetRewardDay").IntValue local LoginRewordID = 4 function UIPushInterfaceRegression:OnOpened(context) self.itemBtnDict = {} self.isGetAll = true self:RegistSystemEvent(EventID.UI_AppPushGift_UpdateRecallGiftInfo, self.UpdateRecallGiftInfo) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.OnFunctionUnlockUpdate) local activityId = MDL.AppPushGift.GetRecallGiftInfo().activityID for index, v in MDL.OperationActivity.RecallGiftReward:GetEnumeratorByActivityID(activityId) do if v.GiftType == 99 then for i, v in ipairs(v.Item_Table) do self.loop_itemReward:AddData(v, 0) end else if v.GiftType == 2 then local giftRewardData = MDL.OperationActivity.CommonGiftReward:GetDataByID(v.MoneyType) local itemTable = {} for i,v in ipairs(giftRewardData.Reward_Table) do table.insert(itemTable, {ItemID = v.RewardID, ItemNum = v.RewardNum}) end local data = { ID = v.ID, Item_Table = itemTable, GiftType = 2, ShowValue = giftRewardData.Rebate, iap = giftRewardData.IapID} self.loop_Info:AddData(data, 0) else self.loop_Info:AddData(v, 0) end end end self:InitLastRewardBtn() end function UIPushInterfaceRegression:OnFunctionUnlockUpdate(id, state) if id == MDL.Unlock.FunctionType.AppPushGift and not state then self:CloseView() end end function UIPushInterfaceRegression:UpdateRecallGiftInfo() self.loop_Info:RefreshCells() self:InitLastRewardBtn() end function UIPushInterfaceRegression:InitLastRewardBtn() local progressStr = string.format("%s/%s", MDL.AppPushGift.GetRecallGiftInfo().continueDays, APPPushGetRewardDay) self.lab_Info.text = string.FormatByIdsId(Const_IDS.IDS_AppPush_LogInDaily, APPPushGetRewardDay, progressStr) local isCanGet = MDL.AppPushGift.GetRecallGiftInfo().continueDays >= APPPushGetRewardDay if isCanGet then local isGet = MDL.AppPushGift.GetGiftState(LoginRewordID) == 1 if isGet then self.btn_GetGift:SetGray(true) self.btn_GetGift:SetText(Const_IDS.IDS_DailySignin_Got) else self.btn_GetGift:SetGray(false) end else self.btn_GetGift:SetGray(true) end end function UIPushInterfaceRegression:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.btn_GetGift then MDL.AppPushGift.BuyRecallGiftReq(LoginRewordID) end end function UIPushInterfaceRegression:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Info then local content = cellTable.content for i, v in ipairs(data.Item_Table) do self:CreateCellItemObj(cellTable.cell.gameObject, content, i, v.ItemID, v.ItemNum) end for i = #data.Item_Table + 1, #content do UIUtils.SetActive(content[i].gameObject, false) end if data.GiftType ~= 2 then local params = string.split(data.ShowValue, ",") cellTable.lab_cost.text = params[2] UTL.Item.MoneyIcon(cellTable.icon_ly, tonumber(params[1])) UIUtils.SetActive(cellTable.icon_ly, true) UIUtils.SetActive(cellTable.img_line, true) else cellTable.lab_cost.text = string.FormatByIdsId(Const_IDS.IDS_AppPush_Offers, data.ShowValue) UIUtils.SetActive(cellTable.icon_ly, false) UIUtils.SetActive(cellTable.img_line, false) end local isGet = MDL.AppPushGift.GetGiftState(data.ID) == 1 if isGet then cellTable.state_Got:SetState(1) else self.isGetAll = false cellTable.state_Got:SetState(0) end self:InitBtnText(data, cellTable.txt_CostNum) elseif scrollRect == self.loop_itemReward then UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) self.itemBtnDict[cellTable.item.event_Click] = data.ItemID end end function UIPushInterfaceRegression:InitBtnText(data, txt_CostNum) if data.GiftType == 0 then UIUtils.SetLabelText(txt_CostNum, Const_IDS.IDS_AppPush_Free) elseif data.GiftType == 1 then txt_CostNum.text = string.FormatByIdsId(Const_IDS.IDS_AppPush_Coin1, data.Price) elseif data.GiftType == 2 then txt_CostNum.text = MDL.Currency.GetFullyIAPPriceByIapID(data.iap) end end function UIPushInterfaceRegression:CreateCellItemObj(cellOjb, content, index, id, num) local item = content[index] if not item then item = self:InstantiateCellCollection(cellOjb, content, self.cell_item.gameObject) end UIUtils.SetActive(item.gameObject, true) UTL.Item.SetItemCell(item.item, id, num) self.itemBtnDict[item.item.event_Click] = id end function UIPushInterfaceRegression:OnCellClicked(scrollRect, index, cellTable, target, data) if target and self.itemBtnDict[target] then UTL.ItemTips.ShowCommonTipsById(self.itemBtnDict[target]) elseif target == cellTable.btn_Get then if data.GiftType ~= 2 then if data.GiftType == 1 then local softCurrencyCount = MDL.Currency.GetSoftTokenCountById(MDL.Currency.CurrencyType.GoldIngot) if softCurrencyCount < data.Price then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail5) return end end MDL.AppPushGift.BuyRecallGiftReq(data.ID) else local activityId = MDL.AppPushGift.GetRecallGiftInfo().activityID MDL.Currency.GetOrderIDReq(CTL.FreeBuy.GetIapIndex(data.iap), MDL.Currency.PayType.RecallGift, data.ID, activityId, MDL.OperationActivity.ActivityType.APPPushGift) end end end return UIPushInterfaceRegression