----- 公会红包-发红包 ----- local this = {} local sortingOrder=0 local packageConfig=nil function this:InitComponent(gameObject) this.itemPre=Util.GetGameObject(gameObject,"Item") this.scrollRoot=Util.GetGameObject(gameObject,"scrollRect") this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scrollRoot.transform,this.itemPre, nil, Vector2.New(this.scrollRoot.transform.rect.width,this.scrollRoot.transform.rect.height),1,2,Vector2.New(80,100)) this.scrollView.moveTween.MomentumAmount = 1 this.scrollView.moveTween.Strength = 2 this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0) this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5) this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5) this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5) this.infoTitle=Util.GetGameObject(gameObject,"infoPanel/Content/Title/Text"):GetComponent("Text") this.infoTitle.text="福利红包" Util.GetGameObject(gameObject,"infoPanel/Content/Text1"):GetComponent("Text").text="红包个数:" Util.GetGameObject(gameObject,"infoPanel/Content/Text2"):GetComponent("Text").text="红包金额:" this.numTxt=Util.GetGameObject(gameObject,"infoPanel/Content/numTxt"):GetComponent("Text") this.sumTxt=Util.GetGameObject(gameObject,"infoPanel/Content/num2Txt"):GetComponent("Text") this.rewardImg=Util.GetGameObject(gameObject,"infoPanel/Content/Image"):GetComponent("Image") this.infoObj=Util.GetGameObject(gameObject,"infoPanel") Util.AddClick(this.infoObj,function() this.infoObj.gameObject:SetActive(false) end) end function this:OnShow(_sortingOrder) sortingOrder=_sortingOrder this:InitView() end function this:BindEvent() end function this:AddListener() end function this:RemoveListener() end function this:OnClose() end function this:OnDestroy() end ---初始化面板 function this:InitView() packageConfig=ConfigManager.GetConfig(ConfigName.GuildRedPackConfig) if not packageConfig then return end local packages=MyGuildManager.GetMyGuidRedPackage() local showList={} for key, value in pairs(packages) do local config=packageConfig[key] --福利红包并且在限定等级 if config and config.BaseType == 2 and PlayerManager.level>=config.Level then -- if packages[i] then value.config=config table.insert(showList,value) --end end end if LengthOfTable(showList)==0 then return end table.sort(showList,function(a,b) if a.num==b.num then return a.config.Sortb.num -- body end end) --设置滚动区信息 this.scrollView:SetData(showList,function(index,root) this:ShowItemInfo(root,showList[index]) end) end --显示红包数据 function this:ShowItemInfo(go,data) if not data then return end local nameImage=Util.GetGameObject(go,"NameImage"):GetComponent("Image") local icon=Util.GetGameObject(go,"Icon"):GetComponent("Image") local desTxt=Util.GetGameObject(go,"Desc"):GetComponent("Text") local numTxt=Util.GetGameObject(go,"numTxt"):GetComponent("Text") local btn_send=Util.GetGameObject(go,"btn_send") local sendTxt=Util.GetGameObject(go,"btn_send/Text"):GetComponent("Text") nameImage.sprite=Util.LoadSprite("g_ghhb_ming_04_zh") icon.sprite=Util.LoadSprite(GetResourcePath(data.config.IconId)) desTxt.text= data.config.RuleDes local num=data.num numTxt.text="数量:"..data.num btn_send:GetComponent("Button").interactable=num>0 Util.SetGray(btn_send,num<1) --发红包按钮 Util.AddOnceClick(btn_send,function() NetManager.RequestWelfareRedPacket(data.config.Id,function() PopupTipPanel.ShowTip("成功发送福利红包!") this:InitView() --刷新发送福利红包按钮红点 CheckRedPointStatus(RedPointType.Guid_SendPackage) MyGuildManager.ReuqsetRedPackage(function() CheckRedPointStatus(RedPointType.Guid_GetPackage) end) --发送公会信息 local redpack=ConfigManager.GetConfigData(ConfigName.GuildRedPackConfig,data.config.Id) if not PlayerManager.familyId then return end -- 构建字符串 local channel = CHAT_CHANNEL.FAMILY local content = string.format( "%d#%s#%s",--"%d#%d#%d#%s#%d#%d|", GLOBAL_CHAT_TYPE.GUILD_REDPACKET, PlayerManager.nickName, redpack.Name ) -- 发送消息 NetManager.RequestSendChatMsg(channel, content, 0, function() local msgId = ChatManager.GetMsgIdFlag(channel) NetManager.RequestChatMsg(channel, msgId, function(data) end) end) end) end) --显示红包信息 Util.AddOnceClick(go,function() this.infoObj.gameObject:SetActive(true) this.numTxt.text=data.config.TotalMoney[1] this.sumTxt.text=data.config.TotalMoney[2] this.rewardImg.sprite=Util.LoadSprite(GetResourcePath(data.config.IconId)) end) end return this