private async Task LoginAsync() { LoginInternet loginObj = new LoginInternet(); LoginResult.Type resultType; ChallengeReq challengeReq = new ChallengeReq(Text_Account.Text); var result = await loginObj.ChallengeAsync(challengeReq); if (string.IsNullOrEmpty(result)) { resultType = LoginResult.Type.CodeError; } LoginReq loginReq = new LoginReq(challengeReq, Text_Password.Password, result); resultType = await loginObj.LoginAsync(loginReq); // loginResult LoginResultViewModel viewModel = LoginResultViewModel.GetInstance(); viewModel.LoginInfo = new LoginResult(resultType).ReusltInfo; //keepActTimer.Start(); // 自动保存账号 if (AppSettings.Default.autoSave) { AppSettings.Default.account = Text_Account.Text; AppSettings.Default.password = Text_Password.Password; AppSettings.Default.Save(); } }
/// <summary> /// 处理View消息 /// </summary> /// <param name="message"></param> public override void OnMessage(Message message) { string name = message.Name; object[] bodys = message.Params; switch (name) { case MessageConst.CMD_BATTLE_REMOVE_HERO_CARD: _model.SelectedCount--; BattleUserCardVo vo = (BattleUserCardVo)bodys[0]; vo.IsUsed = false; View.RemoveCard(vo); break; case MessageConst.CMD_BATTLE_SUPERSTAR_CONFIRM_ERROR1: FlowText.ShowMessage(I18NManager.Get("SupporterActivity_Hint1")); break; case MessageConst.CMD_BATTLE_SUPERSTAR_CONFIRM: var req = new ChallengeReq(); req.LevelId = _model.LevelVo.LevelId; List <BattleUserCardVo> cards = (List <BattleUserCardVo>)bodys[1]; foreach (var vo1 in cards) { req.CardIds.Add(vo1.UserCardVo.CardId); } BattleModel model = GetData <BattleModel>(); req.Fans.Add(model.FansDict); req.Items.Add(model.ItemsDict); var data = NetWorkManager.GetByteData(req); GetService <BattleService>() .Request(data) .SetCallback(OnGetChallenge, OnChallengeError) .Execute(); break; case MessageConst.GUIDE_BATTLE_SUPERSTAR_CONFIRM: View.Confirm(); break; } }
/// <summary> /// 获取验证码 /// </summary> /// <param name="req">验证码请求体</param> /// <returns></returns> public async Task <string> ChallengeAsync(ChallengeReq req) { using (var httpClient = new HttpClient()) { var data = new StringContent(req.GetJson()); var response = await httpClient.PostAsync(req.GetRequestUrl(), data); if (response.IsSuccessStatusCode) { //{"rescode":"-1","resinfo":"authenticator fail"} //{ "challenge":"9XTR","rescode":"0","resinfo":"this user is ok!"} var result = response.Content.ReadAsStringAsync().Result; Console.WriteLine(result); JObject resultJson = JObject.Parse(result); if (resultJson.SelectToken("rescode").ToString() == "0") { return(resultJson.SelectToken("challenge").ToString()); } return(""); } } return(""); }
/// <summary> /// 处理View消息 /// </summary> /// <param name="message"></param> public override void OnMessage(Message message) { string name = message.Name; object[] body = message.Params; switch (name) { case MessageConst.CMD_STORY_READY: Main.ChangeMenu(MainMenuDisplayState.HideAll); break; case MessageConst.CMD_STORY_BRANCH_SELECTED: string id = (string)body[0]; View.Reset(); _storyModel.LoadStroyById(id, (list) => { View.InitBranch(list); }); break; case MessageConst.CMD_STORY_END: if (_storyModel.StoryType == StoryType.MainStory) { //主线剧情 if (_storyModel.Level.IsPass) { //剧情只在第一次看的时候发送后端请求 OnGetChallengeData(null); return; } var req = new ChallengeReq(); req.LevelId = _storyModel.Level.LevelId; _lastChallengeData = NetWorkManager.GetByteData(req); LoadingOverlay.Instance.Show(); GetService <BattleService>() .Request(_lastChallengeData) .SetCallback(OnGetChallengeData, OnGetChallengeDataFail) .Execute(); } else if (_storyModel.StoryType == StoryType.Visit) { Debug.Log(" MessageConst.CMD_STORY_END"); //主线剧情 if (_storyModel.VisitLevel.IsPass) { //剧情只在第一次看的时候发送后端请求 OnGetChallengeData(null); return; } var req = new VisitingChallengeReq(); req.LevelId = _storyModel.VisitLevel.LevelId; _lastChallengeData = NetWorkManager.GetByteData(req); LoadingOverlay.Instance.Show(); GetService <VisitBattleService>() .Request(_lastChallengeData) .SetCallback(OnGetChallengeData, OnGetChallengeDataFail) .Execute(); } else if (_storyModel.StoryType == StoryType.CreateUser) { //序章创建用户 // EventDispatcher.TriggerEvent(EventConst.CreateUserEnd); // GuideManager.SetRemoteGuideStep(GuideTypePB.MainGuide,GuideConst.MainStep_Pass0_1_End); ModuleManager.Instance.Remove(ModuleConfig.MODULE_STORY); } else if (_storyModel.StoryType == StoryType.LoveAppointment) { //恋爱约会 //如果已经解锁就不必发送消息。 //在这里给后端发送通关约会的协议。 EventDispatcher.TriggerEvent(EventConst.LoveStoryEnd, Appointmentdata); //SendMessage(new Message(MessageConst.CMD_lOVEAPPOINTMENT_STORYEND,Appointmentdata)); ModuleManager.Instance.GoBack(); } else if (_storyModel.StoryType == StoryType.ActivityCapsule) { EventDispatcher.TriggerEvent <string, System.Action>(EventConst.ActivityCapsuleTemplateWatchOverStory, _storyModel.StoryId, () => { ModuleManager.Instance.GoBack(); }); EventDispatcher.TriggerEvent <string, System.Action>(EventConst.WatchActivityStoryOver, _storyModel.StoryId, () => { ModuleManager.Instance.GoBack(); }); } break; } }