Bläddra i källkod

轻会员-Upgrade相关bug修复

lvle 1 år sedan
förälder
incheckning
faa2ee8b53
2 ändrade filer med 26 tillägg och 6 borttagningar
  1. 23 4
      PDF Office/Helper/ServiceHelper.cs
  2. 3 2
      PDF Office/ViewModels/MainWindowViewModel.cs

+ 23 - 4
PDF Office/Helper/ServiceHelper.cs

@@ -774,7 +774,7 @@ namespace PDF_Master.Helper
                         for (int i = 0; i < App.Current.Windows.Count; i++)
                         {
                             MainWindow win = App.Current.Windows[i] as MainWindow;
-                            if (win != null)
+                            if (win != null && win.DataContext != null)
                             {
                                 (win.DataContext as MainWindowViewModel).UserVis = Visibility.Visible;
                                 (win.DataContext as MainWindowViewModel).LoginVis = Visibility.Collapsed;
@@ -845,7 +845,7 @@ namespace PDF_Master.Helper
                         for (int i = 0; i < App.Current.Windows.Count; i++)
                         {
                             MainWindow win = App.Current.Windows[i] as MainWindow;
-                            if (win != null)
+                            if (win != null && win.DataContext != null)
                             {
                                 (win.DataContext as MainWindowViewModel).UserVis = Visibility.Visible;
                                 (win.DataContext as MainWindowViewModel).LoginVis = Visibility.Collapsed;
@@ -907,7 +907,7 @@ namespace PDF_Master.Helper
                     for (int i = 0; i < App.Current.Windows.Count; i++)
                     {
                         MainWindow win = App.Current.Windows[i] as MainWindow;
-                        if (win != null)
+                        if (win != null && win.DataContext != null)
                         {
                             (win.DataContext as MainWindowViewModel).UserVis = Visibility.Collapsed;
                             (win.DataContext as MainWindowViewModel).LoginVis = Visibility.Visible;
@@ -968,7 +968,7 @@ namespace PDF_Master.Helper
                     for (int i = 0; i < App.Current.Windows.Count; i++)
                     {
                         MainWindow win = App.Current.Windows[i] as MainWindow;
-                        if (win != null)
+                        if (win != null && win.DataContext != null)
                         {
                             (win.DataContext as MainWindowViewModel).UserVis = Visibility.Collapsed;
                             (win.DataContext as MainWindowViewModel).LoginVis = Visibility.Visible;
@@ -1111,6 +1111,25 @@ namespace PDF_Master.Helper
                     Console.WriteLine(responseData);
                     reader.Close();
                     JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
+                    App.IsLogin = false;
+                    Settings.Default.UserDate.subscribestatus = -1;
+                    Settings.Default.UserDate.subscribepayType = 0;
+                    App.mainWindowViewModel.UpgradeVis = Visibility.Visible;
+                    if(App.Current.Windows!=null&&App.Current.Windows.Count!=0)
+                    {
+                        for (int i = 0; i < App.Current.Windows.Count; i++)
+                        {
+                            MainWindow win = App.Current.Windows[i] as MainWindow;
+                            if (win != null&& win.DataContext!=null)
+                            {
+                                (win.DataContext as MainWindowViewModel).UserVis = Visibility.Collapsed;
+                                (win.DataContext as MainWindowViewModel).LoginVis = Visibility.Visible;
+                                (win.DataContext as MainWindowViewModel).RegisterVis = Visibility.Collapsed;
+                                (win.DataContext as MainWindowViewModel).UpgradeVis = Visibility.Visible;
+                            }
+                        }
+                    }
+
                     if (response != null)
                     {
                         response.Close();

+ 3 - 2
PDF Office/ViewModels/MainWindowViewModel.cs

@@ -383,11 +383,10 @@ namespace PDF_Master.ViewModels
             //判断本地有没有token,没有显示登录,有再判断登录状态
             if (Settings.Default.AppProperties.LoginToken != "")
             {
-
                 string code = ServiceHelper.GetUser();
                 if (code == "330" || code == "304")
                 {
-
+                    UpgradeVis = Visibility.Visible;
                     LoginVis = Visibility.Visible;
                     RegisterVis = Visibility.Collapsed;
                     OphVis = Visibility.Visible;
@@ -401,12 +400,14 @@ namespace PDF_Master.ViewModels
             }
             else if(Settings.Default.UserDate.Email!="")
             {
+                UpgradeVis = Visibility.Visible;
                 LoginVis = Visibility.Visible;
                 RegisterVis = Visibility.Collapsed;
                 OphVis = Visibility.Visible;
             }
             else
             {
+                UpgradeVis = Visibility.Visible;
                 RegisterVis = Visibility.Visible;
                 LoginVis = Visibility.Collapsed;
                 OphVis = Visibility.Visible;