MyMusicViewController.m 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. //
  2. // MyMusicViewController.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by Kyle on 2022/3/28.
  6. //
  7. #import "MyMusicViewController.h"
  8. #import "KSBaseWKWebViewController.h"
  9. #import "JXCategoryView.h"
  10. #import "JXPagerListRefreshView.h"
  11. #import "MyMusicBodyView.h"
  12. #import "TeacherInfo.h"
  13. #import "UserInfoManager.h"
  14. #define HEADER_HEIGHT (64)
  15. @interface MyMusicViewController ()<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 MyMusicViewController
  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 rightButton:[UIImage imageNamed:@"nav_share_image"]];
  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. self.categoryView.indicators = @[lineView];
  44. _pagerView = [self preferredPagingView];
  45. self.pagerView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNaviBarHeight - iPhoneXSafeBottomMargin);
  46. self.pagerView.backgroundColor = [UIColor clearColor];
  47. self.pagerView.mainTableView.backgroundColor = [UIColor clearColor];
  48. self.pagerView.listContainerView.backgroundColor = [UIColor clearColor];
  49. self.pagerView.mainTableView.gestureDelegate = self;
  50. self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
  51. self.pagerView.listContainerView.listCellBackgroundColor = [UIColor clearColor];
  52. [self.view addSubview:self.pagerView];
  53. self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
  54. }
  55. - (void)rightBtnClick { // 获取分享数据
  56. [self showhud];
  57. [KSNetworkingManager queryMusicShareMessageRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  58. [self removehub];
  59. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  60. // if (<#condition#>) {
  61. // <#statements#>
  62. // }
  63. }
  64. else {
  65. [self MBPShow:MESSAGEKEY];
  66. }
  67. } faliure:^(NSError * _Nonnull error) {
  68. [self removehub];
  69. }];
  70. }
  71. - (void)displayShareView {
  72. }
  73. - (void)viewWillAppear:(BOOL)animated {
  74. [super viewWillAppear:animated];
  75. self.navigationController.interactivePopGestureRecognizer.enabled = YES;
  76. [self requestTeachMessage];
  77. if (self.listViewArray.count > self.categoryView.selectedIndex) {
  78. id value = self.listViewArray[self.categoryView.selectedIndex];
  79. if ([value isKindOfClass:[MyMusicBodyView class]]) {
  80. MyMusicBodyView *listView = (MyMusicBodyView *)value;
  81. [listView beginFirstRefresh];
  82. }
  83. }
  84. }
  85. - (void)requestTeachMessage {
  86. [KSNetworkingManager queryTeacherInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  87. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  88. self.teacherInfo = [[TeacherInfo alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
  89. NSString *rongToken = UserDefault(RongTokenKey);
  90. if ([NSString isEmptyString:rongToken]) {
  91. [USER_MANAGER queryUserInfoConnectRongCloud:YES];
  92. }
  93. [self refreshHeadView];
  94. }
  95. else {
  96. [self MBPShow:MESSAGEKEY];
  97. }
  98. } faliure:^(NSError * _Nonnull error) {
  99. }];
  100. }
  101. - (void)refreshHeadView {
  102. // 刷新老师认证和音乐人认证状态
  103. [self refreshAuthStatus];
  104. }
  105. - (void)refreshAuthStatus {
  106. for (NSInteger index = 0; index < self.listViewArray.count; index++) {
  107. id view = self.listViewArray[index];
  108. if ([view isKindOfClass:[MyMusicBodyView class]]) {
  109. MyMusicBodyView *listView = (MyMusicBodyView *)view;
  110. listView.musicianStatus = self.teacherInfo.musicianAuthStatus;
  111. }
  112. }
  113. }
  114. - (void)viewDidAppear:(BOOL)animated {
  115. [super viewDidAppear:animated];
  116. self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
  117. }
  118. - (JXPagerView *)preferredPagingView {
  119. return [[JXPagerListRefreshView alloc] initWithDelegate:self];
  120. }
  121. #pragma mark - JXPagerViewDelegate
  122. - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
  123. return [UIView new];
  124. }
  125. - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
  126. return CGFLOAT_MIN;
  127. }
  128. - (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  129. return HEADER_HEIGHT;
  130. }
  131. - (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  132. return self.categoryView;
  133. }
  134. - (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
  135. //和categoryView的item数量一致
  136. return self.titles.count;
  137. }
  138. - (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
  139. MyMusicBodyView *listView = [[MyMusicBodyView alloc] init];
  140. listView.naviController = self.navigationController;
  141. [self.listViewArray replaceObjectAtIndex:index withObject:listView];
  142. self.listViewArray[index] = listView;
  143. if (index == 0) {
  144. listView.selectIndex = 0;
  145. }else if (index == 1) {
  146. listView.selectIndex = 1;
  147. }
  148. else {
  149. listView.selectIndex = 2;
  150. }
  151. if (self.teacherInfo) {
  152. listView.musicianStatus = self.teacherInfo.musicianAuthStatus;
  153. }
  154. else {
  155. listView.musicianStatus = @"PASS";
  156. }
  157. [listView beginFirstRefresh];
  158. return listView;
  159. }
  160. #pragma mark - JXCategoryViewDelegate
  161. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
  162. self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
  163. if (self.listViewArray.count > index) {
  164. id value = self.listViewArray[index];
  165. if ([value isKindOfClass:[KSJXBodyView class]]) {
  166. KSJXBodyView *listView = (KSJXBodyView *)value;
  167. [listView beginFirstRefresh];
  168. }
  169. }
  170. }
  171. #pragma mark - JXPagerMainTableViewGestureDelegate
  172. - (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
  173. //禁止categoryView左右滑动的时候,上下和左右都可以滚动
  174. if (otherGestureRecognizer == self.categoryView.collectionView.panGestureRecognizer) {
  175. return NO;
  176. }
  177. return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
  178. }
  179. - (NSMutableArray *)listViewArray {
  180. if (!_listViewArray) {
  181. _listViewArray = [NSMutableArray arrayWithArray:@[@"",@"",@""]];
  182. }
  183. return _listViewArray;
  184. }
  185. /*
  186. #pragma mark - Navigation
  187. // In a storyboard-based application, you will often want to do a little preparation before navigation
  188. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  189. // Get the new view controller using [segue destinationViewController].
  190. // Pass the selected object to the new view controller.
  191. }
  192. */
  193. @end