Пример #1
0
 public static object loginByEmail()
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         var email = getState().loginState.email;
         var password = getState().loginState.password;
         return LoginApi.LoginByEmail(email: email, password: password)
         .Then(loginInfo => {
             var user = new User {
                 id = loginInfo.userId,
                 fullName = loginInfo.userFullName,
                 avatar = loginInfo.userAvatar,
                 title = loginInfo.title,
                 coverImage = loginInfo.coverImageWithCDN
             };
             var dict = new Dictionary <string, User> {
                 { user.id, user }
             };
             dispatcher.dispatch(new UserMapAction {
                 userMap = dict
             });
             dispatcher.dispatch(new LoginByEmailSuccessAction {
                 loginInfo = loginInfo
             });
             dispatcher.dispatch(fetchChannels(1));
             dispatcher.dispatch(fetchCreateChannelFilter());
             dispatcher.dispatch <IPromise>(fetchUserProfile(loginInfo.userId));
             dispatcher.dispatch(new CleanEmailAndPasswordAction());
             UserInfoManager.saveUserInfo(loginInfo);
             AnalyticsManager.LoginEvent("email");
             AnalyticsManager.AnalyticsLogin("email", loginInfo.userId);
             JPushPlugin.setJPushAlias(loginInfo.userId);
             BuglyAgent.SetUserId(loginInfo.userId);
             EventBus.publish(sName: EventBusConstant.login_success, new List <object> {
                 loginInfo.userId
             });
             dispatcher.dispatch(new MainNavigatorPopAction());
         })
         .Catch(error => {
             dispatcher.dispatch(new LoginByEmailFailureAction());
             Debuger.LogError(message: error);
             var customSnackBar = new CustomSnackBar(
                 "登录失败,请重试。"
                 );
             customSnackBar.show();
         });
     }));
 }
Пример #2
0
 void _login()
 {
     if (!this.widget.viewModel.loginBtnEnable || this.widget.viewModel.loginLoading)
     {
         return;
     }
     this._emailFocusNode.unfocus();
     this._passwordFocusNode.unfocus();
     this.widget.actionModel.startLoginByEmail();
     this.widget.actionModel.loginByEmail().Catch(_ => {
         this.widget.actionModel.loginByEmailFailure();
         var customSnackBar = new CustomSnackBar(
             "邮箱或密码不正确,请稍后再试。"
             );
         customSnackBar.show();
     });
 }
Пример #3
0
        public static void checkForUpdates(CheckVersionType type)
        {
            if (type == CheckVersionType.setting)
            {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog(message: "正在检查更新")
                    );
            }

            SettingApi.FetchVersion(Config.platform, Config.store, $"{Config.versionCode}")
            .Then(versionResponse => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }

                var status = versionResponse["status"];
                if (status.ToLower() == "need_update" && versionResponse.ContainsKey("url"))
                {
                    var changeLog = "发现新版本,立即更新体验吧!";
                    if (versionResponse.ContainsKey("changeLog"))
                    {
                        if (versionResponse["changeLog"].isNotEmpty())
                        {
                            changeLog = versionResponse["changeLog"];
                        }
                    }

                    CustomDialogUtils.showCustomDialog(
                        barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                        child: new CustomAlertDialog(
                            "版本更新",
                            changeLog,
                            new List <Widget> {
                        new CustomButton(
                            child: new Text(
                                "稍后再说",
                                style: new TextStyle(
                                    height: 1.33f,
                                    fontSize: 16,
                                    fontFamily: "Roboto-Regular",
                                    color: new Color(0xFF959595)
                                    ),
                                textAlign: TextAlign.center
                                ),
                            onPressed: _ignoreUpdater
                            ),
                        new CustomButton(
                            child: new Text(
                                "立即更新",
                                style: CTextStyle.PLargeBlue,
                                textAlign: TextAlign.center
                                ),
                            onPressed: () => {
                            _ignoreUpdater();
                            var url = versionResponse["url"];
                            Application.OpenURL(url);
                        }
                            )
                    }
                            )
                        );
                }
                else
                {
                    if (type == CheckVersionType.setting)
                    {
                        var customSnackBar = new CustomSnackBar(
                            "当前是最新版本",
                            color: CColors.TextBody
                            );
                        customSnackBar.show();
                    }
                }
            })
            .Catch(error => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }
            });
        }
