| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- //
- // WaitExamViewController.m
- // MusicGradeExam
- //
- // Created by Kyle on 2020/7/15.
- // Copyright © 2020 DayaMusic. All rights reserved.
- //
- #import "WaitExamViewController.h"
- #import "WaitExamBodyView.h"
- #import "TicketDetailModel.h"
- #import "OnlineRoomManager.h"
- @interface WaitExamViewController ()
- @property (nonatomic, strong) WaitExamBodyView *bodyView;
- @property (nonatomic, strong) TicketDetailModel *sourceModel;
- @property (nonatomic, strong) OnlineRoomManager *classManager;
- @property (nonatomic, assign) BOOL cancleRequest;
- @end
- @implementation WaitExamViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self allocTitle:@"待考"];
- self.view.backgroundColor = HexRGB(0xf3f4f8);
- [self configUI];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backLoginView) name:@"backLoginView" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshWaitList) name:RefreshWaitListNotification object:nil];
- }
- - (void)refreshWaitList {
- [self requestDataWithHub:NO];
- }
- // 试听课被挤掉
- - (void)backLoginView {
- _cancleRequest = YES;
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
- if(@available(iOS 13.0, *)){
- [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;
- }
- if (_cancleRequest) {
- _cancleRequest = NO;
- [KSRequestManager logoutAction];
- return;
- }
- [self requestDataWithHub:YES];
- }
- - (void)requestDataWithHub:(BOOL)needHub {
- if (needHub) {
- [self showhud];
- }
-
- [KSRequestManager needCheckingDetailRequest:KS_GET examRegistrationId:self.examRegistrationId success:^(NSDictionary * _Nonnull dic) {
- if (needHub) {
- [self removehub];
- }
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- self.sourceModel = [[TicketDetailModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
- [self.bodyView configMessageSource:self.sourceModel];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- if (needHub) {
- [self removehub];
- }
- }];
- }
- - (void)configUI {
- self.scrollView.backgroundColor = HexRGB(0xf3f4f8);
- self.scrollView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - kTabBarHeight - iPhoneXSafeBottomMargin);
- _bodyView = [WaitExamBodyView shareInstance];
- CGFloat viewHeight = 206 + 200 + 19 + 204 + 50 + 21 + 9 + 50 + 27;
- viewHeight = viewHeight > kScreenHeight - kTabBarHeight - iPhoneXSafeBottomMargin ? viewHeight : kScreenHeight - kTabBarHeight - iPhoneXSafeBottomMargin;
- _bodyView.frame = CGRectMake(0, 0, kScreenWidth, viewHeight);
- MJWeakSelf;
- [_bodyView operationCallback:^(JOINROOMACTION action, TicketDetailModel * _Nullable source) {
- [weakSelf opreationAction:action source:source];
- }];
- [self.scrollView addSubview:_bodyView];
- [self.scrollView setContentSize:CGSizeMake(kScreenWidth, viewHeight)];
-
- }
- - (void)opreationAction:(JOINROOMACTION)action source:(TicketDetailModel *)source {
- switch (action) {
- case JOINROOMACTION_SIGN: // 签到
- {
- [self signAction];
- }
- break;
- case JOINROOMACTION_GUIDE: // 引导页
- {
-
- }
- break;
- case JOINROOMACTION_JOIN: // 加入房间
- {
- NSString *roomId = [NSString stringWithFormat:@"%.0f", source.examRegistrationId];
- [self joinRoomAction:roomId];
- }
- break;
- default:
- break;
- }
- }
- #pragma mark ----- 签到
- - (void)signAction {
- [self showhud];
- [KSRequestManager signInRequest:KS_POST examRegistrationId:self.examRegistrationId success:^(NSDictionary * _Nonnull dic) {
- [self removehub];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- self.bodyView.isSign = YES;
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [self removehub];
- }];
- }
- #pragma mark ----- 加入房间
- - (void)joinRoomAction:(NSString *)roomId {
- [self.classManager joinRoomWithId:roomId inViewController:self];
- }
- - (OnlineRoomManager *)classManager {
- if (!_classManager) {
- _classManager = [[OnlineRoomManager alloc] init];
- }
- return _classManager;
- }
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- /*
- #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
|