LoginViewController.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // LoginViewController.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by Kyle on 2022/3/17.
  6. //
  7. #import "LoginViewController.h"
  8. #import "LoginBodyView.h"
  9. #import "VefiCodeLoginController.h"
  10. #import "PasswordLoginController.h"
  11. #import "KSBaseWKWebViewController.h"
  12. #import "NSString+phone.h"
  13. @interface LoginViewController ()
  14. @property (nonatomic, strong) LoginBodyView *bodyView;
  15. @end
  16. @implementation LoginViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. // Do any additional setup after loading the view.
  20. self.ks_prefersNavigationBarHidden = YES;
  21. [self configUI];
  22. }
  23. - (void)configUI {
  24. _bodyView = [LoginBodyView shareInstance];
  25. if (![NSString isEmptyString:UserDefault(PHONEKEY)]) {
  26. _bodyView.phoneField.text = UserDefault(PHONEKEY);
  27. }
  28. CGFloat height = KPortraitHeight;
  29. [self.scrollView addSubview:_bodyView];
  30. [_bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.top.mas_equalTo(self.scrollView.mas_top);
  32. make.right.left.mas_equalTo(self.view);
  33. make.height.mas_equalTo(height);
  34. }];
  35. MJWeakSelf;
  36. [_bodyView loginActionCallback:^(LOGINACTION action, NSString * _Nonnull phoneNo) {
  37. [weakSelf operationWithType:action phone:phoneNo];
  38. }];
  39. }
  40. - (void)operationWithType:(LOGINACTION)action phone:(NSString *)phone {
  41. switch (action) {
  42. case LOGINACTION_CODE:
  43. {
  44. if (![NSString isMobileNum:phone]) {
  45. [self MBPShow:@"手机号码输入有误"];
  46. return;
  47. }
  48. VefiCodeLoginController *ctrl = [[VefiCodeLoginController alloc] init];
  49. ctrl.phoneNo = phone;
  50. [self.navigationController pushViewController:ctrl animated:YES];
  51. }
  52. break;
  53. case LOGINACTION_PASSWORD:
  54. {
  55. PasswordLoginController *ctrl = [[PasswordLoginController alloc] init];
  56. [self.navigationController pushViewController:ctrl animated:YES];
  57. }
  58. break;
  59. case LOGINACTION_REGPROTOCAL: // 注册协议
  60. {
  61. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  62. webCtrl.url = [NSString stringWithFormat:@"%@%@",WEBHOST, @"/#/registerProtocol"];
  63. [self.navigationController pushViewController:webCtrl animated:YES];
  64. }
  65. break;
  66. case LOGINACTION_PRIVACY: // 隐私协议
  67. {
  68. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  69. webCtrl.url = [NSString stringWithFormat:@"%@%@",WEBHOST, @"/#/privacyProtocol"];
  70. [self.navigationController pushViewController:webCtrl animated:YES];
  71. }
  72. break;
  73. default:
  74. break;
  75. }
  76. }
  77. /*
  78. #pragma mark - Navigation
  79. // In a storyboard-based application, you will often want to do a little preparation before navigation
  80. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  81. // Get the new view controller using [segue destinationViewController].
  82. // Pass the selected object to the new view controller.
  83. }
  84. */
  85. @end