| | |
| | | using Snxxz.UI; |
| | | using LitJson; |
| | | |
| | | public class DebugLogin : MonoBehaviour |
| | | public class DebugLogin : MonoBehaviour
|
| | | { |
| | | public InputField appid; |
| | | public InputField serverId; |
| | | public InputField ipInputField; |
| | | public InputField portInputField; |
| | | public InputField portInputField;
|
| | | public InputField gateInputField; |
| | | public InputField account; |
| | | public InputField password; |
| | | |
| | | public Toggle isToken; |
| | | |
| | | public void Login() |
| | | { |
| | | if (isToken.isOn) |
| | | { |
| | | var loginModel = ModelCenter.Instance.GetModel<LoginModel>(); |
| | | |
| | | var ip = ipInputField.text; |
| | | var port = int.Parse(portInputField.text); |
| | | var gamePort = int.Parse(gateInputField.text); |
| | | VersionConfig.Get().m_AppId = appid.text; |
| | | ServerListCenter.Instance.currentServer = new ServerData() |
| | | { |
| | | region_flag = int.Parse(serverId.text), |
| | | login_port = port, |
| | | game_port = gamePort, |
| | | }; |
| | | |
| | | loginModel.sdkLoginResult = new SDKUtility.FP_LoginOk() |
| | | { |
| | | account = account.text, |
| | | token = password.text, |
| | | tokenExpire = "1519750743000", |
| | | phone = 0, |
| | | accountID = 1000 |
| | | }; |
| | | |
| | | loginModel.sdkLogined = true; |
| | | loginModel.AccountLogin(ip, port, gamePort); |
| | | } |
| | | else |
| | | { |
| | | SDKLogin(account.text, password.text); |
| | | } |
| | | } |
| | | |
| | | private void SDKLogin(string _account, string _password) |
| | | { |
| | | var tables = new Dictionary<string, string>(); |
| | | tables["account"] = _account; |
| | | tables["password"] = _password; |
| | | var url = "http://zysdk.zytxgame.com/api.php/Index/login?"; |
| | | HttpRequest.Instance.RequestHttpGet(StringUtility.Contact(url, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType, 1, SDKLoginCallBack); |
| | | } |
| | | |
| | | private void SDKLoginCallBack(bool _ok, string _result) |
| | | { |
| | | if (_ok) |
| | | { |
| | | var result = JsonMapper.ToObject<SDKLoginResult>(_result); |
| | | if (result.errorcode == "1") |
| | | { |
| | | var loginModel = ModelCenter.Instance.GetModel<LoginModel>(); |
| | | loginModel.sdkLogined = true; |
| | | loginModel.sdkLoginResult = new SDKUtility.FP_LoginOk() |
| | | { |
| | | account = result.account, |
| | | token = result.token, |
| | | phone = int.Parse(result.phone), |
| | | accountID = int.Parse(result.account_id), |
| | | tokenExpire = result.token_expire, |
| | | }; |
| | | |
| | | SDKUtility.Instance.FreePlatformCheckIDAuthentication(result.account); |
| | | |
| | | var ip = ipInputField.text; |
| | | var port = int.Parse(portInputField.text); |
| | | var gamePort = int.Parse(gateInputField.text); |
| | | VersionConfig.Get().m_AppId = appid.text; |
| | | ServerListCenter.Instance.currentServer = new ServerData() |
| | | { |
| | | region_flag = int.Parse(serverId.text), |
| | | login_port = port, |
| | | game_port = gamePort, |
| | | }; |
| | | |
| | | loginModel.AccountLogin(ip, port, gamePort); |
| | | } |
| | | else |
| | | { |
| | | MessageWin.Inst.ShowFixedTip(result.errordesc); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | MessageWin.Inst.ShowFixedTip(Language.Get("LoginFailed_Z")); |
| | | } |
| | | } |
| | | |
| | | struct SDKLoginResult |
| | | { |
| | | public string errorcode; |
| | | public string errordesc; |
| | | public string token; |
| | | public string account; |
| | | public string token_expire; |
| | | public string phone; |
| | | public string account_id; |
| | | public void Login()
|
| | | {
|
| | | if (isToken.isOn)
|
| | | {
|
| | | var loginModel = ModelCenter.Instance.GetModel<LoginModel>();
|
| | |
|
| | | var ip = ipInputField.text;
|
| | | var port = int.Parse(portInputField.text);
|
| | | var gamePort = int.Parse(gateInputField.text);
|
| | | VersionConfig.Get().m_AppId = appid.text;
|
| | | ServerListCenter.Instance.currentServer = new ServerData()
|
| | | {
|
| | | region_flag = int.Parse(serverId.text),
|
| | | login_port = port,
|
| | | game_port = gamePort,
|
| | | };
|
| | |
|
| | | loginModel.sdkLoginResult = new SDKUtility.FP_LoginOk()
|
| | | {
|
| | | account = account.text,
|
| | | token = password.text,
|
| | | tokenExpire = "1519750743000",
|
| | | phone = 0,
|
| | | accountID = 1000
|
| | | };
|
| | |
|
| | | loginModel.sdkLogined = true;
|
| | | loginModel.AccountLogin(ip, port, gamePort);
|
| | | }
|
| | | else
|
| | | {
|
| | | SDKLogin(account.text, password.text);
|
| | | }
|
| | | }
|
| | |
|
| | | private void SDKLogin(string _account, string _password)
|
| | | {
|
| | | var tables = new Dictionary<string, string>();
|
| | | tables["account"] = _account;
|
| | | tables["password"] = _password;
|
| | | var url = "http://zysdk.zytxgame.com/api.php/Index/login?";
|
| | | HttpRequest.Instance.RequestHttpGet(StringUtility.Contact(url, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType, 1, SDKLoginCallBack);
|
| | | }
|
| | |
|
| | | private void SDKLoginCallBack(bool _ok, string _result)
|
| | | {
|
| | | if (_ok)
|
| | | {
|
| | | var result = JsonMapper.ToObject<SDKLoginResult>(_result);
|
| | | if (result.errorcode == "1")
|
| | | {
|
| | | var loginModel = ModelCenter.Instance.GetModel<LoginModel>();
|
| | | loginModel.sdkLogined = true;
|
| | | loginModel.sdkLoginResult = new SDKUtility.FP_LoginOk()
|
| | | {
|
| | | account = result.account,
|
| | | token = result.token,
|
| | | phone = int.Parse(result.phone),
|
| | | accountID = int.Parse(result.account_id),
|
| | | tokenExpire = result.token_expire,
|
| | | };
|
| | |
|
| | | SDKUtility.Instance.FreePlatformCheckIDAuthentication(result.account);
|
| | |
|
| | | var ip = ipInputField.text;
|
| | | var port = int.Parse(portInputField.text);
|
| | | var gamePort = int.Parse(gateInputField.text);
|
| | | VersionConfig.Get().m_AppId = appid.text;
|
| | | ServerListCenter.Instance.currentServer = new ServerData()
|
| | | {
|
| | | region_flag = int.Parse(serverId.text),
|
| | | login_port = port,
|
| | | game_port = gamePort,
|
| | | };
|
| | |
|
| | | loginModel.AccountLogin(ip, port, gamePort);
|
| | | }
|
| | | else
|
| | | {
|
| | | MessageWin.Inst.ShowFixedTip(result.errordesc);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | MessageWin.Inst.ShowFixedTip(Language.Get("LoginFailed_Z"));
|
| | | }
|
| | | }
|
| | |
|
| | | struct SDKLoginResult
|
| | | {
|
| | | public string errorcode;
|
| | | public string errordesc;
|
| | | public string token;
|
| | | public string account;
|
| | | public string token_expire;
|
| | | public string phone;
|
| | | public string account_id;
|
| | | } |
| | | } |