/// <summary> /// 登录 /// </summary> /// <param name="userId">User ID.</param> /// <param name="password">User password.</param> /// <param name="callback">Callback.</param> public static void login(string userId, string password, Action <UserModel> callback) { string route = "connector.connectHandler.login"; JsonObject userData = new JsonObject(); userData.Add("userId", userId); userData.Add("password", password); ServiceUser.getInstance().request(route, userData, ((JsonObject obj) => { UserModel userModel = new UserModel(obj); if (userModel.code == 200) { LocalDataModel.setUserInfo(userModel); } else { LocalDataModel.isLogin = false; LocalDataModel.userId = null; LocalDataModel.password = null; } if (callback != null) { callback(userModel); } })); }
private static LocalDataModel getInstance() { if (s_instance == null) { s_instance = new LocalDataModel(); } return(s_instance); }
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); } }); }