|
@@ -6,8 +6,46 @@
|
|
|
//
|
|
|
|
|
|
#import "AccompanyDetailViewController.h"
|
|
|
+#import "AccompanyCourseInfoCell.h"
|
|
|
+#import "AccompanyArrangeCell.h"
|
|
|
+#import "AccompanyHomeworkCell.h"
|
|
|
+#import "AccompanyRemarkCell.h"
|
|
|
+#import "AccompanyEvaluateCell.h"
|
|
|
+#import "AccompanyStudentEvaCell.h"
|
|
|
+#import "AccompanyDetailBottomView.h"
|
|
|
+#import "HomeworkDetailModel.h"
|
|
|
+#import "EvaluateDetailModel.h"
|
|
|
+#import "AccompanyAlertView.h"
|
|
|
+#import "KSChatConversationViewController.h"
|
|
|
+#import "WMPlayer.h"
|
|
|
+#import "RecordCheckManager.h"
|
|
|
+#import "KSPremissionAlert.h"
|
|
|
+#import "KSMediaManager.h"
|
|
|
|
|
|
-@interface AccompanyDetailViewController ()
|
|
|
+@interface AccompanyDetailViewController ()<UITableViewDelegate,UITableViewDataSource,WMPlayerDelegate>
|
|
|
+{
|
|
|
+ WMPlayer *_wmPlayer;
|
|
|
+ CGRect _playerFrame;
|
|
|
+}
|
|
|
+@property (nonatomic, strong) UIView *bgView;
|
|
|
+
|
|
|
+@property (nonatomic, assign) BOOL isRatation;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UITableView *tableView;
|
|
|
+
|
|
|
+@property (nonatomic, strong) AccompanyAlertView *alertView;
|
|
|
+
|
|
|
+@property (nonatomic, strong) NSMutableArray *fileArray;
|
|
|
+
|
|
|
+@property (nonatomic, strong) KSMediaManager *mediaManager;
|
|
|
+
|
|
|
+@property (nonatomic, strong) HomeworkDetailModel *homeworkModel;
|
|
|
+
|
|
|
+@property (nonatomic, strong) EvaluateDetailModel *evaluateModel;
|
|
|
+
|
|
|
+@property (strong, nonatomic) MBProgressHUD *HUD;
|
|
|
+
|
|
|
+@property (nonatomic, strong) AccompanyDetailBottomView *bottomView;
|
|
|
|
|
|
@end
|
|
|
|
|
@@ -16,8 +54,481 @@
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
// Do any additional setup after loading the view.
|
|
|
+ [self allocTitle:@"课程详情"];
|
|
|
+ [self configUI];
|
|
|
+ [self requestCourseInfoMessage];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)requestCourseInfoMessage {
|
|
|
+ [self requestHomeworkMessage];
|
|
|
+ [self requestEvaluateMessage];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)requestHomeworkMessage {
|
|
|
+ [KSNetworkingManager homeworkDetailRequest:KS_GET courseId:self.courseId success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ self.homeworkModel = [[HomeworkDetailModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
|
|
|
+ if (self.homeworkModel.submitHomework == 1) {
|
|
|
+ if (![NSString isEmptyString:self.homeworkModel.studentAttachments]) {
|
|
|
+ self.fileArray = [NSMutableArray arrayWithArray:[self.homeworkModel.studentAttachments componentsSeparatedByString:@","]];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ self.fileArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ self.fileArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ [self.tableView reloadData];
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
+- (void)requestEvaluateMessage {
|
|
|
+ [KSNetworkingManager selectRepliedRequest:KS_POST courseGroupId:self.courseId courseScheduleId:self.courseGroupId success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ self.evaluateModel = [[EvaluateDetailModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ [self.tableView reloadData];
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
+- (void)configUI {
|
|
|
+ [self.scrollView removeFromSuperview];
|
|
|
+ [self.view addSubview:self.tableView];
|
|
|
+ [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.right.mas_equalTo(self.view);
|
|
|
+ make.top.mas_equalTo(self.view.mas_top);
|
|
|
+ make.bottom.mas_equalTo(self.view.mas_bottom).offset(-iPhoneXSafeBottomMargin);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)evaluateWithStatusLabel:(UILabel *)statusLabel {
|
|
|
+ if ([self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
|
|
|
+ statusLabel.text = @"已结束";
|
|
|
+ statusLabel.textColor = HexRGB(0x999999);
|
|
|
+ // 学生未提交 或者 老师已点评作业 或者老师未布置作业
|
|
|
+ if (self.fileArray.count == 0 || self.homeworkModel.reviewHomework == 1 || self.homeworkModel.decorateHomework == 0) {
|
|
|
+ [self.bottomView.actionButton setTitle:@"确认提交" forState:UIControlStateNormal];
|
|
|
+ [self.bottomView.actionButton setBackgroundColor:HexRGB(0xe5e5e5)];
|
|
|
+ [self.bottomView.actionButton setTitleColor:HexRGB(0x666666) forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self.bottomView.actionButton setTitle:@"确认提交" forState:UIControlStateNormal];
|
|
|
+ [self.bottomView.actionButton setBackgroundColor:THEMECOLOR];
|
|
|
+ [self.bottomView.actionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if ([self.homeworkModel.courseStatus isEqualToString:@"ING"]) {
|
|
|
+ statusLabel.text = @"进行中";
|
|
|
+ statusLabel.textColor = THEMECOLOR;
|
|
|
+ [self.bottomView.actionButton setTitle:@"进入教室" forState:UIControlStateNormal];
|
|
|
+ [self.bottomView.actionButton setBackgroundColor:THEMECOLOR];
|
|
|
+ [self.bottomView.actionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ statusLabel.text = @"未开始";
|
|
|
+ statusLabel.textColor = HexRGB(0xff802c);
|
|
|
+ [self.bottomView.actionButton setTitle:@"进入教室" forState:UIControlStateNormal];
|
|
|
+ [self.bottomView.actionButton setBackgroundColor:THEMECOLOR];
|
|
|
+ [self.bottomView.actionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark --- table data source
|
|
|
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
+ return 6;
|
|
|
+}
|
|
|
+
|
|
|
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
+ if (indexPath.row == 0) {
|
|
|
+ AccompanyCourseInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyCourseInfoCell"];
|
|
|
+ cell.statusLabel.textColor = HexRGB(0x999999);
|
|
|
+ [self evaluateWithStatusLabel:cell.statusLabel];
|
|
|
+ [cell configWithStartTime:self.homeworkModel.startTime endTime:self.homeworkModel.endTime teacherAvatar:self.homeworkModel.teacherAvatar teacherName:self.homeworkModel.teacherName teacherId:self.homeworkModel.teacherId courseSubject:self.homeworkModel.subjectName];
|
|
|
+ cell.hideChatButton = YES;
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+ else if (indexPath.row == 1) {
|
|
|
+ AccompanyEvaluateCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyEvaluateCell"];
|
|
|
+ NSString *message = self.evaluateModel.teacherReplied;
|
|
|
+ BOOL hasEvaluate = [NSString isEmptyString:self.evaluateModel.teacherReplied] ? NO : YES;
|
|
|
+ [cell configWithEvaluateMessage:message hasEvaluate:hasEvaluate];
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+ else if (indexPath.row == 2) {
|
|
|
+ AccompanyStudentEvaCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyStudentEvaCell"];
|
|
|
+ NSString *message = self.evaluateModel.studentReplied;
|
|
|
+ BOOL hasEvaluate = [NSString isEmptyString:self.evaluateModel.studentReplied] ? NO : YES;
|
|
|
+ MJWeakSelf;
|
|
|
+ [cell configWithEvaluateMessage:message starNum:self.evaluateModel.score hasEvaluate:hasEvaluate callback:^{
|
|
|
+ [weakSelf evaluateCourse];
|
|
|
+ }];
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+ else if (indexPath.row == 3) {
|
|
|
+ AccompanyArrangeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyArrangeCell"];
|
|
|
+ BOOL hasArrange = self.homeworkModel.decorateHomework == 1 ? YES : NO;
|
|
|
+ [cell configWithHomeworkContent:self.homeworkModel.content hasArrangeHomework:hasArrange];
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+ else if (indexPath.row == 4) {
|
|
|
+ // studentAttachments
|
|
|
+ BOOL canDisplay = self.homeworkModel.decorateHomework == 1 ? YES : NO;
|
|
|
+ AccompanyHomeworkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyHomeworkCell"];
|
|
|
+ MJWeakSelf;
|
|
|
+ [cell configWithAttachmentArray:self.fileArray canDisplaySubmitView:canDisplay callback:^(HOMEWORKACTION action, NSInteger viewIndex) {
|
|
|
+ [weakSelf operationActionWithType:action index:viewIndex];
|
|
|
+ }];
|
|
|
+
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ AccompanyRemarkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyRemarkCell"];
|
|
|
+ BOOL hasEvaluate = self.homeworkModel.reviewHomework == 1? YES : NO;
|
|
|
+ [cell configWithRemarkMessage:self.homeworkModel.teacherReplied hasEvaluate:hasEvaluate];
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 课程评价
|
|
|
+- (void)evaluateCourse {
|
|
|
+ if (![self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
|
|
|
+ [self MBPShow:@"课程结束之后才可以评价哦~"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ self.alertView = [AccompanyAlertView shareInstance];
|
|
|
+ self.alertView.alertTitle.text = @"课程评价";
|
|
|
+ self.alertView.tipsLabel.text = @"请输入您对本次课程的评价~";
|
|
|
+ self.alertView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
|
|
|
+ [self.alertView showInView:[UIApplication sharedApplication].keyWindow showStarView:YES];
|
|
|
+ MJWeakSelf;
|
|
|
+ [self.alertView sureCallback:^(NSString * _Nonnull content, NSInteger starNum) {
|
|
|
+ [weakSelf evaluateAction:content starNum:starNum];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)evaluateAction:(NSString *)content starNum:(NSInteger)starNum {
|
|
|
+ if ([NSString isEmptyString:content]) {
|
|
|
+ [self MBPShow:@"请输入评价内容"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ [self showhud];
|
|
|
+ [KSNetworkingManager accompanyCourseRepliedRequest:KS_POST courseScheduleId:self.courseId courseGroupId:self.courseGroupId studentReplied:content score:starNum success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ [self removehub];
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ [self MBPShow:@"评价成功"];
|
|
|
+ [self requestCourseInfoMessage];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ [self removehub];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)operationActionWithType:(HOMEWORKACTION)action index:(NSInteger)viewIndex {
|
|
|
+ switch (action) {
|
|
|
+ case HOMEWORKACTION_PLAY:
|
|
|
+ {
|
|
|
+ [self playVideoIndex:viewIndex];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case HOMEWORKACTION_DELETE:
|
|
|
+ {
|
|
|
+ [self deleteVideoIndex:viewIndex];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case HOMEWORKACTION_ADD: // 选择视频作业
|
|
|
+ {
|
|
|
+ // 调用相册
|
|
|
+ self.mediaManager = [[KSMediaManager alloc] init];
|
|
|
+ self.mediaManager.mediaType = MEDIATYPE_VIDEO;
|
|
|
+ self.mediaManager.maxPhotoNumber = 1;
|
|
|
+ self.mediaManager.baseCtrl = self;
|
|
|
+ self.mediaManager.needCropImage = NO;
|
|
|
+ MJWeakSelf;
|
|
|
+ [self.mediaManager noAlertCallback:^(NSString * _Nullable videoUrl, NSMutableArray * _Nullable imageArray, NSMutableArray * _Nullable imageAsset) {
|
|
|
+ NSLog(@"%@", videoUrl);
|
|
|
+ // 上传视频
|
|
|
+ [weakSelf uploadVideoWithUrl:videoUrl];
|
|
|
+ }];
|
|
|
+ [self.mediaManager pushImagePickerController];
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark --- 上传视频文件
|
|
|
+- (void)uploadVideoWithUrl:(NSString *)videoUrl {
|
|
|
+ [self hudTipWillShow:YES];
|
|
|
+ NSData *fileData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:videoUrl]];
|
|
|
+ [KSNetworkingManager videoFileUpload:KS_POST fileData:fileData progress:^(int64_t bytesWritten, int64_t totalBytes) {
|
|
|
+ dispatch_main_async_safe(^{
|
|
|
+ // 显示进度
|
|
|
+ if (self.HUD) {
|
|
|
+ self.HUD.progress = bytesWritten / totalBytes;// progress是回调进度
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ [self hudTipWillShow:NO];
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ NSString *fileUrl = [[dic dictionaryValueForKey:@"data"] stringValueForKey:@"url"];
|
|
|
+ // 删除文件
|
|
|
+ [self removeVideoWithPath:videoUrl];
|
|
|
+ [self.fileArray addObject:fileUrl];
|
|
|
+ [self.tableView reloadData];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ [self hudTipWillShow:NO];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)removeVideoWithPath:(NSString *)videoUrl {
|
|
|
+ NSFileManager *fileMamager = [NSFileManager defaultManager];
|
|
|
+ if ([fileMamager fileExistsAtPath:videoUrl]) {
|
|
|
+ [fileMamager removeItemAtPath:videoUrl error:nil];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 播放
|
|
|
+- (void)playVideoIndex:(NSInteger)index {
|
|
|
+ if (self.fileArray.count > index) {
|
|
|
+ NSString *fileUrl = self.fileArray[index];
|
|
|
+ [self playVideoWithUrl:fileUrl];
|
|
|
+ }
|
|
|
+}
|
|
|
+// 删除
|
|
|
+- (void)deleteVideoIndex:(NSInteger)index {
|
|
|
+ if (self.fileArray.count > index) {
|
|
|
+ [self.fileArray removeObjectAtIndex:index];
|
|
|
+ [self.tableView reloadData];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark ------ WMPlayer
|
|
|
+- (void)playVideoWithUrl:(NSString *)fileUrl {
|
|
|
+ fileUrl = [fileUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
|
+ _playerFrame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
+ _wmPlayer = [[WMPlayer alloc] initWithFrame:_playerFrame];
|
|
|
+ WMPlayerModel *playModel = [[WMPlayerModel alloc] init];
|
|
|
+ playModel.videoURL = [NSURL URLWithString:fileUrl];
|
|
|
+ _wmPlayer.playerModel = playModel;
|
|
|
+ _wmPlayer.delegate = self;
|
|
|
+ _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
|
|
|
+ _bgView.backgroundColor = [UIColor blackColor];
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:_bgView];
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:_wmPlayer];
|
|
|
+ [[UIApplication sharedApplication].keyWindow bringSubviewToFront:_wmPlayer];
|
|
|
+
|
|
|
+ [_wmPlayer play];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)backBtn {
|
|
|
+ [wmplayer removePlayer];
|
|
|
+ [_bgView removeFromSuperview];
|
|
|
+ [self setNeedsStatusBarAppearanceUpdate];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn {
|
|
|
+ self.isRatation = !self.isRatation;
|
|
|
+
|
|
|
+ if (self.isRatation) {
|
|
|
+ [wmplayer removeFromSuperview];
|
|
|
+ [UIView animateWithDuration:1.0f animations:^{
|
|
|
+ wmplayer.transform = CGAffineTransformMakeRotation(M_PI_2);
|
|
|
+
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
+ wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
|
|
|
+ [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [wmplayer removeFromSuperview];
|
|
|
+
|
|
|
+ [UIView animateWithDuration:1.0f animations:^{
|
|
|
+ // 复原
|
|
|
+ wmplayer.transform = CGAffineTransformIdentity;
|
|
|
+
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
+ wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
|
|
|
+ [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)bottomButtonAction {
|
|
|
+ // 判断
|
|
|
+ if ([self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) { // 判断是否能提交作业
|
|
|
+ if (self.fileArray.count == 0 || self.homeworkModel.reviewHomework == 1 || self.homeworkModel.decorateHomework == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else { // 提交作业
|
|
|
+ [self submitHomeworkAction];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self tryJoinRoom];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)submitHomeworkAction {
|
|
|
+ if (self.fileArray.count == 0) {
|
|
|
+ [self MBPShow:@"请选择作业视频"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ NSString *attachment = [self.fileArray componentsJoinedByString:@","];
|
|
|
+ [self showhud];
|
|
|
+ [KSNetworkingManager homeSubmitAction:KS_POST courseScheduleId:self.courseId attachment:attachment success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ [self removehub];
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ [self MBPShow:@"作业提交成功"];
|
|
|
+ [self requestCourseInfoMessage];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ [self removehub];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark --- lazying
|
|
|
+- (AccompanyDetailBottomView *)bottomView {
|
|
|
+ if (!_bottomView) {
|
|
|
+ _bottomView = [AccompanyDetailBottomView shareInstance];
|
|
|
+ _bottomView.frame = CGRectMake(0, 0, kScreenWidth, 70);
|
|
|
+ MJWeakSelf;
|
|
|
+ [_bottomView sureAction:^{
|
|
|
+ [weakSelf bottomButtonAction];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ return _bottomView;
|
|
|
+}
|
|
|
+- (UITableView *)tableView {
|
|
|
+ if (!_tableView) {
|
|
|
+ _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
|
|
+ _tableView.backgroundColor = [UIColor clearColor];
|
|
|
+ _tableView.delegate = self;
|
|
|
+ _tableView.dataSource = self;
|
|
|
+ _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
|
+ _tableView.showsHorizontalScrollIndicator = NO;
|
|
|
+ _tableView.showsVerticalScrollIndicator = NO;
|
|
|
+ _tableView.rowHeight = UITableViewAutomaticDimension;
|
|
|
+ _tableView.estimatedRowHeight = 136.0f;
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyCourseInfoCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyCourseInfoCell"];
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyEvaluateCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyEvaluateCell"];
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyStudentEvaCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyStudentEvaCell"];
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyArrangeCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyArrangeCell"];
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyHomeworkCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyHomeworkCell"];
|
|
|
+ [_tableView registerNib:[UINib nibWithNibName:@"AccompanyRemarkCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyRemarkCell"];
|
|
|
+ _tableView.tableFooterView = self.bottomView;
|
|
|
+
|
|
|
+ }
|
|
|
+ return _tableView;
|
|
|
+}
|
|
|
+- (void)hudTipWillShow:(BOOL)willShow{
|
|
|
+ if (willShow) {
|
|
|
+ [self resignFirstResponder];
|
|
|
+ UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
|
|
+ if (!_HUD) {
|
|
|
+ _HUD = [MBProgressHUD showHUDAddedTo:keyWindow animated:YES];
|
|
|
+ _HUD.removeFromSuperViewOnHide = YES;
|
|
|
+ _HUD.mode = MBProgressHUDModeDeterminateHorizontalBar;
|
|
|
+ _HUD.label.text = @"正在上传视频文件...";
|
|
|
+ _HUD.contentColor = [UIColor whiteColor];
|
|
|
+ _HUD.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
|
|
|
+ _HUD.bezelView.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.8];
|
|
|
+ }else{
|
|
|
+ _HUD.progress = 0;
|
|
|
+ [keyWindow addSubview:_HUD];
|
|
|
+ [_HUD showAnimated:YES];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ [_HUD hideAnimated:YES];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+- (void)tryJoinRoom {
|
|
|
+
|
|
|
+ NSDateFormatter *dateFormatter = [NSObject getDateformatter];
|
|
|
+ [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
|
|
|
+ NSDate *beginDate = [dateFormatter dateFromString:self.homeworkModel.startTime];
|
|
|
+ NSDate *endDate = [dateFormatter dateFromString:self.homeworkModel.endTime];
|
|
|
+ NSDate *currentDate = [NSDate date];
|
|
|
+ NSTimeInterval beginTimeInterval = [beginDate timeIntervalSinceDate:currentDate];
|
|
|
+ NSTimeInterval endTimeInterval = [currentDate timeIntervalSinceDate:endDate];
|
|
|
+ if (beginTimeInterval <= self.joinRoomBeforeTime * 60 && endTimeInterval < 0) {
|
|
|
+ [self joinClassRoom];
|
|
|
+ }
|
|
|
+ else if (endTimeInterval > 0) {
|
|
|
+ [self MBPShow:@"该课程已结束"];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ NSString *tipsString = [NSString stringWithFormat:@"课程还未开始,请在上课前%zd分钟进入", self.joinRoomBeforeTime];
|
|
|
+ [self MBPShow:tipsString];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 加入房间
|
|
|
+- (void)joinClassRoom {
|
|
|
+ // 加入房间前判断摄像头和麦克风逻辑
|
|
|
+ PREMISSIONTYPE micEnable = [RecordCheckManager checkPermissionShowAlert:NO showInView:nil];
|
|
|
+ PREMISSIONTYPE cameraEnable = [RecordCheckManager checkCameraPremissionAvaiable:NO showInView:nil];
|
|
|
+ if (micEnable == PREMISSIONTYPE_YES && cameraEnable == PREMISSIONTYPE_YES) {
|
|
|
+ // 进入教室
|
|
|
+ // 判断是否进行课前检测
|
|
|
+
|
|
|
+// [self.classManager joinRoomWithId:[NSString stringWithFormat:@"%zd", self.courseMessage.internalBaseClassIdentifier] subjectName:self.courseMessage.subjectName subjectId:self.courseMessage.subjectId classEndTime:self.courseMessage.endClassTime quitEndTime:self.quitRomeEndTime inViewController:self];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (micEnable == PREMISSIONTYPE_NO && cameraEnable == PREMISSIONTYPE_NO) { // 如果麦克风权限和摄像头权限都没有
|
|
|
+ [self showAlertWithMessage:@"请开启相机和麦克风访问权限" type:CHECKDEVICETYPE_BOTH];
|
|
|
+ }
|
|
|
+ else if (micEnable == PREMISSIONTYPE_NO) { // 如果没有麦克风权限
|
|
|
+ [self showAlertWithMessage:@"请开启麦克风访问权限" type:CHECKDEVICETYPE_MIC];
|
|
|
+ }
|
|
|
+ else if (cameraEnable == PREMISSIONTYPE_NO) { // 如果没有摄像头权限
|
|
|
+ [self showAlertWithMessage:@"请开启相机访问权限" type:CHECKDEVICETYPE_CAMREA];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)showAlertWithMessage:(NSString *)message type:(CHECKDEVICETYPE)deviceType {
|
|
|
+ [KSPremissionAlert shareInstanceDisplayImage:deviceType message:message showInView:self.view cancel:^{
|
|
|
+
|
|
|
+ } confirm:^{
|
|
|
+ [self openSettingView];
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)openSettingView {
|
|
|
+ if (@available(iOS 10, *)) {
|
|
|
+ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
|
|
|
+ } else {
|
|
|
+ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
|
|
|
+ }
|
|
|
+}
|
|
|
/*
|
|
|
#pragma mark - Navigation
|
|
|
|