MinePageCourseView.m 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  1. //
  2. // MinePageCourseView.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by Kyle on 2022/3/30.
  6. //
  7. #import "MinePageCourseView.h"
  8. #import "MinePageSubmitView.h"
  9. #import "KSBaseWKWebViewController.h"
  10. #import "MusicMessageModel.h"
  11. #import "AccompanyCourseCell.h"
  12. #import "LiveCourseCell.h"
  13. #import "MinePageMusicCell.h"
  14. #import "AuthDisplayView.h"
  15. #import "AccompanyLessonModel.h"
  16. #import "KSChatConversationViewController.h"
  17. #import "AccompanyDetailViewController.h"
  18. #import "KSFullDatePicker.h"
  19. #import "CourseTimeSegView.h"
  20. #import "MyMusicSearchView.h"
  21. #import "KSChoosePicker.h"
  22. #import "KSAccompanyWebViewController.h"
  23. @interface MinePageCourseView ()<UITableViewDelegate,UITableViewDataSource>
  24. @property (nonatomic, strong) NSMutableArray *dataArray;
  25. @property (nonatomic, strong) StateView *promptView;
  26. @property (nonatomic, strong) UIView *promptPlaceView;
  27. @property (nonatomic, assign) BOOL networkAvaiable; // 网络是否可用
  28. @property (nonatomic, assign) BOOL isLoadMore;
  29. @property (nonatomic, assign) NSInteger rows;
  30. @property (nonatomic, assign) NSInteger pages;
  31. @property (nonatomic, strong) AuthDisplayView *authView;
  32. @property (nonatomic, strong) MinePageSubmitView *uploadView;
  33. @property (nonatomic, assign) BOOL teacherAuthPass; // 是否通过老师审核
  34. @property (nonatomic, assign) BOOL musicianPass; // 是否通过音乐人审核
  35. @property (nonatomic, strong) CourseTimeSegView *timeSortView;
  36. @property (nonatomic, strong) NSString *chooseMonth;
  37. @property (nonatomic, strong) NSDateFormatter *dateFormatter;
  38. @property (nonatomic, strong) MyMusicSearchView *searchView;
  39. @property (nonatomic, strong) NSString *searchKey;
  40. @property (nonatomic, strong) NSString *subjectIds;
  41. @end
  42. @implementation MinePageCourseView
  43. - (instancetype)initWithFrame:(CGRect)frame {
  44. self = [super initWithFrame:frame];
  45. if (self) {
  46. self.backgroundColor = HexRGB(0xf6f8f9);
  47. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height) style:UITableViewStylePlain];
  48. self.tableView.backgroundColor = HexRGB(0xf6f8f9);
  49. self.tableView.showsVerticalScrollIndicator = NO;
  50. self.tableView.dataSource = self;
  51. self.tableView.delegate = self;
  52. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  53. [self addSubview:self.tableView];
  54. [self.dateFormatter setDateFormat:@"yyyy-MM"];
  55. NSDate *currentDate = [NSDate date];
  56. self.chooseMonth = [self.dateFormatter stringFromDate:currentDate];
  57. UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
  58. headView.backgroundColor = HexRGB(0xf6f8f9);
  59. self.tableView.tableHeaderView = headView;
  60. UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
  61. bottomView.backgroundColor = HexRGB(0xf6f8f9);
  62. self.tableView.tableFooterView = bottomView;
  63. [self.tableView registerNib:[UINib nibWithNibName:@"AccompanyCourseCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyCourseCell"];
  64. [self.tableView registerNib:[UINib nibWithNibName:@"LiveCourseCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"LiveCourseCell"];
  65. [self.tableView registerNib:[UINib nibWithNibName:@"MinePageMusicCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MinePageMusicCell"];
  66. MJWeakSelf;
  67. self.tableView.mj_header = [KSGifRefreshHeader headerWithRefreshingBlock:^{
  68. [weakSelf resetParamenter];
  69. [weakSelf requestData];
  70. }];
  71. self.tableView.mj_footer = [KSGifRefreshFooter footerWithRefreshingBlock:^{
  72. if (weakSelf.isLoadMore) {
  73. weakSelf.pages += 1;
  74. [weakSelf requestData];
  75. }
  76. else {
  77. [weakSelf.tableView.mj_footer endRefreshingWithNoMoreData];
  78. }
  79. }];
  80. }
  81. return self;
  82. }
  83. - (void)endRefresh {
  84. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  85. [self.tableView.mj_header endRefreshing];
  86. [self.tableView.mj_footer endRefreshing];
  87. });
  88. }
  89. - (void)refreshAndRequestData {
  90. [self resetParamenter];
  91. [self requestData];
  92. }
  93. - (void)resetParamenter {
  94. self.isLoadMore = YES;
  95. self.pages = 1;
  96. self.rows = 10;
  97. self.dataArray = [NSMutableArray array];
  98. [self.tableView.mj_footer resetNoMoreData];
  99. [self setPromptString:@"暂无课程~" imageName:@"empty_course" inView:self.tableView];
  100. [self.tableView reloadData];
  101. }
  102. - (void)requestData {
  103. if (self.selectIndex == 1) { // 陪练课
  104. [KSNetworkingManager accompanyCourseRequest:KS_POST classMonth:self.chooseMonth status:nil subjectId:nil page:self.pages rows:self.rows success:^(NSDictionary * _Nonnull dic) {
  105. [self endRefresh];
  106. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  107. NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
  108. for (NSDictionary *parm in sourceArray) {
  109. AccompanyLessonModel *model = [[AccompanyLessonModel alloc] initWithDictionary:parm];
  110. [self.dataArray addObject:model];
  111. }
  112. if (sourceArray.count < self.rows) {
  113. self.isLoadMore = NO;
  114. }
  115. }
  116. else {
  117. [self MBPShow:MESSAGEKEY];
  118. }
  119. [self.tableView reloadData];
  120. [self changePromptLabelStateWithArray:self.dataArray];
  121. } faliure:^(NSError * _Nonnull error) {
  122. [self endRefresh];
  123. if (self.networkAvaiable == NO) {
  124. [self setPromptString:@"暂无网络" imageName:@"no_networking" inView:self.tableView];
  125. }
  126. [self.dataArray removeAllObjects];
  127. [self.tableView reloadData];
  128. [self changePromptLabelStateWithArray:self.dataArray];
  129. }];
  130. }
  131. else if (self.selectIndex == 2) { // 直播课
  132. [KSNetworkingManager LiveCourseGroupRequest:KS_POST groupStatus:@"APPLY" page:self.pages rows:self.rows success:^(NSDictionary * _Nonnull dic) {
  133. [self endRefresh];
  134. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  135. NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
  136. for (NSDictionary *parm in sourceArray) {
  137. LiveCourseModel *model = [[LiveCourseModel alloc] initWithDictionary:parm];
  138. [self.dataArray addObject:model];
  139. }
  140. if (sourceArray.count < self.rows) {
  141. self.isLoadMore = NO;
  142. }
  143. }
  144. else {
  145. [self MBPShow:MESSAGEKEY];
  146. }
  147. [self.tableView reloadData];
  148. [self changePromptLabelStateWithArray:self.dataArray];
  149. } faliure:^(NSError * _Nonnull error) {
  150. [self endRefresh];
  151. if (self.networkAvaiable == NO) {
  152. [self setPromptString:@"暂无网络" imageName:@"no_networking" inView:self.tableView];
  153. }
  154. [self.dataArray removeAllObjects];
  155. [self.tableView reloadData];
  156. [self changePromptLabelStateWithArray:self.dataArray];
  157. }];
  158. }
  159. else if (self.selectIndex == 4) { // 乐谱
  160. [KSNetworkingManager musicListRequest:KS_POST auditStatus:@"PASS" page:self.pages rows:self.rows search:self.searchKey subjectIds:self.subjectIds success:^(NSDictionary * _Nonnull dic) {
  161. [self endRefresh];
  162. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  163. NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
  164. for (NSDictionary *parm in sourceArray) {
  165. MusicMessageModel *model = [[MusicMessageModel alloc] initWithDictionary:parm];
  166. [self.dataArray addObject:model];
  167. }
  168. if (sourceArray.count < self.rows) {
  169. self.isLoadMore = NO;
  170. }
  171. }
  172. else {
  173. [self MBPShow:MESSAGEKEY];
  174. }
  175. [self.tableView reloadData];
  176. [self changePromptLabelStateWithArray:self.dataArray];
  177. } faliure:^(NSError * _Nonnull error) {
  178. [self endRefresh];
  179. if (self.networkAvaiable == NO) {
  180. [self setPromptString:@"暂无网络" imageName:@"no_networking" inView:self.tableView];
  181. }
  182. [self.dataArray removeAllObjects];
  183. [self.tableView reloadData];
  184. [self changePromptLabelStateWithArray:self.dataArray];
  185. }];
  186. }
  187. }
  188. - (void)beginRefreshImmediately {
  189. [self.tableView.mj_header beginRefreshing];
  190. }
  191. - (void)beginFirstRefresh {
  192. if (!self.isHeaderRefreshed) {
  193. [self beginRefreshImmediately];
  194. }
  195. }
  196. - (void)selectCellAtIndexPath:(NSIndexPath *)indexPath {
  197. if (self.lastSelectedIndexPath == indexPath) {
  198. return;
  199. }
  200. if (self.lastSelectedIndexPath != nil) {
  201. UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:self.lastSelectedIndexPath];
  202. [cell setSelected:NO animated:NO];
  203. }
  204. UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
  205. [cell setSelected:YES animated:NO];
  206. self.lastSelectedIndexPath = indexPath;
  207. }
  208. - (void)layoutSubviews {
  209. [super layoutSubviews];
  210. CGFloat topHeight = 50.0f;
  211. if (self.selectIndex == 1) {
  212. topHeight = 50.0f + 34.0f;
  213. }
  214. else if (self.selectIndex == 4) {
  215. topHeight = 50.0f + 50.0f;
  216. }
  217. self.tableView.frame = CGRectMake(0, topHeight, self.bounds.size.width, self.bounds.size.height - topHeight);
  218. if (![self.subviews containsObject:self.uploadView]) {
  219. [self addSubview:self.uploadView];
  220. if (self.selectIndex == 1) {
  221. [self addSubview:self.timeSortView];
  222. }
  223. if (self.selectIndex == 4) {
  224. [self addSubview:self.searchView];
  225. self.uploadView.frame = CGRectMake(0, 50.0f, KPortraitWidth, 50.0f);
  226. }
  227. if (self.selectIndex == 1 || self.selectIndex == 2) {
  228. if (self.teacherAuthPass == NO) {
  229. [self showAuthView];
  230. }
  231. else {
  232. [self hideAuthView];
  233. }
  234. }
  235. else if (self.selectIndex == 4) {
  236. if (self.musicianPass == NO) {
  237. [self showAuthView];
  238. }
  239. else {
  240. [self hideAuthView];
  241. }
  242. }
  243. }
  244. }
  245. #pragma mark - UITableViewDataSource
  246. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  247. return self.dataArray.count;
  248. }
  249. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  250. if (self.selectIndex == 1) {
  251. return 147.0f;
  252. }
  253. else if (self.selectIndex == 2) {
  254. return 150.0f;
  255. }
  256. else {
  257. return 110.0f;;
  258. }
  259. }
  260. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  261. if (self.selectIndex == 1) {
  262. AccompanyLessonModel *model = self.dataArray[indexPath.row];
  263. AccompanyCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyCourseCell"];
  264. MJWeakSelf;
  265. [cell configWithSource:model actionCallback:^(ACCOMPANY_TYPE type, AccompanyLessonModel * _Nonnull source) {
  266. [weakSelf courseOperation:type sourceModel:source];
  267. }];
  268. return cell;
  269. }
  270. else if (self.selectIndex == 2) {
  271. LiveCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LiveCourseCell"];
  272. LiveCourseModel *model = self.dataArray[indexPath.row];
  273. BOOL hiddenInfo = NO;
  274. [cell configCellWithSource:model hideStudentInfo:hiddenInfo];
  275. return cell;
  276. }
  277. else {
  278. MusicMessageModel *model = self.dataArray[indexPath.row];
  279. MinePageMusicCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MinePageMusicCell"];
  280. [cell configWithMessage:model];
  281. return cell;
  282. }
  283. }
  284. - (void)courseOperation:(ACCOMPANY_TYPE)type sourceModel:(AccompanyLessonModel *)model {
  285. switch (type) {
  286. case ACCOMPANY_TYPE_CHAT: // 聊天
  287. {
  288. KSChatConversationViewController *conversationVC = [[KSChatConversationViewController alloc] init];
  289. conversationVC.targetId = model.userId;
  290. conversationVC.conversationType = ConversationType_PRIVATE;
  291. [self.naviController pushViewController:conversationVC animated:YES];
  292. }
  293. break;
  294. case ACCOMPANY_TYPE_ADJUST: // 调整
  295. {
  296. [self showAdjustPicker:model];
  297. }
  298. break;
  299. case ACCOMPANY_DETAIL: // 陪练课详情
  300. {
  301. [self showAccompanyDetail:model];
  302. }
  303. break;
  304. default:
  305. break;
  306. }
  307. }
  308. - (void)showAccompanyDetail:(AccompanyLessonModel *)model {
  309. AccompanyDetailViewController *detailVC = [[AccompanyDetailViewController alloc] init];
  310. detailVC.courseId = model.courseId;
  311. detailVC.courseGroupId = model.courseGoupId;
  312. detailVC.studentId = model.userId;
  313. [self.naviController pushViewController:detailVC animated:YES];
  314. }
  315. - (void)showAdjustPicker:(AccompanyLessonModel *)model {
  316. KSFullDatePicker *picker = [[KSFullDatePicker alloc] initWithTitle:@"课时调整" date:[NSDate date] pickMode:KSDATEPICKER_MODE_DAY_TIME selectDateBlock:^(NSString *date) {
  317. [self courseAdjustAction:model];
  318. } cancleBlock:^{
  319. }];
  320. [picker show];
  321. }
  322. - (void)courseAdjustAction:(AccompanyLessonModel *)model {
  323. }
  324. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  325. if (self.selectIndex == 1) {
  326. AccompanyLessonModel *model = self.dataArray[indexPath.row];
  327. [self showAccompanyDetail:model];
  328. }
  329. else if (self.selectIndex == 2) { // 直播课详情
  330. LiveCourseModel *model = self.dataArray[indexPath.row];
  331. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  332. NSString *url = [NSString stringWithFormat:@"%@%@%.0f", WEBHOST, @"/#/liveDetail?groupId=",model.courseGroupId];
  333. ctrl.url = url;
  334. [self.naviController pushViewController:ctrl animated:YES];
  335. }
  336. else if (self.selectIndex == 4) { // 曲谱详情
  337. MusicMessageModel *model = self.dataArray[indexPath.row];
  338. KSAccompanyWebViewController *detailCtrl = [[KSAccompanyWebViewController alloc] init];
  339. detailCtrl.url = [NSString stringWithFormat:@"%@/accompany?id=%.0f&client=teacher",hostURL, model.internalBaseClassIdentifier];
  340. detailCtrl.hiddenNavBar = YES;
  341. detailCtrl.parmDic = @{@"isOpenLight" : @(YES), @"orientation" : @(0),@"isHideTitle" : @(YES)};
  342. [self.naviController pushViewController:detailCtrl animated:YES];
  343. }
  344. }
  345. /**
  346. 设置没有数据时的显示
  347. @param promptString 提示语
  348. @param imgName 图片名称
  349. @param view 显示在什么地方
  350. */
  351. - (void)setPromptString:(NSString *)promptString imageName:(NSString *)imgName inView:(UIView *)view {
  352. if (self.promptView != nil) {
  353. [self.promptView removeFromSuperview];
  354. }
  355. else {
  356. self.promptView = [[StateView alloc]init];
  357. self.promptView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - 300);
  358. }
  359. _promptPlaceView = view;
  360. //当请求不到数据时 ,自定义提示view 将会出现;
  361. self.promptView.imageName = imgName;
  362. self.promptView.alpha = 0.0f;
  363. [self.promptView setText:promptString];
  364. [view addSubview:self.promptView];
  365. }
  366. // 结束刷新后调用方法
  367. - (void)changePromptLabelStateWithArray:(NSMutableArray *)array {
  368. NSInteger count;
  369. if (array.count) {
  370. count = array.count;
  371. } else {
  372. count = 0;
  373. }
  374. [UIView animateWithDuration:0.1 animations:^{
  375. [[self promptView] setAlpha:count ? 0.0f :1.0f ] ;
  376. }] ;
  377. }
  378. - (BOOL)networkAvaiable {
  379. return [self checkNetworkAvaiable];
  380. }
  381. - (BOOL)checkNetworkAvaiable {
  382. BOOL isExistenceNetwork = YES;
  383. Reachability *reach = [Reachability reachabilityWithHostName:@"www.apple.com"];
  384. switch ([reach currentReachabilityStatus]) {
  385. case NotReachable:
  386. isExistenceNetwork = NO;
  387. //NSLog(@"notReachable");
  388. break;
  389. case ReachableViaWiFi:
  390. isExistenceNetwork = YES;
  391. //NSLog(@"WIFI");
  392. break;
  393. case ReachableViaWWAN:
  394. isExistenceNetwork = YES;
  395. //NSLog(@"3G");
  396. break;
  397. }
  398. return isExistenceNetwork;
  399. }
  400. #pragma mark ----- lazying
  401. - (NSDateFormatter *)dateFormatter {
  402. if (!_dateFormatter) {
  403. _dateFormatter = [NSObject getDateformatter];
  404. }
  405. return _dateFormatter;
  406. }
  407. - (CourseTimeSegView *)timeSortView {
  408. if (!_timeSortView) {
  409. _timeSortView = [CourseTimeSegView shareInstance];
  410. [self.dateFormatter setDateFormat:@"yyyy年M月"];
  411. NSDate *currentDate = [NSDate date];
  412. [_timeSortView.sortTitleLabel setText:[self.dateFormatter stringFromDate:currentDate]];
  413. CGFloat topHeight = 60.0f;
  414. _timeSortView.frame = CGRectMake(0, topHeight, kScreenWidth, 34);
  415. MJWeakSelf;
  416. [_timeSortView sortAction:^{
  417. [weakSelf showPickerView];
  418. }];
  419. }
  420. return _timeSortView;
  421. }
  422. - (void)showPickerView {
  423. KSFullDatePicker *picker = [[KSFullDatePicker alloc] initWithTitle:@"" date:[NSDate date] pickMode:KSDATEPICKER_MODE_YEAR_MONTH selectDateBlock:^(NSString *date) {
  424. self.chooseMonth = date;
  425. NSString *displayTime = [self getTimeDisplay:date];
  426. [self.timeSortView.sortTitleLabel setText:displayTime];
  427. [self resetPickerStatus];
  428. // 请求数据
  429. [self refreshAndRequestData];
  430. } cancleBlock:^{
  431. [self resetPickerStatus];
  432. }];
  433. [picker show];
  434. }
  435. - (NSString *)getTimeDisplay:(NSString *)chooseMonth {
  436. [self.dateFormatter setDateFormat:@"yyyy-MM"];
  437. NSDate *chooseDate = [self.dateFormatter dateFromString:chooseMonth];
  438. [self.dateFormatter setDateFormat:@"yyyy年M月"];
  439. NSString *displayTime = [self.dateFormatter stringFromDate:chooseDate];
  440. return displayTime;
  441. }
  442. - (void)resetPickerStatus {
  443. self.timeSortView.arrowUp = NO;
  444. }
  445. - (void)setTeaherStatus:(NSString *)teaherStatus {
  446. _teaherStatus = teaherStatus;
  447. if ([teaherStatus isEqualToString:@"UNPAALY"]) { // 未申请
  448. self.teacherAuthPass = NO;
  449. }
  450. else if ([teaherStatus isEqualToString:@"DOING"]) { // 审核中
  451. self.teacherAuthPass = NO;
  452. }
  453. else if ([teaherStatus isEqualToString:@"UNPASS"]) { // 不通过
  454. self.teacherAuthPass = NO;
  455. }
  456. else {
  457. self.teacherAuthPass = YES;
  458. }
  459. // 如果
  460. if (self.selectIndex == 2) { // 直播课
  461. if (self.liveFlag == NO) { // 无直播权限直接改成未通过
  462. self.teacherAuthPass = NO;
  463. }
  464. }
  465. if (self.selectIndex == 1) {
  466. self.uploadView.type = MINEPAGETYPE_ACCOMPANY;
  467. }
  468. else if (self.selectIndex == 2) {
  469. self.uploadView.type = MINEPAGETYPE_LIVE;
  470. }
  471. if (self.selectIndex == 1 || self.selectIndex == 2) {
  472. if (self.teacherAuthPass == NO) {
  473. [self showAuthView];
  474. }
  475. else {
  476. [self hideAuthView];
  477. }
  478. }
  479. }
  480. - (void)setMusicianStatus:(NSString *)musicianStatus {
  481. _musicianStatus = musicianStatus;
  482. if ([musicianStatus isEqualToString:@"UNPAALY"]) { // 未申请
  483. self.musicianPass = NO;
  484. }
  485. else if ([musicianStatus isEqualToString:@"DOING"]) { // 审核中
  486. self.musicianPass = NO;
  487. }
  488. else if ([musicianStatus isEqualToString:@"UNPASS"]) { // 不通过
  489. self.musicianPass = NO;
  490. }
  491. else {
  492. self.musicianPass = YES;
  493. }
  494. if (self.selectIndex == 4) {
  495. self.uploadView.type = MINEPAGETYPE_MUSIC;
  496. }
  497. if (self.selectIndex == 4) {
  498. if (self.musicianPass == NO) {
  499. [self showAuthView];
  500. }
  501. else {
  502. [self hideAuthView];
  503. }
  504. }
  505. }
  506. - (void)showAuthView {
  507. [self configAuthDisplay];
  508. if ([self.subviews containsObject:self.authView]) {
  509. [self bringSubviewToFront:self.authView];
  510. }
  511. else {
  512. [self addSubview:self.authView];
  513. [self.authView mas_makeConstraints:^(MASConstraintMaker *make) {
  514. make.left.top.bottom.right.mas_equalTo(self);
  515. }];
  516. }
  517. }
  518. - (void)configAuthDisplay {
  519. [self.authView configDisplayMessage:[self getAuthDisplayMessage]];
  520. if (self.selectIndex == 1) { // 陪练课
  521. if ([self.teaherStatus isEqualToString:@"DOING"]) {
  522. self.authView.sureButton.userInteractionEnabled = NO;
  523. self.authView.sureButton.hidden = YES;
  524. }
  525. else {
  526. self.authView.sureButton.userInteractionEnabled = YES;
  527. self.authView.sureButton.hidden = NO;
  528. }
  529. }
  530. else if (self.selectIndex == 2) { // 直播课
  531. if ([self.teaherStatus isEqualToString:@"DOING"]) {
  532. self.authView.sureButton.userInteractionEnabled = NO;
  533. self.authView.sureButton.hidden = YES;
  534. }
  535. else {
  536. if ([self.teaherStatus isEqual:@"PASS"] && self.liveFlag == NO) {
  537. [self.authView.sureButton setTitle:@"立即开通" forState:UIControlStateNormal];
  538. }
  539. else {
  540. [self.authView.sureButton setTitle:@"去认证" forState:UIControlStateNormal];
  541. }
  542. self.authView.sureButton.userInteractionEnabled = YES;
  543. self.authView.sureButton.hidden = NO;
  544. }
  545. }
  546. else { // 曲谱
  547. if ([self.musicianStatus isEqualToString:@"DOING"]) {
  548. self.authView.sureButton.userInteractionEnabled = NO;
  549. self.authView.sureButton.hidden = YES;
  550. }
  551. else {
  552. self.authView.sureButton.userInteractionEnabled = YES;
  553. self.authView.sureButton.hidden = NO;
  554. }
  555. }
  556. }
  557. - (void)hideAuthView {
  558. if ([self.subviews containsObject:self.authView]) {
  559. [self.authView removeFromSuperview];
  560. self.authView = nil;
  561. }
  562. }
  563. - (MinePageSubmitView *)uploadView {
  564. if (!_uploadView) {
  565. _uploadView = [MinePageSubmitView shareInstance];
  566. CGFloat topHeight = 60.0f;
  567. _uploadView.frame = CGRectMake(0, 0, kScreenWidth, topHeight);
  568. MJWeakSelf;
  569. [_uploadView opreationCallback:^(MINEPAGETYPE type) {
  570. [weakSelf uploadAciton:type];
  571. }];
  572. }
  573. return _uploadView;
  574. }
  575. - (void)uploadAciton:(MINEPAGETYPE)type {
  576. switch (type) {
  577. case MINEPAGETYPE_ACCOMPANY: // 陪练课设置
  578. {
  579. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  580. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/practiceSetting"];
  581. [self.naviController pushViewController:webCtrl animated:YES];
  582. }
  583. break;
  584. case MINEPAGETYPE_LIVE: // 直播课设置
  585. {
  586. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  587. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/liveCreate"];
  588. [self.naviController pushViewController:webCtrl animated:YES];
  589. }
  590. break;
  591. case MINEPAGETYPE_MUSIC: // 上传曲谱
  592. {
  593. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  594. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/music-upload"];
  595. [self.naviController pushViewController:webCtrl animated:YES];
  596. }
  597. break;
  598. default:
  599. break;
  600. }
  601. }
  602. - (AuthDisplayView *)authView {
  603. if (!_authView) {
  604. _authView = [AuthDisplayView shareInstance];
  605. [_authView.imageView setImage:[UIImage imageNamed:[self getAuthDisplayImage]]];
  606. MJWeakSelf;
  607. [_authView sureCallback:^{
  608. [weakSelf authAction];
  609. }];
  610. }
  611. return _authView;
  612. }
  613. - (NSString *)getAuthDisplayImage {
  614. if (self.selectIndex == 1) {
  615. return @"authTeacher_accompany";
  616. }
  617. else if (self.selectIndex == 2) {
  618. return @"authTeacher_Live";
  619. }
  620. else {
  621. return @"authMuscian";
  622. }
  623. }
  624. - (NSString *)getAuthDisplayMessage {
  625. if (self.selectIndex == 1) { // 陪练课
  626. if ([self.teaherStatus isEqualToString:@"DOING"]) { // 审核中
  627. return @"您已提交认证申请,请耐心等待审核结果~";
  628. }
  629. else {
  630. return @"您还没有完成达人认证,认证后才可设置陪练课哦~";
  631. }
  632. }
  633. else if (self.selectIndex == 2) { // 直播课
  634. if ([self.teaherStatus isEqualToString:@"DOING"]) { // 审核中
  635. return @"您已提交认证申请,请耐心等待审核结果~";
  636. }
  637. else {
  638. if ([self.teaherStatus isEqualToString:@"PASS"] && self.liveFlag == NO) { // 如果达人认证通过
  639. return @"您尚未开通直播服务,开通后即可创建直播课程~";
  640. }
  641. return @"您还没有完成达人认证,认证后才可创建直播课哦~";
  642. }
  643. }
  644. else { // 曲谱
  645. if ([self.musicianStatus isEqualToString:@"DOING"]) { // 审核中
  646. return @"您已提交认证申请,请耐心等待审核结果~";
  647. }
  648. else {
  649. return @"您还没有完成音乐人认证,认证后才可上传曲谱哦~";
  650. }
  651. }
  652. }
  653. - (void)authAction {
  654. if (self.selectIndex == 1) {
  655. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  656. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  657. [self.naviController pushViewController:webCtrl animated:YES];
  658. }
  659. else if (self.selectIndex == 2) {
  660. if ([self.teaherStatus isEqual:@"PASS"] && self.liveFlag == NO) { // 开通直播
  661. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  662. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/openLive"];
  663. [self.naviController pushViewController:webCtrl animated:YES];
  664. }
  665. else {
  666. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  667. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  668. [self.naviController pushViewController:webCtrl animated:YES];
  669. }
  670. }
  671. else {
  672. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  673. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/musicCert"];
  674. [self.naviController pushViewController:webCtrl animated:YES];
  675. }
  676. }
  677. - (MyMusicSearchView *)searchView {
  678. if (!_searchView) {
  679. _searchView = [MyMusicSearchView shareInstance];
  680. CGFloat topHeight = 50.0f;
  681. _searchView.frame = CGRectMake(0, 0, kScreenWidth, 50);
  682. MJWeakSelf;
  683. [_searchView musicSearchAction:^(NSString * _Nonnull searchKey, BOOL isChooseSubject) {
  684. if (isChooseSubject) {
  685. [weakSelf searchSubject];
  686. }
  687. else {
  688. [weakSelf evaluateSource:searchKey];
  689. }
  690. }];
  691. }
  692. return _searchView;
  693. }
  694. - (void)evaluateSource:(NSString *)searchKey {
  695. self.searchKey = searchKey;
  696. [self refreshAndRequestData];
  697. }
  698. - (void)searchSubject {
  699. if (self.subjectList.count) {
  700. NSMutableArray *nameArray = [NSMutableArray array];
  701. [nameArray addObject:@"全部"];
  702. for (NSDictionary *parm in self.subjectList) {
  703. [nameArray addObject:[parm stringValueForKey:@"subjectName"]];
  704. }
  705. MJWeakSelf;
  706. KSChoosePicker *picker = [[KSChoosePicker alloc] initWithTitle:@"声部" sourceData:nameArray chooseReturnWithBlock:^(NSString * _Nonnull returnValue, NSInteger chooseIndex) {
  707. if (chooseIndex == 0) {
  708. weakSelf.searchView.sortTitleLabel.text = @"声部";
  709. weakSelf.subjectIds = nil;
  710. }
  711. else {
  712. weakSelf.searchView.sortTitleLabel.text = returnValue;
  713. NSDictionary *parm = self.subjectList[chooseIndex-1];
  714. weakSelf.subjectIds = [parm stringValueForKey:@"subjectId"];
  715. }
  716. self.searchView.arrowUp = NO;
  717. [weakSelf refreshAndRequestData];
  718. } cancel:^{
  719. self.searchView.arrowUp = NO;
  720. }];
  721. [picker showPicker];
  722. }
  723. else {
  724. [self MBPShow:@"无声部信息"];
  725. self.searchView.arrowUp = NO;
  726. }
  727. }
  728. /*
  729. // Only override drawRect: if you perform custom drawing.
  730. // An empty implementation adversely affects performance during animation.
  731. - (void)drawRect:(CGRect)rect {
  732. // Drawing code
  733. }
  734. */
  735. @end