예제 #1
0
        private void Btn_Login_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            MsgBoxPushHelper.RaisePushMsg("登录中...");
            if (string.IsNullOrEmpty(TB_UName.Text))
            {
                MsgBoxPushHelper.RaisePushMsg("账号不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(TB_Pwd.Password))
            {
                MsgBoxPushHelper.RaisePushMsg("密码不能为空!");
                return;
            }

            Account.Instance.UserName = TB_UName.Text;
            if ((bool)CB_MarkPwd.IsChecked)
            {
                Account.Instance.PassWord = TB_Pwd.Password;
            }

            BiliAccount.Account account = BiliAccount.Linq.ByPassword.LoginByPassword(TB_UName.Text, TB_Pwd.Password);

            switch (account.LoginStatus)
            {
            case BiliAccount.Account.LoginStatusEnum.WrongPassword:    //密码错误
                MsgBoxPushHelper.RaisePushMsg("账号或密码错误!");
                break;

            case BiliAccount.Account.LoginStatusEnum.ByPassword:
                Account.Instance.Cookies             = account.strCookies;
                Account.Instance.Csrf_Token          = account.CsrfToken;
                Account.Instance.Expires             = account.Expires_Cookies;
                Account.Instance.AccessToken         = account.AccessToken;
                Account.Instance.RefreshToken        = account.RefreshToken;
                Account.Instance.Expires_AccessToken = account.Expires_AccessToken;
                Account.Instance.Uid       = account.Uid;
                Account.Instance.LoginMode = Account.LOGINMODE.ByPassword;
                Account.Instance.Islogin   = true;
                Account.Instance.GetInfo();

                Account.Instance.Save();

                MsgBoxPushHelper.PushMsg -= MsgBoxPushHelper_PushMsg;
                Close();

                MsgBoxPushHelper.RaisePushMsg($"登录成功!{account.LoginStatus}");
                break;

            default:
                MsgBoxPushHelper.RaisePushMsg($"登录错误,请尝试使用二维码登录。{account.LoginStatus}");
                Btn_TabChange_MouseUp(null, null);
                break;
            }
        }
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            if (string.IsNullOrWhiteSpace(PwdBox.Password))
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(UserTextBox.Text))
            {
                return;
            }
            var user = UserTextBox.Text;
            var pwd  = PwdBox.Password;

            BiliAccount.Account account = null;
            await Task.Run(() =>
            {
                account = BiliAccount.Linq.ByPassword.LoginByPassword(user, pwd);
            });

            if (account == null)
            {
                return;
            }
            switch (account.LoginStatus)
            {
            case BiliAccount.Account.LoginStatusEnum.WrongPassword:
                StatusTextBlock.Text = "密码错误";
                break;

            case BiliAccount.Account.LoginStatusEnum.ByPassword:
                Settings.SESSDATA = account.Cookies["SESSDATA"].Value;
                Settings.Uid      = long.Parse(account.Uid);
                this._canClose    = true;
                this.Hide();
                break;

            case BiliAccount.Account.LoginStatusEnum.NeedSafeVerify:
            case BiliAccount.Account.LoginStatusEnum.NeedTelVerify:
            case BiliAccount.Account.LoginStatusEnum.NeedCaptcha:
            case BiliAccount.Account.LoginStatusEnum.None:
            case BiliAccount.Account.LoginStatusEnum.ByQrCode:
            case BiliAccount.Account.LoginStatusEnum.BySMS:
            default:
                StatusTextBlock.Text = "未知错误,建议更换登录方式";
                break;
            }
        }
예제 #3
0
        /// <summary>
        /// 二维码登陆状态刷新
        /// </summary>
        /// <param name="status"></param>
        /// <param name="account"></param>
        private void ByQRCode_QrCodeStatus_Changed(BiliAccount.Linq.ByQRCode.QrCodeStatus status, BiliAccount.Account account = null)
        {
            switch (status)
            {
            case BiliAccount.Linq.ByQRCode.QrCodeStatus.Scaned:
                if (!HasScaned)
                {
                    Dispatcher?.Invoke(() =>
                    {
                        HasScaned = true;
                        MsgBoxPushHelper.RaisePushMsg("扫描成功,请在手机上确认登录。");
                    });
                }
                break;

            case BiliAccount.Linq.ByQRCode.QrCodeStatus.Success:
                Dispatcher?.Invoke(() =>
                {
                    Account.Instance.Uid        = account.Uid;
                    Account.Instance.Expires    = account.Expires_Cookies;
                    Account.Instance.Cookies    = account.strCookies;
                    Account.Instance.Csrf_Token = account.CsrfToken;
                    Account.Instance.Islogin    = true;
                    Account.Instance.LoginMode  = Account.LOGINMODE.ByQrcode;
                    Account.Instance.Save();

                    MsgBoxPushHelper.PushMsg -= MsgBoxPushHelper_PushMsg;
                    Close();

                    MsgBoxPushHelper.RaisePushMsg($"登录成功!{account.LoginStatus}");
                });
                break;

            default:
                break;
            }
        }