123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749 |
- //
- // NewHomeViewController.m
- // KulexiuForStudent
- //
- // Created by 王智 on 2022/8/29.
- //
- #import "NewHomeViewController.h"
- #import "KSBaseWKWebViewController.h"
- #import "InstrumentChooseViewController.h"
- #import "NotiferMessageViewController.h"
- #import "HomeNavSearchView.h"
- #import "KSScanViewController.h"
- #import "HomeBannerView.h"
- #import <UIButton+WebCache.h>
- #import "TYCyclePagerView.h"
- #import "TYPageControl.h"
- #import "HomeBannerCell.h"
- #import "HomeBannerCell.h"
- #import "HomeButtonView.h"
- #import "KSHomeButton.h"
- #import "PublicNoticeView.h"
- #import "SDCycleScrollView.h"
- #import "NoticeSourceModel.h"
- #import "AppDelegate.h"
- #import "StudentInfoModel.h"
- #import "UserInfoManager.h"
- #import "HomeRecentCourseView.h"
- #import "AccompanyDetailViewController.h"
- #import "MusicRoomDetailViewController.h"
- #import "HomeHotAlbumView.h"
- #import "HomeAlbumModel.h"
- #import "HomeHotAlbumCell.h"
- #import "HomeHotMusicView.h"
- #import "HomeHotMusicCollectionCell.h"
- #import "KSPremissionAlert.h"
- #import "RecordCheckManager.h"
- #import "KSAccompanyWebViewController.h"
- #import "HomeHotTalentView.h"
- #import "HomeHotTalentCell.h"
- #import "TalentTeacherModel.h"
- #import "HomeHotVideoCourseView.h"
- #import "HomeHotVideoCell.h"
- #import "HomeVideoGroupModel.h"
- #import "HomeHotLiveCourseView.h"
- #import "HomeHotLiveCell.h"
- #import "HomeLiveGroupModel.h"
- #import "JXCategoryView.h"
- #import "JXPagerListRefreshView.h"
- #import "HomePageBodyView.h"
- #import "HomeInformationBodyView.h"
- #import "TeacherStyleModel.h"
- #import "HomeTeacherLiveModel.h"
- #define BUTTONWIDTH (65)
- #define BUTTONHEIGHT (80)
- @interface NewHomeViewController ()<JXPagerViewDelegate, JXPagerMainTableViewGestureDelegate,JXCategoryViewDelegate,SDCycleScrollViewDelegate,UIScrollViewDelegate,UICollectionViewDelegate, UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,TYCyclePagerViewDataSource,TYCyclePagerViewDelegate>
- @property (nonatomic, strong) StudentInfoModel *mineInfo;
- @property (nonatomic, strong) HomeNavSearchView *navView;
- @property (nonatomic, strong) HomeMessageModel *flashModel;
- @property (nonatomic, assign) BOOL isFirstLoad;
- // banner
- @property (nonatomic, strong) TYPageControl *pageControl;
- @property (nonatomic, strong) HomeBannerView *bannerView; // banner container
- @property (nonatomic, strong) TYCyclePagerView *bannerScroll; // 活动
- @property (nonatomic, strong) NSMutableArray *bannerArray; // banner 数据
- @property (nonatomic, assign) CGFloat bannerViewHeight; // banner 高度
- // 按钮
- @property (nonatomic, strong) HomeButtonView *buttonContainer; // button container
- @property (nonatomic, strong) UIScrollView *buttonScrollView;
- @property (nonatomic, strong) NSMutableArray *buttonArray; // button 内容
- @property (nonatomic, assign) NSInteger buttonDotWidth;
- @property (nonatomic, assign) CGFloat buttonViewHeight; // button view 高度
- // 公告
- @property (nonatomic, strong) PublicNoticeView *noticeView;
- @property (nonatomic, strong) SDCycleScrollView *noticeScrollView;
- @property (nonatomic, strong) NSMutableArray *noticeArray; // notice数据
- @property (nonatomic, strong) NSMutableArray *noticeTitleArray; // 标题数组
- @property (nonatomic, assign) CGFloat noticeViewHeight;
- // 最近课程
- @property (nonatomic, strong) HomeRecentCourseView *courseView;
- @property (nonatomic, assign) CGFloat courseViewHeight;
- @property (nonatomic, strong) RecentCourseModel *recentCourseModel;
- // 热门专辑
- @property (nonatomic, strong) HomeHotAlbumView *albumView;
- @property (nonatomic, strong) NSMutableArray *albumArray;
- @property (nonatomic, strong) UICollectionView *albumCollectionView; // 专辑容器
- @property (nonatomic, assign) CGFloat albumViewHeight; // album 高度
- // 热门曲谱
- @property (nonatomic, strong) HomeHotMusicView *hotMusicView;
- @property (nonatomic, strong) UICollectionView *musicCollectionView; // 曲谱容器
- @property (nonatomic, strong) NSMutableArray *musicArray; // 曲谱数据
- @property (nonatomic, assign) CGFloat musicViewHeight; // music 高度
- // 推荐达人
- @property (nonatomic, strong) HomeHotTalentView *talentView;
- @property (nonatomic, strong) UICollectionView *talentCollectionView; // 推荐达人容器
- @property (nonatomic, strong) NSMutableArray *talentArray; // 推荐达人数据
- @property (nonatomic, assign) CGFloat talentViewHeight; // talent 高度
- // 视频课
- @property (nonatomic, strong) HomeHotVideoCourseView *videoCourseView;
- @property (nonatomic, strong) UICollectionView *videoCollectionView; // 视频课容器
- @property (nonatomic, strong) NSMutableArray *videoCourseArray; // 视频课数据
- @property (nonatomic, assign) CGFloat videoViewHeight; // video 高度
- // 直播课
- @property (nonatomic, strong) HomeHotLiveCourseView *liveCourseView;
- @property (nonatomic, strong) UICollectionView *liveCollectionView; // 直播课容器
- @property (nonatomic, strong) NSMutableArray *liveCourseArray; // 直播课数据
- @property (nonatomic, assign) CGFloat liveViewHeight; // live 高度
- @property (nonatomic, strong) dispatch_group_t requestGroup;
- // 顶部数据容器
- @property (nonatomic, strong) UIView *headView;
- @property (nonatomic, strong) JXCategoryTitleView *myCategoryView;
- @property (nonatomic, assign) NSInteger currentIndex;
- @property (nonatomic, strong) NSMutableArray *listViewArray;
- @property (nonatomic, assign) CGFloat headViewHeight;
- @property (nonatomic, strong) NSMutableArray *teacherArray;
- @property (nonatomic, strong) NSMutableArray *liveListArray;
- @property (nonatomic, strong) NSMutableArray *informationArray;
- @property (nonatomic, strong) UIView *headBgView;
- @end
- @implementation NewHomeViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- _titles = @[@"达人风采",@"热门资讯"];
- self.isFirstLoad = YES;
- [self configNavView];
- [self configUI];
- }
- - (void)requestTrackAuth {
-
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
- [appDelegate appTrackActionAuth];
- }
- - (void)configNavView {
- [self.scrollView removeFromSuperview];
- [self.view addSubview:self.navView];
- [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.mas_equalTo(self.view);
- make.height.mas_equalTo(kNaviBarHeight);
- }];
- [self.view bringSubviewToFront:self.navView];
- }
- - (void)configHeadView {
- [self.headView addSubview:self.headBgView];
-
- // banner
- [self.headView addSubview:self.bannerView];
- self.bannerViewHeight = [HomeBannerView getViewHeight];
- [self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.mas_equalTo(self.headView);
- make.height.mas_equalTo(self.bannerViewHeight);
- }];
-
- // 按钮
- [self.headView addSubview:self.buttonContainer];
- self.buttonViewHeight = CGFLOAT_MIN;
- [self.buttonContainer mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.bannerView.mas_bottom);
- make.height.mas_equalTo(CGFLOAT_MIN);
- }];
- self.buttonContainer.hidden = YES;
-
- // 公告
- [self.headView addSubview:self.noticeView];
- self.noticeViewHeight = CGFLOAT_MIN;
- [self.noticeView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.buttonContainer.mas_bottom);
- make.height.mas_equalTo(CGFLOAT_MIN);
- }];
- [self.noticeView.adView addSubview:self.noticeScrollView];
- [self.noticeScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.bottom.mas_equalTo(self.noticeView.adView);
- }];
- self.noticeView.hidden = YES;
-
- // 最近课程
- [self.headView addSubview:self.courseView];
- self.courseViewHeight = CGFLOAT_MIN;
- [self.courseView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.noticeView.mas_bottom);
- make.height.mas_equalTo(CGFLOAT_MIN);
- }];
- self.courseView.hidden = YES;
-
- // 热门专辑
- [self.headView addSubview:self.albumView];
- self.albumViewHeight = [HomeHotAlbumView getViewHeight];
- [self.albumView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.courseView.mas_bottom);
- make.height.mas_equalTo(self.albumViewHeight);
- }];
-
- // 热门曲目
- [self.headView addSubview:self.hotMusicView];
- self.musicViewHeight = [HomeHotMusicView getViewHeight];
- [self.hotMusicView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.albumView.mas_bottom);
- make.height.mas_equalTo(self.musicViewHeight);
- }];
-
- // 推荐达人
- [self.headView addSubview:self.talentView];
- self.talentViewHeight = CGFLOAT_MIN;
- [self.talentView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.hotMusicView.mas_bottom);
- make.height.mas_equalTo(self.talentViewHeight);
- }];
- self.talentView.hidden = YES;
-
- // 视频课
- [self.headView addSubview:self.videoCourseView];
- self.videoViewHeight = CGFLOAT_MIN;
- [self.videoCourseView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.talentView.mas_bottom);
- make.height.mas_equalTo(self.videoViewHeight);
- }];
- self.videoCourseView.hidden = YES;
- // 直播
- [self.headView addSubview:self.liveCourseView];
- self.liveViewHeight = CGFLOAT_MIN;
- [self.liveCourseView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.videoCourseView.mas_bottom);
- make.height.mas_equalTo(self.liveViewHeight);
- }];
- self.liveCourseView.hidden = YES;
-
- [self.headBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.bannerView.mas_top);
- make.bottom.mas_equalTo(self.buttonContainer.mas_bottom);
- }];
-
- self.headBgView.layer.masksToBounds = YES;
- self.headBgView.layer.cornerRadius = 18.0f;
- self.headBgView.layer.maskedCorners = kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner;
-
- [self refreshHeadHeight];
- }
- - (void)refreshHeadHeight {
- CGFloat bottomSpace = 20.0f;
- self.headViewHeight = self.bannerViewHeight + self.buttonViewHeight + self.noticeViewHeight + self.courseViewHeight + self.albumViewHeight + self.musicViewHeight + self.talentViewHeight + self.liveViewHeight + self.videoViewHeight + bottomSpace;
- [self.pagerView reloadData];
- }
- - (void)configUI {
- [self configHeadView];
-
- _categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, kNaviBarHeight, kScreenWidth, 44)];
- self.categoryView.backgroundColor = [UIColor clearColor];
- self.categoryView.titles = self.titles;
- self.categoryView.delegate = self;
- self.categoryView.titleFont = [UIFont systemFontOfSize:18.0f weight:UIFontWeightMedium];
- self.categoryView.titleSelectedFont = [UIFont systemFontOfSize:18.0f weight:UIFontWeightMedium];
- self.categoryView.titleSelectedColor = HexRGB(0x333333);
- self.categoryView.titleColor = HexRGB(0x999999);
- self.categoryView.titleColorGradientEnabled = YES;
- self.categoryView.cellWidth = 90.0f;
- self.categoryView.cellSpacing = 16.0f;
- self.categoryView.averageCellSpacingEnabled = NO;
- JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
- lineView.verticalMargin = 10;
- lineView.indicatorColor = THEMECOLOR;
- lineView.indicatorWidth = 63.0f;
- lineView.indicatorHeight = 12.0f;
- self.categoryView.indicators = @[lineView];
-
- _pagerView = [self preferredPagingView];
- self.pagerView.frame = CGRectMake(0, kNaviBarHeight, kScreenWidth, kScreenHeight - kNaviBarHeight - kTabBarHeight);
- self.pagerView.mainTableView.gestureDelegate = self;
- [self.view addSubview:self.pagerView];
- self.pagerView.backgroundColor = [UIColor clearColor];
- self.pagerView.mainTableView.backgroundColor = [UIColor clearColor];
- self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
- // 头部刷新
- MJWeakSelf;
- self.pagerView.mainTableView.mj_header = [KSGifRefreshHeader headerWithRefreshingBlock:^{
- [weakSelf requestData];
- }];
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
- }
- - (JXPagerView *)preferredPagingView {
- return [[JXPagerView alloc] initWithDelegate:self];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- if (self.isFirstLoad == YES) {
- [self requestUserInfo:YES]; // 获取声部
- [self requestTrackAuth];
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
- [appDelegate handleNotiferSource];
- }
- else {
- [self requestUserInfo:YES];
- }
- [self requestUnreadCount];
-
- }
- - (void)requestUnreadCount {
- [KSNetworkingManager queryCountOfUnreadRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *countArray = [dic arrayValueForKey:@"data"];
- NSInteger courseCount = 0;
- NSInteger sysCount = 0;
- for (NSDictionary *parm in countArray) {
- if ([[parm stringValueForKey:@"key"] isEqualToString:@"COURSE"]) {
- courseCount = [parm integerValueForKey:@"value"];
- }
- if ([[parm stringValueForKey:@"key"] isEqualToString:@"SYSTEM"]) {
- sysCount = [parm integerValueForKey:@"value"];
- }
- }
- if (courseCount != 0 || sysCount != 0) {
- self.navView.dotView.hidden = NO;
- }
- else {
- self.navView.dotView.hidden = YES;
- }
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)requestUserInfo:(BOOL)checkSubject {
- self.isFirstLoad = NO;
- [KSNetworkingManager queryStudentInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- self.mineInfo = [[StudentInfoModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
- NSString *rongToken = UserDefault(RongTokenKey);
- if ([NSString isEmptyString:rongToken]) {
- [USER_MANAGER queryUserInfoConnectRongCloud:YES];
- }
- [self refreshSource:checkSubject];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)refreshSource:(BOOL)checkSubject {
- if (checkSubject) {
- if ([NSString isEmptyString:self.mineInfo.subjectName]) {
- [self showInstrumentView:YES];
- }
- else {
- [self requestData];
- }
- }
- }
- - (void)showInstrumentView:(BOOL)hideBackButton {
- InstrumentChooseViewController *ctrl = [[InstrumentChooseViewController alloc] init];
- MJWeakSelf;
- [ctrl chooseCallback:^{
- [weakSelf requestUserInfo:NO];
- [weakSelf requestData];
- }];
- if (hideBackButton) {
- ctrl.isModalPresent = YES;
- CustomNavViewController *navCrtl = [[CustomNavViewController alloc] initWithRootViewController:ctrl];
- navCrtl.modalPresentationStyle = UIModalPresentationFullScreen;
- [self.navigationController presentViewController:navCrtl animated:YES completion:nil];
- }
- else {
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- }
- - (void)requestNewsList {
- dispatch_group_enter(self.requestGroup);
- [KSNetworkingManager homeNewsList:KS_POST version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
- dispatch_group_leave(self.requestGroup);
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSDictionary *result = [dic dictionaryValueForKey:@"data"];
- // banner
- NSArray *bannerArray = [result arrayValueForKey:@"banner"];
- NSMutableArray *bannerInfoArray = [NSMutableArray array];
- for (NSDictionary *parm in bannerArray) {
- HomeMessageModel *model = [[HomeMessageModel alloc] initWithDictionary:parm];
- [bannerInfoArray addObject:model];
- }
- self.bannerArray = [NSMutableArray arrayWithArray:bannerInfoArray];
-
- // button
- NSArray *buttonArray = [result arrayValueForKey:@"appMenu"];
- NSMutableArray *buttonInfoArray = [NSMutableArray array];
- for (NSDictionary *parm in buttonArray) {
- HomeMessageModel *model = [[HomeMessageModel alloc] initWithDictionary:parm];
- [buttonInfoArray addObject:model];
- }
- self.buttonArray = [NSMutableArray arrayWithArray:buttonInfoArray];
-
- // news
- NSArray *flashArray = [result arrayValueForKey:@"flashPage"];
- if (flashArray.count) {
- self.flashModel = [[HomeMessageModel alloc] initWithDictionary:[flashArray firstObject]];
- }
-
- // information
- NSArray *information = [result arrayValueForKey:@"information"];
- NSMutableArray *informationInfoArray = [NSMutableArray array];
- for (NSDictionary *parm in information) {
- HomeMessageModel *model = [[HomeMessageModel alloc] initWithDictionary:parm];
- [informationInfoArray addObject:model];
- }
- self.informationArray = [NSMutableArray arrayWithArray:informationInfoArray];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- dispatch_group_leave(self.requestGroup);
- }];
- }
- - (void)requestHotAlbum {
- dispatch_group_enter(self.requestGroup);
- [KSNetworkingManager HomeHotAlbumRequest:KS_POST page:1 rows:10 version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
- dispatch_group_leave(self.requestGroup);
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
- NSMutableArray *albumArray = [NSMutableArray array];
- for (NSDictionary *parm in sourceArray) {
- HomeAlbumModel *model = [[HomeAlbumModel alloc] initWithDictionary:parm];
- [albumArray addObject:model];
- }
- self.albumArray = [NSMutableArray arrayWithArray:albumArray];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
-
- } faliure:^(NSError * _Nonnull error) {
- dispatch_group_leave(self.requestGroup);
- }];
- }
- - (void)requestCourseInfo {
-
- dispatch_group_enter(self.requestGroup);
- [KSNetworkingManager homeQueryLiveAndVideo:KS_GET version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
- dispatch_group_leave(self.requestGroup);
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSDictionary *sourceDic = [dic dictionaryValueForKey:@"data"];
- NSArray *liveList = [sourceDic arrayValueForKey:@"liveList"];
- NSMutableArray *liveCourse = [NSMutableArray array];
- for (NSDictionary *parm in liveList) {
- HomeLiveGroupModel *model = [[HomeLiveGroupModel alloc] initWithDictionary:parm];
- [liveCourse addObject:model];
- }
- self.liveCourseArray = [NSMutableArray arrayWithArray:liveCourse];
-
- NSArray *videoList = [sourceDic arrayValueForKey:@"videoList"];
- NSMutableArray *videoCourse = [NSMutableArray array];
- for (NSDictionary *parm in videoList) {
- HomeVideoGroupModel *model = [[HomeVideoGroupModel alloc] initWithDictionary:parm];
- [videoCourse addObject:model];
- }
- self.videoCourseArray = [NSMutableArray arrayWithArray:videoCourse];
-
- // 最近课程
- NSDictionary *parm = [sourceDic dictionaryValueForKey:@"recentCourses"];
- if (parm == nil) {
- self.recentCourseModel = nil;
- }
- else {
- self.recentCourseModel = [[RecentCourseModel alloc] initWithDictionary:parm];
- }
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
-
- } faliure:^(NSError * _Nonnull error) {
- dispatch_group_leave(self.requestGroup);
- }];
- }
- - (void)requestNotice {
- dispatch_group_enter(self.requestGroup);
- [KSNetworkingManager helpCenterContentListRequest:KS_POST success:^(NSDictionary * _Nonnull dic) {
- dispatch_group_leave(self.requestGroup);
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
- if (sourceArray.count) {
- NSDictionary *parm = [sourceArray firstObject];
- NoticeSourceModel *bannerModel = [[NoticeSourceModel alloc] initWithDictionary:parm];
- [self.noticeArray addObject:bannerModel];
- [self.noticeTitleArray addObject:bannerModel.title];
- }
- else {
- self.noticeArray = [NSMutableArray array];
- self.noticeTitleArray = [NSMutableArray array];
- }
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- dispatch_group_leave(self.requestGroup);
- }];
- }
- - (void)requestHotMusic {
- dispatch_group_enter(self.requestGroup);
- [KSNetworkingManager homeMusicListRequest:KS_POST version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
- dispatch_group_leave(self.requestGroup);
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
- NSMutableArray *musicArray = [NSMutableArray array];
- for (NSDictionary *parm in sourceArray) {
- HomeHotMusicModel *model = [[HomeHotMusicModel alloc] initWithDictionary:parm];
- [musicArray addObject:model];
- }
- self.musicArray = [NSMutableArray arrayWithArray:musicArray];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- dispatch_group_leave(self.requestGroup);
- }];
- }
- - (void)requestTalentSource {
- dispatch_group_enter(self.requestGroup);
- [KSNetworkingManager queryHotTeacherListRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- dispatch_group_leave(self.requestGroup);
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [dic arrayValueForKey:@"data"];
- NSMutableArray *talentArray = [NSMutableArray array];
- for (NSDictionary *parm in sourceArray) {
- TalentTeacherModel *model = [[TalentTeacherModel alloc] initWithDictionary:parm];
- [talentArray addObject:model];
- }
- self.talentArray = [NSMutableArray arrayWithArray:talentArray];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- dispatch_group_leave(self.requestGroup);
- }];
- }
- - (void)requestTeacherStyle {
- dispatch_group_enter(self.requestGroup);
- [KSNetworkingManager homeQueryTeacherStyle:KS_POST page:1 rows:10 version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
- dispatch_group_leave(self.requestGroup);
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
- NSMutableArray *styleArray = [NSMutableArray array];
- for (NSDictionary *parm in sourceArray) {
- TeacherStyleModel *model = [[TeacherStyleModel alloc] initWithDictionary:parm];
- [styleArray addObject:model];
- }
- self.teacherArray = [NSMutableArray arrayWithArray:styleArray];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- // 回调
- } faliure:^(NSError * _Nonnull error) {
- dispatch_group_leave(self.requestGroup);
- }];
- }
- - (void)requestLiveList {
- dispatch_group_enter(self.requestGroup);
- [KSNetworkingManager queryTeacherLivingListRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- dispatch_group_leave(self.requestGroup);
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [dic arrayValueForKey:@"data"];
- NSMutableArray *liveListArray = [NSMutableArray array];
- for (NSDictionary *parm in sourceArray) {
- HomeTeacherLiveModel *model = [[HomeTeacherLiveModel alloc] initWithDictionary:parm];
- [liveListArray addObject:model];
- }
- self.liveListArray = [NSMutableArray arrayWithArray:liveListArray];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- dispatch_group_leave(self.requestGroup);
- }];
- }
- - (void)requestData {
- [self showhud];
- [self requestNewsList];
- [self requestNotice];
- [self requestCourseInfo];
- // 达人
- [self requestTalentSource];
- [self requestHotAlbum];
- [self requestHotMusic];
-
- [self requestTeacherStyle];
- [self requestLiveList];
- dispatch_group_notify(self.requestGroup, dispatch_get_main_queue(), ^{
- [self removehub];
- [self.pagerView.mainTableView.mj_header endRefreshing];
- [self refreshView];
- });
- }
- - (void)refreshView {
- [self refreshBannaerView];
- [self showButtonMessage];
- [self refreshNotice];
- [self refreshCourseView:self.recentCourseModel];
-
- [self refreshAlbumView];
- [self refreshMusicView];
- // 达人
- [self refreshTalentView];
- // 课程
- [self refreshCourseView];
-
- // 刷新排序
- [self refreshViewLocation];
- [self refreshHeadHeight];
-
- [self refreshPageView];
- }
- - (void)refreshPageView {
- for (NSInteger i = 0; i < self.listViewArray.count; i++) {
- id view = self.listViewArray[i];
- if ([view isKindOfClass:[HomePageBodyView class]]) {
- HomePageBodyView *styleView = (HomePageBodyView *)view;
- styleView.styleArray = [self.teacherArray mutableCopy];
- styleView.liveArray = [self.liveListArray mutableCopy];
- [styleView beginFirstRefresh];
- }
- else if ([view isKindOfClass:[HomeInformationBodyView class]]) {
- HomeInformationBodyView *informationView = (HomeInformationBodyView *)view;
- informationView.informationArray = [self.informationArray mutableCopy];
- [informationView beginFirstRefresh];
- }
- }
- }
- - (void)refreshTalentView {
- if (self.talentArray.count) {
- self.talentViewHeight = [HomeHotTalentView getViewHeight];
- self.talentView.hidden = NO;
- }
- else {
- self.talentViewHeight = CGFLOAT_MIN;
- self.talentView.hidden = YES;
- }
- [self.talentView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(self.talentViewHeight);
- }];
- [self.talentCollectionView reloadData];
- }
- - (void)refreshViewLocation {
- // 如果有课程和公告 且有按钮
- CGFloat buttonViewDefaultHeight = self.buttonArray.count > 5 ? [HomeButtonView getViewHeight] : [HomeButtonView getViewHeight] - 20;
-
- if (self.noticeTitleArray.count && self.recentCourseModel && self.buttonArray.count) {
- self.noticeViewHeight = [PublicNoticeView getViewHeight];
- [self.noticeView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.bannerView.mas_bottom);
- make.height.mas_equalTo(self.noticeViewHeight);
- }];
- self.buttonViewHeight = buttonViewDefaultHeight;
- [self.buttonContainer mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.noticeView.mas_bottom);
- make.height.mas_equalTo(self.buttonViewHeight);
- }];
- self.courseViewHeight = 91.0f;
- [self.courseView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.buttonContainer.mas_bottom);
- make.height.mas_equalTo(self.courseViewHeight);
- }];
-
- [self.headBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.bannerView.mas_top);
- make.bottom.mas_equalTo(self.buttonContainer.mas_bottom);
- }];
- }
- else {
- self.buttonViewHeight = self.buttonArray.count ? buttonViewDefaultHeight : CGFLOAT_MIN;
- [self.buttonContainer mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.bannerView.mas_bottom);
- make.height.mas_equalTo(self.buttonViewHeight);
- }];
- self.noticeViewHeight = self.noticeTitleArray.count ? [PublicNoticeView getViewHeight] : CGFLOAT_MIN;
- [self.noticeView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.buttonContainer.mas_bottom);
- make.height.mas_equalTo(self.noticeViewHeight);
- }];
-
- [self.headBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.bannerView.mas_top);
- make.bottom.mas_equalTo(self.noticeView.mas_bottom);
- }];
-
- CGFloat courseViewHeight = self.recentCourseModel ? 90.0f : CGFLOAT_MIN;
- self.courseViewHeight = courseViewHeight;
- [self.courseView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.top.mas_equalTo(self.noticeView.mas_bottom);
- make.height.mas_equalTo(self.courseViewHeight);
- }];
-
- }
- }
- - (void)refreshBannaerView {
- if (self.bannerArray.count > 1) {
- self.bannerScroll.autoScrollInterval = 3.0f;
- [self.bannerScroll addSubview:self.pageControl];
- }
- else {
- self.bannerScroll.autoScrollInterval = 0;
- [self.pageControl removeFromSuperview];
- }
- _pageControl.numberOfPages = self.bannerArray.count;
- [self.bannerScroll reloadData];
- }
- - (void)showButtonMessage {
-
- // 添加按钮
- if (self.buttonArray.count) {
- self.buttonContainer.hidden = NO;
- if (self.buttonArray.count > 5) { // 大于4个显示底部滚动视图
- self.buttonContainer.buttonPageCtrl.hidden = NO;
- self.buttonContainer.buttonDotLeft.constant = 0;
- NSInteger addPage = (self.buttonArray.count % 5) > 0 ? 1 : 0;
- NSInteger pageCount = self.buttonArray.count / 5 + addPage;
- self.buttonDotWidth = 36 / pageCount;
- self.buttonContainer.buttonDotWidth.constant = self.buttonDotWidth;
- self.buttonScrollView.contentSize = CGSizeMake(kScreenWidth * pageCount, BUTTONHEIGHT);
- }
- else {
- self.buttonContainer.buttonPageCtrl.hidden = YES;
- self.buttonScrollView.contentSize = CGSizeMake(kScreenWidth, BUTTONHEIGHT);
- }
- }
- else {
- self.buttonContainer.hidden = YES;
- self.buttonContainer.buttonPageCtrl.hidden = YES;
- self.buttonScrollView.contentSize = CGSizeMake(kScreenWidth, CGFLOAT_MIN);
- }
-
-
- self.buttonScrollView.contentOffset = CGPointMake(0, 0);
- [self.buttonScrollView removeAllSubViews];
- CGFloat buttonSpace = (kScreenWidth - 5 * BUTTONWIDTH) / 6;
- for (NSInteger i = 0; i < self.buttonArray.count; i++) {
- HomeMessageModel *model = self.buttonArray[i];
- KSHomeButton *buttonView = [KSHomeButton shareInstance];
-
- [buttonView.buttonImage sd_setImageWithURL:[NSURL URLWithString:[model.coverImage getUrlEndcodeString]]];
- buttonView.buttonTitle.text = model.title;
- buttonView.frame = CGRectMake(buttonSpace + (i % 5) * (BUTTONWIDTH + buttonSpace) + (i / 5) * KPortraitWidth, 0, BUTTONWIDTH, BUTTONHEIGHT);
- buttonView.actionButton.tag = 3000 + i;
- [buttonView.actionButton addTarget:self action:@selector(HomeTopButtonAction:) forControlEvents:UIControlEventTouchUpInside];
- [self.buttonScrollView addSubview:buttonView];
- }
- }
- - (void)HomeTopButtonAction:(UIButton *)sender {
- NSInteger index = sender.tag - 3000;
- if ([self checkIsLoginToLoginView:YES]) {
- HomeMessageModel *model = self.buttonArray[index];
- if (![NSString isEmptyString:model.linkUrl]) {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = model.linkUrl;
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- }
- }
- - (void)refreshNotice {
- if (self.noticeTitleArray.count) {
- self.noticeView.hidden = NO;
- }
- else {
- self.noticeView.hidden = YES;
- }
- self.noticeScrollView.titlesGroup = self.noticeTitleArray;
- }
- - (void)refreshCourseView:(RecentCourseModel *)model {
- if (model) {
- [self.courseView configCourseMessage:model];
- self.courseView.hidden = NO;
- }
- else {
- self.courseView.hidden = YES;
- }
- }
- - (void)refreshAlbumView {
- if (self.albumArray.count) {
- self.albumViewHeight = [HomeHotAlbumView getViewHeight];
- self.albumView.hidden = NO;
- }
- else {
- self.albumViewHeight = CGFLOAT_MIN;
- self.albumView.hidden = YES;
- }
- [self.albumView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(self.albumViewHeight);
- }];
- [self.albumCollectionView reloadData];
- }
- - (void)refreshMusicView {
- [self.musicCollectionView reloadData];
- }
- - (void)refreshCourseView {
- // 课程
- if (self.liveCourseArray.count) {
- self.liveViewHeight = [HomeHotLiveCourseView getViewHeight];
- self.liveCourseView.hidden = NO;
- }
- else {
- self.liveViewHeight = CGFLOAT_MIN;
- self.liveCourseView.hidden = YES;
- }
- [self.liveCourseView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(self.liveViewHeight);
- }];
- if (self.videoCourseArray.count) {
- self.videoViewHeight = [HomeHotVideoCourseView getViewHeight];
- self.videoCourseView.hidden = NO;
- }
- else {
- self.videoViewHeight = CGFLOAT_MIN;
- self.videoCourseView.hidden = YES;
- }
- [self.videoCourseView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(self.videoViewHeight);
- }];
-
- [self.videoCollectionView reloadData];
- [self.liveCollectionView reloadData];
- }
- #pragma mark - JXPagerViewDelegate
- - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
- return self.headView;
- }
- - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
- return self.headViewHeight;
- }
- - (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
- return self.categoryView;
- }
- - (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
- return 44;
- }
- - (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
- //和categoryView的item数量一致
- return self.titles.count;
- }
- - (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
- if (index == 0) {
- HomePageBodyView *listView = [[HomePageBodyView alloc] init];
- listView.naviController = self.navigationController;
- [self.listViewArray replaceObjectAtIndex:index withObject:listView];
- self.listViewArray[index] = listView;
- listView.selectIndex = index;
- listView.styleArray = [self.teacherArray mutableCopy];
- listView.liveArray = [self.liveListArray mutableCopy];
- [listView beginFirstRefresh];
- return listView;
- }
- else {
- HomeInformationBodyView *listView = [[HomeInformationBodyView alloc] init];
- listView.naviController = self.navigationController;
- [self.listViewArray replaceObjectAtIndex:index withObject:listView];
- self.listViewArray[index] = listView;
- listView.selectIndex = index;
- listView.informationArray = [self.informationArray mutableCopy];
- [listView beginFirstRefresh];
- return listView;
- }
- }
- #pragma mark - JXCategoryViewDelegate
- - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
- self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
- if (self.listViewArray.count > index) {
- id value = self.listViewArray[index];
- if ([value isKindOfClass:[KSJXBodyView class]]) {
- KSJXBodyView *listView = (KSJXBodyView *)value;
- [listView beginFirstRefresh];
- }
- else if ([value isKindOfClass:[kSJXCollectionView class]]) {
- kSJXCollectionView *listView = (kSJXCollectionView *)value;
- [listView beginFirstRefresh];
- }
- }
- }
- #pragma mark - JXPagerMainTableViewGestureDelegate
- - (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
- //禁止categoryView左右滑动的时候,上下和左右都可以滚动
- if (otherGestureRecognizer == self.categoryView.collectionView.panGestureRecognizer) {
- return NO;
- }
- return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
- }
- - (void)pagerView:(JXPagerView *)pagerView mainTableViewDidScroll:(UIScrollView *)scrollView {
- NSLog(@"sscroll content offset y %f", scrollView.contentOffset.y);
- CGFloat height = self.headViewHeight;
- CGFloat space = scrollView.contentOffset.y;
- if (space > 0) {
- self.navView.lineView.hidden = NO;
- }
- else {
- self.navView.lineView.hidden = YES;
- }
- if (space >= height) {
- self.categoryView.backgroundColor = [UIColor whiteColor];
- }
- else {
- self.categoryView.backgroundColor = [UIColor clearColor];
- }
- }
- #pragma mark - TYCyclePagerViewDataSource代理
- - (NSInteger)numberOfItemsInPagerView:(TYCyclePagerView *)pageView {
- return self.bannerArray.count;
- }
- - (UICollectionViewCell *)pagerView:(TYCyclePagerView *)pagerView cellForItemAtIndex:(NSInteger)index {
- HomeMessageModel *model = self.bannerArray[index];
- HomeBannerCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"HomeBannerCell" forIndex:index];
- [cell configCellWithModel:model];
- return cell;
- }
- - (TYCyclePagerViewLayout *)layoutForPagerView:(TYCyclePagerView *)pageView {
- TYCyclePagerViewLayout *layout = [[TYCyclePagerViewLayout alloc]init];
- layout.itemSize = CGSizeMake(kScreenWidth - 28, (kScreenWidth - 28) / 347 * 132);
- layout.itemSpacing = 0;
- return layout;
-
- }
- - (void)pagerView:(TYCyclePagerView *)pageView didScrollFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex {
- if (pageView == self.bannerScroll) {
- [self.pageControl setCurrentPage:toIndex animate:YES];
- }
- }
- - (void)pagerView:(TYCyclePagerView *)pageView didSelectedItemCell:(__kindof UICollectionViewCell *)cell atIndex:(NSInteger)index {
-
- HomeMessageModel *model = self.bannerArray[index];
- if (![NSString isEmptyString:model.linkUrl]) {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = model.linkUrl;
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- }
- #pragma mark ---- collection data source
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- if (collectionView == self.albumCollectionView) { // 专辑
- return self.albumArray.count;
- }
- else if (collectionView == self.musicCollectionView) { // 乐谱
- NSInteger lastRowCount = (self.musicArray.count % 3) > 0 ? 1 : 0;
- NSInteger count = self.musicArray.count / 3 + lastRowCount;
- return count;
- }
- else if (collectionView == self.talentCollectionView) { // 推荐达人
- return self.talentArray.count;
- }
- else if (collectionView == self.videoCollectionView) { // 视频课
- return self.videoCourseArray.count;
- }
- else { // 直播课
- return self.liveCourseArray.count;
- }
- }
- - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- if (collectionView == self.albumCollectionView) {
- HomeAlbumModel *model = self.albumArray[indexPath.item];
- HomeHotAlbumCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotAlbumCell" forIndexPath:indexPath];
- [cell configWithAlbumModel:model];
- return cell;
- }
- else if (collectionView == self.musicCollectionView) {
- NSMutableArray *songArray = [NSMutableArray array];
- NSInteger length = indexPath.item * 3 + 3 > self.musicArray.count ? self.musicArray.count - indexPath.item * 3: 3;
- NSRange range = NSMakeRange(indexPath.item * 3, length);
-
- songArray = [NSMutableArray arrayWithArray:[self.musicArray subarrayWithRange:range]];
- HomeHotMusicCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotMusicCollectionCell" forIndexPath:indexPath];
- MJWeakSelf;
- [cell configWithSourceArray:songArray callback:^(NSString * _Nonnull songId) {
- [weakSelf displaySongDetail:songId];
- }];
- return cell;
- }
- else if (collectionView == self.talentCollectionView) {
- TalentTeacherModel *talentModel = self.talentArray[indexPath.item];
- HomeHotTalentCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotTalentCell" forIndexPath:indexPath];
- [cell configWithSource:talentModel];
- return cell;
- }
- else if (collectionView == self.videoCollectionView) {
- HomeVideoGroupModel *model = self.videoCourseArray[indexPath.item];
- HomeHotVideoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotVideoCell" forIndexPath:indexPath];
- [cell configWithSource:model];
- return cell;
- }
- else {
- HomeLiveGroupModel *model = self.liveCourseArray[indexPath.item];
- HomeHotLiveCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotLiveCell" forIndexPath:indexPath];
- [cell configWithSource:model];
- return cell;
- }
- }
- - (void)displaySongDetail:(NSString *)songId {
- // 检测权限
- PREMISSIONTYPE micEnable = [RecordCheckManager checkPermissionShowAlert:NO showInView:nil];
- PREMISSIONTYPE cameraEnable = [RecordCheckManager checkCameraPremissionAvaiable:NO showInView:nil];
- if (micEnable == PREMISSIONTYPE_YES && cameraEnable == PREMISSIONTYPE_YES) { // 如果麦克风和摄像头权限都有
- // 跳转到播放页面
- KSAccompanyWebViewController *detailCtrl = [[KSAccompanyWebViewController alloc] init];
- detailCtrl.url = [NSString stringWithFormat:@"%@/accompany?id=%@",hostURL, songId];
- detailCtrl.hiddenNavBar = YES;
- detailCtrl.parmDic = @{@"isOpenLight" : @(YES), @"orientation" : @(0),@"isHideTitle" : @(YES)};
- [self.navigationController pushViewController:detailCtrl animated:YES];
- }
- else {
- if (micEnable == PREMISSIONTYPE_NO && cameraEnable == PREMISSIONTYPE_NO) { // 如果麦克风权限和摄像头权限都没有
- [self showAlertWithMessage:@"请开启相机和麦克风访问权限" type:CHECKDEVICETYPE_BOTH];
- }
- else if (micEnable == PREMISSIONTYPE_NO) { // 如果没有麦克风权限
- [self showAlertWithMessage:@"请开启麦克风访问权限" type:CHECKDEVICETYPE_MIC];
- }
- else if (cameraEnable == PREMISSIONTYPE_NO) { // 如果没有摄像头权限
- [self showAlertWithMessage:@"请开启相机访问权限" type:CHECKDEVICETYPE_CAMREA];
- }
- }
- }
- - (void)showAlertWithMessage:(NSString *)message type:(CHECKDEVICETYPE)deviceType {
- [KSPremissionAlert shareInstanceDisplayImage:deviceType message:message showInView:self.view cancel:^{
-
- } confirm:^{
- [self openSettingView];
- }];
-
- }
- - (void)openSettingView {
- if (@available(iOS 10, *)) {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
- } else {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
- }
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- if (collectionView == self.albumCollectionView) { // 专辑详情
- HomeAlbumModel *model = self.albumArray[indexPath.item];
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/music-album-detail/",model.internalBaseClassIdentifier];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- else if (collectionView == self.talentCollectionView) { // 达人风采
- TalentTeacherModel *model = self.talentArray[indexPath.item];
- [self displayTeacherDetail:[NSString stringWithFormat:@"%.0f",model.userId]];
- }
- else if (collectionView == self.videoCollectionView) { // 视频课
- HomeVideoGroupModel *model = self.videoCourseArray[indexPath.row];
- NSString *url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/videoDetail?groupId=",model.videoGroupId];
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = url;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- else if (collectionView == self.liveCollectionView) { // 直播课详情
- HomeLiveGroupModel *model = self.liveCourseArray[indexPath.row];
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- NSString *url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/liveDetail?groupId=",model.courseGroupId];
- ctrl.url = url;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- }
- // 老师风采
- - (void)displayTeacherDetail:(NSString *)teacherId {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/teacherHome?teacherId=",teacherId];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
- if (collectionView == self.albumCollectionView) {
- return CGSizeMake(100, 134);
- }
- else if (collectionView == self.musicCollectionView) {
- return CGSizeMake(KPortraitWidth * 0.83, 240);
- }
- else if (collectionView == self.talentCollectionView) {
- return CGSizeMake(110, 150);
- }
- else if (collectionView == self.videoCollectionView) {
- return CGSizeMake((KPortraitWidth - 28 - 11) / 2.0f, 157);
- }
- else {
- return CGSizeMake((KPortraitWidth - 28 - 11) / 2.0f, 157);
- }
- }
- #pragma mark ----- SDCycleScrollViewDelegate
- - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
- NoticeSourceModel *noticeModel = self.noticeArray[index];
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@/#/helpCenterDetail?id=%@",WEBHOST, noticeModel.internalBaseClassIdentifier];
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- #pragma mark ------- lazying
- - (HomeNavSearchView *)navView {
- if (!_navView) {
- _navView = [HomeNavSearchView shareInstance];
- MJWeakSelf;
- [_navView homeNavSearchAction:^(HOMENAV_TAG action) {
- [weakSelf homeNavAction:action];
- }];
- }
- return _navView;
- }
- - (void)homeNavAction:(HOMENAV_TAG)action {
- switch (action) {
- case HOMENAV_TAG_SCAN: // 扫一扫
- {
- [self showScanView];
- }
- break;
- case HOMENAV_TAG_MESSAGE: // 消息
- {
- NotiferMessageViewController *ctrl = [[NotiferMessageViewController alloc] init];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- break;
- case HOMENAV_TAG_SEARCH: // 搜索
- {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@/#/music-songbook/search", WEBHOST];
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- break;
- default:
- break;
- }
- }
- - (void)showScanView {
- // 判断是否有权限
- PREMISSIONTYPE albumEnable = [RecordCheckManager checkCameraPremissionAvaiable:NO showInView:nil];
- if (albumEnable == PREMISSIONTYPE_YES) { // 如果有权限
- KSScanViewController *ctrl = [[KSScanViewController alloc] init];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- else {
- if (albumEnable == PREMISSIONTYPE_NO) {
- [self showAlertWithMessage:@"请开启相机访问权限" type:CHECKDEVICETYPE_CAMREA];
- }
- }
- }
- - (dispatch_group_t)requestGroup {
- if (!_requestGroup) {
- _requestGroup = dispatch_group_create();
- }
- return _requestGroup;
- }
- - (UIView *)headView {
- if (!_headView) {
- _headView = [[UIView alloc] init];
- _headView.backgroundColor = [UIColor clearColor];
- }
- return _headView;
- }
- - (NSMutableArray *)listViewArray {
- if (!_listViewArray) {
- _listViewArray = [NSMutableArray arrayWithArray:@[@"",@""]];
- }
- return _listViewArray;
- }
- - (HomeBannerView *)bannerView {
- if (!_bannerView) {
- _bannerView = [HomeBannerView shareInstance];
- [_bannerView.bannerContentView addSubview:self.bannerScroll];
- }
- return _bannerView;
- }
- #pragma mark --- banner
- - (TYCyclePagerView *)bannerScroll {
- if (!_bannerScroll) {
- _bannerScroll = [[TYCyclePagerView alloc] init];
- _bannerScroll.backgroundColor = [UIColor clearColor];
- _bannerScroll.frame = CGRectMake(0, 0, kScreenWidth - 28, (kScreenWidth - 28) / 347 * 132);
- _bannerScroll.isInfiniteLoop = YES;
- _bannerScroll.autoScrollInterval = 3.0f;
- _bannerScroll.reloadDataNeedResetIndex = YES;
- _bannerScroll.dataSource = self;
- _bannerScroll.delegate = self;
- [_bannerScroll registerNib:[UINib nibWithNibName:@"HomeBannerCell" bundle:nil] forCellWithReuseIdentifier:@"HomeBannerCell"];
- if (@available(iOS 11.0, *)) {
- _bannerScroll.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- // Fallback on earlier versions
- if (@available(iOS 13.0, *)) {
- _bannerScroll.collectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
- } else {
- // Fallback on earlier versions
- }
- }
- }
- return _bannerScroll;
- }
- - (TYPageControl *)pageControl {
- if (!_pageControl) {
- _pageControl = [[TYPageControl alloc] init];
- _pageControl.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
- _pageControl.pageIndicatorSpaing = 4.0f;
- _pageControl.frame = CGRectMake(0, (kScreenWidth - 28) * 132 / 347 - 20, kScreenWidth-28 - 12, 12);
- _pageControl.currentPageIndicatorTintColor = HexRGB(0xffffff);
- _pageControl.pageIndicatorTintColor = HexRGB(0xffffff);
- _pageControl.pageIndicatorSize = CGSizeMake(5, 5);
- _pageControl.currentPageIndicatorSize = CGSizeMake(12, 5);
- }
- return _pageControl;
- }
- - (NSMutableArray *)bannerArray {
- if (!_bannerArray) {
- _bannerArray = [NSMutableArray array];
- }
- return _bannerArray;
- }
- #pragma mark ---- scroll view delegate
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- if (scrollView == self.buttonScrollView) {
- NSInteger index = (NSInteger)(scrollView.contentOffset.x / (KPortraitWidth - 28));
-
- [UIView animateWithDuration:0.3f animations:^{
- self.buttonContainer.buttonDotLeft.constant = index * self.buttonDotWidth;
- }];
- }
- }
- #pragma mark ---- button container
- - (HomeButtonView *)buttonContainer {
- if (!_buttonContainer) {
- _buttonContainer = [HomeButtonView shareInstance];
- [_buttonContainer.buttonContentView addSubview:self.buttonScrollView];
- }
- return _buttonContainer;
- }
- - (UIScrollView *)buttonScrollView {
- if (!_buttonScrollView) {
- _buttonScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, KPortraitWidth, BUTTONHEIGHT)];
- _buttonScrollView.backgroundColor = [UIColor clearColor];
- _buttonScrollView.pagingEnabled = YES;
- _buttonScrollView.showsHorizontalScrollIndicator = NO;
- _buttonScrollView.showsVerticalScrollIndicator = NO;
- _buttonScrollView.delegate = self;
- }
- return _buttonScrollView;
- }
- #pragma mark ---- notice view
- - (UIView *)headBgView {
- if (!_headBgView) {
- _headBgView = [[UIView alloc] init];
- _headBgView.backgroundColor = [UIColor whiteColor];
- }
- return _headBgView;
- }
- - (PublicNoticeView *)noticeView {
- if (!_noticeView) {
- _noticeView = [PublicNoticeView shareInstance];
- MJWeakSelf;
- [_noticeView moreCallback:^{
- [weakSelf moreNotice];
- }];
- }
- return _noticeView;
- }
- - (NSMutableArray *)noticeArray {
- if (!_noticeArray) {
- _noticeArray = [NSMutableArray array];
- }
- return _noticeArray;
- }
- - (NSMutableArray *)noticeTitleArray {
- if (!_noticeTitleArray) {
- _noticeTitleArray = [NSMutableArray array];
- }
- return _noticeTitleArray;
- }
- - (void)moreNotice {
- if (self.noticeArray.count) {
- NoticeSourceModel *bannerModel = self.noticeArray[0];
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@/#/helpCenterDetail?id=%@",WEBHOST, bannerModel.internalBaseClassIdentifier];
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- }
- - (SDCycleScrollView *)noticeScrollView {
- if (!_noticeScrollView) {
- _noticeScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImage new]];
- _noticeScrollView.onlyDisplayText = YES;
- _noticeScrollView.autoScroll = NO;
- _noticeScrollView.scrollEnabled = NO;
- _noticeScrollView.scrollDirection = UICollectionViewScrollDirectionVertical;
- _noticeScrollView.titleLabelTextColor = HexRGB(0x1a1a1a);
- _noticeScrollView.titleLabelBackgroundColor = [UIColor clearColor];
- _noticeScrollView.titleLabelTextFont = [UIFont systemFontOfSize:14];
- _noticeScrollView.titlesGroup = self.noticeTitleArray;
- }
- return _noticeScrollView;
- }
- - (HomeRecentCourseView *)courseView {
- if (!_courseView) {
- _courseView = [HomeRecentCourseView shareInstance];
- MJWeakSelf;
- [_courseView joinRoom:^(RECENTCOURSE_TYPE type, RecentCourseModel * _Nonnull courseModel) {
- [weakSelf joinRoomAction:type courseMessage:courseModel];
- }];
- }
- return _courseView;
- }
- - (void)joinRoomAction:(RECENTCOURSE_TYPE)type courseMessage:(RecentCourseModel *)courseModel {
- if (type == RECENTCOURSE_TYPE_ACCOMPANY) {
- AccompanyDetailViewController *detailVC = [[AccompanyDetailViewController alloc] init];
- detailVC.courseId = courseModel.courseId;
- detailVC.courseGroupId = courseModel.courseGroupId;
- detailVC.teacherId = courseModel.teacherId;
- [self.navigationController pushViewController:detailVC animated:YES];
- }
- else if (type == RECENTCOURSE_TYPE_MUSICCLASS) { // 琴房课
- MusicRoomDetailViewController *detailVC = [[MusicRoomDetailViewController alloc] init];
- detailVC.courseId = courseModel.courseId;
- detailVC.courseGroupId = courseModel.courseGroupId;
- detailVC.teacherId = courseModel.teacherId;
- [self.navigationController pushViewController:detailVC animated:YES];
- }
- else {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- NSString *url = [NSString stringWithFormat:@"%@/#/liveDetail?joinRoom=1&groupId=%@&classId=%@", WEBHOST,courseModel.courseGroupId,courseModel.courseId];
- ctrl.url = url;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- }
- #pragma mark ----- 专辑
- - (HomeHotAlbumView *)albumView {
- if (!_albumView) {
- _albumView = [HomeHotAlbumView shareInstance];
- MJWeakSelf;
- [_albumView homeAlbumMore:^{
- [weakSelf moreAlbumDetail];
- }];
- [_albumView.albumContentView addSubview:self.albumCollectionView];
- [self.albumCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.top.mas_equalTo(_albumView.albumContentView);
- }];
- }
- return _albumView;
- }
- - (UICollectionView *)albumCollectionView {
- if (!_albumCollectionView) {
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
- layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
- _albumCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
- _albumCollectionView.backgroundColor = [UIColor clearColor];
- _albumCollectionView.delegate = self;
- _albumCollectionView.dataSource = self;
- _albumCollectionView.showsVerticalScrollIndicator = NO;
- _albumCollectionView.showsHorizontalScrollIndicator = NO;
- if (@available(iOS 11.0, *)) {
- _albumCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- // Fallback on earlier versions
- if (@available(iOS 13.0, *)) {
- _albumCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
- } else {
- // Fallback on earlier versions
- }
- }
- [_albumCollectionView registerNib:[UINib nibWithNibName:@"HomeHotAlbumCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotAlbumCell"];
- }
- return _albumCollectionView;
- }
- - (void)moreAlbumDetail {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/music-album"];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- #pragma mark ---- 热门曲目
- - (HomeHotMusicView *)hotMusicView {
- if (!_hotMusicView) {
- _hotMusicView = [HomeHotMusicView shareInstance];
- MJWeakSelf;
- [_hotMusicView homeMusicMore:^{
- [weakSelf moreHotMusic];
- }];
- [_hotMusicView.musicContentView addSubview:self.musicCollectionView];
- [self.musicCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.top.mas_equalTo(_hotMusicView.musicContentView);
- }];
- }
- return _hotMusicView;
- }
- - (void)moreHotMusic {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/music-list"];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (UICollectionView *)musicCollectionView {
- if (!_musicCollectionView) {
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
- layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
- _musicCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
- _musicCollectionView.backgroundColor = [UIColor clearColor];
- _musicCollectionView.delegate = self;
- _musicCollectionView.dataSource = self;
- _musicCollectionView.showsVerticalScrollIndicator = NO;
- _musicCollectionView.showsHorizontalScrollIndicator = NO;
- if (@available(iOS 11.0, *)) {
- _musicCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- // Fallback on earlier versions
- if (@available(iOS 13.0, *)) {
- _musicCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
- } else {
- // Fallback on earlier versions
- }
- }
- [_musicCollectionView registerNib:[UINib nibWithNibName:@"HomeHotMusicCollectionCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotMusicCollectionCell"];
- }
- return _musicCollectionView;
- }
- #pragma mark ---- talent view
- - (HomeHotTalentView *)talentView {
- if (!_talentView) {
- _talentView = [HomeHotTalentView shareInstance];
- [_talentView.talentContentView addSubview:self.talentCollectionView];
- MJWeakSelf;
- [_talentView homeTalentMore:^{
- [weakSelf teacherMoreIntorduce];
- }];
- [self.talentCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.top.mas_equalTo(_talentView.talentContentView);
- }];
- }
- return _talentView;
- }
- - (void)teacherMoreIntorduce {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherElegant"];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (UICollectionView *)talentCollectionView {
- if (!_talentCollectionView) {
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
- layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
- _talentCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
- _talentCollectionView.backgroundColor = [UIColor clearColor];
- _talentCollectionView.delegate = self;
- _talentCollectionView.dataSource = self;
- _talentCollectionView.showsVerticalScrollIndicator = NO;
- _talentCollectionView.showsHorizontalScrollIndicator = NO;
- if (@available(iOS 11.0, *)) {
- _talentCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- // Fallback on earlier versions
- if (@available(iOS 13.0, *)) {
- _talentCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
- } else {
- // Fallback on earlier versions
- }
- }
- [_talentCollectionView registerNib:[UINib nibWithNibName:@"HomeHotTalentCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotTalentCell"];
- }
- return _talentCollectionView;
- }
- #pragma mark ----- video course
- - (HomeHotVideoCourseView *)videoCourseView {
- if (!_videoCourseView) {
- _videoCourseView = [HomeHotVideoCourseView shareInstance];
- MJWeakSelf;
- [_videoCourseView homeVideoMore:^{
- [weakSelf toVideoMorePage];
- }];
- [_videoCourseView.videoContentView addSubview:self.videoCollectionView];
- [self.videoCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.top.mas_equalTo(_videoCourseView.videoContentView);
- }];
- }
- return _videoCourseView;
- }
- - (UICollectionView *)videoCollectionView {
- if (!_videoCollectionView) {
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
- layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
- _videoCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
- _videoCollectionView.backgroundColor = [UIColor clearColor];
- _videoCollectionView.delegate = self;
- _videoCollectionView.dataSource = self;
- _videoCollectionView.showsVerticalScrollIndicator = NO;
- _videoCollectionView.showsHorizontalScrollIndicator = NO;
- if (@available(iOS 11.0, *)) {
- _videoCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- // Fallback on earlier versions
- if (@available(iOS 13.0, *)) {
- _videoCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
- } else {
- // Fallback on earlier versions
- }
- }
-
- [_videoCollectionView registerNib:[UINib nibWithNibName:@"HomeHotVideoCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotVideoCell"];
- }
- return _videoCollectionView;
- }
- - (void)toVideoMorePage {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/videoClass"];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- #pragma mark ----- live course
- - (HomeHotLiveCourseView *)liveCourseView {
- if (!_liveCourseView) {
- _liveCourseView = [HomeHotLiveCourseView shareInstance];
- MJWeakSelf;
- [_liveCourseView homeLiveMore:^{
- [weakSelf toLiveMorePage];
- }];
- [_liveCourseView.liveContentView addSubview:self.liveCollectionView];
- [self.liveCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.top.mas_equalTo(_liveCourseView.liveContentView);
- }];
- }
- return _liveCourseView;
- }
- - (UICollectionView *)liveCollectionView {
- if (!_liveCollectionView) {
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
- layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
- _liveCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
- _liveCollectionView.backgroundColor = [UIColor clearColor];
- _liveCollectionView.delegate = self;
- _liveCollectionView.dataSource = self;
- _liveCollectionView.showsVerticalScrollIndicator = NO;
- _liveCollectionView.showsHorizontalScrollIndicator = NO;
- if (@available(iOS 11.0, *)) {
- _liveCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- // Fallback on earlier versions
- if (@available(iOS 13.0, *)) {
- _liveCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
- } else {
- // Fallback on earlier versions
- }
- }
- [_liveCollectionView registerNib:[UINib nibWithNibName:@"HomeHotLiveCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotLiveCell"];
- }
- return _liveCollectionView;
- }
- // 更多直播课
- - (void)toLiveMorePage {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/liveClass"];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (NSMutableArray *)informationArray {
- if (!_informationArray) {
- _informationArray = [NSMutableArray array];
- }
- return _informationArray;
- }
- - (NSMutableArray *)teacherArray {
- if (!_teacherArray) {
- _teacherArray = [NSMutableArray array];
- }
- return _teacherArray;
- }
- - (NSMutableArray *)liveListArray {
- if (!_liveListArray) {
- _liveListArray = [NSMutableArray array];
- }
- return _liveListArray;
- }
- /*
- #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
|