local UIAttention = UIViewClass() ----------------------- function UIAttention:OnCreated() self.accountAward = DataSheetManager.ConstData:GetDataByID("FollowAccountAward").IntListValue self.accountLink = DataSheetManager.ConstData:GetDataByID("FollowAccountLink").StringValue end function UIAttention:OnOpened(context) self:RegistSystemEvent(EventID.Attention_ShowRedPoint, self.RefreshBtnState) self:RefreshBtnState() self:InitPanel() end function UIAttention:OnButtonClicked(comp) if comp == self.btn_Go then local state = MDL.Attention.GetAttentionState(CTL.Welfare.WelfareType.AttentionReward) if state == MDL.Attention.AttentionState.CanReceive then MDL.Attention.PushInterfaceOptReq(CTL.Welfare.WelfareType.AttentionReward, MDL.Attention.OptType.Receive) else SDKUtil.OpenPlatWebUrl(self.accountLink, nil) MDL.Attention.PushInterfaceOptReq(CTL.Welfare.WelfareType.AttentionReward, MDL.Attention.OptType.SetReceive) end else for i, v in ipairs(self.group_Item) do if v.item.event_Click == comp then UTL.ItemTips.ShowCommonTipsById(self.accountAward[i * 2 - 1]) end end end end ----------------------- function UIAttention:InitPanel() local index = 1 for i = 1, #self.accountAward, 2 do -- 设置奖励 local itemCell = self.group_Item[index] if not itemCell then itemCell = self:InstantiateCollection(self.group_Item, self.template_Item.gameObject) end UTL.Item.SetItemCell(itemCell.item, self.accountAward[i], self.accountAward[i + 1]) UIUtils.SetActive(itemCell.gameObject, true) index = index + 1 end for i = index, #self.group_Item do UIUtils.SetActive(self.group_Item[i].gameObject, false) end end function UIAttention:RefreshBtnState() local state = MDL.Attention.GetAttentionState(CTL.Welfare.WelfareType.AttentionReward) if state and state == MDL.Attention.AttentionState.CanReceive then UIUtils.SetLabelText(self.txt_go, Const_IDS.IDS_NationClimbTower_GetReward) self.btn_Go:SetRedPoint(true) else UIUtils.SetLabelText(self.txt_go, Const_IDS.IDS_TeamUI_Myteam_GotoActivety) self.btn_Go:SetRedPoint(false) end end return UIAttention