static void OnUserLoginFinished(QKSDKReturn sdkReturn) { /// ErrorCode:错误码,0代码成功 /// Msg:描述 /// User:用户对象 QKCommand tempCmd = SDKCommand.SDKLoginFinish; tempCmd.AddParam("ErrorCode", sdkReturn.ErrorCode); tempCmd.AddParam("Msg", sdkReturn.ErrorMsg); if (0 == sdkReturn.ErrorCode) { QKSDKUser tempUser = QKSDKUser.Parse(sdkReturn.Content.TrySecDecode()); // 缓存非游客用户账号 if (0 == tempUser.GuestMode) { SDKConfig.CacheAccount(mCurrAccount, mCurrPassword); } else { SDKCookie.SetValue("TempAccount", tempUser.Account); SDKCookie.SetValue("TempPassword", tempUser.Account); } tempCmd.AddParam("User", tempUser); } tempCmd.Send(); }
/// <summary> /// 快速登录 /// </summary> static void OnQuickLogin(QKCommand cmd) { string fromType = AccountFromType.QK; // 有临时的账号密码 if (SDKCookie.ContainKey("TempAccount") && SDKCookie.ContainKey("TempPassword")) { mCurrAccount = SDKCookie.GetValue("TempAccount"); mCurrPassword = SDKCookie.GetValue("TempPassword"); // 上传的参数 Dictionary <string, string> upParams = new Dictionary <string, string>(); upParams["AppKey"] = SDKConfig.AppKey; upParams["Account"] = mCurrAccount; upParams["Password"] = mCurrPassword; upParams["FromType"] = fromType; upParams["Sign"] = String.Format("AppKey={0}&Account={1}&FromType={2}&{3}", SDKConfig.AppKey, mCurrAccount, fromType, SDKConfig.AppSecret).TryToQKMD5(); NetTask.AutoFinish(new WWW(LoginUrl, upParams.TryToString().TrySecEncode().TryToBytes()), OnUserLoginFinished); } else { // 上传的参数 Dictionary <string, string> upParams = new Dictionary <string, string>(); upParams["AppKey"] = SDKConfig.AppKey; upParams["FromType"] = fromType; upParams["Sign"] = String.Format("AppKey={0}&FromType={1}&{2}", SDKConfig.AppKey, fromType, SDKConfig.AppSecret).TryToQKMD5(); NetTask.AutoFinish(new WWW(QuickRegistUrl, upParams.TryToString().TrySecEncode().TryToBytes()), OnUserLoginFinished); } }
/// <summary> /// 加载账号缓存 /// </summary> static void LoadAccountCache() { if (SDKCookie.ContainKey("SDKAccountList")) { AccountCache.Clear(); Dictionary <string, string> temp = SDKCookie.GetValue("SDKAccountList").TryToDictionary(); if (null != temp) { AccountCache = new Dictionary <string, string>(temp); } } }
/// <summary> /// 保存缓存的账号列表 /// </summary> static void SaveAccountCache() { SDKCookie.SetValue("SDKAccountList", AccountCache.TryToString()); }