123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- //
- // ExamTicketViewController.m
- // MusicGradeExam
- //
- // Created by Kyle on 2020/7/13.
- // Copyright © 2020 DayaMusic. All rights reserved.
- //
- #import "ExamTicketViewController.h"
- #import "TicketBodyView.h"
- #import "WaitExamViewController.h"
- #import "TicketListModel.h"
- @interface ExamTicketViewController ()
- @property (nonatomic, strong) TicketBodyView *bodyView;
- @property (nonatomic, strong) TicketListModel *sourceModel;
- @end
- @implementation ExamTicketViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- self.view.backgroundColor = HexRGB(0xf3f4f8);
- [self configUI];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
- [self requestData];
- }
- - (void)requestData {
- [KSRequestManager queryCertificationPageRequest:KS_GET examRegistrationId:nil success:^(NSDictionary * _Nonnull dic) {
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *source = [dic arrayValueForKey:@"data"];
- if (source.count) {
- self.sourceModel = [[TicketListModel alloc] initWithDictionary:[source firstObject]];
- }
- else {
- self.sourceModel = nil;
- }
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- [self refreshUI];
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)refreshUI {
- if (self.sourceModel) {
- [self.bodyView configMessage:self.sourceModel];
- self.bodyView.isEmpty = NO;
- }
- else {
- self.bodyView.isEmpty = YES;
- }
- }
- - (void)configUI {
- _bodyView = [TicketBodyView shareInstance];
- CGFloat viewHeight = 412 + 22 + 25 + 30 + iPhoneXSafeTopMargin + 18 + 50 + 20;
- viewHeight = viewHeight > kScreenHeight - kTabBarHeight ? viewHeight : kScreenHeight - kTabBarHeight;
- _bodyView.frame = CGRectMake(0, 0, kScreenWidth, viewHeight);
- MJWeakSelf;
- [_bodyView joinRoomCallback:^(TicketListModel * _Nonnull source, BOOL goBack) {
- if (!goBack) {
- [weakSelf joinRoomAction:[NSString stringWithFormat:@"%.0f",source.examRegistrationId]];
- }
- }];
- [self.scrollView addSubview:_bodyView];
- [self.scrollView setContentSize:CGSizeMake(kScreenWidth, viewHeight)];
- }
- - (void)joinRoomAction:(NSString *)examRegistrationId {
- WaitExamViewController *waitCtrl = [[WaitExamViewController alloc] init];
- waitCtrl.examRegistrationId = examRegistrationId;
- [self.navigationController pushViewController:waitCtrl animated:YES];
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|