123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674 |
- //
- // CourseViewController.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/17.
- //
- #import "CourseViewController.h"
- #import "FSCalendar.h"
- #import "CourseNavView.h"
- #import "LTSCalendarBottomView.h"
- #import <KSFullDatePicker.h>
- #import "TableCourseModel.h"
- #import "KSChatConversationViewController.h"
- #import "KSGroupConversationController.h"
- #import "KSEnterLiveroomManager.h"
- #import "KSBaseWKWebViewController.h"
- #import "AccompanyCourseCell.h"
- #import "CourseForLiveCell.h"
- #import "AccompanyDetailViewController.h"
- #import "VipCouseDetailViewController.h"
- #import "MusicRoomCourseCell.h"
- #import "MusicRoomDetailViewController.h"
- #import "VIPCourseCell.h"
- @interface CourseViewController ()<UITableViewDataSource,UITableViewDelegate,FSCalendarDataSource,FSCalendarDelegate,UIGestureRecognizerDelegate>
- {
- void * _KVOContext;
- }
- @property (nonatomic, strong) CourseNavView *navHeadView;
- @property (nonatomic, strong) NSString *chooseMonth;
- @property (nonatomic, strong) NSString *chooseDay;
- @property (nonatomic,strong) FSCalendar *calendar;
- @property (strong, nonatomic) NSCalendar *gregorian;
- @property (nonatomic, strong) UITableView *tableView;
- @property (strong, nonatomic) UIPanGestureRecognizer *scopeGesture;
- @property (strong, nonatomic) NSDateFormatter *dateFormatter;
- @property (nonatomic, strong) LTSCalendarBottomView *calendarBottom;
- @property (nonatomic, assign) BOOL cancleRequest;
- @property (nonatomic, strong) KSFullDatePicker *datePicker;
- @property (nonatomic, assign) BOOL isPickerChoose; // 是否选择的月份
- @property (nonatomic, assign) NSInteger vipStartTime; // VIP课开课前可进入时间配置(分钟)
- @property (nonatomic, assign) NSInteger vipEndTime; // VIP课结束后退出时间配置(分钟)
- @property (nonatomic, assign) NSInteger practiceStartTime; // 趣纠课开课前可进入时间配置(分钟)
- @property (nonatomic, assign) NSInteger practiceEndTime; // 趣纠课结束后退出时间配置(分钟)
- @property (nonatomic, assign) NSInteger liveStartTime; // 直播课开课前可进入时间配置(分钟)
- @property (nonatomic, assign) NSInteger liveEndTime; // 直播课结束后退出时间配置(分钟)
- @property (nonatomic, assign) NSInteger pianoStartTime; // 琴房课开课前可进入时间配置(分钟)
- @property (nonatomic, assign) NSInteger pianoEndTime; // 琴房课结束后退出时间配置(分钟)
- @end
- @implementation CourseViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- [self configUI];
- [self loadCalendarInfo];
- }
- - (void)loadCalendarInfo {
- NSDateFormatter *formatter = [NSObject getDateformatter];
- [formatter setDateFormat:@"yyyy-MM"];
- NSDate *date = [NSDate date];
- self.chooseMonth = [formatter stringFromDate:date];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- self.chooseDay = [NSString stringWithFormat:@"%@ 00:00:00", [formatter stringFromDate:date]];
- [self.calendar selectDate:date];
-
- // title 显示
- [formatter setDateFormat:@"yyyy年MM月"];
- [self.navHeadView.navTitle setText:[formatter stringFromDate:date]];
-
- [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
-
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self loadMonthCourse:self.chooseMonth];
- if (![NSString isEmptyString:self.chooseDay]) {
- [self getCourseByDate:self.chooseDay];
- }
- }
- - (void)configUI {
- [self.view addSubview:self.navHeadView];
- [self.navHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.mas_equalTo(self.view);
- make.height.mas_equalTo(kNaviBarHeight);
- }];
-
- [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.top.mas_equalTo(self.navHeadView.mas_bottom);
- make.bottom.mas_equalTo(self.view.mas_bottom);
- }];
-
- UIView *containerView = [[UIView alloc] initWithFrame:CGRectZero];
- containerView.backgroundColor = [UIColor clearColor];
- [self.scrollView addSubview:containerView];
- [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.mas_equalTo(self.scrollView);
- make.width.mas_equalTo(self.scrollView);
- }];
-
- self.calendar = [[FSCalendar alloc] init];
- [self configCalendar];
- [containerView addSubview:self.calendar];
- [self.calendar mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(containerView);
- make.top.mas_equalTo(containerView.mas_top);
- make.height.mas_equalTo(300);
- }];
- self.calendarBottom = [LTSCalendarBottomView shareInstance];
- MJWeakSelf;
- [self.calendarBottom changeDisplay:^{
- [weakSelf changeDisplay];
- }];
- [containerView addSubview:self.calendarBottom];
- [self.calendarBottom mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(containerView);
- make.top.mas_equalTo(self.calendar.mas_bottom);
- make.height.mas_equalTo(40);
- }];
-
- [containerView addSubview:self.tableView];
- CGFloat tableHeight = kScreenHeight - kNaviBarHeight - kTabBarHeight - 300 - 40;
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.top.mas_equalTo(self.calendarBottom.mas_bottom);
- make.height.mas_equalTo(tableHeight);
- }];
- [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(self.tableView.mas_bottom);
- }];
-
- UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self.calendar action:@selector(handleScopeGesture:)];
- panGesture.delegate = self;
- panGesture.minimumNumberOfTouches = 1;
- panGesture.maximumNumberOfTouches = 2;
- [self.scrollView addGestureRecognizer:panGesture];
- self.scopeGesture = panGesture;
- [self.tableView.panGestureRecognizer requireGestureRecognizerToFail:panGesture];
- self.scrollView.mj_header = [KSGifRefreshHeader headerWithRefreshingBlock:^{
- [weakSelf.calendar setToday:[NSDate date]];
- [weakSelf loadMonthCourse:weakSelf.chooseMonth];
- if (![NSString isEmptyString:weakSelf.chooseDay]) {
- [weakSelf getCourseByDate:weakSelf.chooseDay];
- }
- }];
- self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- [self configEmptyView];
- }
- - (void)configEmptyView {
- [self setPromptString:@"暂无课程" imageName:@"empty_course" inView:self.tableView];
- // MJWeakSelf;
- // self.actionStatusView = [self setActionPromptString:@"暂无预约课程" buttonTitlle:@"发现课程" imageName:@"no_course" inView:self.tableView actionBlock:^{
- // [weakSelf findCourse];
- // }];
- // [self.actionStatusView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.right.mas_equalTo(self.view);
- // make.top.mas_equalTo(self.calendarBottom.mas_bottom);
- // make.bottom.mas_equalTo(self.view);
- // }];
- }
- - (void)findCourse {
- [self selectBarHomeWithIndex:0];
- }
- - (void)endRefresh {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self.scrollView.mj_header endRefreshing];
- });
- }
- #pragma mark ---- calender action
- // 收起或展开日历
- - (void)changeDisplay {
- FSCalendarScope selectedScope = self.calendar.scope == FSCalendarScopeMonth ? FSCalendarScopeWeek : FSCalendarScopeMonth;
- [self.calendar setScope:selectedScope animated:YES];
- NSString *imgName = selectedScope == FSCalendarScopeWeek ? @"arrow_down" : @"arrow_up";
- [self.calendarBottom.arrowImage setImage:[UIImage imageNamed:imgName]];
- [self.calendar reloadData];
- }
- - (void)configCalendar {
- self.calendar.backgroundColor = [UIColor whiteColor];
- self.calendar.appearance.titleFont = [UIFont systemFontOfSize:14.0f weight:UIFontWeightMedium];
- self.calendar.appearance.titleDefaultColor = HexRGB(0x444444);
- self.calendar.appearance.titleTodayColor = HexRGB(0x444444);
- self.calendar.appearance.titleSelectionColor = [UIColor whiteColor];
- self.calendar.appearance.selectionColor = THEMECOLOR;
- self.calendar.appearance.weekdayFont = [UIFont systemFontOfSize:14.0f];
- self.calendar.appearance.weekdayTextColor = HexRGB(0x777777);
- self.calendar.appearance.titleWeekendColor = THEMECOLOR;
- self.calendar.appearance.todaySelectionColor = THEMECOLOR;
- self.calendar.appearance.todayColor = [UIColor whiteColor];
- self.calendar.appearance.todayBorderColor = [UIColor whiteColor];
- self.calendar.appearance.borderRadius = 0.2f;
- self.calendar.appearance.borderDefaultColor = [UIColor whiteColor];
- self.calendar.appearance.titleHightlightColor = HexRGB(0x444444);
- self.calendar.appearance.backgoundHightlightColor = HexRGBAlpha(0xffd7a6, 0.21);
- self.calendar.appearance.subtitleFont = [UIFont systemFontOfSize:10.0f];
- self.calendar.appearance.subtitleOffset = CGPointMake(0, 3);
- self.calendar.appearance.subtitleTodayColor = HexRGB(0xff6363);
- self.calendar.appearance.subtitleDefaultColor = HexRGB(0xff6363);
- self.calendar.appearance.subtitleSelectionColor = [UIColor whiteColor];
- self.calendar.appearance.titleTodayColor = THEMECOLOR;
- self.calendar.dataSource = self;
- self.calendar.delegate = self;
- // self.calendar.firstWeekday = 2;
- self.calendar.appearance.caseOptions = FSCalendarCaseOptionsWeekdayUsesSingleUpperCase|FSCalendarCaseOptionsHeaderUsesUpperCase;
- self.calendar.calendarHeaderView.hidden = YES;
- self.calendar.locale = [NSLocale localeWithLocaleIdentifier:@"zh_CN"];
- [self.calendar addObserver:self forKeyPath:@"scope" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:_KVOContext];
- self.calendar.placeholderType = FSCalendarPlaceholderTypeNone;
- self.calendar.scope = FSCalendarScopeMonth;
- [self.calendar selectDate:[NSDate date] scrollToDate:YES];
- [self.calendar reloadData];
- }
- #pragma mark - FSCalendarDataSource
- - (NSString *)calendar:(FSCalendar *)calendar subtitleForDate:(NSDate *)date {
-
- // 判断有课的日期显示subtitle
- if ([calendar.highlightDates containsObject:date]) {
- return @"有课";
- }
- return nil;
-
-
- }
- #pragma mark - FSCalendarDelegate
- - (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
- {
- [calendar mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(bounds.size.height);
- // Do other updates
- }];
- [self.tableView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(kScreenHeight - kTabBarHeight - bounds.size.height - kNaviBarHeight - 40);
- }];
- [self.view layoutIfNeeded];
- }
- - (void)calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date atMonthPosition:(FSCalendarMonthPosition)monthPosition
- {
- NSLog(@"did select date %@",[self.dateFormatter stringFromDate:date]);
-
- NSMutableArray *selectedDates = [NSMutableArray arrayWithCapacity:calendar.selectedDates.count];
- [calendar.selectedDates enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- [selectedDates addObject:[self.dateFormatter stringFromDate:obj]];
- }];
- self.navHeadView.navTitle.text = [self.dateFormatter stringFromDate:date];
- NSLog(@"selected dates is %@",selectedDates);
- if (monthPosition == FSCalendarMonthPositionNext || monthPosition == FSCalendarMonthPositionPrevious) {
- [calendar setCurrentPage:date animated:YES];
- }
- NSDateFormatter *formatter = [NSObject getDateformatter];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSString *dateStr = [formatter stringFromDate:date];
- dateStr = [NSString stringWithFormat:@"%@ 00:00:00", dateStr];
- self.chooseDay = dateStr;
- [self getCourseByDate:dateStr];
- }
- - (void)calendarCurrentPageDidChange:(FSCalendar *)calendar {
- if (_isPickerChoose) {
- _isPickerChoose = NO;
- return;
- }
- self.navHeadView.navTitle.text = [self.dateFormatter stringFromDate:calendar.currentPage];
- NSLog(@"%s %@", __FUNCTION__, [self.dateFormatter stringFromDate:calendar.currentPage]);
- // 获取当前月份信息
- NSDateFormatter *formatter = [NSObject getDateformatter];
- [formatter setDateFormat:@"yyyy-MM"];
- NSString *month = [formatter stringFromDate:calendar.currentPage];
- if (![_chooseMonth isEqualToString:month]) {
- _chooseMonth = month;
- [self loadMonthCourse:month];
- }
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSString *chooseDay = [formatter stringFromDate:calendar.currentPage];
- self.chooseDay = chooseDay;
- [self.calendar selectDate:calendar.currentPage];
- [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- NSString *currentDate = [formatter stringFromDate:calendar.currentPage];
- [self getCourseByDate:currentDate];
- }
- #pragma mark --- 获取当前月份有课日期
- - (void)loadMonthCourse:(NSString *)month {
- [KSNetworkingManager queryCourseSchedule:KS_POST classMonth:month success:^(NSDictionary * _Nonnull dic) {
- [self endRefresh];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- NSArray *courseArray = [dic ks_arrayValueForKey:@"data"];
- NSMutableArray *courseDateArray = [NSMutableArray array];
- for (NSString *dateString in courseArray) {
- NSString *dateStr = [NSString stringWithFormat:@"%@ %@", dateString, @"00:00:00"];
- [courseDateArray addObject:dateStr];
- }
- self.calendar.highlightDates = courseDateArray;
- [self.calendar reloadData];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [self endRefresh];
- }];
- }
- #pragma mark --- 获取当日课程
- - (void)getCourseByDate:(NSString *)date {
- [KSNetworkingManager queryCourseForDay:KS_POST classDate:date success:^(NSDictionary * _Nonnull dic) {
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- // 配置信息
- NSDictionary *config = [[dic ks_dictionaryValueForKey:@"data"] ks_dictionaryValueForKey:@"sysConfig"];
- self.vipStartTime = [config ks_integerValueForKey:@"vipStartTime"];
- self.vipEndTime = [config ks_integerValueForKey:@"vipEndTime"];
- self.practiceStartTime = [config ks_integerValueForKey:@"practiceStartTime"];
- self.practiceEndTime = [config ks_integerValueForKey:@"practiceEndTime"];
- self.liveStartTime = [config ks_integerValueForKey:@"liveStartTime"];
- self.liveEndTime = [config ks_integerValueForKey:@"liveEndTime"];
- self.pianoStartTime = [config ks_integerValueForKey:@"pianoStartTime"];
- self.pianoEndTime = [config ks_integerValueForKey:@"pianoEndTime"];
-
- NSArray *courseArray = [[dic ks_dictionaryValueForKey:@"data"] ks_arrayValueForKey:@"studentList"];
- NSMutableArray *lessonArray = [NSMutableArray array];
- for (NSDictionary *parm in courseArray) {
- TableCourseModel *model = [[TableCourseModel alloc] initWithDictionary:parm];
- [lessonArray addObject:model];
- }
- self.dataArray = [lessonArray mutableCopy];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- [self.tableView reloadData];
- [self changePromptLabelState];
- } faliure:^(NSError * _Nonnull error) {
- }];
- }
- #pragma mark - <UIGestureRecognizerDelegate>
- // Whether scope gesture should begin
- - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
- {
- BOOL shouldBegin = self.tableView.contentOffset.y <= -self.tableView.contentInset.top;
- if (shouldBegin) {
- CGPoint velocity = [self.scopeGesture velocityInView:self.view];
- switch (self.calendar.scope) {
- case FSCalendarScopeMonth:
- return velocity.y < 0;
- case FSCalendarScopeWeek:
- return velocity.y > 0;
- }
- }
- return shouldBegin;
- }
- #pragma mark - KVO
- - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
- {
- if (context == _KVOContext) {
- FSCalendarScope oldScope = [change[NSKeyValueChangeOldKey] unsignedIntegerValue];
- FSCalendarScope newScope = [change[NSKeyValueChangeNewKey] unsignedIntegerValue];
- NSLog(@"From %@ to %@",(oldScope==FSCalendarScopeWeek?@"week":@"month"),(newScope==FSCalendarScopeWeek?@"week":@"month"));
- NSString *imgName = newScope == FSCalendarScopeWeek ? @"arrow_down" : @"arrow_up";
- [self.calendarBottom.arrowImage setImage:[UIImage imageNamed:imgName]];
- } else {
- [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
- }
- }
- #pragma mark --- table data source
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.dataArray.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 137.0f;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- TableCourseModel *model = self.dataArray[indexPath.row];
- if ([model.courseType isEqualToString:@"PRACTICE"]) { // 趣纠课
- AccompanyCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyCourseCell"];
- MJWeakSelf;
- [cell configWithCourseMessage:model beforeTime:self.practiceStartTime actionCallback:^(ACCOMPANY_TYPE type, TableCourseModel * _Nonnull courseModel) {
- [weakSelf accompanyLessonAction:type source:courseModel];
- }];
- return cell;
- }
- else if ([model.courseType isEqualToString:@"VIP"]) { // 定制课
- VIPCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VIPCourseCell"];
- MJWeakSelf;
- [cell configWithCourseMessage:model beforeTime:self.vipStartTime actionCallback:^(ACCOMPANY_TYPE type, TableCourseModel * _Nonnull courseModel) {
- [weakSelf vipLessionAction:type source:courseModel];
- }];
- return cell;
- }
- else if ([model.courseType isEqualToString:@"LIVE"]) { // 直播课
- CourseForLiveCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CourseForLiveCell"];
- MJWeakSelf;
- [cell configWithSource:model beforeTime:self.liveStartTime callback:^(LIVECOURSEACTION action, TableCourseModel *sourceModel) {
- [weakSelf liveCourseAction:action source:sourceModel];
- }];
- return cell;
- }
- else {
- MusicRoomCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MusicRoomCourseCell"];
- MJWeakSelf;
- [cell configWithSource:model beforeTime:self.pianoStartTime callback:^(NSString * _Nonnull targetId) {
- [weakSelf chatAction:targetId groupName:@"" isGroup:YES];
- }];
- return cell;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- TableCourseModel *model = self.dataArray[indexPath.row];
- if ([model.courseType isEqualToString:@"PRACTICE"]) { // 趣纠课
- [self showAccompanyDetailAction:model];
- }
- else if ([model.courseType isEqualToString:@"VIP"]) {
- [self showVipDetailAction:model];
- }
- else if ([model.courseType isEqualToString:@"LIVE"]) { // 直播课详情
- [self liveCourseDetail:model.courseId courseGroupId:model.courseGoupId];
- }
- else if ([model.courseType isEqualToString:@"PIANO_ROOM_CLASS"]) { // 琴房课详情
- [self showMusicRoomDetail:model];
- }
- else {
- [self showAccompanyDetailAction:model];
- }
- }
- - (void)accompanyLessonAction:(ACCOMPANY_TYPE)action source:(TableCourseModel *)source {
- switch (action) {
- case ACCOMPANY_TYPE_CHAT:
- {
- [self chatAction:source.imUserId groupName:source.name isGroup:NO];
- }
- break;
- case ACCOMPANY_DETAIL:
- {
- [self showAccompanyDetailAction:source];
- }
- break;
- default:
- break;
- }
- }
- - (void)vipLessionAction:(ACCOMPANY_TYPE)action source:(TableCourseModel *)source {
- switch (action) {
- case ACCOMPANY_TYPE_CHAT:
- {
- [self chatAction:source.imUserId groupName:source.name isGroup:NO];
- }
- break;
- case ACCOMPANY_DETAIL:
- {
- [self showVipDetailAction:source];
- }
- break;
- default:
- break;
- }
- }
- - (void)showAccompanyDetailAction:(TableCourseModel *)source {
- AccompanyDetailViewController *detailVC = [[AccompanyDetailViewController alloc] init];
- detailVC.courseId = source.courseId;
- detailVC.courseGroupId = source.courseGoupId;
- [self.navigationController pushViewController:detailVC animated:YES];
- }
- - (void)showVipDetailAction:(TableCourseModel *)source {
- VipCouseDetailViewController *detailVC = [[VipCouseDetailViewController alloc] init];
- detailVC.courseId = source.courseId;
- detailVC.courseGroupId = source.courseGoupId;
- [self.navigationController pushViewController:detailVC animated:YES];
- }
- - (void)showMusicRoomDetail:(TableCourseModel *)source {
- MusicRoomDetailViewController *detailVC = [[MusicRoomDetailViewController alloc] init];
- detailVC.courseId = source.courseId;
- detailVC.courseGroupId = source.courseGoupId;
- [self.navigationController pushViewController:detailVC animated:YES];
- }
- - (void)liveCourseAction:(LIVECOURSEACTION)action source:(TableCourseModel *)source {
- switch (action) {
- case LIVECOURSEACTION_CHAT: // 聊天
- {
- [self chatAction:source.imGroupId groupName:@"" isGroup:YES];
- }
- break;
- case LIVECOURSEACTION_LIVEROOM: // 直播课上课
- {
- [self liveCourseDetail:source.courseId courseGroupId:source.courseGoupId];
- }
- break;
- default:
- break;
- }
- }
- - (void)chatAction:(NSString *)targetId groupName:(NSString *)targetName isGroup:(BOOL)isGroup {
- if ([NSString isEmptyString:targetId] && isGroup) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"报名未结束,暂无群组"];
- return;
- }
- if (isGroup) {
- TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
- model.groupID = targetId;
- KSGroupConversationController *ctrl = [[KSGroupConversationController alloc] init];
- ctrl.conversation = model;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- else {
- TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
- model.userID = targetId;
- KSChatConversationViewController *ctrl = [[KSChatConversationViewController alloc] init];
- ctrl.conversation = model;
- [self.navigationController pushViewController:ctrl animated:YES];
-
- }
-
- }
- - (void)liveCourseDetail:(NSString *)courseId courseGroupId:(NSString *)courseGroupId {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- NSString *url = [NSString stringWithFormat:@"%@/#/liveDetail?joinRoom=1&groupId=%@&classId=%@", WEBHOST, courseGroupId,courseId];
- ctrl.url = url;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- #pragma mark --- lazying
- - (CourseNavView *)navHeadView {
- if (!_navHeadView) {
- _navHeadView = [CourseNavView shareInstance];
- MJWeakSelf;
- [_navHeadView chooseNavCallback:^{
- [weakSelf displayMounthPicker];
- }];
-
- }
- return _navHeadView;
- }
- - (KSFullDatePicker *)datePicker {
- if (!_datePicker) {
- _datePicker = [[KSFullDatePicker alloc] initWithTitle:@"" date:[NSDate date] pickMode:KSDATEPICKER_MODE_YEAR_MONTH sureButtonColor:CLIENT_THEMECOLOR selectDateBlock:^(NSString *date) {
- self.navHeadView.navTitle.text = [self getTimeDisplay:date];
- self.chooseMonth = date;
- [self resetPickerStatus];
- [self scrollCalendarToChooseMonth];
-
- } cancleBlock:^{
- [self resetPickerStatus];
- }];
- }
- return _datePicker;
- }
- - (void)scrollCalendarToChooseMonth {
- self.isPickerChoose = YES;
- NSDateFormatter *formatter = [NSObject getDateformatter];
- [formatter setDateFormat:@"yyyy-MM"];
- NSDate *chooseDate = [formatter dateFromString:self.chooseMonth];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- self.chooseDay = [NSString stringWithFormat:@"%@ 00:00:00", [formatter stringFromDate:chooseDate]];
- [self.calendar setCurrentPage:chooseDate animated:YES];
- [self loadMonthCourse:self.chooseMonth];
- if (![NSString isEmptyString:self.chooseDay]) {
- [self.calendar selectDate:chooseDate];
- [self getCourseByDate:self.chooseDay];
- }
- }
- - (NSString *)getTimeDisplay:(NSString *)chooseMonth {
- [self.dateFormatter setDateFormat:@"yyyy-MM"];
- NSDate *chooseDate = [self.dateFormatter dateFromString:chooseMonth];
- [self.dateFormatter setDateFormat:@"yyyy年MM月"];
- NSString *displayTime = [self.dateFormatter stringFromDate:chooseDate];
- return displayTime;
- }
- - (void)resetPickerStatus {
- self.navHeadView.arrowUp = NO;
- }
- - (void)displayMounthPicker {
- [self.datePicker show];
- }
- - (NSDateFormatter *)dateFormatter {
- if (!_dateFormatter) {
- _dateFormatter = [NSObject getDateformatter];
- _dateFormatter.dateFormat = @"yyyy年MM月";
- }
- return _dateFormatter;
- }
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.backgroundColor = [UIColor clearColor];
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.showsHorizontalScrollIndicator = NO;
- [_tableView registerNib:[UINib nibWithNibName:@"AccompanyCourseCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyCourseCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"CourseForLiveCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"CourseForLiveCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"MusicRoomCourseCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MusicRoomCourseCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"VIPCourseCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"VIPCourseCell"];
-
- UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 15)];
- bottomView.backgroundColor = [UIColor clearColor];
- _tableView.tableFooterView = bottomView;
-
- }
- return _tableView;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|