Files
JJBB/Assets/Project/Script/GameLogic/GameManager/ControllUrlManager.cs

635 lines
15 KiB
C#
Raw Normal View History

2024-08-23 15:49:34 +08:00
using Module.Log;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ControllUrlManager
{
#region static
//获取服务器列表
private static string _IPListUrl;
public static string IPListUrl
{
get
{
if (string.IsNullOrEmpty(_IPListUrl))
{
_IPListUrl = GCGame.Table.SystemParam.GetSystemParam_STRING(27);
}
return _IPListUrl;
}
}
//登陆验证
private static string _LoginVerifyUrl;
public static string LoginVerifyUrl
{
get
{
if (string.IsNullOrEmpty(_LoginVerifyUrl))
{
_LoginVerifyUrl = GCGame.Table.SystemParam.GetSystemParam_STRING(26);
}
return _LoginVerifyUrl;
}
}
//充值结果
private static string _PayResultUrl;
public static string PayResultUrl
{
get
{
return _PayResultUrl;
}
}
//图片上传
private static string _ImageUpLoadUrl;
public static string ImageUpLoadUrl
{
get
{
return _ImageUpLoadUrl;
}
}
//图片下载
private static string _ImageDownLoadUrl;
public static string ImageDownLoadUrl
{
get
{
return _ImageDownLoadUrl;
}
}
//FQA
private static string _FQAKeywordUrl;
public static string FQAKeywordUrl
{
get
{
if (string.IsNullOrEmpty(_FQAKeywordUrl))
{
_FQAKeywordUrl = GCGame.Table.SystemParam.GetSystemParam_STRING(40);
}
return _FQAKeywordUrl;
}
}
//申诉
private static string _AvoidAppealUrl;
public static string AvoidAppealUrl
{
get
{
if (string.IsNullOrEmpty(_AvoidAppealUrl))
{
_AvoidAppealUrl = GCGame.Table.SystemParam.GetSystemParam_STRING(30);
}
return _AvoidAppealUrl;
}
}
//举报
private static string _AvoidReportUrl;
public static string AvoidReportUrl
{
get
{
if (string.IsNullOrEmpty(_AvoidReportUrl))
{
_AvoidReportUrl = GCGame.Table.SystemParam.GetSystemParam_STRING(31);
}
return _AvoidReportUrl;
}
}
//公告
private static string _LoginNoticeUrl;
public static string LoginNoticeUrl
{
get
{
if (string.IsNullOrEmpty(_LoginNoticeUrl))
{
_LoginNoticeUrl = GCGame.Table.SystemParam.GetSystemParam_STRING(43);
}
return _LoginNoticeUrl;
}
}
//平台记录
private static string _PlatFormUrl;
public static string PlatFormUrl
{
get
{
return _PlatFormUrl;
}
}
//激活码
private static string _ReceivePackageUrl;
public static string ReceivePackageUrl
{
get
{
return _ReceivePackageUrl;
}
}
#if UNITY_ANDROID
//ZYSDK信息上报
private static string _ZYSDKRoleInfoUrl = "http://serv.zhanyou-game.com:8098/Api/User/report_role";
public static string ZYSDKRoleInfoUrl
{
get
{
return _ZYSDKRoleInfoUrl;
}
}
//ZYSDK充值
private static string _ZYSDKPayPostUrl = "http://serv.zhanyou-game.com:8098/Api/Order/order_create";
public static string ZYSDKPayPostUrl
{
get
{
return _ZYSDKPayPostUrl;
}
}
//ZYSDK登录
private static string _ZYSDKLoginUrl = "http://139.159.226.174:8098/Api/User/login";
public static string ZYSDKLoginUrl
{
get
{
return _ZYSDKLoginUrl;
}
}
//ZYSDK注册
private static string _ZYSDKRegisterUrl = "http://139.159.226.174:8098/Api/User/register";
public static string ZYSDKRegisterUrl
{
get
{
return _ZYSDKRegisterUrl;
}
}
//ZYSDK手机注册
private static string _ZYSDKRegisterPhoneUrl = "http://139.159.226.174:8098/Api/User/phone_register";
public static string ZYSDKRegisterPhoneUrl
{
get
{
return _ZYSDKRegisterPhoneUrl;
}
}
//ZYSDK绑定手机
private static string _ZYSDKBindPhoneUrl = "http://139.159.226.174:8098/Api/User/bind_phone";
public static string ZYSDKBindPhoneUrl
{
get
{
return _ZYSDKBindPhoneUrl;
}
}
//ZYSDK修改密码
private static string _ZYSDKResetPassUrl = "http://139.159.226.174:8098/Api/User/reset_pass";
public static string ZYSDKResetPassUrl
{
get
{
return _ZYSDKResetPassUrl;
}
}
//ZYSDK请求手机验证码
private static string _ZYSDKAskPhoneCode = "http://139.159.226.174:8098/Api/Msg/send_sms_code";
public static string ZYSDKAskPhoneCode
{
get
{
return _ZYSDKAskPhoneCode;
}
}
//ZYSDK请求设置新密码
private static string _ZYSDKAskForgetPassWord = "http://139.159.226.174:8098/Api/User/set_pwd";
public static string ZYSDKAskForgetPassWord
{
get
{
return _ZYSDKAskForgetPassWord;
}
}
//ZYSDK请求验证手机号
private static string _ZYSDKAskValidatePhone = "http://139.159.226.174:8098/Api/Msg/get_user_by_phone";
public static string ZYSDKAskValidatePhone
{
get
{
return _ZYSDKAskValidatePhone;
}
}
//apple 支付回调
private static string _AppleIAPReceipt;
public static string AppleIAPReceipt
{
get
{
if (string.IsNullOrEmpty(_AppleIAPReceipt))
{
_AppleIAPReceipt = "";
}
return _AppleIAPReceipt;
}
}
#else
//ZYSDK信息上报
private static string _ZYSDKRoleInfoUrl = "";
public static string ZYSDKRoleInfoUrl
{
get
{
return _ZYSDKRoleInfoUrl;
}
}
//ZYSDK充值
private static string _ZYSDKPayPostUrl = "";
public static string ZYSDKPayPostUrl
{
get
{
return _ZYSDKPayPostUrl;
}
}
//ZYSDK登录
private static string _ZYSDKLoginUrl = "";
public static string ZYSDKLoginUrl
{
get
{
return _ZYSDKLoginUrl;
}
}
//ZYSDK注册
private static string _ZYSDKRegisterUrl = "";
public static string ZYSDKRegisterUrl
{
get
{
return _ZYSDKRegisterUrl;
}
}
//ZYSDK手机注册
private static string _ZYSDKRegisterPhoneUrl = "";
public static string ZYSDKRegisterPhoneUrl
{
get
{
return _ZYSDKRegisterPhoneUrl;
}
}
//ZYSDK绑定手机
private static string _ZYSDKBindPhoneUrl = "";
public static string ZYSDKBindPhoneUrl
{
get
{
return _ZYSDKBindPhoneUrl;
}
}
//ZYSDK修改密码
private static string _ZYSDKResetPassUrl = "";
public static string ZYSDKResetPassUrl
{
get
{
return _ZYSDKResetPassUrl;
}
}
//ZYSDK请求手机验证码
private static string _ZYSDKAskPhoneCode = "";
public static string ZYSDKAskPhoneCode
{
get
{
return _ZYSDKAskPhoneCode;
}
}
//ZYSDK请求设置新密码
private static string _ZYSDKAskForgetPassWord = "";
public static string ZYSDKAskForgetPassWord
{
get
{
return _ZYSDKAskForgetPassWord;
}
}
//ZYSDK请求验证手机号
private static string _ZYSDKAskValidatePhone = "";
public static string ZYSDKAskValidatePhone
{
get
{
return _ZYSDKAskValidatePhone;
}
}
//apple 支付回调
private static string _AppleIAPReceipt;
public static string AppleIAPReceipt
{
get
{
if (string.IsNullOrEmpty(_AppleIAPReceipt))
{
_AppleIAPReceipt = "";
}
return _AppleIAPReceipt;
}
}
#endif
//资源更新链接
private static string _ResUpdate;
public static string ResUpdate
{
get
{
if (string.IsNullOrEmpty(_ResUpdate))
{
_ResUpdate = NetworkConfig.AssetBundleUrl;
}
return _ResUpdate;
}
}
//web 充值
private static string _AskWebChargeUrl;
public static string AskWebChargeUrl
{
get
{
if (string.IsNullOrEmpty(_AskWebChargeUrl))
{
_AskWebChargeUrl = "";
//_BabaChargeUrl = "";
}
return _AskWebChargeUrl;
}
}
//web 充值
private static string _BabaChargeUrl;
public static string BabaChargeUrl
{
get
{
return _BabaChargeUrl;
}
set
{
_BabaChargeUrl = value;
}
}
//web 充值
private static string _MamaChargeUrl;
public static string MamaChargeUrl
{
get
{
return _MamaChargeUrl;
}
set
{
_MamaChargeUrl = value;
}
}
//表格版本
public static string _Table_Version;
public static string Table_Version
{
get
{
return _Table_Version;
}
}
#endregion
#region
[System.Serializable]
public class ApiResult
{
public int errno;
public string msg;
public ApiUrlInfo[] data;
}
[System.Serializable]
public class ApiUrlInfo
{
public string name;
public string key;
public string url;
public string description;
public string version;
}
public static Action _Callback;
public static void InitUrls(Action callBack)
{
_Callback = callBack;
GameManager.gameManager.StartCoroutine(InitUrlWWW());
}
protected static IEnumerator InitUrlWWW()
{
string url = NetworkConfig.ApiUrl;
string apiKey = NetworkConfig.ApkKey;
if (string.IsNullOrEmpty(url))
{
#if APP_STORE
url = "";
#else
url = "";
#endif
}
if (string.IsNullOrEmpty(apiKey))
{
apiKey = "ZYAPI";
}
Debug.Log("url:" + url);
WWWForm form = new WWWForm();
string timeStamp = GCGame.Utils.GetTimeStamp();
string randomStr = GCGame.Utils.GetRandomStr();
string sign = GCGame.Utils.GetSignString(timeStamp, randomStr, apiKey);
form.AddField("timestamp", timeStamp);
form.AddField("nonce_str", randomStr);
form.AddField("sign", sign);
if (NetworkConfig.IPListUrl.Contains("192.168"))
{
form.AddField("version", "0.0.0.1");
}
else
{
#if UNITY_EDITOR
form.AddField("version", "1.0.0.1");
#elif UNITY_IPHONE && !UNITY_EDITOR
string versionStr = Application.version + ".1";
form.AddField("version", versionStr);
#elif UNITY_ANDROID && !UNITY_EDITOR
string versionStr = Application.version;
form.AddField("version", versionStr);
#endif
}
if (!string.IsNullOrEmpty(NetworkConfig._cchid))
{
form.AddField("ccid", NetworkConfig._cchid);
}
// Upload to a cgi script
//byte[] reqData = DESEncryption.EncryptData(form.data);
WWW w = new WWW(url, form);
yield return w;
if (!string.IsNullOrEmpty(w.error))
{
LogModule.ErrorLog("InitUrls error: " + url + w.error);
}
else
{
string result = w.text;
result = DESEncryption.DecryptData(result);
//Debug.Log("result:" + result);
var uploadRet = JsonUtility.FromJson<ApiResult>(result);
if (uploadRet.errno != 0)
{
LogModule.ErrorLog("InitUrls error:" + w.error);
GUIData.AddNotifyData(uploadRet.msg);
}
else
{
for (int i = 0; i < uploadRet.data.Length; ++i)
{
if (uploadRet.data[i].key.Equals("server_list"))
{
_IPListUrl = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("login_verify"))
{
_LoginVerifyUrl = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("avoid_appeal"))
{
_AvoidAppealUrl = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("avoid_report"))
{
_AvoidReportUrl = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("faq_keyword_upload"))
{
_FQAKeywordUrl = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("image_get"))
{
_ImageDownLoadUrl = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("image_upload"))
{
_ImageUpLoadUrl = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("login_notice"))
{
_LoginNoticeUrl = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("player_platform"))
{
_PlatFormUrl = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("receive_package"))
{
_ReceivePackageUrl = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("pay_callback_apple"))
{
_AppleIAPReceipt = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("res_update_url"))
{
#if UNITY_EDITOR
Debug.Log("res_update_url:" + uploadRet.data[i].url);
#endif
_ResUpdate = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("pay_callback_HGA"))
{
#if UNITY_ANDROID
_PayResultUrl = uploadRet.data[i].url;
#endif
}
else if (uploadRet.data[i].key.Equals("pay_callback_HGiOS"))
{
#if UNITY_IOS
_PayResultUrl = uploadRet.data[i].url;
#endif
}
else if (uploadRet.data[i].key.Equals("a_li_pay"))
{
_AskWebChargeUrl = uploadRet.data[i].url;
}
else if (uploadRet.data[i].key.Equals("tableVersion"))
{
_Table_Version = uploadRet.data[i].url;
}
}
}
}
if (_Callback != null)
{
_Callback.Invoke();
}
}
#endregion
}