123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816 |
- //
- // MinePageCourseView.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/30.
- //
- #import "MinePageCourseView.h"
- #import "MinePageSubmitView.h"
- #import "KSBaseWKWebViewController.h"
- #import "MusicMessageModel.h"
- #import "AccompanyCourseCell.h"
- #import "LiveCourseCell.h"
- #import "MinePageMusicCell.h"
- #import "AuthDisplayView.h"
- #import "AccompanyLessonModel.h"
- #import "KSChatConversationViewController.h"
- #import "AccompanyDetailViewController.h"
- #import "KSFullDatePicker.h"
- #import "CourseTimeSegView.h"
- #import "MyMusicSearchView.h"
- #import "KSChoosePicker.h"
- #import "KSAccompanyWebViewController.h"
- @interface MinePageCourseView ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) NSMutableArray *dataArray;
- @property (nonatomic, strong) StateView *promptView;
- @property (nonatomic, strong) UIView *promptPlaceView;
- @property (nonatomic, assign) BOOL networkAvaiable; // 网络是否可用
- @property (nonatomic, assign) BOOL isLoadMore;
- @property (nonatomic, assign) NSInteger rows;
- @property (nonatomic, assign) NSInteger pages;
- @property (nonatomic, strong) AuthDisplayView *authView;
- @property (nonatomic, strong) MinePageSubmitView *uploadView;
- @property (nonatomic, assign) BOOL teacherAuthPass; // 是否通过老师审核
- @property (nonatomic, assign) BOOL musicianPass; // 是否通过音乐人审核
- @property (nonatomic, strong) CourseTimeSegView *timeSortView;
- @property (nonatomic, strong) NSString *chooseMonth;
- @property (nonatomic, strong) NSDateFormatter *dateFormatter;
- @property (nonatomic, strong) MyMusicSearchView *searchView;
- @property (nonatomic, strong) NSString *searchKey;
- @property (nonatomic, strong) NSString *subjectIds;
- @end
- @implementation MinePageCourseView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = HexRGB(0xf6f8f9);
- self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height) style:UITableViewStylePlain];
- self.tableView.backgroundColor = HexRGB(0xf6f8f9);
- self.tableView.showsVerticalScrollIndicator = NO;
- self.tableView.dataSource = self;
- self.tableView.delegate = self;
- self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- [self addSubview:self.tableView];
-
- [self.dateFormatter setDateFormat:@"yyyy-MM"];
- NSDate *currentDate = [NSDate date];
- self.chooseMonth = [self.dateFormatter stringFromDate:currentDate];
-
- UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
- headView.backgroundColor = HexRGB(0xf6f8f9);
- self.tableView.tableHeaderView = headView;
-
- UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
- bottomView.backgroundColor = HexRGB(0xf6f8f9);
- self.tableView.tableFooterView = bottomView;
-
- [self.tableView registerNib:[UINib nibWithNibName:@"AccompanyCourseCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyCourseCell"];
- [self.tableView registerNib:[UINib nibWithNibName:@"LiveCourseCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"LiveCourseCell"];
- [self.tableView registerNib:[UINib nibWithNibName:@"MinePageMusicCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MinePageMusicCell"];
- MJWeakSelf;
- self.tableView.mj_header = [KSGifRefreshHeader headerWithRefreshingBlock:^{
- [weakSelf resetParamenter];
- [weakSelf requestData];
- }];
- self.tableView.mj_footer = [KSGifRefreshFooter footerWithRefreshingBlock:^{
- if (weakSelf.isLoadMore) {
- weakSelf.pages += 1;
- [weakSelf requestData];
- }
- else {
- [weakSelf.tableView.mj_footer endRefreshingWithNoMoreData];
- }
- }];
- }
- return self;
- }
- - (void)endRefresh {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self.tableView.mj_header endRefreshing];
- [self.tableView.mj_footer endRefreshing];
- });
- }
- - (void)refreshAndRequestData {
- [self resetParamenter];
- [self requestData];
- }
- - (void)resetParamenter {
- self.isLoadMore = YES;
- self.pages = 1;
- self.rows = 10;
-
- self.dataArray = [NSMutableArray array];
- [self.tableView.mj_footer resetNoMoreData];
- [self setPromptString:@"暂无课程~" imageName:@"empty_course" inView:self.tableView];
- [self.tableView reloadData];
- }
- - (void)requestData {
- if (self.selectIndex == 1) { // 陪练课
- [KSNetworkingManager accompanyCourseRequest:KS_POST classMonth:self.chooseMonth status:nil subjectId:nil page:self.pages rows:self.rows success:^(NSDictionary * _Nonnull dic) {
- [self endRefresh];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
- for (NSDictionary *parm in sourceArray) {
- AccompanyLessonModel *model = [[AccompanyLessonModel alloc] initWithDictionary:parm];
- [self.dataArray addObject:model];
- }
-
- if (sourceArray.count < self.rows) {
- self.isLoadMore = NO;
- }
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- [self.tableView reloadData];
- [self changePromptLabelStateWithArray:self.dataArray];
- } faliure:^(NSError * _Nonnull error) {
- [self endRefresh];
- if (self.networkAvaiable == NO) {
- [self setPromptString:@"暂无网络" imageName:@"no_networking" inView:self.tableView];
- }
- [self.dataArray removeAllObjects];
- [self.tableView reloadData];
- [self changePromptLabelStateWithArray:self.dataArray];
- }];
- }
- else if (self.selectIndex == 2) { // 直播课
- [KSNetworkingManager LiveCourseGroupRequest:KS_POST groupStatus:@"APPLY" page:self.pages rows:self.rows success:^(NSDictionary * _Nonnull dic) {
- [self endRefresh];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
- for (NSDictionary *parm in sourceArray) {
- LiveCourseModel *model = [[LiveCourseModel alloc] initWithDictionary:parm];
- [self.dataArray addObject:model];
- }
-
- if (sourceArray.count < self.rows) {
- self.isLoadMore = NO;
- }
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- [self.tableView reloadData];
- [self changePromptLabelStateWithArray:self.dataArray];
- } faliure:^(NSError * _Nonnull error) {
- [self endRefresh];
- if (self.networkAvaiable == NO) {
- [self setPromptString:@"暂无网络" imageName:@"no_networking" inView:self.tableView];
- }
- [self.dataArray removeAllObjects];
- [self.tableView reloadData];
- [self changePromptLabelStateWithArray:self.dataArray];
- }];
- }
- else if (self.selectIndex == 4) { // 乐谱
- [KSNetworkingManager musicListRequest:KS_POST auditStatus:@"PASS" page:self.pages rows:self.rows search:self.searchKey subjectIds:self.subjectIds success:^(NSDictionary * _Nonnull dic) {
- [self endRefresh];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
- for (NSDictionary *parm in sourceArray) {
- MusicMessageModel *model = [[MusicMessageModel alloc] initWithDictionary:parm];
- [self.dataArray addObject:model];
- }
- if (sourceArray.count < self.rows) {
- self.isLoadMore = NO;
- }
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- [self.tableView reloadData];
- [self changePromptLabelStateWithArray:self.dataArray];
- } faliure:^(NSError * _Nonnull error) {
- [self endRefresh];
- if (self.networkAvaiable == NO) {
- [self setPromptString:@"暂无网络" imageName:@"no_networking" inView:self.tableView];
- }
- [self.dataArray removeAllObjects];
- [self.tableView reloadData];
- [self changePromptLabelStateWithArray:self.dataArray];
- }];
- }
- }
- - (void)beginRefreshImmediately {
- [self.tableView.mj_header beginRefreshing];
- }
- - (void)beginFirstRefresh {
- if (!self.isHeaderRefreshed) {
- [self beginRefreshImmediately];
- }
- }
- - (void)selectCellAtIndexPath:(NSIndexPath *)indexPath {
-
- if (self.lastSelectedIndexPath == indexPath) {
- return;
- }
- if (self.lastSelectedIndexPath != nil) {
- UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:self.lastSelectedIndexPath];
- [cell setSelected:NO animated:NO];
- }
- UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
- [cell setSelected:YES animated:NO];
- self.lastSelectedIndexPath = indexPath;
- }
- - (void)layoutSubviews {
- [super layoutSubviews];
- CGFloat topHeight = 50.0f;
- if (self.selectIndex == 1) {
- topHeight = 50.0f + 34.0f;
- }
- else if (self.selectIndex == 4) {
- topHeight = 50.0f + 50.0f;
- }
- self.tableView.frame = CGRectMake(0, topHeight, self.bounds.size.width, self.bounds.size.height - topHeight);
- if (![self.subviews containsObject:self.uploadView]) {
- [self addSubview:self.uploadView];
- if (self.selectIndex == 1) {
- [self addSubview:self.timeSortView];
- }
- if (self.selectIndex == 4) {
- [self addSubview:self.searchView];
- self.uploadView.frame = CGRectMake(0, 50.0f, KPortraitWidth, 50.0f);
- }
- if (self.selectIndex == 1 || self.selectIndex == 2) {
- if (self.teacherAuthPass == NO) {
- [self showAuthView];
- }
- else {
- [self hideAuthView];
- }
- }
- else if (self.selectIndex == 4) {
- if (self.musicianPass == NO) {
- [self showAuthView];
- }
- else {
- [self hideAuthView];
- }
- }
- }
- }
- #pragma mark - UITableViewDataSource
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return self.dataArray.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (self.selectIndex == 1) {
- return 147.0f;
- }
- else if (self.selectIndex == 2) {
- return 150.0f;
- }
- else {
- return 110.0f;;
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (self.selectIndex == 1) {
- AccompanyLessonModel *model = self.dataArray[indexPath.row];
- AccompanyCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyCourseCell"];
- MJWeakSelf;
- [cell configWithSource:model actionCallback:^(ACCOMPANY_TYPE type, AccompanyLessonModel * _Nonnull source) {
- [weakSelf courseOperation:type sourceModel:source];
- }];
- return cell;
- }
- else if (self.selectIndex == 2) {
- LiveCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LiveCourseCell"];
- LiveCourseModel *model = self.dataArray[indexPath.row];
- BOOL hiddenInfo = NO;
- [cell configCellWithSource:model hideStudentInfo:hiddenInfo];
- return cell;
- }
- else {
- MusicMessageModel *model = self.dataArray[indexPath.row];
- MinePageMusicCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MinePageMusicCell"];
- [cell configWithMessage:model];
- return cell;
- }
- }
- - (void)courseOperation:(ACCOMPANY_TYPE)type sourceModel:(AccompanyLessonModel *)model {
- switch (type) {
- case ACCOMPANY_TYPE_CHAT: // 聊天
- {
- KSChatConversationViewController *conversationVC = [[KSChatConversationViewController alloc] init];
- conversationVC.targetId = model.userId;
- conversationVC.conversationType = ConversationType_PRIVATE;
- [self.naviController pushViewController:conversationVC animated:YES];
- }
- break;
- case ACCOMPANY_TYPE_ADJUST: // 调整
- {
- [self showAdjustPicker:model];
- }
- break;
- case ACCOMPANY_DETAIL: // 陪练课详情
- {
- [self showAccompanyDetail:model];
- }
- break;
- default:
- break;
- }
- }
- - (void)showAccompanyDetail:(AccompanyLessonModel *)model {
- AccompanyDetailViewController *detailVC = [[AccompanyDetailViewController alloc] init];
- detailVC.courseId = model.courseId;
- detailVC.courseGroupId = model.courseGoupId;
- detailVC.studentId = model.userId;
- [self.naviController pushViewController:detailVC animated:YES];
- }
- - (void)showAdjustPicker:(AccompanyLessonModel *)model {
-
- KSFullDatePicker *picker = [[KSFullDatePicker alloc] initWithTitle:@"课时调整" date:[NSDate date] pickMode:KSDATEPICKER_MODE_DAY_TIME selectDateBlock:^(NSString *date) {
- [self courseAdjustAction:model];
- } cancleBlock:^{
-
- }];
- [picker show];
- }
- - (void)courseAdjustAction:(AccompanyLessonModel *)model {
-
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- if (self.selectIndex == 1) {
- AccompanyLessonModel *model = self.dataArray[indexPath.row];
- [self showAccompanyDetail:model];
- }
- else if (self.selectIndex == 2) { // 直播课详情
- LiveCourseModel *model = self.dataArray[indexPath.row];
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- NSString *url = [NSString stringWithFormat:@"%@%@%.0f", WEBHOST, @"/#/liveDetail?groupId=",model.courseGroupId];
- ctrl.url = url;
- [self.naviController pushViewController:ctrl animated:YES];
- }
- else if (self.selectIndex == 4) { // 曲谱详情
- MusicMessageModel *model = self.dataArray[indexPath.row];
- KSAccompanyWebViewController *detailCtrl = [[KSAccompanyWebViewController alloc] init];
- detailCtrl.url = [NSString stringWithFormat:@"%@/accompany?id=%.0f&client=teacher",hostURL, model.internalBaseClassIdentifier];
- detailCtrl.hiddenNavBar = YES;
- detailCtrl.parmDic = @{@"isOpenLight" : @(YES), @"orientation" : @(0),@"isHideTitle" : @(YES)};
- [self.naviController pushViewController:detailCtrl animated:YES];
- }
- }
- /**
- 设置没有数据时的显示
-
- @param promptString 提示语
- @param imgName 图片名称
- @param view 显示在什么地方
- */
- - (void)setPromptString:(NSString *)promptString imageName:(NSString *)imgName inView:(UIView *)view {
- if (self.promptView != nil) {
- [self.promptView removeFromSuperview];
- }
- else {
- self.promptView = [[StateView alloc]init];
- self.promptView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - 300);
- }
- _promptPlaceView = view;
- //当请求不到数据时 ,自定义提示view 将会出现;
- self.promptView.imageName = imgName;
- self.promptView.alpha = 0.0f;
- [self.promptView setText:promptString];
- [view addSubview:self.promptView];
- }
- // 结束刷新后调用方法
- - (void)changePromptLabelStateWithArray:(NSMutableArray *)array {
- NSInteger count;
- if (array.count) {
- count = array.count;
- } else {
- count = 0;
- }
-
- [UIView animateWithDuration:0.1 animations:^{
- [[self promptView] setAlpha:count ? 0.0f :1.0f ] ;
- }] ;
-
- }
- - (BOOL)networkAvaiable {
- return [self checkNetworkAvaiable];
- }
- - (BOOL)checkNetworkAvaiable {
- BOOL isExistenceNetwork = YES;
- Reachability *reach = [Reachability reachabilityWithHostName:@"www.apple.com"];
- switch ([reach currentReachabilityStatus]) {
- case NotReachable:
- isExistenceNetwork = NO;
- //NSLog(@"notReachable");
- break;
- case ReachableViaWiFi:
- isExistenceNetwork = YES;
- //NSLog(@"WIFI");
- break;
- case ReachableViaWWAN:
- isExistenceNetwork = YES;
- //NSLog(@"3G");
- break;
- }
- return isExistenceNetwork;
- }
- #pragma mark ----- lazying
- - (NSDateFormatter *)dateFormatter {
- if (!_dateFormatter) {
- _dateFormatter = [NSObject getDateformatter];
- }
- return _dateFormatter;
- }
- - (CourseTimeSegView *)timeSortView {
- if (!_timeSortView) {
- _timeSortView = [CourseTimeSegView shareInstance];
- [self.dateFormatter setDateFormat:@"yyyy年M月"];
- NSDate *currentDate = [NSDate date];
- [_timeSortView.sortTitleLabel setText:[self.dateFormatter stringFromDate:currentDate]];
- CGFloat topHeight = 60.0f;
- _timeSortView.frame = CGRectMake(0, topHeight, kScreenWidth, 34);
- MJWeakSelf;
- [_timeSortView sortAction:^{
- [weakSelf showPickerView];
- }];
- }
- return _timeSortView;
- }
- - (void)showPickerView {
- KSFullDatePicker *picker = [[KSFullDatePicker alloc] initWithTitle:@"" date:[NSDate date] pickMode:KSDATEPICKER_MODE_YEAR_MONTH selectDateBlock:^(NSString *date) {
- self.chooseMonth = date;
- NSString *displayTime = [self getTimeDisplay:date];
- [self.timeSortView.sortTitleLabel setText:displayTime];
- [self resetPickerStatus];
- // 请求数据
- [self refreshAndRequestData];
- } cancleBlock:^{
- [self resetPickerStatus];
- }];
- [picker show];
- }
- - (NSString *)getTimeDisplay:(NSString *)chooseMonth {
- [self.dateFormatter setDateFormat:@"yyyy-MM"];
- NSDate *chooseDate = [self.dateFormatter dateFromString:chooseMonth];
- [self.dateFormatter setDateFormat:@"yyyy年M月"];
- NSString *displayTime = [self.dateFormatter stringFromDate:chooseDate];
- return displayTime;
- }
- - (void)resetPickerStatus {
- self.timeSortView.arrowUp = NO;
- }
- - (void)setTeaherStatus:(NSString *)teaherStatus {
- _teaherStatus = teaherStatus;
-
- if ([teaherStatus isEqualToString:@"UNPAALY"]) { // 未申请
- self.teacherAuthPass = NO;
- }
- else if ([teaherStatus isEqualToString:@"DOING"]) { // 审核中
- self.teacherAuthPass = NO;
- }
- else if ([teaherStatus isEqualToString:@"UNPASS"]) { // 不通过
- self.teacherAuthPass = NO;
- }
- else {
- self.teacherAuthPass = YES;
- }
-
- // 如果
- if (self.selectIndex == 2) { // 直播课
- if (self.liveFlag == NO) { // 无直播权限直接改成未通过
- self.teacherAuthPass = NO;
- }
- }
-
- if (self.selectIndex == 1) {
- self.uploadView.type = MINEPAGETYPE_ACCOMPANY;
- }
- else if (self.selectIndex == 2) {
- self.uploadView.type = MINEPAGETYPE_LIVE;
- }
- if (self.selectIndex == 1 || self.selectIndex == 2) {
- if (self.teacherAuthPass == NO) {
- [self showAuthView];
- }
- else {
- [self hideAuthView];
- }
- }
- }
- - (void)setMusicianStatus:(NSString *)musicianStatus {
- _musicianStatus = musicianStatus;
- if ([musicianStatus isEqualToString:@"UNPAALY"]) { // 未申请
- self.musicianPass = NO;
- }
- else if ([musicianStatus isEqualToString:@"DOING"]) { // 审核中
- self.musicianPass = NO;
- }
- else if ([musicianStatus isEqualToString:@"UNPASS"]) { // 不通过
- self.musicianPass = NO;
- }
- else {
- self.musicianPass = YES;
- }
- if (self.selectIndex == 4) {
- self.uploadView.type = MINEPAGETYPE_MUSIC;
- }
- if (self.selectIndex == 4) {
- if (self.musicianPass == NO) {
- [self showAuthView];
- }
- else {
- [self hideAuthView];
- }
- }
- }
- - (void)showAuthView {
- [self configAuthDisplay];
- if ([self.subviews containsObject:self.authView]) {
- [self bringSubviewToFront:self.authView];
- }
- else {
- [self addSubview:self.authView];
- [self.authView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.bottom.right.mas_equalTo(self);
- }];
- }
- }
- - (void)configAuthDisplay {
- [self.authView configDisplayMessage:[self getAuthDisplayMessage]];
- if (self.selectIndex == 1) { // 陪练课
- if ([self.teaherStatus isEqualToString:@"DOING"]) {
- self.authView.sureButton.userInteractionEnabled = NO;
- self.authView.sureButton.hidden = YES;
- }
- else {
- self.authView.sureButton.userInteractionEnabled = YES;
- self.authView.sureButton.hidden = NO;
- }
- }
- else if (self.selectIndex == 2) { // 直播课
- if ([self.teaherStatus isEqualToString:@"DOING"]) {
- self.authView.sureButton.userInteractionEnabled = NO;
- self.authView.sureButton.hidden = YES;
- }
- else {
- if ([self.teaherStatus isEqual:@"PASS"] && self.liveFlag == NO) {
- [self.authView.sureButton setTitle:@"立即开通" forState:UIControlStateNormal];
- }
- else {
- [self.authView.sureButton setTitle:@"去认证" forState:UIControlStateNormal];
- }
- self.authView.sureButton.userInteractionEnabled = YES;
- self.authView.sureButton.hidden = NO;
- }
- }
- else { // 曲谱
- if ([self.musicianStatus isEqualToString:@"DOING"]) {
- self.authView.sureButton.userInteractionEnabled = NO;
- self.authView.sureButton.hidden = YES;
- }
- else {
-
- self.authView.sureButton.userInteractionEnabled = YES;
- self.authView.sureButton.hidden = NO;
- }
- }
-
- }
- - (void)hideAuthView {
- if ([self.subviews containsObject:self.authView]) {
- [self.authView removeFromSuperview];
- self.authView = nil;
- }
- }
- - (MinePageSubmitView *)uploadView {
- if (!_uploadView) {
- _uploadView = [MinePageSubmitView shareInstance];
- CGFloat topHeight = 60.0f;
- _uploadView.frame = CGRectMake(0, 0, kScreenWidth, topHeight);
- MJWeakSelf;
- [_uploadView opreationCallback:^(MINEPAGETYPE type) {
- [weakSelf uploadAciton:type];
- }];
- }
- return _uploadView;
- }
- - (void)uploadAciton:(MINEPAGETYPE)type {
- switch (type) {
- case MINEPAGETYPE_ACCOMPANY: // 陪练课设置
- {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/practiceSetting"];
- [self.naviController pushViewController:webCtrl animated:YES];
- }
- break;
- case MINEPAGETYPE_LIVE: // 直播课设置
- {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/liveCreate"];
- [self.naviController pushViewController:webCtrl animated:YES];
- }
- break;
- case MINEPAGETYPE_MUSIC: // 上传曲谱
- {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/music-upload"];
- [self.naviController pushViewController:webCtrl animated:YES];
- }
- break;
- default:
- break;
- }
- }
- - (AuthDisplayView *)authView {
- if (!_authView) {
- _authView = [AuthDisplayView shareInstance];
- [_authView.imageView setImage:[UIImage imageNamed:[self getAuthDisplayImage]]];
- MJWeakSelf;
- [_authView sureCallback:^{
- [weakSelf authAction];
- }];
- }
- return _authView;
- }
- - (NSString *)getAuthDisplayImage {
- if (self.selectIndex == 1) {
- return @"authTeacher_accompany";
- }
- else if (self.selectIndex == 2) {
- return @"authTeacher_Live";
- }
- else {
- return @"authMuscian";
- }
- }
- - (NSString *)getAuthDisplayMessage {
- if (self.selectIndex == 1) { // 陪练课
- if ([self.teaherStatus isEqualToString:@"DOING"]) { // 审核中
- return @"您已提交认证申请,请耐心等待审核结果~";
- }
- else {
- return @"您还没有完成达人认证,认证后才可设置陪练课哦~";
- }
- }
- else if (self.selectIndex == 2) { // 直播课
- if ([self.teaherStatus isEqualToString:@"DOING"]) { // 审核中
- return @"您已提交认证申请,请耐心等待审核结果~";
- }
- else {
- if ([self.teaherStatus isEqualToString:@"PASS"] && self.liveFlag == NO) { // 如果达人认证通过
- return @"您尚未开通直播服务,开通后即可创建直播课程~";
- }
- return @"您还没有完成达人认证,认证后才可创建直播课哦~";
- }
- }
- else { // 曲谱
- if ([self.musicianStatus isEqualToString:@"DOING"]) { // 审核中
- return @"您已提交认证申请,请耐心等待审核结果~";
- }
- else {
- return @"您还没有完成音乐人认证,认证后才可上传曲谱哦~";
- }
- }
- }
- - (void)authAction {
- if (self.selectIndex == 1) {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
- [self.naviController pushViewController:webCtrl animated:YES];
- }
- else if (self.selectIndex == 2) {
- if ([self.teaherStatus isEqual:@"PASS"] && self.liveFlag == NO) { // 开通直播
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/openLive"];
- [self.naviController pushViewController:webCtrl animated:YES];
- }
- else {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
- [self.naviController pushViewController:webCtrl animated:YES];
- }
- }
- else {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/musicCert"];
- [self.naviController pushViewController:webCtrl animated:YES];
- }
- }
- - (MyMusicSearchView *)searchView {
- if (!_searchView) {
- _searchView = [MyMusicSearchView shareInstance];
- CGFloat topHeight = 50.0f;
- _searchView.frame = CGRectMake(0, 0, kScreenWidth, 50);
- MJWeakSelf;
- [_searchView musicSearchAction:^(NSString * _Nonnull searchKey, BOOL isChooseSubject) {
- if (isChooseSubject) {
- [weakSelf searchSubject];
- }
- else {
- [weakSelf evaluateSource:searchKey];
- }
- }];
- }
- return _searchView;
- }
- - (void)evaluateSource:(NSString *)searchKey {
- self.searchKey = searchKey;
- [self refreshAndRequestData];
- }
- - (void)searchSubject {
- if (self.subjectList.count) {
- NSMutableArray *nameArray = [NSMutableArray array];
- [nameArray addObject:@"全部"];
- for (NSDictionary *parm in self.subjectList) {
- [nameArray addObject:[parm stringValueForKey:@"subjectName"]];
- }
- MJWeakSelf;
- KSChoosePicker *picker = [[KSChoosePicker alloc] initWithTitle:@"声部" sourceData:nameArray chooseReturnWithBlock:^(NSString * _Nonnull returnValue, NSInteger chooseIndex) {
- if (chooseIndex == 0) {
- weakSelf.searchView.sortTitleLabel.text = @"声部";
- weakSelf.subjectIds = nil;
- }
- else {
- weakSelf.searchView.sortTitleLabel.text = returnValue;
- NSDictionary *parm = self.subjectList[chooseIndex-1];
- weakSelf.subjectIds = [parm stringValueForKey:@"subjectId"];
- }
- self.searchView.arrowUp = NO;
- [weakSelf refreshAndRequestData];
- } cancel:^{
- self.searchView.arrowUp = NO;
- }];
- [picker showPicker];
- }
- else {
- [self MBPShow:@"无声部信息"];
- self.searchView.arrowUp = NO;
- }
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|