VipCouseDetailViewController.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. //
  2. // VipCouseDetailViewController.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by 王智 on 2024/11/13.
  6. //
  7. #import "VipCouseDetailViewController.h"
  8. #import "AccompanyNavView.h"
  9. #import "CourseGroupPlanAlertView.h"
  10. #import "VipCouseInfoCell.h"
  11. #import "AccompanyEvaluateCell.h"
  12. #import "AccompanyStudentEvaCell.h"
  13. #import "AccompanyArrangeCell.h"
  14. #import "AccompanyHomeworkCell.h"
  15. #import "AccompanyRemarkCell.h"
  16. #import "HomeworkDetailModel.h"
  17. #import "EvaluateDetailModel.h"
  18. #import "KSChatConversationViewController.h"
  19. #import <WMPlayer.h>
  20. #import <RecordCheckManager.h>
  21. #import "KSPremissionAlert.h"
  22. #import "OnlineClassManager.h"
  23. #import "AccompanyDetailBottomView.h"
  24. @interface VipCouseDetailViewController ()<UITableViewDelegate,UITableViewDataSource,WMPlayerDelegate>
  25. {
  26. WMPlayer *_wmPlayer;
  27. CGRect _playerFrame;
  28. }
  29. @property (nonatomic, strong) UIView *bgView;
  30. @property (nonatomic, assign) BOOL isRatation;
  31. @property (nonatomic, strong) AccompanyNavView *navView;
  32. @property (nonatomic, strong) UITableView *tableView;
  33. @property (nonatomic, strong) HomeworkDetailModel *homeworkModel;
  34. @property (nonatomic, strong) EvaluateDetailModel *evaluateModel;
  35. @property (nonatomic, strong) AccompanyDetailBottomView *bottomView;
  36. @property (nonatomic, strong) CourseGroupPlanAlertView *alertView;
  37. @property (nonatomic, strong) NSMutableArray *fileArray;
  38. @property (nonatomic, strong) OnlineClassManager *classManager;
  39. @end
  40. @implementation VipCouseDetailViewController
  41. - (void)viewDidLoad {
  42. [super viewDidLoad];
  43. // Do any additional setup after loading the view.
  44. self.ks_prefersNavigationBarHidden = YES;
  45. [self configUI];
  46. }
  47. - (void)requestCourseInfoMessage {
  48. [self requestHomeworkMessage];
  49. [self requestEvaluateMessage];
  50. [self requestRoomConfig];
  51. }
  52. - (void)viewWillAppear:(BOOL)animated {
  53. [super viewWillAppear:animated];
  54. [self requestCourseInfoMessage];
  55. [self configStatusViewColorWhite:YES];
  56. }
  57. - (void)viewWillDisappear:(BOOL)animated {
  58. [super viewWillDisappear:animated];
  59. [self configStatusViewColorWhite:NO];
  60. }
  61. - (void)requestRoomConfig {
  62. [KSNetworkingManager selectRoomConfigRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  63. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  64. NSDictionary *result = [dic ks_dictionaryValueForKey:@"data"];
  65. self.joinRoomBeforeTime = [result ks_integerValueForKey:@"practiceStartTime"];
  66. self.quitRomeEndTime = [result ks_integerValueForKey:@"practiceEndTime"];
  67. }
  68. else {
  69. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  70. }
  71. } faliure:^(NSError * _Nonnull error) {
  72. }];
  73. }
  74. - (void)requestHomeworkMessage {
  75. [KSNetworkingManager homeworkDetailRequest:KS_GET courseId:self.courseId studentId:self.studentId success:^(NSDictionary * _Nonnull dic) {
  76. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  77. self.homeworkModel = [[HomeworkDetailModel alloc] initWithDictionary:[dic ks_dictionaryValueForKey:@"data"]];
  78. if (self.homeworkModel.submitHomework == 1) {
  79. if (![NSString isEmptyString:self.homeworkModel.studentAttachments]) {
  80. self.fileArray = [NSMutableArray arrayWithArray:[self.homeworkModel.studentAttachments componentsSeparatedByString:@","]];
  81. }
  82. else {
  83. self.fileArray = [NSMutableArray array];
  84. }
  85. }
  86. else {
  87. self.fileArray = [NSMutableArray array];
  88. }
  89. }
  90. else {
  91. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  92. }
  93. [self evaluateViewDisplay];
  94. [self.tableView reloadData];
  95. } faliure:^(NSError * _Nonnull error) {
  96. }];
  97. }
  98. - (void)evaluateViewDisplay {
  99. if ([self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
  100. self.bottomView.hidden = YES;
  101. UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KPortraitWidth, 15)];
  102. self.tableView.tableFooterView = bottomView;
  103. }
  104. else {
  105. CGFloat bottomHeight = [AccompanyDetailBottomView getViewHeight];
  106. UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KPortraitWidth, bottomHeight)];
  107. self.tableView.tableFooterView = bottomView;
  108. self.bottomView.hidden = NO;
  109. self.bottomView.sureButton.userInteractionEnabled = YES;
  110. [self.bottomView.sureButton setTitle:@"进入教室" forState:UIControlStateNormal];
  111. [self.bottomView.sureButton setBackgroundColor:THEMECOLOR];
  112. [self.bottomView.sureButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  113. }
  114. }
  115. - (void)requestEvaluateMessage {
  116. [KSNetworkingManager selectRepliedRequest:KS_POST courseGroupId:self.courseGroupId courseScheduleId:self.courseId studentId:self.studentId success:^(NSDictionary * _Nonnull dic) {
  117. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  118. self.evaluateModel = [[EvaluateDetailModel alloc] initWithDictionary:[dic ks_dictionaryValueForKey:@"data"]];
  119. }
  120. else {
  121. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  122. }
  123. [self.tableView reloadData];
  124. } faliure:^(NSError * _Nonnull error) {
  125. }];
  126. }
  127. - (void)configUI {
  128. [self.scrollView removeFromSuperview];
  129. [self.view addSubview:self.navView];
  130. CGFloat height = [self.navView getViewHeight];
  131. [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
  132. make.left.right.top.mas_equalTo(self.view);
  133. make.height.mas_equalTo(height);
  134. }];
  135. [self.view addSubview:self.tableView];
  136. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  137. make.left.right.mas_equalTo(self.view);
  138. make.top.mas_equalTo(self.view.mas_top).offset(kNaviBarHeight);
  139. make.bottom.mas_equalTo(self.view.mas_bottom);
  140. }];
  141. CGFloat bottomHeight = [AccompanyDetailBottomView getViewHeight];
  142. [self.view addSubview:self.bottomView];
  143. [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  144. make.left.right.bottom.mas_equalTo(self.view);
  145. make.height.mas_equalTo(bottomHeight);
  146. }];
  147. self.bottomView.hidden = YES;
  148. }
  149. - (void)evaluateWithStatusLabel:(UILabel *)statusLabel {
  150. if ([self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
  151. statusLabel.text = @"已结束";
  152. statusLabel.textColor = HexRGB(0x999999);
  153. }
  154. else if ([self.homeworkModel.courseStatus isEqualToString:@"ING"]) {
  155. statusLabel.text = @"进行中";
  156. statusLabel.textColor = THEMECOLOR;
  157. }
  158. else {
  159. statusLabel.text = @"未开始";
  160. statusLabel.textColor = HexRGB(0xff802c);
  161. }
  162. }
  163. #pragma mark --- table data source
  164. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  165. return 6;
  166. }
  167. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  168. if (indexPath.row == 0) {
  169. VipCouseInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VipCouseInfoCell"];
  170. [cell configWithSource:self.homeworkModel];
  171. return cell;
  172. }
  173. else if (indexPath.row == 1) {
  174. AccompanyEvaluateCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyEvaluateCell"];
  175. NSString *message = self.evaluateModel.teacherReplied;
  176. BOOL hasEvaluate = [NSString isEmptyString:self.evaluateModel.teacherReplied] ? NO : YES;
  177. MJWeakSelf;
  178. [cell configWithEvaluateMessage:message hasEvaluate:hasEvaluate courseStatus:self.homeworkModel.courseStatus callback:^{
  179. [weakSelf evaluateCourse];
  180. }];
  181. return cell;
  182. }
  183. else if (indexPath.row == 2) {
  184. AccompanyStudentEvaCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyStudentEvaCell"];
  185. NSString *message = self.evaluateModel.studentReplied;
  186. BOOL hasEvaluate = [NSString isEmptyString:self.evaluateModel.studentReplied] ? NO : YES;
  187. [cell configWithEvaluateMessage:message courseStatus:self.homeworkModel.courseStatus starNum:self.evaluateModel.score hasEvaluate:hasEvaluate];
  188. return cell;
  189. }
  190. else if (indexPath.row == 3) {
  191. AccompanyArrangeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyArrangeCell"];
  192. BOOL hasArrange = self.homeworkModel.decorateHomework == 1 ? YES : NO;
  193. MJWeakSelf;
  194. [cell configWithHomeworkContent:self.homeworkModel.content hasArrangeHomework:hasArrange courseStatus:self.homeworkModel.courseStatus callback:^{
  195. [weakSelf arrangeHomework];
  196. }];
  197. return cell;
  198. }
  199. else if (indexPath.row == 4) {
  200. BOOL hasSubmitHomework = self.homeworkModel.submitHomework == 1 ? YES : NO;
  201. BOOL isExpired = self.homeworkModel.homeworkExpire == 1 ? YES : NO;
  202. AccompanyHomeworkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyHomeworkCell"];
  203. MJWeakSelf;
  204. [cell configWithAttachmentArray:self.fileArray hasSubmit:hasSubmitHomework isExpired:isExpired callback:^(NSInteger viewIndex) {
  205. [weakSelf playVideoIndex:viewIndex];
  206. }];
  207. return cell;
  208. }
  209. else {
  210. AccompanyRemarkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyRemarkCell"];
  211. BOOL hasEvaluate = self.homeworkModel.reviewHomework == 1? YES : NO;
  212. BOOL hasSubmitHomework = self.homeworkModel.submitHomework == 1 ? YES : NO;
  213. MJWeakSelf;
  214. [cell configWithRemarkMessage:self.homeworkModel.teacherReplied hasEvaluate:hasEvaluate hasSubmitHomework:hasSubmitHomework callback:^{
  215. [weakSelf evaluateHomework];
  216. }];
  217. return cell;
  218. }
  219. }
  220. - (void)chatAction {
  221. if (self.homeworkModel && ![NSString isEmptyString:self.homeworkModel.imUserId]) {
  222. TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
  223. model.userID = self.homeworkModel.imUserId;
  224. KSChatConversationViewController *ctrl = [[KSChatConversationViewController alloc] init];
  225. ctrl.conversation = model;
  226. [self.navigationController pushViewController:ctrl animated:YES];
  227. }
  228. }
  229. - (void)evaluateCourse {
  230. if (![self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
  231. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"课程结束之后才可以评价哦"];
  232. return;
  233. }
  234. self.alertView = [CourseGroupPlanAlertView sharedInstance];
  235. [self.alertView configWithHeadTitle:@"评价学员" tipsDesc:@"请输入您对本次课程学员表现的评价" sureButtonTitle:@"提交" maxCount:200];
  236. MJWeakSelf;
  237. [self.alertView configWithDesc:@"" callback:^(NSString * _Nullable planString) {
  238. [weakSelf evaluateAction:planString];
  239. }];
  240. [self.alertView showInView:self.view];
  241. }
  242. - (void)evaluateAction:(NSString *)content {
  243. if ([NSString isEmptyString:content]) {
  244. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请输入评价内容"];
  245. return;
  246. }
  247. [LOADING_MANAGER showHUD];
  248. [KSNetworkingManager teacherCourseRepliedRequest:KS_POST courseScheduleId:self.courseId courseGroupId:self.courseGroupId studentId:self.studentId teacherReplied:content success:^(NSDictionary * _Nonnull dic) {
  249. [LOADING_MANAGER removeHUD];
  250. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  251. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"评价成功"];
  252. [self requestCourseInfoMessage];
  253. }
  254. else {
  255. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  256. }
  257. } faliure:^(NSError * _Nonnull error) {
  258. [LOADING_MANAGER removeHUD];
  259. }];
  260. }
  261. - (void)arrangeHomework {
  262. if (![self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
  263. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"课程结束之后才可以布置作业哦~"];
  264. return;
  265. }
  266. self.alertView = [CourseGroupPlanAlertView sharedInstance];
  267. [self.alertView configWithHeadTitle:@"布置作业" tipsDesc:@"请输入本次课程作业内容" sureButtonTitle:@"提交" maxCount:200];
  268. MJWeakSelf;
  269. [self.alertView configWithDesc:@"" callback:^(NSString * _Nullable planString) {
  270. [weakSelf arrangeAction:planString];
  271. }];
  272. [self.alertView showInView:self.view];
  273. }
  274. - (void)arrangeAction:(NSString *)homeworkContent {
  275. [LOADING_MANAGER showHUD];
  276. [KSNetworkingManager homeworkDecorateRequest:KS_POST content:homeworkContent courseScheduleId:self.courseId success:^(NSDictionary * _Nonnull dic) {
  277. [LOADING_MANAGER removeHUD];
  278. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  279. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"布置成功"];
  280. [self requestCourseInfoMessage];
  281. }
  282. else {
  283. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  284. }
  285. } faliure:^(NSError * _Nonnull error) {
  286. [LOADING_MANAGER removeHUD];
  287. }];
  288. }
  289. // 评价作业
  290. - (void)evaluateHomework {
  291. if (self.homeworkModel.decorateHomework == 0) {
  292. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"您还未布置作业"];
  293. return;
  294. }
  295. else if (self.homeworkModel.submitHomework == 0) {
  296. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"学生还未提交作业"];
  297. return;
  298. }
  299. self.alertView = [CourseGroupPlanAlertView sharedInstance];
  300. [self.alertView configWithHeadTitle:@"作业点评" tipsDesc:@"请输入您对本次作业的点评" sureButtonTitle:@"提交" maxCount:200];
  301. MJWeakSelf;
  302. [self.alertView configWithDesc:@"" callback:^(NSString * _Nullable planString) {
  303. [weakSelf commentAction:planString];
  304. }];
  305. [self.alertView showInView:self.view];
  306. }
  307. - (void)commentAction:(NSString *)commentMessage {
  308. [LOADING_MANAGER showHUD];
  309. [KSNetworkingManager homeworkReviewRequest:KS_POST courseScheduleId:self.courseId studentId:self.studentId review:commentMessage success:^(NSDictionary * _Nonnull dic) {
  310. [LOADING_MANAGER removeHUD];
  311. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  312. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"点评成功"];
  313. [self requestCourseInfoMessage];
  314. }
  315. else {
  316. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  317. }
  318. } faliure:^(NSError * _Nonnull error) {
  319. [LOADING_MANAGER removeHUD];
  320. }];
  321. }
  322. - (void)playVideoIndex:(NSInteger)index {
  323. if (self.fileArray.count > index) {
  324. NSString *fileUrl = self.fileArray[index];
  325. [self playVideoWithUrl:fileUrl];
  326. }
  327. }
  328. #pragma mark ------ WMPlayer
  329. - (void)playVideoWithUrl:(NSString *)fileUrl {
  330. fileUrl = [fileUrl getUrlEndcodeString];
  331. _playerFrame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
  332. _wmPlayer = [[WMPlayer alloc] initWithFrame:_playerFrame];
  333. WMPlayerModel *playModel = [[WMPlayerModel alloc] init];
  334. playModel.videoURL = [NSURL URLWithString:fileUrl];
  335. _wmPlayer.playerModel = playModel;
  336. _wmPlayer.delegate = self;
  337. _wmPlayer.tintColor = THEMECOLOR;
  338. _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
  339. _bgView.backgroundColor = [UIColor blackColor];
  340. [[UIApplication sharedApplication].keyWindow addSubview:_bgView];
  341. [[UIApplication sharedApplication].keyWindow addSubview:_wmPlayer];
  342. [[UIApplication sharedApplication].keyWindow bringSubviewToFront:_wmPlayer];
  343. [_wmPlayer play];
  344. }
  345. - (void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)backBtn {
  346. [wmplayer removePlayer];
  347. [_bgView removeFromSuperview];
  348. [self setNeedsStatusBarAppearanceUpdate];
  349. }
  350. - (void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn {
  351. self.isRatation = !self.isRatation;
  352. if (self.isRatation) {
  353. [wmplayer removeFromSuperview];
  354. [UIView animateWithDuration:1.0f animations:^{
  355. wmplayer.transform = CGAffineTransformMakeRotation(M_PI_2);
  356. } completion:^(BOOL finished) {
  357. wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
  358. [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
  359. [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
  360. }];
  361. }
  362. else {
  363. [wmplayer removeFromSuperview];
  364. [UIView animateWithDuration:1.0f animations:^{
  365. // 复原
  366. wmplayer.transform = CGAffineTransformIdentity;
  367. } completion:^(BOOL finished) {
  368. wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
  369. [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
  370. [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
  371. }];
  372. }
  373. }
  374. #pragma mark --- lazying
  375. - (OnlineClassManager *)classManager {
  376. if (!_classManager) {
  377. _classManager = [[OnlineClassManager alloc] init];
  378. }
  379. return _classManager;
  380. }
  381. - (UITableView *)tableView {
  382. if (!_tableView) {
  383. _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  384. _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  385. _tableView.delegate = self;
  386. _tableView.dataSource = self;
  387. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  388. _tableView.showsVerticalScrollIndicator = NO;
  389. _tableView.showsHorizontalScrollIndicator = NO;
  390. _tableView.backgroundColor = [UIColor clearColor];
  391. _tableView.rowHeight = UITableViewAutomaticDimension;
  392. [_tableView registerNib:[UINib nibWithNibName:@"VipCouseInfoCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"VipCouseInfoCell"];
  393. [_tableView registerNib:[UINib nibWithNibName:@"AccompanyEvaluateCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyEvaluateCell"];
  394. [_tableView registerNib:[UINib nibWithNibName:@"AccompanyStudentEvaCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyStudentEvaCell"];
  395. [_tableView registerNib:[UINib nibWithNibName:@"AccompanyArrangeCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyArrangeCell"];
  396. [_tableView registerNib:[UINib nibWithNibName:@"AccompanyHomeworkCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyHomeworkCell"];
  397. [_tableView registerNib:[UINib nibWithNibName:@"AccompanyRemarkCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyRemarkCell"];
  398. _tableView.estimatedRowHeight = 136.0f;
  399. }
  400. return _tableView;
  401. }
  402. - (AccompanyNavView *)navView {
  403. if (!_navView) {
  404. _navView = [AccompanyNavView shareInstance];
  405. MJWeakSelf;
  406. [_navView navCallback:^{
  407. [weakSelf backAction];
  408. }];
  409. }
  410. return _navView;
  411. }
  412. - (AccompanyDetailBottomView *)bottomView {
  413. if (!_bottomView) {
  414. _bottomView = [AccompanyDetailBottomView shareInstance];
  415. MJWeakSelf;
  416. [_bottomView joinroomCallback:^{
  417. [weakSelf tryJoinRoom];
  418. }];
  419. }
  420. return _bottomView;
  421. }
  422. - (void)tryJoinRoom {
  423. NSDateFormatter *dateFormatter = [NSObject getDateformatter];
  424. [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  425. NSDate *beginDate = [dateFormatter dateFromString:self.homeworkModel.startTime];
  426. NSDate *endDate = [dateFormatter dateFromString:self.homeworkModel.endTime];
  427. NSDate *currentDate = [NSDate date];
  428. NSTimeInterval beginTimeInterval = [beginDate timeIntervalSinceDate:currentDate];
  429. NSTimeInterval endTimeInterval = [currentDate timeIntervalSinceDate:endDate];
  430. if (beginTimeInterval <= self.joinRoomBeforeTime * 60 && endTimeInterval < 0) {
  431. [self joinClassRoom];
  432. }
  433. else if (endTimeInterval > 0) {
  434. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"该课程已结束"];
  435. }
  436. else {
  437. NSString *tipsString = [NSString stringWithFormat:@"课程还未开始,请在上课前%zd分钟进入", self.joinRoomBeforeTime];
  438. [LOADING_MANAGER MBShowAUTOHidingInWindow:tipsString];
  439. }
  440. }
  441. // 加入房间
  442. - (void)joinClassRoom {
  443. // 加入房间前判断摄像头和麦克风逻辑
  444. [RecordCheckManager checkCameraPremissionAvaiableCallback:^(PREMISSIONTYPE type) {
  445. [self afterCheckCameraCheckMic:type];
  446. }];
  447. }
  448. - (void)afterCheckCameraCheckMic:(PREMISSIONTYPE)cameraType {
  449. [RecordCheckManager checkMicPermissionAvaiableCallback:^(PREMISSIONTYPE type) {
  450. if (type == PREMISSIONTYPE_YES && cameraType == PREMISSIONTYPE_YES) {
  451. // 判断是否进行课前检测
  452. [self.classManager joinRoomWithId:self.courseId subjectName:self.homeworkModel.subjectName classEndTime:self.homeworkModel.endTime inViewController:self];
  453. }
  454. else {
  455. NSString *content = @"";
  456. CHECKDEVICETYPE checkType = CHECKDEVICETYPE_BOTH;
  457. if (cameraType == PREMISSIONTYPE_NO && type == PREMISSIONTYPE_NO) {
  458. content = @"请开启相机和麦克风访问权限";
  459. checkType = CHECKDEVICETYPE_BOTH;
  460. }
  461. else if (cameraType == PREMISSIONTYPE_NO && type == PREMISSIONTYPE_YES) {
  462. content = @"请开启相机访问权限";
  463. checkType = CHECKDEVICETYPE_CAMREA;
  464. }
  465. else if (cameraType == PREMISSIONTYPE_YES && type == PREMISSIONTYPE_NO) {
  466. content = @"请开启麦克风访问权限";
  467. checkType = CHECKDEVICETYPE_MIC;
  468. }
  469. [self showAlertWithMessage:content type:checkType];
  470. }
  471. }];
  472. }
  473. - (void)showAlertWithMessage:(NSString *)message type:(CHECKDEVICETYPE)deviceType {
  474. [KSPremissionAlert shareInstanceDisplayImage:deviceType message:message showInView:self.view cancel:^{
  475. } confirm:^{
  476. [self openSettingView];
  477. }];
  478. }
  479. - (void)openSettingView {
  480. if (@available(iOS 10, *)) {
  481. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
  482. } else {
  483. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
  484. }
  485. }
  486. /*
  487. #pragma mark - Navigation
  488. // In a storyboard-based application, you will often want to do a little preparation before navigation
  489. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  490. // Get the new view controller using [segue destinationViewController].
  491. // Pass the selected object to the new view controller.
  492. }
  493. */
  494. @end