|  | @@ -0,0 +1,535 @@
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//  VipCouseDetailViewController.m
 | 
	
		
			
				|  |  | +//  KulexiuForStudent
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//  Created by 王智 on 2024/11/13.
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#import "VipCouseDetailViewController.h"
 | 
	
		
			
				|  |  | +#import "AccompanyCourseInfoCell.h"
 | 
	
		
			
				|  |  | +#import "AccompanyArrangeCell.h"
 | 
	
		
			
				|  |  | +#import "AccompanyHomeworkCell.h"
 | 
	
		
			
				|  |  | +#import "AccompanyRemarkCell.h"
 | 
	
		
			
				|  |  | +#import "AccompanyEvaluateCell.h"
 | 
	
		
			
				|  |  | +#import "AccompanyStudentEvaCell.h"
 | 
	
		
			
				|  |  | +#import "HomeworkDetailModel.h"
 | 
	
		
			
				|  |  | +#import "EvaluateDetailModel.h"
 | 
	
		
			
				|  |  | +#import "AccompanyAlertView.h"
 | 
	
		
			
				|  |  | +#import <WMPlayer.h>
 | 
	
		
			
				|  |  | +#import <RecordCheckManager.h>
 | 
	
		
			
				|  |  | +#import "KSPremissionAlert.h"
 | 
	
		
			
				|  |  | +#import "KSMediaManager.h"
 | 
	
		
			
				|  |  | +#import "OnlineClassManager.h"
 | 
	
		
			
				|  |  | +#import "HomeworkDetailViewController.h"
 | 
	
		
			
				|  |  | +#import "KSChatConversationViewController.h"
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@interface VipCouseDetailViewController ()<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) OnlineClassManager *classManager;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@property (nonatomic, assign) BOOL canModify;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@property (nonatomic, assign) BOOL isModify; // 是否修改作业
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@end
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@implementation VipCouseDetailViewController
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)viewDidLoad {
 | 
	
		
			
				|  |  | +    [super viewDidLoad];
 | 
	
		
			
				|  |  | +    // Do any additional setup after loading the view.
 | 
	
		
			
				|  |  | +    [self allocTitle:@"课程详情"];
 | 
	
		
			
				|  |  | +    [self configUI];
 | 
	
		
			
				|  |  | +    self.isModify = NO;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)viewWillAppear:(BOOL)animated {
 | 
	
		
			
				|  |  | +    [super viewWillAppear:animated];
 | 
	
		
			
				|  |  | +    [self requestCourseInfoMessage];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)requestCourseInfoMessage {
 | 
	
		
			
				|  |  | +    [self requestHomeworkMessage];
 | 
	
		
			
				|  |  | +    [self requestEvaluateMessage];
 | 
	
		
			
				|  |  | +    [self requestRoomConfig];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)requestRoomConfig {
 | 
	
		
			
				|  |  | +    [KSNetworkingManager selectRoomConfigRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
 | 
	
		
			
				|  |  | +        if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
 | 
	
		
			
				|  |  | +            NSDictionary *result = [dic ks_dictionaryValueForKey:@"data"];
 | 
	
		
			
				|  |  | +            self.joinRoomBeforeTime = [result ks_integerValueForKey:@"practiceStartTime"];
 | 
	
		
			
				|  |  | +            self.quitRomeEndTime = [result ks_integerValueForKey:@"practiceEndTime"];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        else {
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    } faliure:^(NSError * _Nonnull error) {
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +    }];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)requestHomeworkMessage {
 | 
	
		
			
				|  |  | +    [KSNetworkingManager homeworkDetailRequest:KS_GET courseId:self.courseId success:^(NSDictionary * _Nonnull dic) {
 | 
	
		
			
				|  |  | +        if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
 | 
	
		
			
				|  |  | +            self.homeworkModel = [[HomeworkDetailModel alloc] initWithDictionary:[dic ks_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 {
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        [self evaluateViewDisplay];
 | 
	
		
			
				|  |  | +        [self.tableView reloadData];
 | 
	
		
			
				|  |  | +    } faliure:^(NSError * _Nonnull error) {
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +    }];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)evaluateViewDisplay {
 | 
	
		
			
				|  |  | +    // 老师布置过作业且没有点评 可以点击
 | 
	
		
			
				|  |  | +    if (self.homeworkModel.reviewHomework == 1 || self.homeworkModel.decorateHomework == 0) {
 | 
	
		
			
				|  |  | +        self.canModify = NO;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    else {
 | 
	
		
			
				|  |  | +        self.canModify = YES;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)requestEvaluateMessage {
 | 
	
		
			
				|  |  | +    [KSNetworkingManager selectRepliedRequest:KS_POST courseGroupId:self.courseGroupId courseScheduleId:self.courseId success:^(NSDictionary * _Nonnull dic) {
 | 
	
		
			
				|  |  | +        if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
 | 
	
		
			
				|  |  | +            self.evaluateModel = [[EvaluateDetailModel alloc] initWithDictionary:[dic ks_dictionaryValueForKey:@"data"]];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        else {
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER MBShowAUTOHidingInWindow: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);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    else if ([self.homeworkModel.courseStatus isEqualToString:@"ING"]) {
 | 
	
		
			
				|  |  | +        statusLabel.text = @"进行中";
 | 
	
		
			
				|  |  | +        statusLabel.textColor = THEMECOLOR;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    else {
 | 
	
		
			
				|  |  | +        statusLabel.text = @"未开始";
 | 
	
		
			
				|  |  | +        statusLabel.textColor = HexRGB(0xff802c);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#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 isMusicRoom:NO];
 | 
	
		
			
				|  |  | +        MJWeakSelf;
 | 
	
		
			
				|  |  | +        [cell chatCalkback:^{
 | 
	
		
			
				|  |  | +            [weakSelf chatAction];
 | 
	
		
			
				|  |  | +        }];
 | 
	
		
			
				|  |  | +        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;
 | 
	
		
			
				|  |  | +        BOOL isExpired = self.homeworkModel.homeworkExpire == 1 ? YES : NO;
 | 
	
		
			
				|  |  | +        AccompanyHomeworkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyHomeworkCell"];
 | 
	
		
			
				|  |  | +        cell.canSubmit = NO;
 | 
	
		
			
				|  |  | +        cell.showSubmitButton = self.canModify;
 | 
	
		
			
				|  |  | +        MJWeakSelf;
 | 
	
		
			
				|  |  | +        [cell configWithAttachmentArray:self.fileArray canDisplaySubmitView:canDisplay isExpired:isExpired 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)chatAction {
 | 
	
		
			
				|  |  | +    if (self.homeworkModel && ![NSString isEmptyString:self.homeworkModel.imUserId]) {
 | 
	
		
			
				|  |  | +        TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
 | 
	
		
			
				|  |  | +        model.userID = self.homeworkModel.imUserId;
 | 
	
		
			
				|  |  | +        KSChatConversationViewController *ctrl = [[KSChatConversationViewController alloc] init];
 | 
	
		
			
				|  |  | +        ctrl.conversation = model;
 | 
	
		
			
				|  |  | +        [self.navigationController pushViewController:ctrl animated:YES];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +// 课程评价
 | 
	
		
			
				|  |  | +- (void)evaluateCourse {
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    if (![self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER MBShowAUTOHidingInWindow:@"课程结束之后才可以评价哦~"];
 | 
	
		
			
				|  |  | +        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]) {
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请输入评价内容"];
 | 
	
		
			
				|  |  | +        return;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    [LOADING_MANAGER showHUD];
 | 
	
		
			
				|  |  | +    [KSNetworkingManager accompanyCourseRepliedRequest:KS_POST courseScheduleId:self.courseId courseGroupId:self.courseGroupId studentReplied:content score:starNum success:^(NSDictionary * _Nonnull dic) {
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER removeHUD];
 | 
	
		
			
				|  |  | +        if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER MBShowAUTOHidingInWindow:@"评价成功"];
 | 
	
		
			
				|  |  | +            [self requestCourseInfoMessage];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        else {
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    } faliure:^(NSError * _Nonnull error) {
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER removeHUD];
 | 
	
		
			
				|  |  | +    }];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (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];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        case HOMEWORKACTION_HOMEWOEKPAGE:
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            HomeworkDetailViewController *detalVC = [[HomeworkDetailViewController alloc] init];
 | 
	
		
			
				|  |  | +            detalVC.courseId = self.courseId;
 | 
	
		
			
				|  |  | +            MJWeakSelf;
 | 
	
		
			
				|  |  | +            [detalVC backRefreshAction:^{
 | 
	
		
			
				|  |  | +                [weakSelf requestCourseInfoMessage];
 | 
	
		
			
				|  |  | +            }];
 | 
	
		
			
				|  |  | +            [self.navigationController pushViewController:detalVC animated:YES];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        default:
 | 
	
		
			
				|  |  | +            break;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#pragma mark --- 上传视频文件
 | 
	
		
			
				|  |  | +- (void)uploadVideoWithUrl:(NSString *)videoUrl {
 | 
	
		
			
				|  |  | +    [self hudTipWillShow:YES];
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    NSURL *uploadFileUrl = [NSURL fileURLWithPath:videoUrl];
 | 
	
		
			
				|  |  | +    NSData *fileData = [NSData dataWithContentsOfURL:uploadFileUrl];
 | 
	
		
			
				|  |  | +    NSString *suffix = [NSString stringWithFormat:@".%@",[uploadFileUrl pathExtension]];
 | 
	
		
			
				|  |  | +    [UPLOAD_MANAGER configWithfilePath:@"homework"];
 | 
	
		
			
				|  |  | +    [UPLOAD_MANAGER videoUpload:fileData fileName:@"video" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
 | 
	
		
			
				|  |  | +        dispatch_main_async_safe(^{
 | 
	
		
			
				|  |  | +            // 显示进度
 | 
	
		
			
				|  |  | +            if (self.HUD) {
 | 
	
		
			
				|  |  | +                self.HUD.progress = bytesWritten / totalBytes;// progress是回调进度
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    } successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
 | 
	
		
			
				|  |  | +        [self hudTipWillShow:NO];
 | 
	
		
			
				|  |  | +        NSString *fileUrl = [fileUrlArray lastObject];
 | 
	
		
			
				|  |  | +        self.isModify = YES;
 | 
	
		
			
				|  |  | +        // 删除文件
 | 
	
		
			
				|  |  | +        [self removeVideoWithPath:videoUrl];
 | 
	
		
			
				|  |  | +        [self.fileArray addObject:fileUrl];
 | 
	
		
			
				|  |  | +        [self.tableView reloadData];
 | 
	
		
			
				|  |  | +    } faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
 | 
	
		
			
				|  |  | +        [self hudTipWillShow:NO];
 | 
	
		
			
				|  |  | +        if (![NSString isEmptyString:descMessaeg]) {
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER MBShowAUTOHidingInWindow:descMessaeg];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (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];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    self.isModify = YES;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#pragma mark ------ WMPlayer
 | 
	
		
			
				|  |  | +- (void)playVideoWithUrl:(NSString *)fileUrl {
 | 
	
		
			
				|  |  | +    fileUrl = [fileUrl getUrlEndcodeString];
 | 
	
		
			
				|  |  | +    _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];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (void)submitHomeworkAction {
 | 
	
		
			
				|  |  | +    if (self.homeworkModel.homeworkExpire == 1) {
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER MBShowAUTOHidingInWindow:@"作业已过期无法提交和查看!"];
 | 
	
		
			
				|  |  | +        return;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    if (self.isModify == NO) {
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请先选择视频文件"];
 | 
	
		
			
				|  |  | +        return;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    if (self.fileArray.count == 0) {
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请选择作业视频"];
 | 
	
		
			
				|  |  | +        return;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    NSString *attachment = [self.fileArray componentsJoinedByString:@","];
 | 
	
		
			
				|  |  | +    [LOADING_MANAGER showHUD];
 | 
	
		
			
				|  |  | +    [KSNetworkingManager homeSubmitAction:KS_POST courseScheduleId:self.courseId attachment:attachment success:^(NSDictionary * _Nonnull dic) {
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER removeHUD];
 | 
	
		
			
				|  |  | +        if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER MBShowAUTOHidingInWindow:@"作业提交成功"];
 | 
	
		
			
				|  |  | +            [self requestCourseInfoMessage];
 | 
	
		
			
				|  |  | +            self.isModify = NO;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        else {
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    } faliure:^(NSError * _Nonnull error) {
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER removeHUD];
 | 
	
		
			
				|  |  | +    }];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#pragma mark --- lazying
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (OnlineClassManager *)classManager {
 | 
	
		
			
				|  |  | +    if (!_classManager) {
 | 
	
		
			
				|  |  | +        _classManager = [[OnlineClassManager alloc] init];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    return _classManager;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +- (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"];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    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 = HexRGBAlpha(0x000000, 0.8);
 | 
	
		
			
				|  |  | +        }else{
 | 
	
		
			
				|  |  | +            _HUD.progress = 0;
 | 
	
		
			
				|  |  | +            [keyWindow addSubview:_HUD];
 | 
	
		
			
				|  |  | +            [_HUD showAnimated:YES];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }else{
 | 
	
		
			
				|  |  | +        [_HUD hideAnimated: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
 |