using System.Collections; using System.Collections.Generic; using UnityEngine; namespace LoyalSoftSDK { public class SoftSDKInstance { private static SoftSDKInstance instance; public static SoftSDKInstance GetInstance() { if(instance==null) { instance = new SoftSDKInstance(); } return instance; } public delegate void SoftCallBackHandler(string datat); public SoftCallBackHandler OnCallBackHandler; public const int PayPlugCode = 2; // public const string payWx = "http://120.26.46.141/official/pay/wxpay/pay.php"; // public const string payZfb = "http://120.26.46.141/official/pay/alipay/pay.php"; // public const string payWx = "115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php"; // public const string payZfb = "115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php"; /// /// 是否外网, true:外网地址, false:内网地址(192.168.10.xx). /// public readonly static eNetType netType = eNetType.Online_dev; public readonly static string payWx = netType switch { eNetType.Online => "https://ylsjtt.game7000.com/ylsj2019/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php", _=> "https://ylsjtt.game7000.com/ylsj2019_dev/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php", }; public readonly static string payZfb = netType switch { eNetType.Online => "https://ylsjtt.game7000.com/ylsj2019/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php", _ => "https://ylsjtt.game7000.com/ylsj2019_dev/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php" }; // public readonly static string payWx =GlobalConfig.netType == eNetType. // }// = "";// "https://ylsjtt.game7000.com/ylsj2019/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php";//"115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php"; // public const string payZfb = "";//"https://ylsjtt.game7000.com/ylsj2019/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php";//"115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php"; // public const string payWxdev = "https://ylsjtt.game7000.com/ylsj2019_dev/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php";//"115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/wxpay/pay.php"; //public const string payZfbdev = "https://ylsjtt.game7000.com/ylsj2019_dev/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php";//"115.159.121.129/TTTTTT/Gameserver/Amfphp/service_call/pay/official/alipay/pay.php"; public void InitSDK(string appId) { if (appId.Equals("test")) { UIFormManager.GetInstance().InitCanvas(); Dictionary data = new Dictionary(); data.Add("action", "Init"); data.Add("title", "初始化"); //UIFormManager.GetInstance().ShowUIForm("TestPanel", null, data); } else { Dictionary backData = new Dictionary(); if (UIFormManager.GetInstance().InitCanvas()) { backData.Add("action", "initSuccees"); backData.Add("data", "loyal"); backData.Add("msg", "初始化成功"); } else { backData.Add("action", "initFail"); backData.Add("data", "loyal"); backData.Add("msg", "初始化失败"); } SendCallBackMsg(MiniJSON.Json.Serialize(backData)); } } public void LoginSDK(bool autoLogin) { Dictionary data = new Dictionary(); data.Add("action", "star"); data.Add("autoLogin", autoLogin.ToString()); UIFormManager.GetInstance().ShowUIForm("LoginPanel",null, data); } public void LogOutSDK() { if (UserManager.GetInstance().GetCurUser() == null) return; UserManager.GetInstance().SetSaveUserData(UserManager.GetInstance().GetCurUser().Account,"", UserManager.GetInstance().GetSaveUser().lastLoginTime); UserManager.GetInstance().ClearCurUser(); UIFormManager.GetInstance().CloseUIForm("FloatPanel"); Dictionary backData = new Dictionary(); backData.Add("action", "logoutSuccees"); backData.Add("data", ""); backData.Add("msg", "登出成功"); SendCallBackMsg(MiniJSON.Json.Serialize(backData)); } public void ExitGame() { UIFormManager.GetInstance().OnEscape(); // UIFormManager.GetInstance().ShowUIForm("ExitGamePanel", null, null); } public void SubmitData() { } public void Pay(string product_id, string product_name,string product_count,string product_price, string party_id, string party_name, string amount,string zoneid,string callbackInfo,string ageRange ) { Debug.Log("install pay"); Dictionary data = new Dictionary(); data.Add("action", "pay"); data.Add("product_id", product_id); data.Add("product_name", product_name); data.Add("product_count", product_count); data.Add("product_price", product_price); data.Add("party_id", party_id); data.Add("party_name", party_name); data.Add("ageRange ", ageRange); data.Add("amount", amount); data.Add("zoneid", zoneid); data.Add("callbackInfo", callbackInfo); if (!GlobalConfig.is_SandBox) { UIFormManager.GetInstance().ShowUIForm("PayPanel", null, data); } else { List> listdata=new List> (); //listdata.Add(new KeyValuePair("action", "pay")); //listdata.Add(new KeyValuePair("product_id", product_id)); //listdata.Add(new KeyValuePair("product_name", product_name)); //listdata.Add(new KeyValuePair("product_count", product_count)); //listdata.Add(new KeyValuePair("product_price", product_price)); //listdata.Add(new KeyValuePair("party_id", party_id)); //listdata.Add(new KeyValuePair("party_name", party_name)); //listdata.Add(new KeyValuePair("ageRange ", ageRange)); //listdata.Add(new KeyValuePair("amount", amount)); //listdata.Add(new KeyValuePair("zoneid", zoneid)); //listdata.Add(new KeyValuePair("callbackInfo", callbackInfo)); //listdata.Add(new KeyValuePair("accountId", UserProxy.Instance.player.uid)); //listdata.Add(new KeyValuePair("channel","soft")); listdata.Add(new KeyValuePair("accountId", UserProxy.Instance.player.uid)); listdata.Add(new KeyValuePair("amount", amount)); listdata.Add(new KeyValuePair("channel", "soft")); listdata.Add(new KeyValuePair("callbackInfo", callbackInfo)); listdata.Add(new KeyValuePair("zoneid", zoneid)); listdata.Add(new KeyValuePair("product_id", product_id)); listdata.Add(new KeyValuePair("product_name", product_name)); listdata.Add(new KeyValuePair("product_count", product_count)); listdata.Add(new KeyValuePair("product_price", product_price)); listdata.Add(new KeyValuePair("party_id", party_id)); listdata.Add(new KeyValuePair("party_name", party_name)); listdata.Add(new KeyValuePair("ageRange", "18")); FakePay(listdata); } } public void SetCallBack(SoftCallBackHandler callback) { OnCallBackHandler = callback; } public void SendCallBackMsg(string datat) { if(OnCallBackHandler!=null) { OnCallBackHandler.Invoke(datat); } } public void GetSoftPayBack(string jsonData) { Dictionary data = new Dictionary(); data.Add("action", "paySult"); UIFormManager.GetInstance().ShowUIForm("PayPanel", null, data); } public void SendtoPayPanl(string jsonData) { if(UIFormManager.GetInstance().paypanl==null) { Debug.LogError("确认打开过支付界面吗?"); return; } UIFormManager.GetInstance().paypanl.GetPayResults(jsonData); } public void FakePay(List> data) { ///测试待修改.这里要加. ///测试待修改.这里要加. ShopProxy.Instance.ImitateBuy(data, (s) => { PayProxy.Instance.PayDeliverGoods(long.Parse(s.cpOrderId), (lst) => { if (lst.Count > 0) { PanelHelper.Instance.ShowPanel("UI_ShopPrizesPanel", (panel) => { PanelHelper.Instance.ClosePanel("UI_WaitingForPaySuccessWindow"); UI_ShopPrizesPanel shopPrize = panel.GetComponent(); shopPrize.Init(); shopPrize.Show(lst); }); } else { PanelHelper.Instance.ClosePanel("UI_WaitingForPaySuccessWindow"); UI_CueDialog.Instance().Open("交易完成"); } Debug.Log("交易完成"); }); }); } } }