VideoCourseViewController.m 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. //
  2. // VideoCourseViewController.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by Kyle on 2022/3/28.
  6. //
  7. #import "VideoCourseViewController.h"
  8. #import "KSBaseWKWebViewController.h"
  9. #import "JXCategoryView.h"
  10. #import "JXPagerListRefreshView.h"
  11. #import "VideoListBodyView.h"
  12. #import "TeacherInfo.h"
  13. #import "UserInfoManager.h"
  14. #define HEADER_HEIGHT (50)
  15. @interface VideoCourseViewController ()<JXPagerViewDelegate, JXPagerMainTableViewGestureDelegate,JXCategoryViewDelegate>
  16. @property (nonatomic, assign) NSInteger selectedIndex;
  17. @property (nonatomic, strong) NSMutableArray *listViewArray;
  18. @property (nonatomic, strong) TeacherInfo *teacherInfo;
  19. @end
  20. @implementation VideoCourseViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. // Do any additional setup after loading the view.
  24. [self allocTitle:@"视频课"];
  25. _titles = @[@"已上架",@"审核中",@"审核失败"];
  26. [self configUI];
  27. }
  28. - (void)configUI {
  29. [self rightButtonTitle:@"创建课程" color:HexRGB(0x000000)];
  30. [self.scrollView removeFromSuperview];
  31. self.view.backgroundColor = HexRGB(0xf6f8f9);
  32. _categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, HEADER_HEIGHT)];
  33. self.categoryView.titles = self.titles;
  34. self.categoryView.delegate = self;
  35. self.categoryView.titleFont = [UIFont systemFontOfSize:17.0f];
  36. self.categoryView.titleSelectedFont = [UIFont systemFontOfSize:17.0f weight:UIFontWeightMedium];
  37. self.categoryView.titleSelectedColor = HexRGB(0x333333);
  38. self.categoryView.titleColor = HexRGB(0x666666);
  39. self.categoryView.titleColorGradientEnabled = YES;
  40. JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
  41. lineView.indicatorColor = THEMECOLOR;
  42. lineView.indicatorWidth = 16;
  43. lineView.indicatorHeight = 4.0f;
  44. self.categoryView.indicators = @[lineView];
  45. _pagerView = [self preferredPagingView];
  46. self.pagerView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNaviBarHeight - iPhoneXSafeBottomMargin);
  47. self.pagerView.backgroundColor = [UIColor clearColor];
  48. self.pagerView.mainTableView.backgroundColor = [UIColor clearColor];
  49. self.pagerView.listContainerView.backgroundColor = [UIColor clearColor];
  50. self.pagerView.mainTableView.gestureDelegate = self;
  51. self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
  52. self.pagerView.listContainerView.listCellBackgroundColor = [UIColor clearColor];
  53. [self.view addSubview:self.pagerView];
  54. }
  55. - (void)requestTeachMessage {
  56. [KSNetworkingManager queryTeacherInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  57. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  58. self.teacherInfo = [[TeacherInfo alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
  59. NSString *rongToken = UserDefault(RongTokenKey);
  60. if ([NSString isEmptyString:rongToken]) {
  61. [USER_MANAGER queryUserInfoConnectRongCloud:YES];
  62. }
  63. [self refreshAuthStatus];
  64. }
  65. else {
  66. [self MBPShow:MESSAGEKEY];
  67. }
  68. } faliure:^(NSError * _Nonnull error) {
  69. }];
  70. }
  71. - (void)refreshAuthStatus {
  72. for (NSInteger index = 0; index < self.listViewArray.count; index++) {
  73. id view = self.listViewArray[index];
  74. if ([view isKindOfClass:[VideoListBodyView class]]) {
  75. VideoListBodyView *listView = (VideoListBodyView *)view;
  76. listView.teaherStatus = self.teacherInfo.entryStatus;
  77. }
  78. }
  79. }
  80. - (void)rightBtnClick { // 创建视频课
  81. if ([self.teacherInfo.entryStatus isEqualToString:@"PASS"]) {
  82. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  83. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/videoCreate"];
  84. [self.navigationController pushViewController:webCtrl animated:YES];
  85. }
  86. else {
  87. [self MBPShow:@"您还没有完成达人认证,认证后才可创建视频课哦~"];
  88. }
  89. }
  90. - (void)viewWillAppear:(BOOL)animated {
  91. [super viewWillAppear:animated];
  92. self.navigationController.interactivePopGestureRecognizer.enabled = YES;
  93. [self requestTeachMessage];
  94. if (self.listViewArray.count > self.categoryView.selectedIndex) {
  95. id value = self.listViewArray[self.categoryView.selectedIndex];
  96. if ([value isKindOfClass:[VideoListBodyView class]]) {
  97. VideoListBodyView *listView = (VideoListBodyView *)value;
  98. [listView beginFirstRefresh];
  99. }
  100. }
  101. }
  102. - (void)viewDidAppear:(BOOL)animated {
  103. [super viewDidAppear:animated];
  104. self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
  105. }
  106. - (JXPagerView *)preferredPagingView {
  107. return [[JXPagerListRefreshView alloc] initWithDelegate:self];
  108. }
  109. #pragma mark - JXPagerViewDelegate
  110. - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
  111. return [UIView new];
  112. }
  113. - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
  114. return CGFLOAT_MIN;
  115. }
  116. - (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  117. return HEADER_HEIGHT;
  118. }
  119. - (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  120. return self.categoryView;
  121. }
  122. - (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
  123. //和categoryView的item数量一致
  124. return self.titles.count;
  125. }
  126. - (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
  127. VideoListBodyView *listView = [[VideoListBodyView alloc] init];
  128. listView.naviController = self.navigationController;
  129. [self.listViewArray replaceObjectAtIndex:index withObject:listView];
  130. self.listViewArray[index] = listView;
  131. listView.selectIndex = index;
  132. if (self.teacherInfo) {
  133. listView.teaherStatus = self.teacherInfo.entryStatus;
  134. }
  135. else {
  136. listView.teaherStatus = @"PASS";
  137. }
  138. [listView beginFirstRefresh];
  139. return listView;
  140. }
  141. #pragma mark - JXCategoryViewDelegate
  142. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
  143. self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
  144. if (self.listViewArray.count > index) {
  145. id value = self.listViewArray[index];
  146. if ([value isKindOfClass:[VideoListBodyView class]]) {
  147. VideoListBodyView *listView = (VideoListBodyView *)value;
  148. [listView beginFirstRefresh];
  149. }
  150. }
  151. }
  152. #pragma mark - JXPagerMainTableViewGestureDelegate
  153. - (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
  154. //禁止categoryView左右滑动的时候,上下和左右都可以滚动
  155. if (otherGestureRecognizer == self.categoryView.collectionView.panGestureRecognizer) {
  156. return NO;
  157. }
  158. return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
  159. }
  160. - (NSMutableArray *)listViewArray {
  161. if (!_listViewArray) {
  162. _listViewArray = [NSMutableArray arrayWithArray:@[@"",@"",@""]];
  163. }
  164. return _listViewArray;
  165. }
  166. /*
  167. #pragma mark - Navigation
  168. // In a storyboard-based application, you will often want to do a little preparation before navigation
  169. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  170. // Get the new view controller using [segue destinationViewController].
  171. // Pass the selected object to the new view controller.
  172. }
  173. */
  174. @end