local UIOACommonTaskBase = UIViewClass() function UIOACommonTaskBase:OnOpened(context) self.activityId = context.activityId self.activityType = context.activityType self:RegistSystemEvent(EventID.UI_OACommon_TaskInfoRefresh, self.InitPanel) self:RegistSystemEvent(EventID.UI_OACommon_TaskDataRefresh, self.InitPanel) self:RegistSystemEvent(EventID.UI_OACommon_TaskRewardClaim, self.InitPanel) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) MDL.OACommon.OATaskInfoReq(self.activityId) end function UIOACommonTaskBase:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UIOACommonTaskBase:InitPanel() if self.loop_TaskLeftTab.Count > 0 then self.loop_TaskLeftTab:ClearCells() end local defaultTabId = 1 if self.context.selectTabId and self.context.selectTabId > 0 then defaultTabId = self.context.selectTabId self.context.selectTabId = nil else defaultTabId = CTL.OACommon.GetDefaultTabId(self.activityId) end for taskType, taskData in pairs(MDL.OACommon.GetTaskData(self.activityId)) do self.loop_TaskLeftTab:AddData(taskData, 0) end self.loop_TaskLeftTab:SelectIndex(defaultTabId - 1) self:RefreshGetAllBtn() end --新增一键领取,部分旧换皮活动可能未加节点 function UIOACommonTaskBase:RefreshGetAllBtn() if self.btn_GetAll then for taskType, taskData in pairs(MDL.OACommon.GetTaskData(self.activityId)) do if CTL.OACommon.IsTabHasReward(self.activityId, taskData[1].TaskType) then UIUtils.SetActive(self.btn_GetAll, true) return end end UIUtils.SetActive(self.btn_GetAll, false) end end function UIOACommonTaskBase:RefreshTasks(isReset, index) if isReset then if self.loop_Tasks.Count > 0 then self.loop_Tasks:ClearCells() end for i, v in ipairs(MDL.OACommon.GetTaskData(self.activityId, self.context.selectTabId)) do self.loop_Tasks:AddData(v, 0) end else self.loop_Tasks:RefreshCells() end end function UIOACommonTaskBase:InitTaskInfoCell(cellTable, data) for i, v in ipairs(cellTable.group_Items) do local itemData = data.TaskReward_Table[i] if itemData then UIUtils.SetActive(v.gameObject.transform.parent, true) UTL.Item.SetItemCell(v, itemData.TaskRewardID, itemData.TaskRewardNum) else UIUtils.SetActive(v.gameObject.transform.parent, false) end end local status = MDL.OACommon.GetTaskStatus(self.activityId, data.ID) local taskStateEnum = MDL.OACommon.ActivityTaskState if status == taskStateEnum.UnDone then cellTable.state_Btn:SetState(1) elseif status == taskStateEnum.Done then cellTable.state_Btn:SetState(0) elseif status == taskStateEnum.Commit then cellTable.state_Btn:SetState(2) end local conditionData = MDL.OperationActivity.HotGenCondID:GetDataByCondID(data.CondID) local triggerData = conditionData.Task_Table[1] local triggerCount = MDL.OACommon.GetTriggerCount(self.activityId, triggerData.Trigger, triggerData.Param2) local targetParam, des = CTL.Hegemony.GetTriggerContentById(data.CondID, triggerCount, true) cellTable.txt_TaskContent.text = des end function UIOACommonTaskBase:ClickTaskInfoCell(cellTable, target, data) if target == cellTable.event_Collect then local status = MDL.OACommon.GetTaskStatus(self.activityId, data.ID) if status == MDL.OACommon.ActivityTaskState.Done then MDL.OACommon.OATaskRewardReq(self.activityId, data.ID) elseif status == MDL.OACommon.ActivityTaskState.UnDone then local conditionData = MDL.OperationActivity.HotGenCondID:GetDataByCondID(data.CondID) local triggerData = DataSheetManager.TriggerType:GetDataByID(conditionData.Task_Table[1].Trigger) CTL.ItemSources.ExecuteSourceFunctionById(triggerData.ItemSourceID, nil, {activityId = self.activityId, activityType = self.activityType}) end else for i, v in ipairs(cellTable.group_Items) do if target == v.event_Click then UTL.ItemTips.ShowCommonTipsById(data.TaskReward_Table[i].TaskRewardID) end end end end function UIOACommonTaskBase:InitTaskTabCell(cellTable, data) cellTable.txt_UnselectTabName.text = data[1].PushTabName cellTable.txt_SelectedTabName.text = data[1].PushTabName cellTable.cell:SetRedPoint(CTL.OACommon.IsTabHasReward(self.activityId, data[1].TaskType)) end function UIOACommonTaskBase:SelectTaskTabCell(data, index) if self.context.selectTabId ~= data[1].TaskType then self.context.selectTabId = data[1].TaskType self:RefreshTasks(true, index) end end function UIOACommonTaskBase:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIOACommonTaskBase:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.btn_GetAll then MDL.OACommon.ClaimAtyTaskAllRwdRequest(self.activityId) end end function UIOACommonTaskBase:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_TaskLeftTab then self:InitTaskTabCell(cellTable, data) elseif scrollRect == self.loop_Tasks then self:InitTaskInfoCell(cellTable, data) end end function UIOACommonTaskBase:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.loop_TaskLeftTab then self:SelectTaskTabCell(data, index) end end function UIOACommonTaskBase:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Tasks then self:ClickTaskInfoCell(cellTable, target, data) end end return UIOACommonTaskBase