ExamTicketViewController.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // ExamTicketViewController.m
  3. // MusicGradeExam
  4. //
  5. // Created by Kyle on 2020/7/13.
  6. // Copyright © 2020 DayaMusic. All rights reserved.
  7. //
  8. #import "ExamTicketViewController.h"
  9. #import "TicketBodyView.h"
  10. #import "WaitExamViewController.h"
  11. #import "TicketListModel.h"
  12. @interface ExamTicketViewController ()
  13. @property (nonatomic, strong) TicketBodyView *bodyView;
  14. @property (nonatomic, strong) TicketListModel *sourceModel;
  15. @end
  16. @implementation ExamTicketViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. // Do any additional setup after loading the view.
  20. self.ks_prefersNavigationBarHidden = YES;
  21. self.view.backgroundColor = HexRGB(0xf3f4f8);
  22. [self configUI];
  23. }
  24. - (void)viewWillAppear:(BOOL)animated {
  25. [super viewWillAppear:animated];
  26. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
  27. [self requestData];
  28. }
  29. - (void)requestData {
  30. [KSRequestManager queryCertificationPageRequest:KS_GET examRegistrationId:nil success:^(NSDictionary * _Nonnull dic) {
  31. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  32. NSArray *source = [dic arrayValueForKey:@"data"];
  33. if (source.count) {
  34. self.sourceModel = [[TicketListModel alloc] initWithDictionary:[source firstObject]];
  35. }
  36. else {
  37. self.sourceModel = nil;
  38. }
  39. }
  40. else {
  41. [self MBPShow:MESSAGEKEY];
  42. }
  43. [self refreshUI];
  44. } faliure:^(NSError * _Nonnull error) {
  45. }];
  46. }
  47. - (void)refreshUI {
  48. if (self.sourceModel) {
  49. [self.bodyView configMessage:self.sourceModel];
  50. self.bodyView.isEmpty = NO;
  51. }
  52. else {
  53. self.bodyView.isEmpty = YES;
  54. }
  55. }
  56. - (void)configUI {
  57. _bodyView = [TicketBodyView shareInstance];
  58. CGFloat viewHeight = 412 + 22 + 25 + 30 + iPhoneXSafeTopMargin + 18 + 50 + 20;
  59. viewHeight = viewHeight > kScreenHeight - kTabBarHeight ? viewHeight : kScreenHeight - kTabBarHeight;
  60. _bodyView.frame = CGRectMake(0, 0, kScreenWidth, viewHeight);
  61. MJWeakSelf;
  62. [_bodyView joinRoomCallback:^(TicketListModel * _Nonnull source, BOOL goBack) {
  63. if (!goBack) {
  64. [weakSelf joinRoomAction:[NSString stringWithFormat:@"%.0f",source.examRegistrationId]];
  65. }
  66. }];
  67. [self.scrollView addSubview:_bodyView];
  68. [self.scrollView setContentSize:CGSizeMake(kScreenWidth, viewHeight)];
  69. }
  70. - (void)joinRoomAction:(NSString *)examRegistrationId {
  71. WaitExamViewController *waitCtrl = [[WaitExamViewController alloc] init];
  72. waitCtrl.examRegistrationId = examRegistrationId;
  73. [self.navigationController pushViewController:waitCtrl animated:YES];
  74. }
  75. /*
  76. #pragma mark - Navigation
  77. // In a storyboard-based application, you will often want to do a little preparation before navigation
  78. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  79. // Get the new view controller using [segue destinationViewController].
  80. // Pass the selected object to the new view controller.
  81. }
  82. */
  83. @end