local UIWelfareTestingGiftLihui = UIViewClass() local EventSystem = require('Event/EventSystem') function UIWelfareTestingGiftLihui:OnOpened() self:RegistSystemEvent(EventID.UI_TestingGift_GetReward, self.UpdateInfo) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.TestingGift_FaceBook, self.UpdateRed) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.TestingGift_StoreScore, self.UpdateRed) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.TestingGift_BindAccount, self.UpdateRed) self.dataList = {} self.IdTable = {} self.rewardList = {} local titleList = {} for i, v in ipairs(CTL.Welfare.BindAccountIdTable) do local data = DataSheetManager.Welfare:GetDataByID(v) if CTL.TestingGift.CheckTabShow(data) then self.dataList[v] = data table.insert(titleList,Const_IDS[self.dataList[v].Title]) table.insert(self.IdTable,v) end end self.currentIndex = 0 self.context = self.dataList[self.IdTable[self.currentIndex+1]] if #titleList > 1 then UTL.Toggle.InitToggleGroupByIDS(self.toggle_LeftGroup, "text_toggle",titleList) self.toggle_LeftGroup:SelectIndex(self.currentIndex) else self:SwitchWelfare(self.currentIndex) end end function UIWelfareTestingGiftLihui:OnValueChanged(comp, value) if comp == self.toggle_LeftGroup then self:SwitchWelfare(value) end end function UIWelfareTestingGiftLihui:SwitchWelfare(index) self.currentIndex = index self.context = DataSheetManager.Welfare:GetDataByID(self.IdTable[self.currentIndex+1]) self:SetSubTabRed() self:UpdateInfo() end function UIWelfareTestingGiftLihui:UpdateInfo() local hasReward = MDL.TestingGift.HasClaimReward(self.context.ID) if self.context.IsLocal then UIUtils.SetLocalizationImage(self.img_Activities, self.context.Image) else UIUtils.SetImageByAssetBundle(self.img_Activities, self.context.Image) end self.btn_Concern:SetGray(false) if self.context.Button == "FB" then self.state_Btn:SetState(1) self.state_Lab:SetState(0) elseif self.context.Button == "Reviews" then self.state_Btn:SetState(0) self.state_Lab:SetState(2) elseif self.context.Button == "Bind" then self.state_Lab:SetState(1) if hasReward then self.state_Btn:SetState(3) self.btn_Concern:SetGray(true, false) else self.state_Btn:SetState(2) end end --奖励数量固定 local reward = DataSheetManager.PromotionReward:GetDataByID(self.context.Reward) for i, v in ipairs(reward.Item_Table) do UTL.Item.SetItemCell(self.group_Reward[i], v.ItemID, v.ItemNum) self.rewardList[i] = v.ItemID end --奖励是否发放 if hasReward then UIUtils.SetActive(self.img_MailTipsBg,true) UIUtils.SetLabelText(self.lab_MailTips, Const_IDS.IDS_BindAccount_MailTips) else UIUtils.SetActive(self.img_MailTipsBg,false) end --设置红点 self:UpdateRed() end function UIWelfareTestingGiftLihui:UpdateRed() self:UpdateTabRed() self:UpdateBtnRed() EventSystem.Dispatch(EventID.UI_WelfareBase_RefreshRedPoint) end function UIWelfareTestingGiftLihui:UpdateTabRed() if #self.IdTable > 1 then for i, v in ipairs(self.IdTable) do local index = i - 1 local redKey = MDL.TestingGift.RedPointKey[v] if redKey then local isRed = CTL.RedPoint.GetRedPointActive(redKey) self.toggle_LeftGroup:SetRedPoint(index,isRed) else self.toggle_LeftGroup:SetRedPoint(index,false) end end end end function UIWelfareTestingGiftLihui:SetSubTabRed() if self.context then local redKey = MDL.TestingGift.RedPointKey[self.context.ID] if redKey then MDL.TestingGift.SetSubTabRed(self.context, true) end EventSystem.Dispatch(EventID.UI_WelfareBase_BindAccountRefreshRed) EventSystem.Dispatch(EventID.UI_WelfareBase_RefreshRedPoint) end end function UIWelfareTestingGiftLihui:UpdateBtnRed() local data = self.context local redKey = MDL.TestingGift.RedPointKey[data.ID] if redKey then local isRed = CTL.RedPoint.GetRedPointActive(redKey) self.btn_Concern:SetRedPoint(isRed) else self.btn_Concern:SetRedPoint(false) end end function UIWelfareTestingGiftLihui:OnButtonClicked(comp) if comp == self.btn_Concern then CTL.TestingGift.OnSDKCall(self.context.Button, self.context.ID) end for i, v in ipairs(self.rewardList) do if comp == self.group_Reward[i].event_Click then UTL.ItemTips.ShowCommonTipsById(self.rewardList[i]) end end end function UIWelfareTestingGiftLihui:OnClosed() self:SetSubTabRed() end return UIWelfareTestingGiftLihui