/// <summary> /// 登录 /// </summary> /// <param name="type"></param> /// <returns></returns> public bool Login(LoginType type) { ILoginStrategy strategy = null; switch (type) { case LoginType.Email: strategy = new EmailLogin(); break; case LoginType.Phone: strategy = new PhoneLogin(); break; case LoginType.QrCode: strategy = new QrCodeLogin(); break; } _loginContext = new LoginContext(strategy, this); JObject j = _loginContext.Login(); //解析返回值 AuthInfoHelper auth = new AuthInfoHelper(j); if (auth.Code == 200) { ID = auth.UserID; return(true); } return(false); }
/// <summary> /// 构造函数 /// </summary> /// <param name="loginStrategy"></param> /// <param name="user"></param> public LoginContext(ILoginStrategy loginStrategy, User user) { _loginStrategy = loginStrategy; User = user; }