137 lines
4.8 KiB
Lua
137 lines
4.8 KiB
Lua
----- 公会红包-抢红包排行榜 -----
|
||
local this = {}
|
||
this.firstHead=nil --第一名玩家头像
|
||
this.playerScrollHead={}--玩家头像组
|
||
this.firstHead={}--第一名头像组
|
||
local uidList={}--临时存储uid列表
|
||
local guildSetting=ConfigManager.GetConfigData(ConfigName.GuildSetting,1)
|
||
local sortingOrder=0
|
||
|
||
function this:InitComponent(gameObject)
|
||
this.firstPre=Util.GetGameObject(gameObject,"FirstPre")
|
||
this.firstPlayerHead=Util.GetGameObject(this.firstPre,"PlayerHead")--第一名玩家头像
|
||
this.firstPlayerName=Util.GetGameObject(this.firstPre,"PlayerName"):GetComponent("Text")--第一名玩家名
|
||
this.detailBtn=Util.GetGameObject(this.firstPre,"DetailBtn")--查看详情按钮
|
||
|
||
this.scrollRoot=Util.GetGameObject(gameObject,"ScrollRoot")--滚动条根节点
|
||
this.rankPre=Util.GetGameObject(gameObject,"RankPre")--排名预设
|
||
this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scrollRoot.transform,this.rankPre, nil,
|
||
Vector2.New(this.scrollRoot.transform.rect.width,this.scrollRoot.transform.rect.height),1,1,Vector2.New(0,10))
|
||
this.scrollView.moveTween.MomentumAmount = 1
|
||
this.scrollView.moveTween.Strength = 2
|
||
|
||
this.noRank=Util.GetGameObject(gameObject,"NoRank")--无排名信息提示
|
||
end
|
||
|
||
function this:BindEvent()
|
||
|
||
end
|
||
|
||
function this:AddListener()
|
||
|
||
end
|
||
|
||
function this:RemoveListener()
|
||
|
||
end
|
||
|
||
function this:OnShow(_sortingOrder)
|
||
-- logWarnTrance("打开发红包排行榜")
|
||
sortingOrder=_sortingOrder
|
||
this:InitRankView()
|
||
end
|
||
|
||
function this:OnClose()
|
||
-- logWarnTrance("关闭发红包排行榜")
|
||
end
|
||
|
||
function this:OnDestroy()
|
||
this.scrollView=nil
|
||
end
|
||
|
||
--初始化排名面板
|
||
function this:InitRankView()
|
||
--先请求已点赞信息 好赋值进排行信息
|
||
NetManager.GetAllSendLikeResponse(function(msg)
|
||
-- for k,v in ipairs(msg.uid) do
|
||
-- Log(tostring(v))
|
||
-- end
|
||
uidList={}
|
||
for k,v in ipairs(msg.uid) do
|
||
table.insert(uidList, v)
|
||
end
|
||
end)
|
||
|
||
--请求排行信息
|
||
NetManager.RequestRankInfo(RANK_TYPE.GUILD_REDPACKET, function (msg)
|
||
this.firstPlayerHead:SetActive(#msg.ranks>0)
|
||
this.detailBtn:SetActive(#msg.ranks>0)
|
||
this.noRank:SetActive(#msg.ranks==0)
|
||
if #msg.ranks==0 then this.firstPlayerName.text="虚位以待!" end
|
||
|
||
this.scrollView:SetData(msg.ranks,function(index, root)
|
||
this:SetShow(root, msg.ranks[index],msg.myRankInfo.rank)
|
||
if index>1 then return end
|
||
this:SetFirstShow(msg.ranks[index])
|
||
end)
|
||
end)
|
||
end
|
||
|
||
--设置第一数据
|
||
function this:SetFirstShow(data)
|
||
if not this.firstHead[this.firstPre] then this.firstHead[this.firstPre]= CommonPool.CreateNode(POOL_ITEM_TYPE.PLAYER_HEAD, this.firstPlayerHead) end
|
||
this.firstHead[this.firstPre]:Reset()
|
||
this.firstHead[this.firstPre]:SetHead(data.head)
|
||
this.firstHead[this.firstPre]:SetFrame(data.headFrame)
|
||
this.firstHead[this.firstPre]:SetLevel(data.level)
|
||
this.firstHead[this.firstPre]:SetScale(Vector3.one *0.9)
|
||
|
||
this.firstPlayerName.text=data.userName
|
||
--查看详情按钮
|
||
Util.AddClick(this.detailBtn,function()
|
||
UIManager.OpenPanel(UIName.PlayerInfoPopup, data.uid)
|
||
end)
|
||
end
|
||
|
||
--设置每条数据
|
||
function this:SetShow(root,data,mydata)
|
||
local selfBg=Util.GetGameObject(root,"SelfBG"):GetComponent("Image")
|
||
local rankImage=Util.GetGameObject(root,"RankImage"):GetComponent("Image")
|
||
local rankText = Util.GetGameObject(root, "RankText"):GetComponent("Text")
|
||
local playerHead=Util.GetGameObject(root,"PlayerHead")
|
||
local playerName=Util.GetGameObject(root,"PlayerName"):GetComponent("Text")
|
||
local btn=Util.GetGameObject(root,"Button")
|
||
|
||
selfBg.enabled = data.rankInfo.rank==mydata
|
||
|
||
rankImage.sprite = SetRankNumFrame(data.rankInfo.rank)
|
||
rankText.text = data.rankInfo.rank > 3 and data.rankInfo.rank or ""
|
||
if not this.playerScrollHead[root] then
|
||
this.playerScrollHead[root] = CommonPool.CreateNode(POOL_ITEM_TYPE.PLAYER_HEAD, playerHead)
|
||
end
|
||
this.playerScrollHead[root]:Reset()
|
||
this.playerScrollHead[root]:SetHead(data.head)
|
||
this.playerScrollHead[root]:SetFrame(data.headFrame)
|
||
this.playerScrollHead[root]:SetLevel(data.level)
|
||
this.playerScrollHead[root]:SetScale(Vector3.one * 0.7)
|
||
playerName.text = data.userName
|
||
|
||
for k, v in pairs(uidList) do
|
||
btn:GetComponent("Button").interactable=data.uid~=v
|
||
if data.uid==v then
|
||
Util.SetGray(btn,true)
|
||
break
|
||
end
|
||
end
|
||
--点赞
|
||
Util.AddOnceClick(btn,function()
|
||
NetManager.GetRedPackageLikeRequest(data.uid,function(msg)
|
||
btn:GetComponent("Button").interactable=false
|
||
PopupTipPanel.ShowTip(string.format( "点赞成功,获得 %d金币!",guildSetting.GiveLikeReward[2]))
|
||
Util.SetGray(btn,true)
|
||
end)
|
||
end)
|
||
end
|
||
|
||
return this
|