using ET; using UnityEngine; using GFGGame.Launcher; namespace GFGGame { public class QDDouYouManagerIos : SingletonBase { public bool isLogining; //ios sdk 返回的 public string uid; public string account; public string token; public void Init() { Debug.Log("实例化DouYouSDKListenerIos"); QDDouYouManagerInitIos.Instance.douYouSDKListenerIos = new DouYouSDKListenerIos(); } public void Login() { QDDouYouManagerInitIos.Instance.ShowLogin(); } public void OnCreateRole() { QDManager.PushRoleAction(DouYouRoleLogReportType.CreateRole); } public void OnEnterGame() { QDManager.PushRoleAction(DouYouRoleLogReportType.EnterGame); } public void OnQuitToLoginView() { Debug.Log($"DouYou ios OnQuitToLoginView"); } public void Logout() { Debug.Log($"Game.HotUpdate DouYou ios Logout"); QDDouYouManagerInitIos.Instance.Logout(); } public void LoginOutBefore() { QDManager.PushRoleAction(DouYouRoleLogReportType.ExitGame); } // 辅助方法:处理空值 private static string HandleNullString(string value) { return string.IsNullOrEmpty(value) ? "" : value; } public void Pay(int buyID, int count, string orderID, long price) { ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(buyID); if (shopCfg == null) { Log.Error($"recharge {buyID} config not found!"); return; } ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId); if (itemCfg == null) { Log.Error($"recharge {buyID} itemCfgId:{shopCfg.itemId} config not found!"); return; } string currencyName = string.Empty; if (shopCfg.costType == CostType.FREE) { //免费 currencyName = "免费"; } else if (shopCfg.costType == CostType.ITEM) { //货币 ItemCfg costItemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.costId); if (costItemCfg == null) { currencyName = $"货币{shopCfg.costId}"; } else { currencyName = costItemCfg.name; } } else if (shopCfg.costType == CostType.RMB) { //人民币 currencyName = "人民币"; } else { //指定渠道商品id currencyName = $"指定商品id{shopCfg.costId}"; } var zoneScene = GameGlobal.zoneScene; if (zoneScene == null) return; if (zoneScene.GetComponent() == null || zoneScene.GetComponent().IsDisposed) return; var roleInfo = zoneScene.GetComponent().GetCurrentRole(); if (roleInfo == null) return; if (GameGlobal.myNumericComponent == null) return; int lvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl); int vipLvl = GameGlobal.myNumericComponent.GetAsInt(NumericType.VipLevel); if (zoneScene.GetComponent() == null) return; if (zoneScene.GetComponent().recentlyServerInfo == null) return; var serverInfosComponent = zoneScene.GetComponent(); //自定义参数 string cpOrderId = orderID; string productPrice = price.ToString(); string productId = IAPManager.Instance.GetIosProductId(shopCfg.id); string productName = shopCfg?.itemName ?? ""; string productDesc = shopCfg?.itemName ?? ""; string productCount = count.ToString(); string exchangeRate = 1.ToString(); string serverId = (serverInfosComponent?.CurrentServerId ?? 0).ToString(); string serverName = serverInfosComponent?.recentlyServerInfo?.ServerName ?? ""; string roleId = roleInfo.Id.ToString(); string roleName = roleInfo.Name; string roleLevel = lvl.ToString(); string roleVip = vipLvl.ToString(); string partyName = LeagueDataManager.Instance.LeagueData?.Name ?? ""; string roleBalence = "0"; string other = orderID + "|gfg|" + roleInfo.Id; Debug.Log( $"Ios ShowPay: cpOrderId:{cpOrderId} productPrice:{productPrice} productId:{productId} productName:{productName} productDesc:{productDesc} " + $"productCount:{productCount} exchangeRate:{exchangeRate} serverId:{serverId} serverName:{serverName} roleId:{roleId} roleName:{roleName} " + $"roleLevel:{roleLevel} roleVip:{roleVip} partyName:{partyName} roleBalence:{roleBalence} other:{other} currencyName:{currencyName}"); QDDouYouManagerInitIos.Instance.ShowPay(cpOrderId, productPrice, productId, productName, productDesc, productCount, exchangeRate, currencyName, serverId, serverName, roleId, roleName, roleLevel, roleVip, partyName, roleBalence, other); } public void Exit() { QDManager.PushRoleAction(DouYouRoleLogReportType.ExitGame); QDDouYouManagerInitIos.Instance.Logout(); } } /// /// SDK回调 /// public class DouYouSDKListenerIos : IDouYouSDKListenerIos { /// /// SDK实例化成功 /// /// SDK 实例化成功 public void InitSuccessAb(string message) { Debug.Log("Game.HotUpdate InitSuccessAb: " + message); } public void InitErrorAb(string message) { Debug.Log("Game.HotUpdate InitErrorAb: " + message); } /// /// 登录成功 /// /// resUid + "|gfg|" + token public void LoginSuccessAb(string message) { Debug.Log("Game.HotUpdate ios LoginSuccessAb: " + message); DouYouIosSdkLoginResModel douYouIosSdkLoginResModel = LitJson.JsonMapper.ToObject(message); if (douYouIosSdkLoginResModel == null) { Log.Error($"注意,解析登录回调失败,回调的字符串为 {message} douYouIosSdkLoginResModel is null."); return; } QDDouYouManagerIos.Instance.isLogining = false; QDDouYouManagerIos.Instance.uid = douYouIosSdkLoginResModel.uid; QDDouYouManagerIos.Instance.token = douYouIosSdkLoginResModel.token; //登录成功的回调 EventAgent.DispatchEvent(ConstMessage.ON_PLATFORM_SDK_LOGINED, douYouIosSdkLoginResModel.uid); } /// /// 登录失败 /// /// public void LoginErrorAb(string message) { Debug.Log("Game.HotUpdate LoginErrorAb: " + message); } /// /// 切换账号回调---先当成退出登录处理 /// public void SwitchAccountsAb(string message) { Debug.Log("Game.HotUpdate SwitchAccountsAb: " + message); GameController.QuitToLoginView(true); EventAgent.DispatchEvent(ConstMessage.OUT_LOGIN); } /// /// 退出登录后 /// /// 退出登录成功! public void LogoutSuccessAb(string message) { Debug.Log("Game.HotUpdate LogoutSuccessAb: " + message); GameController.QuitToLoginView(true); EventAgent.DispatchEvent(ConstMessage.OUT_LOGIN); } /// /// 退出登录失败 /// /// public void LogoutErrorAb(string message) { Debug.Log("Game.HotUpdate LogoutErrorAb: " + message); } /// /// 支付失败 /// /// code + "|gfg|" + params.toString() public void PayErrorAb(string message) { Debug.Log("Game.HotUpdate PayErrorAb: " + message); //改变临时订单状态为失败 } /// /// 支付成功 /// /// code + "|gfg|" + params.toString() public void PaySuccessAb(string message) { Debug.Log("Game.HotUpdate PaySuccessAb" + message); //改变临时订单状态为支付成功 QDManager.PushRoleAction(DouYouRoleLogReportType.Pay); } //角色升级上报成功回调 public void RoleInfoReportSuccessAb(string message) { } //角色升级上报失败回调 public void RoleInfoReportErrorAb(string message) { } } }