789 lines
37 KiB
Lua
789 lines
37 KiB
Lua
require("Base/BasePanel")
|
|
GoodFriendMainPanel = Inherit(BasePanel)
|
|
local this = GoodFriendMainPanel
|
|
local friendNumber = 0
|
|
local index = 1
|
|
local canApplyFriendsList={}
|
|
--初始化组件(用于子类重写)
|
|
function GoodFriendMainPanel:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft })
|
|
this.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
|
|
this.friendListBtn = Util.GetGameObject(self.gameObject, "switchBtn/friendListBtn")
|
|
this.friendApplicationBtn = Util.GetGameObject(self.gameObject, "switchBtn/friendApplicationBtn")
|
|
this.friendSearchBtn = Util.GetGameObject(self.gameObject, "switchBtn/friendSearchBtn")
|
|
this.blackListBtn = Util.GetGameObject(self.gameObject, "switchBtn/blackListBtn")
|
|
this.friendListImage = Util.GetGameObject(self.gameObject, "switchBtn/friendListBtn/Image"):GetComponent("Image")
|
|
this.friendListSelect = Util.GetGameObject(self.gameObject, "switchBtn/friendListBtn/select")
|
|
this.friendListText = Util.GetGameObject(self.gameObject, "switchBtn/friendListBtn/Text"):GetComponent("Text")
|
|
this.friendApplicationImage = Util.GetGameObject(self.gameObject, "switchBtn/friendApplicationBtn/Image"):GetComponent("Image")
|
|
this.friendApplicationSelect = Util.GetGameObject(self.gameObject, "switchBtn/friendApplicationBtn/select")
|
|
this.friendApplicationText = Util.GetGameObject(self.gameObject, "switchBtn/friendApplicationBtn/Text"):GetComponent("Text")
|
|
this.friendSearchImage = Util.GetGameObject(self.gameObject, "switchBtn/friendSearchBtn/Image"):GetComponent("Image")
|
|
this.friendSearchSelect = Util.GetGameObject(self.gameObject, "switchBtn/friendSearchBtn/select")
|
|
this.friendSearchText = Util.GetGameObject(self.gameObject, "switchBtn/friendSearchBtn/Text"):GetComponent("Text")
|
|
this.blackListImage = Util.GetGameObject(self.gameObject, "switchBtn/blackListBtn/Image"):GetComponent("Image")
|
|
this.blackListSelect = Util.GetGameObject(self.gameObject, "switchBtn/blackListBtn/select")
|
|
this.blackListText = Util.GetGameObject(self.gameObject, "switchBtn/blackListBtn/Text"):GetComponent("Text")
|
|
this.blackListRemoveAllBtn=Util.GetGameObject(self.gameObject, "blackList/bottomImage/btn")
|
|
this.blackFriendNum=Util.GetGameObject(self.gameObject, "blackList/blackFriendNumber/blackFriendTextNumber"):GetComponent("Text")
|
|
this.friendList = Util.GetGameObject(self.gameObject, "friendList")
|
|
this.friendApplication = Util.GetGameObject(self.gameObject, "friendApplication")
|
|
this.friendSearch = Util.GetGameObject(self.gameObject, "friendSearch")
|
|
this.blackList = Util.GetGameObject(self.gameObject, "blackList")
|
|
this.item1 = Util.GetGameObject(self.gameObject, "friendList/item1")
|
|
this.item2 = Util.GetGameObject(self.gameObject, "friendApplication/item2")
|
|
this.item3 = Util.GetGameObject(self.gameObject, "friendSearch/item3")
|
|
this.item4 = Util.GetGameObject(self.gameObject, "blackList/item4")
|
|
this.friendListContentGrid = Util.GetGameObject(self.gameObject, "friendList/scrollRect")
|
|
this.friendApplicationContentGrid = Util.GetGameObject(self.gameObject, "friendApplication/scrollRect")
|
|
this.friendSearchContentGrid = Util.GetGameObject(self.gameObject, "friendSearch/scrollRect")
|
|
this.blackListContentGrid = Util.GetGameObject(self.gameObject, "blackList/scrollRect")
|
|
this.friendNumberText = Util.GetGameObject(self.gameObject, "friendList/friendNumber/friendTextNumber")
|
|
this.presentBtn = Util.GetGameObject(self.gameObject, "friendList/bottomImage/presentBtn")
|
|
this.receiveBtn = Util.GetGameObject(self.gameObject, "friendList/bottomImage/receiveBtn")
|
|
this.agreeAllBtn = Util.GetGameObject(self.gameObject, "friendApplication/bottomImage/agreeAllBtn")
|
|
this.refreshButton = Util.GetGameObject(self.gameObject, "refreshButton")
|
|
this.searchButton = Util.GetGameObject(self.gameObject, "friendSearch/bottomImage/searchButton")
|
|
this.applyAllButton = Util.GetGameObject(self.gameObject, "friendSearch/titleBgImage/appplyAll")
|
|
this.searchUserNameText = Util.GetGameObject(self.gameObject, "friendSearch/bottomImage/InputField/roleNameSearchText"):GetComponent("Text")
|
|
this.roleImage1 = Util.GetGameObject(self.gameObject, "friendList/roleImage")
|
|
this.roleImage2 = Util.GetGameObject(self.gameObject, "friendApplication/roleImage")
|
|
this.roleImage3 = Util.GetGameObject(self.gameObject, "friendSearch/roleImage")
|
|
this.roleImage4 = Util.GetGameObject(self.gameObject, "blackList/roleImage")
|
|
this.roleTalk1 = Util.GetGameObject(self.gameObject, "friendList/roleImage/talkImage/Text"):GetComponent("Text")
|
|
this.roleTalk2 = Util.GetGameObject(self.gameObject, "friendApplication/roleImage/talkImage/Text"):GetComponent("Text")
|
|
this.roleTalk3 = Util.GetGameObject(self.gameObject, "friendSearch/roleImage/talkImage/Text"):GetComponent("Text")
|
|
this.roleTalk4 = Util.GetGameObject(self.gameObject, "blackList/roleImage/talkImage/Text"):GetComponent("Text")
|
|
this.titleText = Util.GetGameObject(self.gameObject, "friendSearch/titleBgImage/titleText"):GetComponent("Text")
|
|
this.haveGetRewardNumText=Util.GetGameObject(self.gameObject, "friendList/haveGetRewardNum/haveGetRewardNumText"):GetComponent("Text")
|
|
this.mask = Util.GetGameObject(self.gameObject, "switchBtn/mask")
|
|
--GoodFriendManager.GetFriendInfoRequest(1)--1:好友, 2:推荐列表 3:申请列表
|
|
--GoodFriendManager.GetFriendInfoRequest(3)--1:好友, 2:推荐列表 3:申请列表
|
|
--GoodFriendManager.GetFriendInfoRequest(2)--1:好友, 2:推荐列表 3:申请列表
|
|
local v21 = this.friendListContentGrid:GetComponent("RectTransform").rect
|
|
this.ScrollView1 = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.friendListContentGrid.transform,
|
|
this.item1, nil, Vector2.New(-v21.x * 2, -v21.y * 2), 1, 1, Vector2.New(0, 15))
|
|
this.ScrollView1.moveTween.MomentumAmount = 1
|
|
this.ScrollView1.moveTween.Strength = 2
|
|
|
|
local v22 = this.friendApplicationContentGrid:GetComponent("RectTransform").rect
|
|
this.ScrollView2 = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.friendApplicationContentGrid.transform,
|
|
this.item2, nil, Vector2.New(-v22.x * 2, -v22.y * 2), 1, 1, Vector2.New(0, 15))
|
|
this.ScrollView2.moveTween.MomentumAmount = 1
|
|
this.ScrollView2.moveTween.Strength = 2
|
|
|
|
local v23 = this.friendSearchContentGrid:GetComponent("RectTransform").rect
|
|
this.ScrollView3 = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.friendSearchContentGrid.transform,
|
|
this.item3, nil, Vector2.New(-v23.x * 2, -v23.y * 2), 1, 1, Vector2.New(0, 15))
|
|
this.ScrollView3.moveTween.MomentumAmount = 1
|
|
this.ScrollView3.moveTween.Strength = 2
|
|
|
|
local v24 = this.blackListContentGrid:GetComponent("RectTransform").rect
|
|
this.ScrollView4 = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.blackListContentGrid.transform,
|
|
this.item4, nil, Vector2.New(-v24.x * 2, -v24.y * 2), 1, 1, Vector2.New(0, 15))
|
|
this.ScrollView4.moveTween.MomentumAmount = 1
|
|
this.ScrollView4.moveTween.Strength = 2
|
|
|
|
this.friendApplicationRedPoint = Util.GetGameObject(self.gameObject, "switchBtn/friendApplicationBtn/friendApplicationRedPoint")
|
|
this.friendListRedPoint = Util.GetGameObject(self.gameObject, "switchBtn/friendListBtn/friendListRedPoint")
|
|
this.getAllRedPoint = Util.GetGameObject(self.gameObject, "friendList/bottomImage/receiveBtn/GetAllRed")
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function GoodFriendMainPanel:BindEvent()
|
|
Util.AddClick(this.btnBack, function()
|
|
self:ClosePanel()
|
|
--UIManager.OpenPanel(UIName.MainPanel)
|
|
end)
|
|
Util.AddClick(this.blackListRemoveAllBtn, function()
|
|
GoodFriendManager.RequestDeleteFromBlackList(0, function()
|
|
PopupTipPanel.ShowTip(Language[10788])
|
|
end)
|
|
end)
|
|
|
|
Util.AddClick(this.presentBtn, function()
|
|
local isCanPresent = false
|
|
for i, v in pairs(GoodFriendManager.friendAllData) do
|
|
if (v.isGive == 0) then
|
|
isCanPresent = true
|
|
end
|
|
end
|
|
if (isCanPresent == true) then
|
|
GoodFriendManager.FriendGivePresentRequest(2, 0)
|
|
else
|
|
PopupTipPanel.ShowTip(Language[10789])
|
|
end
|
|
end)
|
|
Util.AddClick(this.receiveBtn, function()
|
|
if (GoodFriendManager.MaxEnergyGet >= 1) then
|
|
local isCanGet = false
|
|
for i, v in pairs(GoodFriendManager.friendAllData) do
|
|
if (v.haveReward == 1) then
|
|
isCanGet = true
|
|
end
|
|
end
|
|
if (isCanGet == true) then
|
|
GoodFriendManager.FriendTakeHeartRequest(2, 0)
|
|
else
|
|
PopupTipPanel.ShowTip(Language[10790])
|
|
end
|
|
else
|
|
PopupTipPanel.ShowTip(Language[10791])
|
|
end
|
|
end)
|
|
Util.AddClick(this.agreeAllBtn, function()
|
|
if (table.nums(GoodFriendManager.friendAllData) < GoodFriendManager.goodFriendLimit) then
|
|
if (table.nums(GoodFriendManager.friendApplicationData) > 0) then
|
|
GoodFriendManager.FriendInviteOperationRequest(3, 0)
|
|
else
|
|
PopupTipPanel.ShowTip(Language[10792])
|
|
end
|
|
else
|
|
PopupTipPanel.ShowTip(Language[10793])
|
|
end
|
|
end)
|
|
Util.AddClick(this.searchButton, function()
|
|
local userName = this.searchUserNameText.text
|
|
if (userName == "") then
|
|
PopupTipPanel.ShowTip(Language[10794])
|
|
else
|
|
GoodFriendManager.FriendSearchRequest(userName)
|
|
end
|
|
this.isInRecommendPage = false
|
|
this.titleText.text = Language[10795]
|
|
end)
|
|
Util.AddClick(this.refreshButton, function()
|
|
GoodFriendManager.RefreshRecommend(2)
|
|
this.titleText.text = Language[10796]
|
|
this.isInRecommendPage = true
|
|
end)
|
|
Util.AddClick(this.applyAllButton, function()
|
|
canApplyFriendsList={}
|
|
for i, v in pairs(GoodFriendManager.friendSearchData) do
|
|
local isFriend = GoodFriendManager.IsMyFriend(v.id)
|
|
if isFriend or v.isApplyed == 1 or (table.nums(GoodFriendManager.friendAllData) >= GoodFriendManager.goodFriendLimit)
|
|
or GoodFriendManager.IsInBlackList(v.id) then
|
|
else
|
|
table.insert(canApplyFriendsList,v.id)
|
|
end
|
|
end
|
|
if #canApplyFriendsList > 0 then
|
|
GoodFriendManager.InviteFriendRequest(canApplyFriendsList,function ()
|
|
PopupTipPanel.ShowTip(Language[10797])
|
|
this.BtnClickEvnet(3)
|
|
end)
|
|
else
|
|
PopupTipPanel.ShowTip(Language[10798])
|
|
end
|
|
end)
|
|
|
|
Util.AddClick(this.friendListBtn, function()
|
|
this.BtnClickEvnet(1)
|
|
end)
|
|
Util.AddClick(this.friendApplicationBtn, function()
|
|
this.BtnClickEvnet(2)
|
|
end)
|
|
Util.AddClick(this.friendSearchBtn, function()
|
|
this.BtnClickEvnet(3)
|
|
end)
|
|
Util.AddClick(this.blackListBtn, function()
|
|
this.BtnClickEvnet(4)
|
|
end)
|
|
|
|
-- 绑定红点
|
|
BindRedPointObject(RedPointType.Friend_Reward, this.friendListRedPoint)
|
|
BindRedPointObject(RedPointType.Friend_GetAllReward,this.getAllRedPoint)
|
|
BindRedPointObject(RedPointType.Friend_Application, this.friendApplicationRedPoint)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function GoodFriendMainPanel:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.Friend.OnFriendList, this.FriendListDataShow,self)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Friend.OnFriendApplication, this.FriendApplicationDataShow,self)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Friend.OnFriendSearch, this.FriendSearchDataShow,self)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Friend.OnBlackFriend, this.BlackListDataShow,self)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function GoodFriendMainPanel:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Friend.OnFriendList, this.FriendListDataShow,self)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Friend.OnFriendApplication, this.FriendApplicationDataShow,self)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Friend.OnFriendSearch, this.FriendSearchDataShow,self)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Friend.OnBlackFriend, this.BlackListDataShow,self)
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function GoodFriendMainPanel:OnOpen(...)
|
|
this.isPlayAnim = false
|
|
this.mask:SetActive(true)
|
|
Timer.New(function ()
|
|
this.isPlayAnim = true
|
|
this.mask:SetActive(false)
|
|
end,1):Start()
|
|
index = 1
|
|
local args = {...}
|
|
this.isBlackPage = args[1]
|
|
index = args[2] and args[2] or 1
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function GoodFriendMainPanel:OnShow()
|
|
this.roleImage1:SetActive(false)
|
|
this.roleImage2:SetActive(false)
|
|
this.roleImage3:SetActive(false)
|
|
this.roleImage4:SetActive(false)
|
|
this:FriendApplicationDataShow()
|
|
this.isInRecommendPage = true
|
|
this:OnRefreshData()
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.GoodFriend })
|
|
if(not this.isBlackPage) then
|
|
if(this.friendListRedPoint.activeSelf or (not this.friendApplicationRedPoint.activeSelf and not this.friendListRedPoint.activeSelf)) then
|
|
-- this.friendListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_001")
|
|
-- this.friendApplicationImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.friendSearchImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.blackListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
this.friendListText.text = Language[10799]
|
|
this.friendApplicationText.text = Language[10800]
|
|
this.friendSearchText.text = Language[10801]
|
|
this.blackListText.text = Language[10802]
|
|
this.friendList:SetActive(true)
|
|
this.friendApplication:SetActive(false)
|
|
this.friendSearch:SetActive(false)
|
|
this.blackList:SetActive(false)
|
|
this.friendListSelect:SetActive(true)
|
|
this.friendApplicationSelect:SetActive(false)
|
|
this.friendSearchSelect:SetActive(false)
|
|
this.blackListSelect:SetActive(false)
|
|
else
|
|
this.friendList:SetActive(false)
|
|
this.friendApplication:SetActive(true)
|
|
this.friendSearch:SetActive(false)
|
|
this.blackList:SetActive(false)
|
|
this.friendListSelect:SetActive(false)
|
|
this.friendApplicationSelect:SetActive(true)
|
|
this.friendSearchSelect:SetActive(false)
|
|
this.blackListSelect:SetActive(false)
|
|
-- this.friendListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.friendApplicationImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_001")
|
|
-- this.friendSearchImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.blackListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
this.friendListText.text = Language[10803]
|
|
this.friendApplicationText.text = Language[10804]
|
|
this.friendSearchText.text = Language[10801]
|
|
this.blackListText.text = Language[10802]
|
|
end
|
|
else
|
|
this.friendList:SetActive(false)
|
|
this.friendApplication:SetActive(false)
|
|
this.friendSearch:SetActive(false)
|
|
this.blackList:SetActive(true)
|
|
this.friendListSelect:SetActive(false)
|
|
this.friendApplicationSelect:SetActive(false)
|
|
this.friendSearchSelect:SetActive(false)
|
|
this.blackListSelect:SetActive(true)
|
|
-- this.friendListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.friendApplicationImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.friendSearchImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.blackListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_001")
|
|
this.friendListText.text = Language[10803]
|
|
this.friendApplicationText.text = Language[10800]
|
|
this.friendSearchText.text = Language[10801]
|
|
this.blackListText.text = Language[10805]
|
|
|
|
end
|
|
this.BtnClickEvnet(index)
|
|
end
|
|
|
|
--刷新界面数据
|
|
function GoodFriendMainPanel:OnRefreshData()
|
|
if (table.nums(GoodFriendManager.friendAllData) <= 0) then
|
|
this.roleImage1:SetActive(true)
|
|
this.roleTalk1.text = Language[10806]
|
|
else
|
|
this.roleImage1:SetActive(false)
|
|
end
|
|
if (table.nums(GoodFriendManager.friendApplicationData) <= 0) then
|
|
this.roleImage2:SetActive(true)
|
|
this.roleTalk2.text = Language[10792]
|
|
else
|
|
this.roleImage2:SetActive(false)
|
|
end
|
|
if (table.nums(GoodFriendManager.friendSearchData) > 0) then
|
|
this.roleImage3:SetActive(false)
|
|
else
|
|
this.roleImage3:SetActive(true)
|
|
this.roleTalk3.text = Language[10807]
|
|
end
|
|
if (this.isInRecommendPage) then
|
|
this.roleTalk3.text = Language[10808]
|
|
end
|
|
|
|
if (table.nums(GoodFriendManager.blackFriendList) <= 0) then
|
|
this.roleImage4:SetActive(true)
|
|
else
|
|
this.roleImage4:SetActive(false)
|
|
end
|
|
end
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function GoodFriendMainPanel:OnClose()
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function GoodFriendMainPanel:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
|
|
SubUIManager.Close(this.UpView)
|
|
ClearRedPointObject(RedPointType.Friend_Reward, this.friendListRedPoint)
|
|
ClearRedPointObject(RedPointType.Friend_GetAllReward,this.getAllRedPoint)
|
|
ClearRedPointObject(RedPointType.Friend_Application, this.friendApplicationRedPoint)
|
|
this.ScrollView1 = nil
|
|
this.ScrollView2 = nil
|
|
this.ScrollView3 = nil
|
|
this.ScrollView4 = nil
|
|
end
|
|
|
|
--好友列表循环滚动数据
|
|
function GoodFriendMainPanel:FriendListDataShow()
|
|
CheckRedPointStatus(RedPointType.Friend_GetAllReward)
|
|
this:OnRefreshData()
|
|
local list = {}
|
|
local j = 1
|
|
for i, v in pairs(GoodFriendManager.friendAllData) do
|
|
list[j] = v
|
|
if (table.nums(GoodFriendManager.friendAllData) > 1) then
|
|
if v.offLineTime == "0" then
|
|
list[j].onLineState = 1
|
|
else
|
|
list[j].onLineState = 2
|
|
end
|
|
end
|
|
j = j + 1
|
|
end
|
|
if (#list > 1) then
|
|
table.sort(list, function(a, b)
|
|
if a.onLineState == b.onLineState then
|
|
return tonumber(a.offLineTime) > tonumber(b.offLineTime)
|
|
else
|
|
return a.onLineState < b.onLineState
|
|
end
|
|
end)
|
|
end
|
|
-- for i = 1 ,100 do
|
|
-- local friendData = GoodFriendManager.CreateFriendData()
|
|
-- friendData.id = i
|
|
-- friendData.name = i.."name"
|
|
-- friendData.lv = i
|
|
-- friendData.offLineTime = 0
|
|
-- friendData.haveReward = 0
|
|
-- friendData.isGive = 0
|
|
-- friendData.head = 0
|
|
-- friendData.frame = 0
|
|
-- friendData.soulVal = 0
|
|
-- table.insert(list,friendData)
|
|
-- end
|
|
this.ScrollView1:SetData(list, function(index, item)
|
|
local itemData = list[index]
|
|
this:FriendListRefreshData(item, itemData)
|
|
end,true,this.isPlayAnim)
|
|
this.friendNumberText:GetComponent("Text").text = Language[10809] .. #list .. "/" .. GoodFriendManager.goodFriendLimit
|
|
this.haveGetRewardNumText.text=Language[10810]..(GoodFriendManager.MaxEnergy-GoodFriendManager.MaxEnergyGet).."/"..GoodFriendManager.MaxEnergy
|
|
end
|
|
--好友申请循环滚动数据
|
|
function GoodFriendMainPanel:FriendApplicationDataShow()
|
|
-- 检测红点
|
|
CheckRedPointStatus(RedPointType.Friend_Application)
|
|
this:OnRefreshData()
|
|
local list = {}
|
|
local j = 1
|
|
for i, v in pairs(GoodFriendManager.friendApplicationData) do
|
|
list[j] = v
|
|
if (table.nums(GoodFriendManager.friendApplicationData) > 1) then
|
|
if v.offLineTime == "0" then
|
|
list[j].onLineState = 1
|
|
else
|
|
list[j].onLineState = 2
|
|
end
|
|
end
|
|
j = j + 1
|
|
end
|
|
if (#list >= 1) then
|
|
this.friendApplicationRedPoint:SetActive(true)
|
|
table.sort(list, function(a, b)
|
|
if a.onLineState == b.onLineState then
|
|
return tonumber(a.offLineTime) > tonumber(b.offLineTime)
|
|
else
|
|
return a.onLineState < b.onLineState
|
|
end
|
|
end)
|
|
else
|
|
this.friendApplicationRedPoint:SetActive(false)
|
|
end
|
|
this.ScrollView2:SetData(list, function(index, item)
|
|
local itemData = list[index]
|
|
this:FriendApplicationRefreshData(item, itemData)
|
|
end,false,this.isPlayAnim)
|
|
end
|
|
|
|
--好友搜索循环滚动数据
|
|
function GoodFriendMainPanel:FriendSearchDataShow()
|
|
this:OnRefreshData()
|
|
local list = {}
|
|
local j = 1
|
|
for i, v in pairs(GoodFriendManager.friendSearchData) do
|
|
list[j] = v
|
|
if (table.nums(GoodFriendManager.friendSearchData) > 1) then
|
|
if v.offLineTime == "0" then
|
|
list[j].onLineState = 1
|
|
else
|
|
list[j].onLineState = 2
|
|
end
|
|
end
|
|
j = j + 1
|
|
end
|
|
if (#list > 1) then
|
|
table.sort(list, function(a, b)
|
|
if a.onLineState == b.onLineState then
|
|
return tonumber(a.offLineTime) > tonumber(b.offLineTime)
|
|
else
|
|
return a.onLineState < b.onLineState
|
|
end
|
|
end)
|
|
end
|
|
this.ScrollView3:SetData(list, function(index, item)
|
|
local itemData = list[index]
|
|
this:FriendSearchRefreshData(item, itemData)
|
|
end,false,this.isPlayAnim)
|
|
end
|
|
|
|
--黑名单滚动数据
|
|
function GoodFriendMainPanel:BlackListDataShow()
|
|
this:OnRefreshData()
|
|
local list = {}
|
|
local j = 1
|
|
for i, v in pairs(GoodFriendManager.blackFriendList) do
|
|
list[j] = v
|
|
if (table.nums(GoodFriendManager.blackFriendList) > 1) then
|
|
if v.offLineTime == "0" then
|
|
list[j].onLineState = 1
|
|
else
|
|
list[j].onLineState = 2
|
|
end
|
|
end
|
|
j = j + 1
|
|
end
|
|
if (#list > 1) then
|
|
table.sort(list, function(a, b)
|
|
if a.onLineState == b.onLineState then
|
|
return tonumber(a.offLineTime) > tonumber(b.offLineTime)
|
|
else
|
|
return a.onLineState < b.onLineState
|
|
end
|
|
end)
|
|
end
|
|
this.ScrollView4:SetData(list, function(index, item)
|
|
local itemData = list[index]
|
|
this:BlackListRefreshData(item, itemData)
|
|
end,false,this.isPlayAnim)
|
|
this.blackFriendNum.text= Language[10811] .. #list .. "/" .. GoodFriendManager.blackFriendLimit
|
|
end
|
|
|
|
|
|
--好友
|
|
function GoodFriendMainPanel:FriendListRefreshData(item, itemData)
|
|
local head = Util.GetGameObject(item, "friendHeadIcon")
|
|
head:GetComponent("Image").sprite = GetPlayerHeadSprite(this.spLoader, itemData.head)
|
|
Util.GetGameObject(item, "friendHeadIcon/friendHeadFrame"):GetComponent("Image").sprite = GetPlayerHeadFrameSprite(this.spLoader, itemData.frame)
|
|
Util.GetGameObject(item, "Image/nameText"):GetComponent("Text").text = itemData.name
|
|
Util.GetGameObject(item, "lvbg/levelText"):GetComponent("Text").text = itemData.lv
|
|
local deleteFriendBtn = Util.GetGameObject(item, "deleteFriend")
|
|
local givingEnergyBtn = Util.GetGameObject(item, "givingEnergy")
|
|
local presentEnergyBtn = Util.GetGameObject(item, "presentEnergy")
|
|
local haveEnergyBtn = Util.GetGameObject(item, "havePresent")
|
|
local sendMessageBtn = Util.GetGameObject(item, "sendMessage")
|
|
if (itemData.offLineTime == "0") then
|
|
Util.GetGameObject(item, "Image/bg"):SetActive(true)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):SetActive(false)
|
|
else
|
|
Util.GetGameObject(item, "Image/bg"):SetActive(false)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):SetActive(true)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):GetComponent("Text").text = this:ShowTime(itemData.offLineTime)
|
|
end
|
|
if (GoodFriendManager.MaxEnergyGet >= 1) then
|
|
if (itemData.isGive == 0) then
|
|
Util.GetGameObject(item, "givingEnergy"):SetActive(false)
|
|
Util.GetGameObject(item, "presentEnergy"):SetActive(true)
|
|
Util.GetGameObject(item, "havePresent"):SetActive(false)
|
|
end
|
|
if (itemData.haveReward == 1) then
|
|
Util.GetGameObject(item, "givingEnergy"):SetActive(true)
|
|
Util.GetGameObject(item, "presentEnergy"):SetActive(false)
|
|
Util.GetGameObject(item, "havePresent"):SetActive(false)
|
|
Util.GetGameObject(item, "givingEnergy/givingEnergyRedPoint"):SetActive(true)
|
|
end
|
|
else
|
|
if (itemData.haveReward == 1) then
|
|
Util.GetGameObject(item, "givingEnergy"):SetActive(true)
|
|
Util.GetGameObject(item, "presentEnergy"):SetActive(false)
|
|
Util.GetGameObject(item, "havePresent"):SetActive(false)
|
|
Util.GetGameObject(item, "givingEnergy/givingEnergyRedPoint"):SetActive(false)
|
|
end
|
|
if (itemData.isGive == 0) then
|
|
Util.GetGameObject(item, "givingEnergy"):SetActive(false)
|
|
Util.GetGameObject(item, "presentEnergy"):SetActive(true)
|
|
Util.GetGameObject(item, "havePresent"):SetActive(false)
|
|
end
|
|
end
|
|
if (itemData.isGive == 1 and itemData.haveReward == 0) then
|
|
Util.GetGameObject(item, "givingEnergy"):SetActive(false)
|
|
Util.GetGameObject(item, "presentEnergy"):SetActive(false)
|
|
Util.GetGameObject(item, "havePresent"):SetActive(true)
|
|
end
|
|
Util.AddOnceClick(deleteFriendBtn, function()
|
|
local tip = string.format(Language[10812], itemData.name)
|
|
MsgPanel.ShowTwo(tip, nil, function()
|
|
GoodFriendManager.DelFriendRequest(itemData.id)
|
|
end)
|
|
end)
|
|
Util.AddOnceClick(givingEnergyBtn, function()
|
|
if (GoodFriendManager.MaxEnergyGet >= 1) then
|
|
GoodFriendManager.FriendTakeHeartRequest(1, itemData.id)
|
|
else
|
|
PopupTipPanel.ShowTip(Language[10791])
|
|
end
|
|
end)
|
|
Util.AddOnceClick(presentEnergyBtn, function()
|
|
GoodFriendManager.FriendGivePresentRequest(1, itemData.id)
|
|
end)
|
|
Util.AddOnceClick(haveEnergyBtn, function()
|
|
PopupTipPanel.ShowTip(Language[10813])
|
|
end)
|
|
Util.AddOnceClick(sendMessageBtn, function()
|
|
UIManager.OpenPanel(UIName.FriendChatPanel, itemData.id)
|
|
end)
|
|
|
|
Util.AddOnceClick(head, function()
|
|
UIManager.OpenPanel(UIName.PlayerInfoPopup, itemData.id)
|
|
end)
|
|
|
|
end
|
|
-- 好友申请
|
|
function GoodFriendMainPanel:FriendApplicationRefreshData(item, itemData)
|
|
local head = Util.GetGameObject(item, "friendHeadIcon")
|
|
head:GetComponent("Image").sprite = GetPlayerHeadSprite(this.spLoader, itemData.head)
|
|
Util.GetGameObject(item, "friendHeadIcon/friendHeadFrame"):GetComponent("Image").sprite = GetPlayerHeadFrameSprite(this.spLoader, itemData.frame)
|
|
item.gameObject:SetActive(true)
|
|
Util.GetGameObject(item, "Image/nameText"):GetComponent("Text").text = itemData.name
|
|
Util.GetGameObject(item, "lvbg/levelText"):GetComponent("Text").text = itemData.lv
|
|
local agreeBtn = Util.GetGameObject(item, "agree")
|
|
local refuseBtn = Util.GetGameObject(item, "refuse")
|
|
if (itemData.offLineTime == "0") then
|
|
Util.GetGameObject(item, "Image/bg"):SetActive(true)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):SetActive(false)
|
|
else
|
|
Util.GetGameObject(item, "Image/bg"):SetActive(false)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):SetActive(true)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):GetComponent("Text").text = this:ShowTime(itemData.offLineTime)
|
|
end
|
|
Util.AddOnceClick(agreeBtn, function()
|
|
if GoodFriendManager.IsInBlackList(itemData.id) then
|
|
PopupTipPanel.ShowTip(Language[10814])
|
|
return
|
|
end
|
|
if (table.nums(GoodFriendManager.friendAllData) < GoodFriendManager.goodFriendLimit) then
|
|
GoodFriendManager.FriendInviteOperationRequest(1, itemData.id)
|
|
else
|
|
PopupTipPanel.ShowTip(Language[10793])
|
|
end
|
|
end)
|
|
Util.AddOnceClick(refuseBtn, function()
|
|
GoodFriendManager.FriendInviteOperationRequest(2, itemData.id)
|
|
end)
|
|
Util.AddOnceClick(head, function()
|
|
UIManager.OpenPanel(UIName.PlayerInfoPopup, itemData.id)
|
|
end)
|
|
end
|
|
-- 好友搜索
|
|
function GoodFriendMainPanel:FriendSearchRefreshData(item, itemData)
|
|
local head = Util.GetGameObject(item, "friendHeadIcon")
|
|
head:GetComponent("Image").sprite = GetPlayerHeadSprite(this.spLoader, itemData.head)
|
|
Util.GetGameObject(item, "friendHeadIcon/friendHeadFrame"):GetComponent("Image").sprite = GetPlayerHeadFrameSprite(this.spLoader, itemData.frame)
|
|
|
|
Util.GetGameObject(item, "Image/nameText"):GetComponent("Text").text = itemData.name
|
|
Util.GetGameObject(item, "lvbg/levelText"):GetComponent("Text").text = itemData.lv
|
|
local applicationFriendBtn = Util.GetGameObject(item, "applicationFriend")
|
|
local applicationFriendText = Util.GetGameObject(item, "applicationFriend/applicationFriendText"):GetComponent("Text")
|
|
if (itemData.offLineTime == "0") then
|
|
Util.GetGameObject(item, "Image/bg"):SetActive(true)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):SetActive(false)
|
|
else
|
|
Util.GetGameObject(item, "Image/bg"):SetActive(false)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):SetActive(true)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):GetComponent("Text").text = this:ShowTime(itemData.offLineTime)
|
|
end
|
|
local isFriend = GoodFriendManager.IsMyFriend(itemData.id)
|
|
if isFriend then
|
|
Util.SetGray(applicationFriendBtn, true)
|
|
applicationFriendText.text = Language[10815]
|
|
elseif itemData.isApplyed == 1 then
|
|
Util.SetGray(applicationFriendBtn, true)
|
|
applicationFriendText.text = Language[10816]
|
|
else
|
|
Util.SetGray(applicationFriendBtn, false)
|
|
applicationFriendText.text = Language[10817]
|
|
end
|
|
|
|
Util.AddOnceClick(applicationFriendBtn, function()
|
|
if isFriend then
|
|
PopupTipPanel.ShowTip(Language[10818])
|
|
return
|
|
end
|
|
if itemData.isApplyed == 1 then
|
|
PopupTipPanel.ShowTip(Language[10819])
|
|
return
|
|
end
|
|
if (table.nums(GoodFriendManager.friendAllData) >= GoodFriendManager.goodFriendLimit) then
|
|
PopupTipPanel.ShowTip(Language[10793])
|
|
return
|
|
end
|
|
if GoodFriendManager.IsInBlackList(itemData.id) then
|
|
PopupTipPanel.ShowTip(Language[10814])
|
|
return
|
|
end
|
|
GoodFriendManager.InviteFriendRequest(itemData.id,function ()
|
|
PopupTipPanel.ShowTip(Language[10797])
|
|
end)
|
|
end)
|
|
Util.AddOnceClick(head, function()
|
|
UIManager.OpenPanel(UIName.PlayerInfoPopup, itemData.id)
|
|
end)
|
|
end
|
|
|
|
-- 黑名单
|
|
function GoodFriendMainPanel:BlackListRefreshData(item, itemData)
|
|
local head = Util.GetGameObject(item, "friendHeadIcon")
|
|
head:GetComponent("Image").sprite = GetPlayerHeadSprite(this.spLoader, itemData.head)
|
|
Util.GetGameObject(item, "friendHeadIcon/friendHeadFrame"):GetComponent("Image").sprite = GetPlayerHeadFrameSprite(this.spLoader, itemData.frame)
|
|
Util.GetGameObject(item, "Image/nameText"):GetComponent("Text").text = itemData.name
|
|
Util.GetGameObject(item, "lvbg/levelText"):GetComponent("Text").text = itemData.lv
|
|
if (itemData.offLineTime == "0") then
|
|
Util.GetGameObject(item, "Image/bg"):SetActive(true)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):SetActive(false)
|
|
else
|
|
Util.GetGameObject(item, "Image/bg"):SetActive(false)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):SetActive(true)
|
|
Util.GetGameObject(item, "Image/lastOnlineText"):GetComponent("Text").text = this:ShowTime(itemData.offLineTime)
|
|
end
|
|
|
|
local removeBlackListBtn = Util.GetGameObject(item, "deleteFriend")
|
|
Util.AddOnceClick(removeBlackListBtn, function()
|
|
GoodFriendManager.RequestDeleteFromBlackList(itemData.id, function()
|
|
PopupTipPanel.ShowTip(Language[10788])
|
|
end)
|
|
end)
|
|
Util.AddOnceClick(head, function()
|
|
UIManager.OpenPanel(UIName.PlayerInfoPopup, itemData.id, PLAYER_INFO_VIEW_TYPE.BLACK_REMOVE)
|
|
end)
|
|
end
|
|
|
|
--格式化时间
|
|
function GoodFriendMainPanel:ShowTime(time)
|
|
local onlineTime = math.floor(PlayerManager.serverTime - time / 1000)
|
|
local timeText = ""
|
|
if (onlineTime < 60) then
|
|
timeText = Language[10820]
|
|
return timeText
|
|
elseif (onlineTime >= 60 and onlineTime < 3600) then
|
|
timeText = math.floor(onlineTime / 60) .. Language[10821]
|
|
return timeText
|
|
elseif (onlineTime >= 3600 and onlineTime < 3600 * 24) then
|
|
timeText = math.floor(onlineTime / 3600) .. Language[10822]
|
|
return timeText
|
|
elseif (onlineTime >= 3600 * 24 and onlineTime <= 3600 * 24 * 30) then
|
|
timeText = math.floor(onlineTime / (3600 * 24)) .. Language[10823]
|
|
return timeText
|
|
elseif (onlineTime > 3600 * 24 * 30) then
|
|
timeText = Language[10824]
|
|
return timeText
|
|
end
|
|
end
|
|
function this.BtnClickEvnet(index)
|
|
if index == 1 then
|
|
this.friendList:SetActive(true)
|
|
this.friendApplication:SetActive(false)
|
|
this.friendSearch:SetActive(false)
|
|
this.blackList:SetActive(false)
|
|
-- this.friendListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_001")
|
|
this.friendListSelect:SetActive(true)
|
|
this.friendApplicationSelect:SetActive(false)
|
|
this.friendSearchSelect:SetActive(false)
|
|
this.blackListSelect:SetActive(false)
|
|
--this.friendApplicationImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.friendSearchImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.blackListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
this.friendListText.text = Language[10799]
|
|
this.friendApplicationText.text = Language[10800]
|
|
this.friendSearchText.text = Language[10801]
|
|
this.blackListText.text = Language[10802]
|
|
GoodFriendManager.RefreshFriendStateRequest()
|
|
elseif index == 2 then
|
|
this.friendList:SetActive(false)
|
|
this.friendApplication:SetActive(true)
|
|
this.friendSearch:SetActive(false)
|
|
this.blackList:SetActive(false)
|
|
this.friendListSelect:SetActive(false)
|
|
this.friendApplicationSelect:SetActive(true)
|
|
this.friendSearchSelect:SetActive(false)
|
|
this.blackListSelect:SetActive(false)
|
|
-- this.friendListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.friendApplicationImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_001")
|
|
-- this.friendSearchImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.blackListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
this.friendListText.text = Language[10803]
|
|
this.friendApplicationText.text = Language[10804]
|
|
this.friendSearchText.text = Language[10801]
|
|
this.blackListText.text = Language[10802]
|
|
elseif index == 3 then
|
|
this.friendList:SetActive(false)
|
|
this.friendApplication:SetActive(false)
|
|
this.friendSearch:SetActive(true)
|
|
this.blackList:SetActive(false)
|
|
this.friendListSelect:SetActive(false)
|
|
this.friendApplicationSelect:SetActive(false)
|
|
this.friendSearchSelect:SetActive(true)
|
|
this.blackListSelect:SetActive(false)
|
|
-- this.friendListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.friendApplicationImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.friendSearchImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_001")
|
|
-- this.blackListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
this.friendListText.text = Language[10803]
|
|
this.friendApplicationText.text = Language[10800]
|
|
this.friendSearchText.text = Language[10825]
|
|
this.blackListText.text = Language[10802]
|
|
GoodFriendManager.RefreshRecommend(2)
|
|
elseif index == 4 then
|
|
this.friendList:SetActive(false)
|
|
this.friendApplication:SetActive(false)
|
|
this.friendSearch:SetActive(false)
|
|
this.blackList:SetActive(true)
|
|
this.friendListSelect:SetActive(false)
|
|
this.friendApplicationSelect:SetActive(false)
|
|
this.friendSearchSelect:SetActive(false)
|
|
this.blackListSelect:SetActive(true)
|
|
-- this.friendListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.friendApplicationImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.friendSearchImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_002")
|
|
-- this.blackListImage.sprite = this.spLoader:LoadSprite("r_hero_xuanze_001")
|
|
this.friendListText.text = Language[10803]
|
|
this.friendApplicationText.text = Language[10800]
|
|
this.friendSearchText.text = Language[10801]
|
|
this.blackListText.text = Language[10805]
|
|
GoodFriendManager.RefreshRecommend(4)
|
|
end
|
|
end
|
|
return GoodFriendMainPanel
|
|
|