123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- using LitJson;
- using SC.XR.Unity;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- public class InviteDlg : UnitySingleton<InviteDlg>
- {
- public Button searchBtn;
- public Button inviteBtn;
- public Button clearBtn;
- public Button closeBtn;
- public GameObject noLinkMan;
- public Text shoumsgText;
- public SCInputField searchInputField;
- public UserList userList;
- public GameObject hisTextObj;
- public Image inviteBtnImage;
- public List<InviteUserConfig> InviteUnionIdList = new List<InviteUserConfig>();//选择还未被邀请
- public List<InviteUserConfig> InvitingUnionIdList = new List<InviteUserConfig>();//已经邀请了还没同意或者拒绝
- // Start is called before the first frame update
- protected override void Awake()
- {
- base.Awake();
- WSHandler.Office.OnUserSearch += UserSearch;
- WSHandler.Office.OnInviteUsers += InviteUsers;
- WSHandler.Office.OnCallRecordsList += CallRecordsList;
- }
- protected override void OnDestroy()
- {
- base.OnDestroy();
- WSHandler.Office.OnUserSearch -= UserSearch;
- WSHandler.Office.OnInviteUsers -= InviteUsers;
- WSHandler.Office.OnCallRecordsList -= CallRecordsList;
- }
- private void InviteUsers(JsonData data)
- {
- if (data["data"]["code"].ToString() == "200")
- {
- for (int i = 0; i < InviteUnionIdList.Count; i++)
- {
- InvitingUnionIdList.Add(InviteUnionIdList[i]);
- }
- InviteUnionIdList.Clear();
- RoomOtherUser.Instance.UpdateList();
- }
- }
- private List<InviteUserConfig> inviteUserConfigList = new List<InviteUserConfig>();
- private void UserSearch(JsonData data)
- {
- switch (data["data"]["code"].ToString())
- {
- case "200":
- HideHistory();
- if (inviteUserConfigList.Count > 0)
- {
- inviteUserConfigList.Clear();
- }
- if (data["data"]["data"].Count > 0)
- {
- noLinkMan.SetActive(false);
- for (int i = 0; i < data["data"]["data"].Count; i++)
- {
- InviteUserConfig inviteUserConfig = new InviteUserConfig(data["data"]["data"][i]["unionId"].ToString(), data["data"]["data"][i]["phone"].ToString(), data["data"]["data"][i]["avatar"].ToString(), data["data"]["data"][i]["nickName"].ToString(), data["data"]["data"][i]["online"].ToString());
- inviteUserConfigList.Add(inviteUserConfig);
- }
- userList.Init(inviteUserConfigList);
- inviteUserConfigList.Clear();
- }
- else
- {
- noLinkMan.SetActive(true);
- shoumsgText.text = "无有效的联系人";
- }
- break;
- case "5001":
- HideHistory();
- noLinkMan.SetActive(true);
- shoumsgText.text = "无有效的联系人";
- break;
- default:
- break;
- }
- }
- private List<InviteUserConfig> historyConfigList = new List<InviteUserConfig>();
- public void ShowHistory()
- {
- InviteUnionIdList.Clear();
- clearBtn.gameObject.SetActive(false);
- userList.DestoryAll();
- hisTextObj.SetActive(true);
- InitInviteBtn();
- WSHandler.Office.GetRecordsList();
- }
- private List<InviteUserConfig> zaixianList = new List<InviteUserConfig>();
- private List<InviteUserConfig> mangluList = new List<InviteUserConfig>();
- private List<InviteUserConfig> lixianList = new List<InviteUserConfig>();
- private void AddHisInviteUserList(List<InviteUserConfig> inviteUserConfigs)
- {
- if (inviteUserConfigs.Count > 0)
- {
- for (int i = 0; i < inviteUserConfigs.Count; i++)
- {
- historyConfigList.Add(inviteUserConfigs[i]);
- }
- }
- }
- private void CallRecordsList(JsonData data)
- {
- if (data.Keys.Contains("data"))
- {
- if (data["data"]["data"].Count > 0)
- {
- noLinkMan.SetActive(false);
- for (int i = 0; i < data["data"]["data"].Count; i++)
- {
- if (!string.IsNullOrEmpty(data["data"]["data"][i]["nickName"].ToString()))
- {
- InviteUserConfig inviteUserConfig = new InviteUserConfig(data["data"]["data"][i]["contacts"].ToString(), data["data"]["data"][i]["phone"].ToString(), data["data"]["data"][i]["avatar"].ToString(), data["data"]["data"][i]["nickName"].ToString(), data["data"]["data"][i]["online"].ToString());
- switch (data["data"]["data"][i]["online"].ToString())
- {
- case "1":
- zaixianList.Add(inviteUserConfig);
- break;
- case "2":
- mangluList.Add(inviteUserConfig);
- break;
- case "0":
- lixianList.Add(inviteUserConfig);
- break;
- }
- }
- }
- AddHisInviteUserList(zaixianList);
- AddHisInviteUserList(mangluList);
- AddHisInviteUserList(lixianList);
- userList.Init(historyConfigList);
- zaixianList.Clear();
- mangluList.Clear();
- lixianList.Clear();
- historyConfigList.Clear();
- }
- else
- {
- noLinkMan.SetActive(true);
- shoumsgText.text = "暂时无记录";
- }
- }
- else
- {
- noLinkMan.SetActive(true);
- shoumsgText.text = "暂时无记录";
- }
- }
- public void HideHistory()
- {
- userList.DestoryAll();
- hisTextObj.SetActive(false);
- }
- void Start()
- {
- searchBtn.onClick.AddListener(ClickOnSearch);
- clearBtn.onClick.AddListener(ClickOnClear);
- closeBtn.onClick.AddListener(ClickOnClose);
- searchInputField.onValueChanged.AddListener(Inputscearchchanged);
- inviteBtn.onClick.AddListener(ClickOnInvite);
- //searchInputField.onEndEdit.AddListener(InputsearchEnd);
- }
- public void InitInviteBtn()
- {
- inviteBtn.enabled = false;
- Color color = Color.white;
- color.r = 71 / 255f;
- color.g = 126 / 255f;
- color.b = 186 / 255f;
- color.a = 220 / 255f;
- inviteBtnImage.color = color;
- }
- public void RecoverInviteBtn()
- {
- inviteBtn.enabled = true;
- Color color = Color.white;
- color.r = 76 / 255f;
- color.g = 166 / 255f;
- color.b = 255 / 255f;
- color.a = 230 / 255f;
- inviteBtnImage.color = color;
- }
- private void ClickOnInvite()
- {
- if (InvitingUnionIdList != null && InviteUnionIdList != null && InviteUnionIdList.Count > 0)
- {
- if (IsContains(InvitingUnionIdList, InviteUnionIdList))
- {
- PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "邀请列表有用户正在通话中");
- }
- else
- {
- if (!string.IsNullOrEmpty(RoomMainInfo.roomNum))
- {
- if (RemoteRtc.Instance.customPeerList != null)
- {
- if (RemoteRtc.Instance.customPeerList.getPeers().Count + InvitingUnionIdList.Count + InviteUnionIdList.Count > RoomMainInfo.roomMaxPeopleNum - 1)
- {
- PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, "房间人数大于房间总人数");
- }
- else
- {
- this.gameObject.SetActive(false);
- WSHandler.Office.InviteUsers(RoomMainInfo.roomNum, InviteUnionIdList);
- ClickOnClear();
- }
- }
- }
- }
- }
- }
- public bool IsContains(List<InviteUserConfig> vs1, List<InviteUserConfig> vs2)
- {
- List<InviteUserConfig> vs3 = new List<InviteUserConfig>();
- vs3 = vs1.Intersect(vs2).ToList();
- if (vs3.Count > 0)
- {
- vs3 = null;
- return true;
- }
- else
- {
- vs3 = null;
- return false;
- }
- }
- //private void InputsearchEnd(string content)
- //{
- // if (content != "")
- // {
- // clearBtn.gameObject.SetActive(true);
- // }
- //}
- private void Inputscearchchanged(string content)
- {
- if (content == "")
- {
- if (gameObject.activeSelf)
- {
- ShowHistory();
- clearBtn.gameObject.SetActive(false);
- }
- }
- else
- {
- clearBtn.gameObject.SetActive(true);
- }
- }
- private void ClickOnSearch()
- {
- if (searchInputField.text != "")
- {
- if (searchInputField.text.Length >2)
- {
- WSHandler.Office.UserSearch(searchInputField.text);
- }
- else
- {
- HideHistory();
- noLinkMan.SetActive(true);
- shoumsgText.text = "无有效的联系人";
- }
- }
- }
- private void ClickOnClear()
- {
- if (searchInputField.text != "")
- {
- searchInputField.text = "";
- }
- clearBtn.gameObject.SetActive(false);
- }
- private void ClickOnClose()
- {
- InviteUnionIdList.Clear();
- this.gameObject.SetActive(false);
- ClickOnClear();
- }
- }
|