Пример #4
0
        public static void checkForUpdates(CheckVersionType type)
        {
            if (type == CheckVersionType.setting)
            {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog(message: "正在检查更新")
                    );
            }

            SettingApi.CheckNewVersion(platform: Config.platform, store: Config.store, $"{Config.versionCode}")
            .Then(versionResponse => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }

                var status = versionResponse.status;
                if (status == "NEED_UPDATE" && versionResponse.url.isNotEmpty())
                {
                    if (type == CheckVersionType.initialize && !needNoticeNewVersion() || needForceUpdate())
                    {
                        return;
                    }
                    markUpdateNoticeTime();
                    CustomDialogUtils.showCustomDialog(
                        barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                        child: new CustomAlertDialog(
                            null,
                            message: versionResponse.changeLog,
                            new List <Widget> {
                        new CustomButton(
                            child: new Center(
                                child: new Text(
                                    "稍后再说",
                                    style: CTextStyle.PLargeBody5.defaultHeight(),
                                    textAlign: TextAlign.center
                                    )
                                ),
                            onPressed: CustomDialogUtils.hiddenCustomDialog
                            ),
                        new CustomButton(
                            child: new Center(
                                child: new Text(
                                    "立即更新",
                                    style: CTextStyle.PLargeBlue.defaultHeight(),
                                    textAlign: TextAlign.center
                                    )
                                ),
                            onPressed: () => {
                            CustomDialogUtils.hiddenCustomDialog();
                            Application.OpenURL(url: versionResponse.url);
                        }
                            )
                    },
                            new Stack(
                                children: new List <Widget> {
                        Image.asset("image/updaterBg"),
                        new Align(
                            alignment: Alignment.bottomCenter,
                            child: new Container(height: 1, color: CColors.White)
                            )
                    }
                                )
                            )
                        );
                }
                else
                {
                    if (type == CheckVersionType.setting)
                    {
                        var customSnackBar = new CustomSnackBar(
                            "当前是最新版本",
                            color: CColors.TextBody
                            );
                        customSnackBar.show();
                    }
                }
            })
            .Catch(error => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }
            });
        }
Пример #5
0
        public static void checkForUpdates(CheckVersionType type)
        {
            if (type == CheckVersionType.setting)
            {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog(message: "正在检查更新")
                    );
            }

            SettingApi.CheckNewVersion(platform: Config.platform, store: Config.store, $"{Config.versionCode}")
            .Then(versionResponse => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }

                var status = versionResponse.status;
                if (status == "NEED_UPDATE" && versionResponse.url.isNotEmpty())
                {
                    if (type == CheckVersionType.initialize && !needNoticeNewVersion())
                    {
                        return;
                    }

                    markUpdateNoticeTime();
                    CustomDialogUtils.showCustomDialog(
                        barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                        child: new CustomAlertDialog(
                            "版本更新",
                            message: versionResponse.changeLog,
                            new List <Widget> {
                        new CustomButton(
                            child: new Text(
                                "稍后再说",
                                style: new TextStyle(
                                    height: 1.33f,
                                    fontSize: 16,
                                    fontFamily: "Roboto-Regular",
                                    color: new Color(0xFF959595)
                                    ),
                                textAlign: TextAlign.center
                                ),
                            onPressed: CustomDialogUtils.hiddenCustomDialog
                            ),
                        new CustomButton(
                            child: new Text(
                                "立即更新",
                                style: CTextStyle.PLargeBlue,
                                textAlign: TextAlign.center
                                ),
                            onPressed: () => {
                            CustomDialogUtils.hiddenCustomDialog();
                            Application.OpenURL(url: versionResponse.url);
                        }
                            )
                    }
                            )
                        );
                }
                else
                {
                    if (type == CheckVersionType.setting)
                    {
                        var customSnackBar = new CustomSnackBar(
                            "当前是最新版本",
                            color: CColors.TextBody
                            );
                        customSnackBar.show();
                    }
                }
            })
            .Catch(error => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }
            });
        }