1
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Assets.MyGame.Scripts.Net.API;
|
||||
using Assets.MyGame.Scripts.Net.APIRequest;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Ocsp;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
@@ -16,7 +17,12 @@ namespace Assets.MyGame.Scripts.Net
|
||||
{
|
||||
public static Dictionary<APIType, string> dic_API = new Dictionary<APIType, string>();
|
||||
//public const string baseURL = "http://game5241.wzaxr.top";
|
||||
#if UNITY_EDITOR
|
||||
public const string baseURL = "http://8.137.163.153";
|
||||
#else
|
||||
public const string baseURL = "http://8.137.8.46";
|
||||
|
||||
#endif
|
||||
static string token;
|
||||
|
||||
static APIManager()
|
||||
@@ -146,7 +152,11 @@ namespace Assets.MyGame.Scripts.Net
|
||||
|
||||
static IEnumerator IEGetSend<T>(string url, RequestParamBase paramObj, Action<T> action)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("url----" + url);
|
||||
|
||||
#endif
|
||||
|
||||
// 将 RequestParamBase 转成 GET 参数
|
||||
if (paramObj != null)
|
||||
{
|
||||
@@ -183,14 +193,20 @@ namespace Assets.MyGame.Scripts.Net
|
||||
{
|
||||
var json = req.downloadHandler.text;
|
||||
var res = JsonConvert.DeserializeObject<APIResponse<T>>(json);
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("url----" + url+"--"+ "Json-"+json+"res--"+JsonConvert.SerializeObject(res));
|
||||
|
||||
#endif
|
||||
// 自动保存 token
|
||||
if (typeof(T) == typeof(UserToken))
|
||||
{
|
||||
var ut = res.data as UserToken;
|
||||
if (ut != null) token = ut.token;
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("微信登录成功 Token" + token);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
if (res.code == 0)
|
||||
{
|
||||
@@ -205,7 +221,10 @@ namespace Assets.MyGame.Scripts.Net
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Debug.LogError(req.error);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,8 +255,11 @@ namespace Assets.MyGame.Scripts.Net
|
||||
{
|
||||
var json = req.downloadHandler.text;
|
||||
var res = JsonConvert.DeserializeObject<APIResponse<T>>(json);
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("url----" + url + "--" + "Json-" + json + "res--" + JsonConvert.SerializeObject(res));
|
||||
|
||||
#endif
|
||||
|
||||
if (res.code == 0)
|
||||
{
|
||||
action?.Invoke(res.data);
|
||||
@@ -250,7 +272,10 @@ namespace Assets.MyGame.Scripts.Net
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Debug.LogError(req.error);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,7 +295,10 @@ namespace Assets.MyGame.Scripts.Net
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Debug.LogError("RequestBase 不是 RequestParamBase 或 RequestObjBase");
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -287,13 +315,18 @@ namespace Assets.MyGame.Scripts.Net
|
||||
}
|
||||
public static void Log(string json)
|
||||
{
|
||||
Debug.Log(json);
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log(json);
|
||||
|
||||
#endif
|
||||
}
|
||||
public static void ErrorHandle(int code, string message)
|
||||
{
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
Debug.LogError("错误代码:" + code + "错误信息:" + message);
|
||||
|
||||
#endif
|
||||
//这里之后补弹窗
|
||||
UIManager.Instance.ShowBoardError("错误代码:" + code + "错误信息:" + message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user