--每日首胜 local UISyncSoloBattleDailyReward = UIViewClass() --region 生命周期方法 function UISyncSoloBattleDailyReward:OnOpened(context) self:RegistSystemEvent(EventID.UI_FairPlay_RefreshDailyRewardUI,self.ShowGetRewardInfo) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title,Const_IDS.IDS_1v1RewardPlus_DailyWin) self:InitData() end function UISyncSoloBattleDailyReward:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_Get then --领取奖励 self:OnClickGetReward() else for i, v in ipairs(self.group_Item) do if comp == v.event_Click then UTL.ItemTips.ShowCommonTipsById(self.FixedReward[i].ItemID) end end end end function UISyncSoloBattleDailyReward:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UISyncSoloBattleDailyReward:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Item then --随机奖励 UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) end end function UISyncSoloBattleDailyReward:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Item then --随机奖励道具点击 if target == cellTable.item.event_Click then UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end end --endregion function UISyncSoloBattleDailyReward:InitData() local rewardResult = CTL.SyncSolo.GetRewardOfEveryDay() if rewardResult then self.FixedReward = rewardResult.FixedReward self:ShowFixedReward(rewardResult.FixedReward) self:ShowRandomReward(rewardResult.RandomNum,rewardResult.RandomReward) self:ShowGetRewardInfo() else logging.error(LTAG.ERROR,"CTL.SyncSolo.GetRewardOfEveryDay 没拿到奖励数据") end end --显示固定奖励 function UISyncSoloBattleDailyReward:ShowFixedReward(reward) for i,v in ipairs(self.group_Item) do local itemGo = self.group_Item[i].gameObject.transform.parent.gameObject if reward[i] then UIUtils.SetActive(itemGo,true) UTL.Item.SetItemCell(self.group_Item[i], reward[i].ItemID, reward[i].ItemNum) else UIUtils.SetActive(itemGo,false) end end end --显示随机奖励 rewardNum 奖励种类 function UISyncSoloBattleDailyReward:ShowRandomReward(rewardNum,reward) --奖励种类提示 UIUtils.SetLabel(self.txt_Tip2,string.FormatByIdsId(Const_IDS.IDS_1v1RewardPlus_RandomReward_Tips,tostring(rewardNum))) --随机奖励 self.loop_Item:ReloadAll(reward) end --显示领取UI的信息 function UISyncSoloBattleDailyReward:ShowGetRewardInfo() local state = MDL.SyncSolo.GetFirstWinOfEveryDayState() if state == MDL.SyncSolo.RewardState.NotReach then --未完成 UIUtils.SetActive(self.btn_Get,false) UIUtils.SetActive(self.txt_Tip,true) UIUtils.SetLabelText(self.txt_Tip,Const_IDS.IDS_1v1RewardPlus_NotWin) elseif state == MDL.SyncSolo.RewardState.NotGet then --未领取 UIUtils.SetActive(self.txt_Tip,false) UIUtils.SetActive(self.btn_Get,true) self.btn_Get:SetRedPoint(true) elseif state == MDL.SyncSolo.RewardState.Get then --已领取 UIUtils.SetActive(self.btn_Get,false) UIUtils.SetActive(self.txt_Tip,true) UIUtils.SetLabelText(self.txt_Tip,Const_IDS.IDS_1v1RewardPlus_TodayAlreadyGet) end end --领取奖励 function UISyncSoloBattleDailyReward:OnClickGetReward() MDL.SyncSolo.FairSoloGetDailyRewardReq() end return UISyncSoloBattleDailyReward