//查询联系人列表 public void SearchContact(string nickName, string sex, string typeName) { ServiceUser.searchContact(nickName, sex, typeName, (contactObj) => { if (contactObj.code == 200) { for (int i = 0; i < _contactCellRect.content.childCount; i++) { GameObject go = _contactCellRect.content.GetChild(i).gameObject; Destroy(go); } foreach (NickNameResponseModel nickNameModel in contactObj.contacts) { GameObject cell = Instantiate(_contactCellPfb); ContactCell contactCell = cell.GetComponent <ContactCell>(); contactCell.Init(nickNameModel.contactId, nickNameModel.nickName, readContact, deleteContact); cell.transform.SetParent(_contactCellRect.content); } GameObject defaultCell = Instantiate(_contactCellPfb); ContactCell defaultContactCell = defaultCell.GetComponent <ContactCell>(); defaultContactCell.onClickCellDelegate = (id) => { CreateCell(); }; defaultContactCell.SetDefault(); defaultCell.transform.SetParent(_contactCellRect.content); } else { ProgressHUDManager.showComfirmHUD(contactObj.msg); } }); }
IEnumerator setupNetworkConnect() { NetworkBase.Reset(); yield return(null); Debug.Log("开始连接"); ServiceGate.connect((JsonObject obj) => { ServiceGate.queryEntry(((EntryResponse result) => { if (result.code == 200) { ProgressHUDManager.showHUD("正在连接服务器"); int localPort = LocalDataModel.currentLoginPort; LocalDataModel.host = result.host; LocalDataModel.port = (localPort != 0) ? localPort : result.port; ServiceUser.connect((JsonObject connectResult) => { Debug.Log("连接成功"); ProgressHUDManager.hideCurrentHUD(); SceneManager.LoadScene("Login"); }); } })); }); }
private void safeCallCallback(Action <bool> callback, bool result) { ProgressHUDManager.hideCurrentHUD(); isReconnecting = false; if (callback != null) { callback(result); } }
public void CreateSlogan(TypeSlogan slogan) { if (_typesSloganRect.content.childCount > 101) { ProgressHUDManager.showComfirmHUD("类别已满上限,请清除无用类别"); return; } slogan.typeName = ""; slogan.isEditor = true; }
public void CreateCell() { if (_contactCellRect.content.childCount > 1001) { ProgressHUDManager.showComfirmHUD("联系人已满上限,请清除无用联系人"); return; } addressMessage.SetDefault(); addressMessage.isEditor = true; addressMessage.updateOrCreateDelegate = addContact; selectId = 0; }
private static void reconnectGate(Action <JsonObject> callback) { ProgressHUDManager.showYesOrNoHUD("网络无法连接,点击“确定”重试", (bool yesOrNo) => { if (yesOrNo) { connect(callback); } else { ProgressHUDManager.showComfirmHUD("连接中止,重连请重启"); } }); }
private void logOff() { ProgressHUDManager.showYesOrNoHUD("确认注销账户吗?", (yes) => { if (yes) { LocalDataModel.userName = null; LocalDataModel.password = null; LocalDataModel.isLogin = false; SceneManager.LoadScene("Login"); } }); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { ProgressHUDManager.showYesOrNoHUD("确定退出吗?", (bool yesOrNo) => { if (yesOrNo) { Application.Quit(); } }); } }
private IEnumerator timeOutCounter(Action <JsonObject> callback) { yield return(new WaitForSeconds(timeoutTime)); ProgressHUDManager.showComfirmHUD("连接网络超时,请检查网络设置", () => { ProgressHUDManager.hideCurrentHUD(); if (callback != null) { JsonObject obj = new JsonObject(); obj.Add("timeout", true); callback(obj); } }); }
public void reconnect(Action <bool> callback, bool needLogin) { if (isReconnecting == true) { return; } Loom.QueueOnMainThread(() => { ProgressHUDManager.showComfirmHUD("已断开连接,点击“确认”重连", () => { Debug.Log("开始重连"); if (Application.internetReachability == NetworkReachability.NotReachable) { Debug.Log("网络不通"); ProgressHUDManager.showComfirmHUD("连接失败,请检查网络状态", () => { reconnect(callback); }); return; } isReconnecting = true; if (pclient != null) { refreshPclient(); } ProgressHUDManager.showHUD("正在重新连接"); connectToServer((JsonObject obj) => { BaseModel model = new BaseModel(obj); if (model.timeout) // 判断连接超时 { isReconnecting = false; reconnect(callback); return; } Debug.Log("重新连接结束, 正在尝试登陆"); ServiceUser.login(LocalDataModel.userId, LocalDataModel.password, (UserModel user) => { if (user.code == 200) { Debug.Log("登陆成功"); notifyLoginComplete(user); } else { Debug.Log("登陆失败"); safeCallCallback(callback, false); } }); }); }); }); }
private void modifyPassword(string password) { ServiceUser.modifyPassword(password, (responseObj) => { if (responseObj.code == 200) { ProgressHUDManager.showTipMsgHUD(responseObj.msg); _passwordPanel.gameObject.SetActive(false); isOpenPwPanel = false; } else { ProgressHUDManager.showComfirmHUD(responseObj.msg); } }); }
private void onClickConfirm() { if (password == "" || confirmPw == "") { ProgressHUDManager.showTipMsgHUD("请输入密码"); } else if (password != confirmPw) { ProgressHUDManager.showTipMsgHUD("确认密码不一致"); } else if (modifyPasswordDelegate != null) { modifyPasswordDelegate(password); } }
private void addType(TypeSlogan slogan)//为标签管理添加新的标签 { ServiceUser.addType(slogan.typeName, (responseObj) => { if (responseObj.code == 200) { ProgressHUDManager.showTipMsgHUD(responseObj.msg); showType(); } else { ProgressHUDManager.showComfirmHUD(responseObj.msg); slogan.SetDefault(); slogan.isEditor = false; } }); }
private void showType() { ServiceUser.showType((typeObj) => { if (typeObj.code == 200) { for (int i = 0; i < _typesSloganRect.content.childCount; i++) { GameObject go = _typesSloganRect.content.GetChild(i).gameObject; Destroy(go); } int row = typeObj.types.Count / 5; if (row >= 3) { _typesSloganRect.content.GetComponent <RectTransform>().sizeDelta = new Vector2(0, _sloganRectHeight * row); } else { _typesSloganRect.content.GetComponent <RectTransform>().sizeDelta = new Vector2(0, _sloganRectHeight); } foreach (ContactTypeModel typeModel in typeObj.types) { GameObject sloganObj = Instantiate(typeSloganPfb); TypeSlogan slogan = sloganObj.GetComponent <TypeSlogan>(); slogan.typeName = typeModel.typeName; slogan.typeId = typeModel.typeId; slogan.onClickSloganDelegate = setSearchTypeName; slogan.onEndEditDelegate = updateSlogan; slogan.onSlotEndDelegate = newType; slogan.onDropEndDelegate = dropType; sloganObj.transform.SetParent(_typesSloganRect.content); } GameObject defaultSloganObj = Instantiate(typeSloganPfb); TypeSlogan defaultSlogan = defaultSloganObj.GetComponent <TypeSlogan>(); defaultSlogan.onClickSloganDelegate = CreateSlogan; defaultSlogan.onEndEditDelegate = addType; defaultSlogan.SetDefault(); defaultSloganObj.transform.SetParent(_typesSloganRect.content); } else { ProgressHUDManager.showComfirmHUD(typeObj.msg); } }); }
private void updateSlogan(TypeSlogan slogan) { ServiceUser.updateType(slogan.typeId, slogan.typeName, (responseObj) => { if (responseObj.code == 200) { ProgressHUDManager.showTipMsgHUD(responseObj.msg); if (selectId != -1) { readContact(selectId); } } else { ProgressHUDManager.showComfirmHUD(responseObj.msg); slogan.ReturnName(); } }); }
public static void connect(Action <JsonObject> callback) { ProgressHUDManager.showHUD("正在分配服务器"); ServiceGate.getInstance().connectToServer((JsonObject obj) => { ProgressHUDManager.hideCurrentHUD(); BaseModel model = new BaseModel(obj); if (model.timeout) { reconnectGate(callback); } else { if (callback != null) { callback(obj); } } }); }
private void addContact() { ServiceUser.addContact(addressMessage, (contactObj) => { if (contactObj.code == 200) { addressMessage.isEditor = false; selectId = contactObj.contacts[0].contactId; ProgressHUDManager.showTipMsgHUD(contactObj.msg); ShowContactCell(); addressMessage.updateOrCreateDelegate = updateContact; } else { ProgressHUDManager.showComfirmHUD(contactObj.msg); } }); }
private void updateContact() { ServiceUser.updateContact(addressMessage, (responseObj) => { if (responseObj.code == 200) { addressMessage.isEditor = false; ShowContactCell(); ProgressHUDManager.showTipMsgHUD(responseObj.msg); addressMessage.newType = new List <int>(); addressMessage.deleteType = new List <int>(); } else { ProgressHUDManager.showComfirmHUD(responseObj.msg); } }); }
private void dropType(int typeId)//删除类别表中的某类别 { ProgressHUDManager.showYesOrNoHUD("确认删除标签吗?", (yes) => { if (yes) { ServiceUser.dropType(typeId, (responseObj) => { if (responseObj.code == 200) { ProgressHUDManager.showTipMsgHUD(responseObj.msg); showType(); } else { ProgressHUDManager.showComfirmHUD(responseObj.msg); } }); } }); }
private void deleteContact(ContactCell cell) { ProgressHUDManager.showYesOrNoHUD("确认删除该联系人吗?", (yes) => { if (yes) { ServiceUser.dropContact(cell.contactId, (responseObj) => { if (responseObj.code == 200) { ProgressHUDManager.showTipMsgHUD(responseObj.msg); Destroy(cell.gameObject); } else { ProgressHUDManager.showComfirmHUD(responseObj.msg); } }); } }); }
private void deleteUser() { ProgressHUDManager.showYesOrNoHUD("确认删除账户吗?", (yes) => { if (yes) { ServiceUser.deleteUser((responseObj) => { if (responseObj.code == 200) { ProgressHUDManager.showComfirmHUD("删除成功,即将登出界面", () => { SceneManager.LoadScene("Login"); }); } else { ProgressHUDManager.showComfirmHUD(responseObj.msg); } }); } }); }
private void modifyNickName(string nickName) { if (!_editorName) { editorName = true; _userNickName.Select(); } else { ServiceUser.modifyNickName(nickName, (responseObj) => { if (responseObj.code == 200) { ProgressHUDManager.showTipMsgHUD(responseObj.msg); editorName = false; } else { ProgressHUDManager.showComfirmHUD(responseObj.msg); } }); } }
//显示联系人列表 public void ShowContactCell() { ServiceUser.showContact((contactObj) => { if (contactObj.code == 200) { for (int i = 0; i < _contactCellRect.content.childCount; i++) { GameObject go = _contactCellRect.content.GetChild(i).gameObject; Destroy(go); } int row = contactObj.contacts.Count / 5; if (row >= 3) { _contactCellRect.content.GetComponent <RectTransform>().sizeDelta = new Vector2(0, _cellRectHeight * row); } else { _contactCellRect.content.GetComponent <RectTransform>().sizeDelta = new Vector2(0, _cellRectHeight); } foreach (NickNameResponseModel nickNameModel in contactObj.contacts) { GameObject cell = Instantiate(_contactCellPfb); ContactCell contactCell = cell.GetComponent <ContactCell>(); contactCell.Init(nickNameModel.contactId, nickNameModel.nickName, readContact, deleteContact); cell.transform.SetParent(_contactCellRect.content); } GameObject defaultCell = Instantiate(_contactCellPfb); ContactCell defaultContactCell = defaultCell.GetComponent <ContactCell>(); defaultContactCell.onClickCellDelegate = (id) => { CreateCell(); }; defaultContactCell.SetDefault(); defaultCell.transform.SetParent(_contactCellRect.content); } else { ProgressHUDManager.showComfirmHUD(contactObj.msg); } }); }
public void sendLoginRequest() { //ProgressHUDManager.showHUD ("正在登陆游戏"); string userId = null; string password = null; if (userIdText.text != "" && passwordText.text != "") { userId = userIdText.text; password = passwordText.text; } else { if (LocalDataModel.userId != null) { userId = LocalDataModel.userId; } if (LocalDataModel.password != null) { password = LocalDataModel.password; } } ServiceUser.login(userId, password, (UserModel userObj) => { Debug.Log("登陆返回"); //ProgressHUDManager.hideCurrentHUD(); if (userObj.code == 200) { LocalDataModel.isLogin = true; SceneManager.LoadScene("MainMenuScene"); } else { ProgressHUDManager.showTipMsgHUD(userObj.msg); } }); }
public void sendRegisterRequest() { if (passwordText.text != comfirmPwText.text) { ProgressHUDManager.showTipMsgHUD("密码确认不一致,请确认输入密码"); return; } string userId = userIdText.text; string password = passwordText.text; ServiceUser.register(userId, password, (UserModel userObj) => { Debug.Log("注册返回"); if (userObj.code == 200) { LocalDataModel.setUserInfo(userObj); ProgressHUDManager.showTipMsgHUD(userObj.msg); } else { ProgressHUDManager.showTipMsgHUD(userObj.msg); } }); }
private void readContact(int contactId) { ServiceUser.readContact(contactId, (addressObj) => { if (addressObj.code == 200) { addressMessage.isEditor = false; addressMessage.nickName = addressObj.nickName; addressMessage.sex = addressObj.sex; addressMessage.tel = addressObj.tel; addressMessage.email = addressObj.email; addressMessage.types = addressObj.types; addressMessage.remarks = addressObj.remarks; addressMessage.updateOrCreateDelegate = updateContact; addressMessage.newType = new List <int>(); addressMessage.deleteType = new List <int>(); selectId = contactId; } else { ProgressHUDManager.showComfirmHUD(addressObj.msg); } }); }
void Awake() { s_instance = this; DontDestroyOnLoad(s_instance.gameObject); }