miduo_client/Assets/ManagedResources/~Lua/Modules/Guild/RedPacketView/RedPacket_RankView.lua

163 lines
6.0 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
----- 公会红包-抢红包排行榜 -----
2020-05-09 13:31:21 +08:00
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=Language[11073] end
-- this.scrollView:SetData(msg.ranks,function(index, root)
-- if index==1 then
-- this:SetFirstShow(msg.ranks[index])
-- end
-- this:SetShow(root, msg.ranks[index],msg.myRankInfo.rank)
-- end)
-- end)
RankingManager.InitData(RANK_TYPE.GUILD_REDPACKET,function()
local ranks,myRankInfo = RankingManager.GetRankingInfo()
this.firstPlayerHead:SetActive(#ranks>0)
this.detailBtn:SetActive(#ranks>0)
this.noRank:SetActive(#ranks==0)
if #ranks==0 then this.firstPlayerName.text=Language[11073] end
this.SetRankDataShow(ranks,myRankInfo)
end,nil,1)
2020-05-09 13:31:21 +08:00
end
function this.SetRankDataShow(ranks,myRankInfo)
this.scrollView:SetData(ranks,function(index, root)
if index==1 then
this:SetFirstShow(ranks[index])
end
this:SetShow(root, ranks[index],myRankInfo.rank)
if index==#ranks then
RankingManager.RequestNextWarPowerPageData(function()
local ranks,myRankInfo = RankingManager.GetRankingInfo()
this.SetRankDataShow(ranks,myRankInfo)
end)
end
end)
end
2020-05-09 13:31:21 +08:00
--设置第一数据
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)
2020-09-25 21:19:01 +08:00
this.firstHead[this.firstPre]:SetLayer(this.sortingOrder)
this.firstHead[this.firstPre]:SetEffectScale(0.85)
2020-05-09 13:31:21 +08:00
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)
2020-09-25 21:19:01 +08:00
this.playerScrollHead[root]:SetLayer(this.sortingOrder)
this.firstHead[this.firstPre]:SetEffectScale(0.75)
2020-05-09 13:31:21 +08:00
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
2020-06-23 18:36:24 +08:00
PopupTipPanel.ShowTip(string.format( Language[11074],guildSetting.GiveLikeReward[2]))
2020-05-09 13:31:21 +08:00
Util.SetGray(btn,true)
end)
end)
end
2020-06-23 18:36:24 +08:00
return this