/// <summary> /// openid注册 /// </summary> private async void OnRegister(RegisterByOpenIdPara registerByOpenIdPara) { try { if (!Tools.IsNetConnective()) { CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long); return; } registerByOpenIdPara.authCode = AuthCode; registerByOpenIdPara.tel = Tel; registerByOpenIdPara.userPwd = Pwd; registerByOpenIdPara.invitePhone = InvitePhone; registerByOpenIdPara.userType = SelectedIdentityIndex.ToString(); SimpleRD simpleRD = await RestSharpService.RegisterByOpenId(registerByOpenIdPara); if (simpleRD.code == 200) { LoginRD loginRD = await RestSharpService.LoginByOpenId(registerByOpenIdPara.openId); if (loginRD.result.message == null) { CrossToastPopUp.Current.ShowToastSuccess("欢迎您登录美而好家具!", ToastLength.Long); GlobalVariables.LoggedUser = loginRD.result; //将登录用户的信息保存成全局静态变量 GlobalVariables.IsLogged = true; JObject log = new JObject(); log.Add("LoginTime", DateTime.UtcNow); log.Add("UserInfo", JsonConvert.SerializeObject(loginRD.result)); string fileName = Path.Combine(FileSystem.CacheDirectory, "log.dat"); File.WriteAllText(fileName, log.ToString()); Application.Current.MainPage.Navigation.RemovePage(Application.Current.MainPage.Navigation.NavigationStack[0]); MainPage mainPage = new MainPage(); await Application.Current.MainPage.Navigation.PushAsync(mainPage); } else { CrossToastPopUp.Current.ShowToastError(loginRD.result.message, ToastLength.Long); } } else { CrossToastPopUp.Current.ShowToastError("注册失败!请联系管理员!", ToastLength.Long); } } catch (Exception) { throw; } }
/// <summary> /// 注册 /// </summary> private async void OnRegister() { try { if (!Tools.IsNetConnective()) { CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long); return; } RegisterPara registerPara = new RegisterPara { authCode = AuthCode, tel = Tel, userPwd = Pwd, //userName = registerViewModel.UserName, invitePhone = InvitePhone, userType = SelectedIdentityIndex.ToString() }; //registerPara.userType = IsDesignerChecked ? "1" : "0"; SimpleRD simpleRD = await _restSharpService.Register(registerPara); if (simpleRD.code == 200) { CrossToastPopUp.Current.ShowToastSuccess("注册成功!请返回登录页面!", ToastLength.Long); //Application.Current.MainPage.Navigation.PopModalAsync(); } else { CrossToastPopUp.Current.ShowToastError("注册失败!请联系管理员!", ToastLength.Long); } } catch (Exception) { throw; } }