ScanLoginViewController.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // ScanLoginViewController.m
  3. // GuanYueTeamTeacher
  4. //
  5. // Created by 王智 on 2024/3/12.
  6. //
  7. #import "ScanLoginViewController.h"
  8. #import "ScanLoginBodyView.h"
  9. #import "ScanFailViewController.h"
  10. @interface ScanLoginViewController ()
  11. @property (nonatomic, strong) ScanLoginBodyView *bodyView;
  12. @end
  13. @implementation ScanLoginViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. // Do any additional setup after loading the view.
  17. [self allocTitle:@"授权登录"];
  18. [self configUI];
  19. }
  20. - (void)configUI {
  21. [self.scrollView removeFromSuperview];
  22. [self.view addSubview:self.bodyView];
  23. [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.left.right.top.bottom.mas_equalTo(self.view);
  25. }];
  26. }
  27. - (ScanLoginBodyView *)bodyView {
  28. if (!_bodyView) {
  29. _bodyView = [ScanLoginBodyView shareInstance];
  30. MJWeakSelf;
  31. [_bodyView authActionCallback:^(BOOL isAuth) {
  32. [weakSelf authAction:isAuth];
  33. }];
  34. }
  35. return _bodyView;
  36. }
  37. - (void)authAction:(BOOL)isAuth {
  38. if (isAuth) {
  39. [LOADING_MANAGER showCustomLoading:@"登录中.."];
  40. [KSNetworkingManager verifyQrcode:KS_POST uuid:self.uuid success:^(NSDictionary * _Nonnull dic) {
  41. [LOADING_MANAGER removeCustomLoading];
  42. if ([dic ks_integerValueForKey:@"code"] == 200) {
  43. [LOADING_MANAGER KSShowMsg:@"授权成功" promptCompletion:^{
  44. [self.navigationController popToRootViewControllerAnimated:YES];
  45. }];
  46. }
  47. else {
  48. ScanFailViewController *ctrl = [[ScanFailViewController alloc] init];
  49. if ([dic ks_integerValueForKey:@"code"] == 5440) { // 过期
  50. ctrl.failType = SCANFAIL_EXPIRED;
  51. }
  52. else {
  53. ctrl.failType = SCANFAIL_AUTHFAILED;
  54. }
  55. [self.navigationController pushViewController:ctrl animated:YES];
  56. }
  57. } faliure:^(NSError * _Nonnull error) {
  58. [LOADING_MANAGER removeCustomLoading];
  59. }];
  60. }
  61. else {
  62. [self.navigationController popToRootViewControllerAnimated:YES];
  63. }
  64. }
  65. - (void)backAction {
  66. [self.navigationController popToRootViewControllerAnimated:YES];
  67. }
  68. /*
  69. #pragma mark - Navigation
  70. // In a storyboard-based application, you will often want to do a little preparation before navigation
  71. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  72. // Get the new view controller using [segue destinationViewController].
  73. // Pass the selected object to the new view controller.
  74. }
  75. */
  76. @end