NewHomeViewController.m 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700
  1. //
  2. // NewHomeViewController.m
  3. // KulexiuForStudent
  4. //
  5. // Created by 王智 on 2022/8/29.
  6. //
  7. #import "NewHomeViewController.h"
  8. #import "KSBaseWKWebViewController.h"
  9. #import "InstrumentChooseViewController.h"
  10. #import "NotiferMessageViewController.h"
  11. #import "HomeNavSearchView.h"
  12. #import "KSScanViewController.h"
  13. #import "HomeBannerView.h"
  14. #import <UIButton+WebCache.h>
  15. #import "TYCyclePagerView.h"
  16. #import "TYPageControl.h"
  17. #import "HomeBannerCell.h"
  18. #import "HomeBannerCell.h"
  19. #import "HomeButtonView.h"
  20. #import "KSHomeButton.h"
  21. #import "PublicNoticeView.h"
  22. #import "SDCycleScrollView.h"
  23. #import "NoticeSourceModel.h"
  24. #import "AppDelegate.h"
  25. #import "StudentInfoModel.h"
  26. #import "UserInfoManager.h"
  27. #import "HomeRecentCourseView.h"
  28. #import "AccompanyDetailViewController.h"
  29. #import "MusicRoomDetailViewController.h"
  30. #import "HomeHotAlbumView.h"
  31. #import "HomeAlbumModel.h"
  32. #import "HomeHotAlbumCell.h"
  33. #import "HomeHotMusicView.h"
  34. #import "HomeHotMusicCollectionCell.h"
  35. #import "KSPremissionAlert.h"
  36. #import "RecordCheckManager.h"
  37. #import "KSAccompanyWebViewController.h"
  38. #import "HomeHotTalentView.h"
  39. #import "HomeHotTalentCell.h"
  40. #import "TalentTeacherModel.h"
  41. #import "HomeHotVideoCourseView.h"
  42. #import "HomeHotVideoCell.h"
  43. #import "HomeVideoGroupModel.h"
  44. #import "HomeHotLiveCourseView.h"
  45. #import "HomeHotLiveCell.h"
  46. #import "HomeLiveGroupModel.h"
  47. #import "JXCategoryView.h"
  48. #import "JXPagerListRefreshView.h"
  49. #import "HomePageBodyView.h"
  50. #import "HomeInformationBodyView.h"
  51. #import "TeacherStyleModel.h"
  52. #import "HomeTeacherLiveModel.h"
  53. #define BUTTONWIDTH (65)
  54. #define BUTTONHEIGHT (80)
  55. @interface NewHomeViewController ()<JXPagerViewDelegate, JXPagerMainTableViewGestureDelegate,JXCategoryViewDelegate,SDCycleScrollViewDelegate,UIScrollViewDelegate,UICollectionViewDelegate, UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,TYCyclePagerViewDataSource,TYCyclePagerViewDelegate>
  56. @property (nonatomic, strong) StudentInfoModel *mineInfo;
  57. @property (nonatomic, strong) HomeNavSearchView *navView;
  58. @property (nonatomic, strong) HomeMessageModel *flashModel;
  59. @property (nonatomic, assign) BOOL isFirstLoad;
  60. // banner
  61. @property (nonatomic, strong) TYPageControl *pageControl;
  62. @property (nonatomic, strong) HomeBannerView *bannerView; // banner container
  63. @property (nonatomic, strong) TYCyclePagerView *bannerScroll; // 活动
  64. @property (nonatomic, strong) NSMutableArray *bannerArray; // banner 数据
  65. @property (nonatomic, assign) CGFloat bannerViewHeight; // banner 高度
  66. // 按钮
  67. @property (nonatomic, strong) HomeButtonView *buttonContainer; // button container
  68. @property (nonatomic, strong) UIScrollView *buttonScrollView;
  69. @property (nonatomic, strong) NSMutableArray *buttonArray; // button 内容
  70. @property (nonatomic, assign) NSInteger buttonDotWidth;
  71. @property (nonatomic, assign) CGFloat buttonViewHeight; // button view 高度
  72. // 公告
  73. @property (nonatomic, strong) PublicNoticeView *noticeView;
  74. @property (nonatomic, strong) SDCycleScrollView *noticeScrollView;
  75. @property (nonatomic, strong) NSMutableArray *noticeArray; // notice数据
  76. @property (nonatomic, strong) NSMutableArray *noticeTitleArray; // 标题数组
  77. @property (nonatomic, assign) CGFloat noticeViewHeight;
  78. // 最近课程
  79. @property (nonatomic, strong) HomeRecentCourseView *courseView;
  80. @property (nonatomic, assign) CGFloat courseViewHeight;
  81. @property (nonatomic, strong) RecentCourseModel *recentCourseModel;
  82. // 热门专辑
  83. @property (nonatomic, strong) HomeHotAlbumView *albumView;
  84. @property (nonatomic, strong) NSMutableArray *albumArray;
  85. @property (nonatomic, strong) UICollectionView *albumCollectionView; // 专辑容器
  86. @property (nonatomic, assign) CGFloat albumViewHeight; // album 高度
  87. // 热门曲谱
  88. @property (nonatomic, strong) HomeHotMusicView *hotMusicView;
  89. @property (nonatomic, strong) UICollectionView *musicCollectionView; // 曲谱容器
  90. @property (nonatomic, strong) NSMutableArray *musicArray; // 曲谱数据
  91. @property (nonatomic, assign) CGFloat musicViewHeight; // music 高度
  92. // 推荐达人
  93. @property (nonatomic, strong) HomeHotTalentView *talentView;
  94. @property (nonatomic, strong) UICollectionView *talentCollectionView; // 推荐达人容器
  95. @property (nonatomic, strong) NSMutableArray *talentArray; // 推荐达人数据
  96. @property (nonatomic, assign) CGFloat talentViewHeight; // talent 高度
  97. // 视频课
  98. @property (nonatomic, strong) HomeHotVideoCourseView *videoCourseView;
  99. @property (nonatomic, strong) UICollectionView *videoCollectionView; // 视频课容器
  100. @property (nonatomic, strong) NSMutableArray *videoCourseArray; // 视频课数据
  101. @property (nonatomic, assign) CGFloat videoViewHeight; // video 高度
  102. // 直播课
  103. @property (nonatomic, strong) HomeHotLiveCourseView *liveCourseView;
  104. @property (nonatomic, strong) UICollectionView *liveCollectionView; // 直播课容器
  105. @property (nonatomic, strong) NSMutableArray *liveCourseArray; // 直播课数据
  106. @property (nonatomic, assign) CGFloat liveViewHeight; // live 高度
  107. @property (nonatomic, strong) dispatch_group_t requestGroup;
  108. // 顶部数据容器
  109. @property (nonatomic, strong) UIView *headView;
  110. @property (nonatomic, strong) JXCategoryTitleView *myCategoryView;
  111. @property (nonatomic, assign) NSInteger currentIndex;
  112. @property (nonatomic, strong) NSMutableArray *listViewArray;
  113. @property (nonatomic, assign) CGFloat headViewHeight;
  114. @property (nonatomic, strong) NSMutableArray *teacherArray;
  115. @property (nonatomic, strong) NSMutableArray *liveListArray;
  116. @property (nonatomic, strong) NSMutableArray *informationArray;
  117. @end
  118. @implementation NewHomeViewController
  119. - (void)viewDidLoad {
  120. [super viewDidLoad];
  121. // Do any additional setup after loading the view.
  122. self.ks_prefersNavigationBarHidden = YES;
  123. _titles = @[@"达人风采",@"热门资讯"];
  124. self.isFirstLoad = YES;
  125. [self configNavView];
  126. [self configUI];
  127. }
  128. - (void)requestTrackAuth {
  129. AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  130. [appDelegate appTrackActionAuth];
  131. }
  132. - (void)configNavView {
  133. [self.scrollView removeFromSuperview];
  134. [self.view addSubview:self.navView];
  135. [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
  136. make.left.right.top.mas_equalTo(self.view);
  137. make.height.mas_equalTo(kNaviBarHeight);
  138. }];
  139. // [self.view bringSubviewToFront:self.scrollView];
  140. [self.view bringSubviewToFront:self.navView];
  141. // [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
  142. // make.left.right.mas_equalTo(self.view);
  143. // make.top.mas_equalTo(self.view.mas_top).offset(kNaviBarHeight);
  144. // make.bottom.mas_equalTo(self.view.mas_bottom);
  145. // }];
  146. // self.scrollView.backgroundColor = [UIColor clearColor];
  147. // self.scrollView.scrollEnabled = NO;
  148. // MJWeakSelf;
  149. // self.scrollView.mj_header = [KSGifRefreshHeader headerWithRefreshingBlock:^{
  150. // [weakSelf requestData];
  151. // }];
  152. }
  153. - (void)configHeadView {
  154. UIView *headBgView = [[UIView alloc] init];
  155. headBgView.backgroundColor = [UIColor whiteColor];
  156. [self.headView addSubview:headBgView];
  157. // banner
  158. [self.headView addSubview:self.bannerView];
  159. self.bannerViewHeight = [HomeBannerView getViewHeight];
  160. [self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
  161. make.left.right.top.mas_equalTo(self.headView);
  162. make.height.mas_equalTo(self.bannerViewHeight);
  163. }];
  164. // 按钮
  165. [self.headView addSubview:self.buttonContainer];
  166. self.buttonViewHeight = CGFLOAT_MIN;
  167. [self.buttonContainer mas_makeConstraints:^(MASConstraintMaker *make) {
  168. make.left.right.mas_equalTo(self.headView);
  169. make.top.mas_equalTo(self.bannerView.mas_bottom);
  170. make.height.mas_equalTo(CGFLOAT_MIN);
  171. }];
  172. self.buttonContainer.hidden = YES;
  173. // 公告
  174. [self.headView addSubview:self.noticeView];
  175. self.noticeViewHeight = CGFLOAT_MIN;
  176. [self.noticeView mas_makeConstraints:^(MASConstraintMaker *make) {
  177. make.left.right.mas_equalTo(self.headView);
  178. make.top.mas_equalTo(self.buttonContainer.mas_bottom);
  179. make.height.mas_equalTo(CGFLOAT_MIN);
  180. }];
  181. [self.noticeView.adView addSubview:self.noticeScrollView];
  182. [self.noticeScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  183. make.top.left.right.bottom.mas_equalTo(self.noticeView.adView);
  184. }];
  185. self.noticeView.hidden = YES;
  186. // 最近课程
  187. [self.headView addSubview:self.courseView];
  188. self.courseViewHeight = CGFLOAT_MIN;
  189. [self.courseView mas_makeConstraints:^(MASConstraintMaker *make) {
  190. make.left.right.mas_equalTo(self.headView);
  191. make.top.mas_equalTo(self.noticeView.mas_bottom);
  192. make.height.mas_equalTo(CGFLOAT_MIN);
  193. }];
  194. self.courseView.hidden = YES;
  195. // 热门专辑
  196. [self.headView addSubview:self.albumView];
  197. self.albumViewHeight = [HomeHotAlbumView getViewHeight];
  198. [self.albumView mas_makeConstraints:^(MASConstraintMaker *make) {
  199. make.left.right.mas_equalTo(self.headView);
  200. make.top.mas_equalTo(self.courseView.mas_bottom);
  201. make.height.mas_equalTo(self.albumViewHeight);
  202. }];
  203. // 热门曲目
  204. [self.headView addSubview:self.hotMusicView];
  205. self.musicViewHeight = [HomeHotMusicView getViewHeight];
  206. [self.hotMusicView mas_makeConstraints:^(MASConstraintMaker *make) {
  207. make.left.right.mas_equalTo(self.headView);
  208. make.top.mas_equalTo(self.albumView.mas_bottom);
  209. make.height.mas_equalTo(self.musicViewHeight);
  210. }];
  211. // 推荐达人
  212. [self.headView addSubview:self.talentView];
  213. self.talentViewHeight = CGFLOAT_MIN;
  214. [self.talentView mas_makeConstraints:^(MASConstraintMaker *make) {
  215. make.left.right.mas_equalTo(self.headView);
  216. make.top.mas_equalTo(self.hotMusicView.mas_bottom);
  217. make.height.mas_equalTo(self.talentViewHeight);
  218. }];
  219. self.talentView.hidden = YES;
  220. // 视频课
  221. [self.headView addSubview:self.videoCourseView];
  222. self.videoViewHeight = CGFLOAT_MIN;
  223. [self.videoCourseView mas_makeConstraints:^(MASConstraintMaker *make) {
  224. make.left.right.mas_equalTo(self.headView);
  225. make.top.mas_equalTo(self.talentView.mas_bottom);
  226. make.height.mas_equalTo(self.videoViewHeight);
  227. }];
  228. self.videoCourseView.hidden = YES;
  229. // 直播
  230. [self.headView addSubview:self.liveCourseView];
  231. self.liveViewHeight = CGFLOAT_MIN;
  232. [self.liveCourseView mas_makeConstraints:^(MASConstraintMaker *make) {
  233. make.left.right.mas_equalTo(self.headView);
  234. make.top.mas_equalTo(self.videoCourseView.mas_bottom);
  235. make.height.mas_equalTo(self.liveViewHeight);
  236. }];
  237. self.liveCourseView.hidden = YES;
  238. [headBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  239. make.left.right.mas_equalTo(self.headView);
  240. make.top.mas_equalTo(self.bannerView.mas_top);
  241. make.bottom.mas_equalTo(self.buttonContainer.mas_bottom);
  242. }];
  243. headBgView.layer.masksToBounds = YES;
  244. headBgView.layer.cornerRadius = 10.0f;
  245. headBgView.layer.maskedCorners = kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner;
  246. [self refreshHeadHeight];
  247. }
  248. - (void)refreshHeadHeight {
  249. self.headViewHeight = self.bannerViewHeight + self.buttonViewHeight + self.noticeViewHeight + self.courseViewHeight + self.albumViewHeight + self.musicViewHeight + self.talentViewHeight + self.liveViewHeight + self.videoViewHeight;
  250. [self.pagerView reloadData];
  251. }
  252. - (void)configUI {
  253. [self configHeadView];
  254. _categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, kNaviBarHeight, kScreenWidth, 50)];
  255. self.categoryView.backgroundColor = [UIColor clearColor];
  256. self.categoryView.titles = self.titles;
  257. self.categoryView.delegate = self;
  258. self.categoryView.titleFont = [UIFont systemFontOfSize:18.0f weight:UIFontWeightMedium];
  259. self.categoryView.titleSelectedFont = [UIFont systemFontOfSize:18.0f weight:UIFontWeightMedium];
  260. self.categoryView.titleSelectedColor = HexRGB(0x333333);
  261. self.categoryView.titleColor = HexRGB(0x999999);
  262. self.categoryView.titleColorGradientEnabled = YES;
  263. self.categoryView.cellWidth = 90.0f;
  264. self.categoryView.cellSpacing = 16.0f;
  265. self.categoryView.averageCellSpacingEnabled = NO;
  266. JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
  267. lineView.verticalMargin = 10;
  268. lineView.indicatorColor = THEMECOLOR;
  269. lineView.indicatorWidth = 63.0f;
  270. lineView.indicatorHeight = 12.0f;
  271. self.categoryView.indicators = @[lineView];
  272. _pagerView = [self preferredPagingView];
  273. self.pagerView.frame = CGRectMake(0, kNaviBarHeight, kScreenWidth, kScreenHeight - kNaviBarHeight - kTabBarHeight);
  274. self.pagerView.mainTableView.gestureDelegate = self;
  275. [self.view addSubview:self.pagerView];
  276. self.pagerView.backgroundColor = [UIColor clearColor];
  277. self.pagerView.mainTableView.backgroundColor = [UIColor clearColor];
  278. self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
  279. }
  280. - (void)viewDidAppear:(BOOL)animated {
  281. [super viewDidAppear:animated];
  282. self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
  283. }
  284. - (JXPagerView *)preferredPagingView {
  285. return [[JXPagerListRefreshView alloc] initWithDelegate:self];
  286. }
  287. - (void)viewWillAppear:(BOOL)animated {
  288. [super viewWillAppear:animated];
  289. if (self.isFirstLoad == YES) {
  290. [self requestUserInfo:YES]; // 获取声部
  291. [self requestTrackAuth];
  292. AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  293. [appDelegate handleNotiferSource];
  294. }
  295. else {
  296. [self requestUserInfo:YES];
  297. }
  298. [self requestUnreadCount];
  299. }
  300. - (void)requestUnreadCount {
  301. [KSNetworkingManager queryCountOfUnreadRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  302. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  303. NSArray *countArray = [dic arrayValueForKey:@"data"];
  304. NSInteger courseCount = 0;
  305. NSInteger sysCount = 0;
  306. for (NSDictionary *parm in countArray) {
  307. if ([[parm stringValueForKey:@"key"] isEqualToString:@"COURSE"]) {
  308. courseCount = [parm integerValueForKey:@"value"];
  309. }
  310. if ([[parm stringValueForKey:@"key"] isEqualToString:@"SYSTEM"]) {
  311. sysCount = [parm integerValueForKey:@"value"];
  312. }
  313. }
  314. if (courseCount != 0 || sysCount != 0) {
  315. self.navView.dotView.hidden = NO;
  316. }
  317. else {
  318. self.navView.dotView.hidden = YES;
  319. }
  320. }
  321. else {
  322. [self MBPShow:MESSAGEKEY];
  323. }
  324. } faliure:^(NSError * _Nonnull error) {
  325. }];
  326. }
  327. - (void)requestUserInfo:(BOOL)checkSubject {
  328. self.isFirstLoad = NO;
  329. [KSNetworkingManager queryStudentInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  330. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  331. self.mineInfo = [[StudentInfoModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
  332. NSString *rongToken = UserDefault(RongTokenKey);
  333. if ([NSString isEmptyString:rongToken]) {
  334. [USER_MANAGER queryUserInfoConnectRongCloud:YES];
  335. }
  336. [self refreshSource:checkSubject];
  337. }
  338. else {
  339. [self MBPShow:MESSAGEKEY];
  340. }
  341. } faliure:^(NSError * _Nonnull error) {
  342. }];
  343. }
  344. - (void)refreshSource:(BOOL)checkSubject {
  345. if (checkSubject) {
  346. if ([NSString isEmptyString:self.mineInfo.subjectName]) {
  347. [self showInstrumentView:YES];
  348. }
  349. else {
  350. [self requestData];
  351. }
  352. }
  353. }
  354. - (void)showInstrumentView:(BOOL)hideBackButton {
  355. InstrumentChooseViewController *ctrl = [[InstrumentChooseViewController alloc] init];
  356. MJWeakSelf;
  357. [ctrl chooseCallback:^{
  358. [weakSelf requestUserInfo:NO];
  359. [weakSelf requestData];
  360. }];
  361. if (hideBackButton) {
  362. ctrl.isModalPresent = YES;
  363. CustomNavViewController *navCrtl = [[CustomNavViewController alloc] initWithRootViewController:ctrl];
  364. navCrtl.modalPresentationStyle = UIModalPresentationFullScreen;
  365. [self.navigationController presentViewController:navCrtl animated:YES completion:nil];
  366. }
  367. else {
  368. [self.navigationController pushViewController:ctrl animated:YES];
  369. }
  370. }
  371. - (void)requestNewsList {
  372. dispatch_group_enter(self.requestGroup);
  373. [KSNetworkingManager homeNewsList:KS_POST version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
  374. dispatch_group_leave(self.requestGroup);
  375. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  376. NSDictionary *result = [dic dictionaryValueForKey:@"data"];
  377. // banner
  378. NSArray *bannerArray = [result arrayValueForKey:@"banner"];
  379. NSMutableArray *bannerInfoArray = [NSMutableArray array];
  380. for (NSDictionary *parm in bannerArray) {
  381. HomeMessageModel *model = [[HomeMessageModel alloc] initWithDictionary:parm];
  382. [bannerInfoArray addObject:model];
  383. }
  384. self.bannerArray = [NSMutableArray arrayWithArray:bannerInfoArray];
  385. // button
  386. NSArray *buttonArray = [result arrayValueForKey:@"appMenu"];
  387. NSMutableArray *buttonInfoArray = [NSMutableArray array];
  388. for (NSDictionary *parm in buttonArray) {
  389. HomeMessageModel *model = [[HomeMessageModel alloc] initWithDictionary:parm];
  390. [buttonInfoArray addObject:model];
  391. }
  392. self.buttonArray = [NSMutableArray arrayWithArray:buttonInfoArray];
  393. // news
  394. NSArray *flashArray = [result arrayValueForKey:@"flashPage"];
  395. if (flashArray.count) {
  396. self.flashModel = [[HomeMessageModel alloc] initWithDictionary:[flashArray firstObject]];
  397. }
  398. // information
  399. NSArray *information = [result arrayValueForKey:@"information"];
  400. NSMutableArray *informationInfoArray = [NSMutableArray array];
  401. for (NSDictionary *parm in information) {
  402. HomeMessageModel *model = [[HomeMessageModel alloc] initWithDictionary:parm];
  403. [informationInfoArray addObject:model];
  404. }
  405. self.informationArray = [NSMutableArray arrayWithArray:informationInfoArray];
  406. }
  407. else {
  408. [self MBPShow:MESSAGEKEY];
  409. }
  410. } faliure:^(NSError * _Nonnull error) {
  411. dispatch_group_leave(self.requestGroup);
  412. }];
  413. }
  414. - (void)requestHotAlbum {
  415. dispatch_group_enter(self.requestGroup);
  416. [KSNetworkingManager HomeHotAlbumRequest:KS_POST page:1 rows:10 version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
  417. dispatch_group_leave(self.requestGroup);
  418. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  419. NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
  420. NSMutableArray *albumArray = [NSMutableArray array];
  421. for (NSDictionary *parm in sourceArray) {
  422. HomeAlbumModel *model = [[HomeAlbumModel alloc] initWithDictionary:parm];
  423. [albumArray addObject:model];
  424. }
  425. self.albumArray = [NSMutableArray arrayWithArray:albumArray];
  426. }
  427. else {
  428. [self MBPShow:MESSAGEKEY];
  429. }
  430. } faliure:^(NSError * _Nonnull error) {
  431. dispatch_group_leave(self.requestGroup);
  432. }];
  433. }
  434. - (void)requestCourseInfo {
  435. dispatch_group_enter(self.requestGroup);
  436. [KSNetworkingManager homeQueryLiveAndVideo:KS_GET version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
  437. dispatch_group_leave(self.requestGroup);
  438. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  439. NSDictionary *sourceDic = [dic dictionaryValueForKey:@"data"];
  440. NSArray *liveList = [sourceDic arrayValueForKey:@"liveList"];
  441. NSMutableArray *liveCourse = [NSMutableArray array];
  442. for (NSDictionary *parm in liveList) {
  443. HomeLiveGroupModel *model = [[HomeLiveGroupModel alloc] initWithDictionary:parm];
  444. [liveCourse addObject:model];
  445. }
  446. self.liveCourseArray = [NSMutableArray arrayWithArray:liveCourse];
  447. NSArray *videoList = [sourceDic arrayValueForKey:@"videoList"];
  448. NSMutableArray *videoCourse = [NSMutableArray array];
  449. for (NSDictionary *parm in videoList) {
  450. HomeVideoGroupModel *model = [[HomeVideoGroupModel alloc] initWithDictionary:parm];
  451. [videoCourse addObject:model];
  452. }
  453. self.videoCourseArray = [NSMutableArray arrayWithArray:videoCourse];
  454. // 最近课程
  455. NSDictionary *parm = [sourceDic dictionaryValueForKey:@"recentCourses"];
  456. if (parm == nil) {
  457. self.recentCourseModel = nil;
  458. }
  459. else {
  460. self.recentCourseModel = [[RecentCourseModel alloc] initWithDictionary:parm];
  461. }
  462. }
  463. else {
  464. [self MBPShow:MESSAGEKEY];
  465. }
  466. } faliure:^(NSError * _Nonnull error) {
  467. dispatch_group_leave(self.requestGroup);
  468. }];
  469. }
  470. - (void)requestNotice {
  471. dispatch_group_enter(self.requestGroup);
  472. [KSNetworkingManager helpCenterContentListRequest:KS_POST success:^(NSDictionary * _Nonnull dic) {
  473. dispatch_group_leave(self.requestGroup);
  474. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  475. NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
  476. if (sourceArray.count) {
  477. NSDictionary *parm = [sourceArray firstObject];
  478. NoticeSourceModel *bannerModel = [[NoticeSourceModel alloc] initWithDictionary:parm];
  479. [self.noticeArray addObject:bannerModel];
  480. [self.noticeTitleArray addObject:bannerModel.title];
  481. }
  482. else {
  483. self.noticeArray = [NSMutableArray array];
  484. self.noticeTitleArray = [NSMutableArray array];
  485. }
  486. }
  487. else {
  488. [self MBPShow:MESSAGEKEY];
  489. }
  490. } faliure:^(NSError * _Nonnull error) {
  491. dispatch_group_leave(self.requestGroup);
  492. }];
  493. }
  494. - (void)requestHotMusic {
  495. dispatch_group_enter(self.requestGroup);
  496. [KSNetworkingManager homeMusicListRequest:KS_POST version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
  497. dispatch_group_leave(self.requestGroup);
  498. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  499. NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
  500. NSMutableArray *musicArray = [NSMutableArray array];
  501. for (NSDictionary *parm in sourceArray) {
  502. HomeHotMusicModel *model = [[HomeHotMusicModel alloc] initWithDictionary:parm];
  503. [musicArray addObject:model];
  504. }
  505. self.musicArray = [NSMutableArray arrayWithArray:musicArray];
  506. }
  507. else {
  508. [self MBPShow:MESSAGEKEY];
  509. }
  510. } faliure:^(NSError * _Nonnull error) {
  511. dispatch_group_leave(self.requestGroup);
  512. }];
  513. }
  514. - (void)requestTalentSource {
  515. dispatch_group_enter(self.requestGroup);
  516. [KSNetworkingManager queryHotTeacherListRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  517. dispatch_group_leave(self.requestGroup);
  518. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  519. NSArray *sourceArray = [dic arrayValueForKey:@"data"];
  520. NSMutableArray *talentArray = [NSMutableArray array];
  521. for (NSDictionary *parm in sourceArray) {
  522. TalentTeacherModel *model = [[TalentTeacherModel alloc] initWithDictionary:parm];
  523. [talentArray addObject:model];
  524. }
  525. self.talentArray = [NSMutableArray arrayWithArray:talentArray];
  526. }
  527. else {
  528. [self MBPShow:MESSAGEKEY];
  529. }
  530. } faliure:^(NSError * _Nonnull error) {
  531. dispatch_group_leave(self.requestGroup);
  532. }];
  533. }
  534. - (void)requestTeacherStyle {
  535. dispatch_group_enter(self.requestGroup);
  536. [KSNetworkingManager homeQueryTeacherStyle:KS_POST page:1 rows:10 version:[USER_MANAGER getCurrentVersion] success:^(NSDictionary * _Nonnull dic) {
  537. dispatch_group_leave(self.requestGroup);
  538. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  539. NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
  540. NSMutableArray *styleArray = [NSMutableArray array];
  541. for (NSDictionary *parm in sourceArray) {
  542. TeacherStyleModel *model = [[TeacherStyleModel alloc] initWithDictionary:parm];
  543. [styleArray addObject:model];
  544. }
  545. self.teacherArray = [NSMutableArray arrayWithArray:styleArray];
  546. }
  547. else {
  548. [self MBPShow:MESSAGEKEY];
  549. }
  550. // 回调
  551. } faliure:^(NSError * _Nonnull error) {
  552. dispatch_group_leave(self.requestGroup);
  553. }];
  554. }
  555. - (void)requestLiveList {
  556. dispatch_group_enter(self.requestGroup);
  557. [KSNetworkingManager queryTeacherLivingListRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  558. dispatch_group_leave(self.requestGroup);
  559. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  560. NSArray *sourceArray = [dic arrayValueForKey:@"data"];
  561. NSMutableArray *liveListArray = [NSMutableArray array];
  562. for (NSDictionary *parm in sourceArray) {
  563. HomeTeacherLiveModel *model = [[HomeTeacherLiveModel alloc] initWithDictionary:parm];
  564. [liveListArray addObject:model];
  565. }
  566. self.liveListArray = [NSMutableArray arrayWithArray:liveListArray];
  567. }
  568. else {
  569. [self MBPShow:MESSAGEKEY];
  570. }
  571. } faliure:^(NSError * _Nonnull error) {
  572. dispatch_group_leave(self.requestGroup);
  573. }];
  574. }
  575. - (void)requestData {
  576. [self showhud];
  577. [self requestNewsList];
  578. [self requestNotice];
  579. [self requestCourseInfo];
  580. // 达人
  581. [self requestTalentSource];
  582. [self requestHotAlbum];
  583. [self requestHotMusic];
  584. [self requestTeacherStyle];
  585. [self requestLiveList];
  586. dispatch_group_notify(self.requestGroup, dispatch_get_main_queue(), ^{
  587. [self removehub];
  588. [self.scrollView.mj_header endRefreshing];
  589. [self refreshView];
  590. });
  591. }
  592. - (void)refreshView {
  593. [self refreshBannaerView];
  594. [self showButtonMessage];
  595. [self refreshNotice];
  596. [self refreshCourseView:self.recentCourseModel];
  597. [self refreshAlbumView];
  598. [self refreshMusicView];
  599. // 达人
  600. [self refreshTalentView];
  601. // 课程
  602. [self refreshCourseView];
  603. // 刷新排序
  604. [self refreshViewLocation];
  605. [self refreshHeadHeight];
  606. [self refreshPageView];
  607. }
  608. - (void)refreshPageView {
  609. for (NSInteger i = 0; i < self.listViewArray.count; i++) {
  610. id view = self.listViewArray[i];
  611. if ([view isKindOfClass:[HomePageBodyView class]]) {
  612. HomePageBodyView *styleView = (HomePageBodyView *)view;
  613. styleView.styleArray = [self.teacherArray mutableCopy];
  614. styleView.liveArray = [self.liveListArray mutableCopy];
  615. [styleView beginFirstRefresh];
  616. }
  617. else if ([view isKindOfClass:[HomeInformationBodyView class]]) {
  618. HomeInformationBodyView *informationView = (HomeInformationBodyView *)view;
  619. informationView.informationArray = [self.informationArray mutableCopy];
  620. [informationView beginFirstRefresh];
  621. }
  622. }
  623. }
  624. - (void)refreshTalentView {
  625. if (self.talentArray.count) {
  626. self.talentViewHeight = [HomeHotTalentView getViewHeight];
  627. self.talentView.hidden = NO;
  628. }
  629. else {
  630. self.talentViewHeight = CGFLOAT_MIN;
  631. self.talentView.hidden = YES;
  632. }
  633. [self.talentView mas_updateConstraints:^(MASConstraintMaker *make) {
  634. make.height.mas_equalTo(self.talentViewHeight);
  635. }];
  636. [self.talentCollectionView reloadData];
  637. }
  638. - (void)refreshViewLocation {
  639. // 如果有课程和公告 且有按钮
  640. CGFloat buttonViewDefaultHeight = self.buttonArray.count > 5 ? [HomeButtonView getViewHeight] : [HomeButtonView getViewHeight] - 20;
  641. if (self.noticeTitleArray.count && self.recentCourseModel && self.buttonArray.count) {
  642. self.noticeViewHeight = [PublicNoticeView getViewHeight];
  643. [self.noticeView mas_remakeConstraints:^(MASConstraintMaker *make) {
  644. make.left.right.mas_equalTo(self.headView);
  645. make.top.mas_equalTo(self.bannerView.mas_bottom);
  646. make.height.mas_equalTo(self.noticeViewHeight);
  647. }];
  648. self.buttonViewHeight = buttonViewDefaultHeight;
  649. [self.buttonContainer mas_remakeConstraints:^(MASConstraintMaker *make) {
  650. make.left.right.mas_equalTo(self.headView);
  651. make.top.mas_equalTo(self.noticeView.mas_bottom);
  652. make.height.mas_equalTo(self.buttonViewHeight);
  653. }];
  654. [self.courseView mas_remakeConstraints:^(MASConstraintMaker *make) {
  655. make.left.right.mas_equalTo(self.view);
  656. make.top.mas_equalTo(self.buttonContainer.mas_bottom);
  657. make.height.mas_equalTo(91.0f);
  658. }];
  659. }
  660. else {
  661. self.buttonViewHeight = self.buttonArray.count ? buttonViewDefaultHeight : CGFLOAT_MIN;
  662. [self.buttonContainer mas_remakeConstraints:^(MASConstraintMaker *make) {
  663. make.left.right.mas_equalTo(self.headView);
  664. make.top.mas_equalTo(self.bannerView.mas_bottom);
  665. make.height.mas_equalTo(self.buttonViewHeight);
  666. }];
  667. self.noticeViewHeight = self.noticeTitleArray.count ? [PublicNoticeView getViewHeight] : CGFLOAT_MIN;
  668. [self.noticeView mas_remakeConstraints:^(MASConstraintMaker *make) {
  669. make.left.right.mas_equalTo(self.headView);
  670. make.top.mas_equalTo(self.buttonContainer.mas_bottom);
  671. make.height.mas_equalTo(self.noticeViewHeight);
  672. }];
  673. CGFloat courseViewHeight = self.recentCourseModel ? 90.0f : CGFLOAT_MIN;
  674. [self.courseView mas_remakeConstraints:^(MASConstraintMaker *make) {
  675. make.left.right.mas_equalTo(self.headView);
  676. make.top.mas_equalTo(self.noticeView.mas_bottom);
  677. make.height.mas_equalTo(courseViewHeight);
  678. }];
  679. }
  680. }
  681. - (void)refreshBannaerView {
  682. if (self.bannerArray.count > 1) {
  683. self.bannerScroll.autoScrollInterval = 3.0f;
  684. [self.bannerScroll addSubview:self.pageControl];
  685. }
  686. else {
  687. self.bannerScroll.autoScrollInterval = 0;
  688. [self.pageControl removeFromSuperview];
  689. }
  690. _pageControl.numberOfPages = self.bannerArray.count;
  691. [self.bannerScroll reloadData];
  692. }
  693. - (void)showButtonMessage {
  694. // 添加按钮
  695. if (self.buttonArray.count) {
  696. self.buttonContainer.hidden = NO;
  697. if (self.buttonArray.count > 5) { // 大于4个显示底部滚动视图
  698. self.buttonContainer.buttonPageCtrl.hidden = NO;
  699. self.buttonContainer.buttonDotLeft.constant = 0;
  700. NSInteger addPage = (self.buttonArray.count % 5) > 0 ? 1 : 0;
  701. NSInteger pageCount = self.buttonArray.count / 5 + addPage;
  702. self.buttonDotWidth = 36 / pageCount;
  703. self.buttonContainer.buttonDotWidth.constant = self.buttonDotWidth;
  704. self.buttonScrollView.contentSize = CGSizeMake(kScreenWidth * pageCount, BUTTONHEIGHT);
  705. }
  706. else {
  707. self.buttonContainer.buttonPageCtrl.hidden = YES;
  708. self.buttonScrollView.contentSize = CGSizeMake(kScreenWidth, BUTTONHEIGHT);
  709. }
  710. }
  711. else {
  712. self.buttonContainer.hidden = YES;
  713. self.buttonContainer.buttonPageCtrl.hidden = YES;
  714. self.buttonScrollView.contentSize = CGSizeMake(kScreenWidth, CGFLOAT_MIN);
  715. }
  716. self.buttonScrollView.contentOffset = CGPointMake(0, 0);
  717. [self.buttonScrollView removeAllSubViews];
  718. CGFloat buttonSpace = (kScreenWidth - 5 * BUTTONWIDTH) / 6;
  719. for (NSInteger i = 0; i < self.buttonArray.count; i++) {
  720. HomeMessageModel *model = self.buttonArray[i];
  721. KSHomeButton *buttonView = [KSHomeButton shareInstance];
  722. [buttonView.buttonImage sd_setImageWithURL:[NSURL URLWithString:[model.coverImage getUrlEndcodeString]]];
  723. buttonView.buttonTitle.text = model.title;
  724. buttonView.frame = CGRectMake(buttonSpace + (i % 5) * (BUTTONWIDTH + buttonSpace) + (i / 5) * KPortraitWidth, 0, BUTTONWIDTH, BUTTONHEIGHT);
  725. buttonView.actionButton.tag = 3000 + i;
  726. [buttonView.actionButton addTarget:self action:@selector(HomeTopButtonAction:) forControlEvents:UIControlEventTouchUpInside];
  727. [self.buttonScrollView addSubview:buttonView];
  728. }
  729. }
  730. - (void)HomeTopButtonAction:(UIButton *)sender {
  731. NSInteger index = sender.tag - 3000;
  732. if ([self checkIsLoginToLoginView:YES]) {
  733. HomeMessageModel *model = self.buttonArray[index];
  734. if (![NSString isEmptyString:model.linkUrl]) {
  735. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  736. webCtrl.url = model.linkUrl;
  737. [self.navigationController pushViewController:webCtrl animated:YES];
  738. }
  739. }
  740. }
  741. - (void)refreshNotice {
  742. if (self.noticeTitleArray.count) {
  743. self.noticeView.hidden = NO;
  744. }
  745. else {
  746. self.noticeView.hidden = YES;
  747. }
  748. self.noticeScrollView.titlesGroup = self.noticeTitleArray;
  749. }
  750. - (void)refreshCourseView:(RecentCourseModel *)model {
  751. if (model) {
  752. [self.courseView configCourseMessage:model];
  753. self.courseView.hidden = NO;
  754. }
  755. else {
  756. self.courseView.hidden = YES;
  757. }
  758. }
  759. - (void)refreshAlbumView {
  760. if (self.albumArray.count) {
  761. self.albumViewHeight = [HomeHotAlbumView getViewHeight];
  762. self.albumView.hidden = NO;
  763. }
  764. else {
  765. self.albumViewHeight = CGFLOAT_MIN;
  766. self.albumView.hidden = YES;
  767. }
  768. [self.albumView mas_updateConstraints:^(MASConstraintMaker *make) {
  769. make.height.mas_equalTo(self.albumViewHeight);
  770. }];
  771. [self.albumCollectionView reloadData];
  772. }
  773. - (void)refreshMusicView {
  774. [self.musicCollectionView reloadData];
  775. }
  776. - (void)refreshCourseView {
  777. // 课程
  778. if (self.liveCourseArray.count) {
  779. self.liveViewHeight = [HomeHotLiveCourseView getViewHeight];
  780. self.liveCourseView.hidden = NO;
  781. }
  782. else {
  783. self.liveViewHeight = CGFLOAT_MIN;
  784. self.liveCourseView.hidden = YES;
  785. }
  786. [self.liveCourseView mas_updateConstraints:^(MASConstraintMaker *make) {
  787. make.height.mas_equalTo(self.liveViewHeight);
  788. }];
  789. if (self.videoCourseArray.count) {
  790. self.videoViewHeight = [HomeHotVideoCourseView getViewHeight];
  791. self.videoCourseView.hidden = NO;
  792. }
  793. else {
  794. self.videoViewHeight = CGFLOAT_MIN;
  795. self.videoCourseView.hidden = YES;
  796. }
  797. [self.videoCourseView mas_updateConstraints:^(MASConstraintMaker *make) {
  798. make.height.mas_equalTo(self.videoViewHeight);
  799. }];
  800. [self.videoCollectionView reloadData];
  801. [self.liveCollectionView reloadData];
  802. }
  803. #pragma mark - JXPagerViewDelegate
  804. - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
  805. return self.headView;
  806. }
  807. - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
  808. return self.headViewHeight;
  809. }
  810. - (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  811. return self.categoryView;
  812. }
  813. - (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
  814. return 50;
  815. }
  816. - (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
  817. //和categoryView的item数量一致
  818. return self.titles.count;
  819. }
  820. - (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
  821. if (index == 0) {
  822. HomePageBodyView *listView = [[HomePageBodyView alloc] init];
  823. listView.naviController = self.navigationController;
  824. [self.listViewArray replaceObjectAtIndex:index withObject:listView];
  825. self.listViewArray[index] = listView;
  826. listView.selectIndex = index;
  827. listView.styleArray = [self.teacherArray mutableCopy];
  828. listView.liveArray = [self.liveListArray mutableCopy];
  829. [listView beginFirstRefresh];
  830. return listView;
  831. }
  832. else {
  833. HomeInformationBodyView *listView = [[HomeInformationBodyView alloc] init];
  834. listView.naviController = self.navigationController;
  835. [self.listViewArray replaceObjectAtIndex:index withObject:listView];
  836. self.listViewArray[index] = listView;
  837. listView.selectIndex = index;
  838. listView.informationArray = [self.informationArray mutableCopy];
  839. [listView beginFirstRefresh];
  840. return listView;
  841. }
  842. }
  843. #pragma mark - JXCategoryViewDelegate
  844. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
  845. self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
  846. if (self.listViewArray.count > index) {
  847. id value = self.listViewArray[index];
  848. if ([value isKindOfClass:[KSJXBodyView class]]) {
  849. KSJXBodyView *listView = (KSJXBodyView *)value;
  850. [listView beginFirstRefresh];
  851. }
  852. else if ([value isKindOfClass:[kSJXCollectionView class]]) {
  853. kSJXCollectionView *listView = (kSJXCollectionView *)value;
  854. [listView beginFirstRefresh];
  855. }
  856. }
  857. }
  858. #pragma mark - JXPagerMainTableViewGestureDelegate
  859. - (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
  860. //禁止categoryView左右滑动的时候,上下和左右都可以滚动
  861. if (otherGestureRecognizer == self.categoryView.collectionView.panGestureRecognizer) {
  862. return NO;
  863. }
  864. return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
  865. }
  866. #pragma mark - TYCyclePagerViewDataSource代理
  867. - (NSInteger)numberOfItemsInPagerView:(TYCyclePagerView *)pageView {
  868. return self.bannerArray.count;
  869. }
  870. - (UICollectionViewCell *)pagerView:(TYCyclePagerView *)pagerView cellForItemAtIndex:(NSInteger)index {
  871. HomeMessageModel *model = self.bannerArray[index];
  872. HomeBannerCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"HomeBannerCell" forIndex:index];
  873. [cell configCellWithModel:model];
  874. return cell;
  875. }
  876. - (TYCyclePagerViewLayout *)layoutForPagerView:(TYCyclePagerView *)pageView {
  877. TYCyclePagerViewLayout *layout = [[TYCyclePagerViewLayout alloc]init];
  878. layout.itemSize = CGSizeMake(kScreenWidth - 28, (kScreenWidth - 28) / 347 * 132);
  879. layout.itemSpacing = 0;
  880. return layout;
  881. }
  882. - (void)pagerView:(TYCyclePagerView *)pageView didScrollFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex {
  883. if (pageView == self.bannerScroll) {
  884. [self.pageControl setCurrentPage:toIndex animate:YES];
  885. }
  886. }
  887. - (void)pagerView:(TYCyclePagerView *)pageView didSelectedItemCell:(__kindof UICollectionViewCell *)cell atIndex:(NSInteger)index {
  888. HomeMessageModel *model = self.bannerArray[index];
  889. if (![NSString isEmptyString:model.linkUrl]) {
  890. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  891. webCtrl.url = model.linkUrl;
  892. [self.navigationController pushViewController:webCtrl animated:YES];
  893. }
  894. }
  895. #pragma mark ---- collection data source
  896. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  897. return 1;
  898. }
  899. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  900. if (collectionView == self.albumCollectionView) { // 专辑
  901. return self.albumArray.count;
  902. }
  903. else if (collectionView == self.musicCollectionView) { // 乐谱
  904. NSInteger lastRowCount = (self.musicArray.count % 3) > 0 ? 1 : 0;
  905. NSInteger count = self.musicArray.count / 3 + lastRowCount;
  906. return count;
  907. }
  908. else if (collectionView == self.talentCollectionView) { // 推荐达人
  909. return self.talentArray.count;
  910. }
  911. else if (collectionView == self.videoCollectionView) { // 视频课
  912. return self.videoCourseArray.count;
  913. }
  914. else { // 直播课
  915. return self.liveCourseArray.count;
  916. }
  917. }
  918. - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  919. if (collectionView == self.albumCollectionView) {
  920. HomeAlbumModel *model = self.albumArray[indexPath.item];
  921. HomeHotAlbumCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotAlbumCell" forIndexPath:indexPath];
  922. [cell configWithAlbumModel:model];
  923. return cell;
  924. }
  925. else if (collectionView == self.musicCollectionView) {
  926. NSMutableArray *songArray = [NSMutableArray array];
  927. NSInteger length = indexPath.item * 3 + 3 > self.musicArray.count ? self.musicArray.count - indexPath.item * 3: 3;
  928. NSRange range = NSMakeRange(indexPath.item * 3, length);
  929. songArray = [NSMutableArray arrayWithArray:[self.musicArray subarrayWithRange:range]];
  930. HomeHotMusicCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotMusicCollectionCell" forIndexPath:indexPath];
  931. MJWeakSelf;
  932. [cell configWithSourceArray:songArray callback:^(NSString * _Nonnull songId) {
  933. [weakSelf displaySongDetail:songId];
  934. }];
  935. return cell;
  936. }
  937. else if (collectionView == self.talentCollectionView) {
  938. TalentTeacherModel *talentModel = self.talentArray[indexPath.item];
  939. HomeHotTalentCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotTalentCell" forIndexPath:indexPath];
  940. [cell configWithSource:talentModel];
  941. return cell;
  942. }
  943. else if (collectionView == self.videoCollectionView) {
  944. HomeVideoGroupModel *model = self.videoCourseArray[indexPath.item];
  945. HomeHotVideoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotVideoCell" forIndexPath:indexPath];
  946. [cell configWithSource:model];
  947. return cell;
  948. }
  949. else {
  950. HomeLiveGroupModel *model = self.liveCourseArray[indexPath.item];
  951. HomeHotLiveCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotLiveCell" forIndexPath:indexPath];
  952. [cell configWithSource:model];
  953. return cell;
  954. }
  955. }
  956. - (void)displaySongDetail:(NSString *)songId {
  957. // 检测权限
  958. PREMISSIONTYPE micEnable = [RecordCheckManager checkPermissionShowAlert:NO showInView:nil];
  959. PREMISSIONTYPE cameraEnable = [RecordCheckManager checkCameraPremissionAvaiable:NO showInView:nil];
  960. if (micEnable == PREMISSIONTYPE_YES && cameraEnable == PREMISSIONTYPE_YES) { // 如果麦克风和摄像头权限都有
  961. // 跳转到播放页面
  962. KSAccompanyWebViewController *detailCtrl = [[KSAccompanyWebViewController alloc] init];
  963. detailCtrl.url = [NSString stringWithFormat:@"%@/accompany?id=%@",hostURL, songId];
  964. detailCtrl.hiddenNavBar = YES;
  965. detailCtrl.parmDic = @{@"isOpenLight" : @(YES), @"orientation" : @(0),@"isHideTitle" : @(YES)};
  966. [self.navigationController pushViewController:detailCtrl animated:YES];
  967. }
  968. else {
  969. if (micEnable == PREMISSIONTYPE_NO && cameraEnable == PREMISSIONTYPE_NO) { // 如果麦克风权限和摄像头权限都没有
  970. [self showAlertWithMessage:@"请开启相机和麦克风访问权限" type:CHECKDEVICETYPE_BOTH];
  971. }
  972. else if (micEnable == PREMISSIONTYPE_NO) { // 如果没有麦克风权限
  973. [self showAlertWithMessage:@"请开启麦克风访问权限" type:CHECKDEVICETYPE_MIC];
  974. }
  975. else if (cameraEnable == PREMISSIONTYPE_NO) { // 如果没有摄像头权限
  976. [self showAlertWithMessage:@"请开启相机访问权限" type:CHECKDEVICETYPE_CAMREA];
  977. }
  978. }
  979. }
  980. - (void)showAlertWithMessage:(NSString *)message type:(CHECKDEVICETYPE)deviceType {
  981. [KSPremissionAlert shareInstanceDisplayImage:deviceType message:message showInView:self.view cancel:^{
  982. } confirm:^{
  983. [self openSettingView];
  984. }];
  985. }
  986. - (void)openSettingView {
  987. if (@available(iOS 10, *)) {
  988. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
  989. } else {
  990. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
  991. }
  992. }
  993. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  994. if (collectionView == self.albumCollectionView) { // 专辑详情
  995. HomeAlbumModel *model = self.albumArray[indexPath.item];
  996. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  997. ctrl.url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/music-album-detail/",model.internalBaseClassIdentifier];
  998. [self.navigationController pushViewController:ctrl animated:YES];
  999. }
  1000. else if (collectionView == self.talentCollectionView) { // 达人风采
  1001. TalentTeacherModel *model = self.talentArray[indexPath.item];
  1002. [self displayTeacherDetail:[NSString stringWithFormat:@"%.0f",model.userId]];
  1003. }
  1004. else if (collectionView == self.videoCollectionView) { // 视频课
  1005. HomeVideoGroupModel *model = self.videoCourseArray[indexPath.row];
  1006. NSString *url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/videoDetail?groupId=",model.videoGroupId];
  1007. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  1008. ctrl.url = url;
  1009. [self.navigationController pushViewController:ctrl animated:YES];
  1010. }
  1011. else if (collectionView == self.liveCollectionView) { // 直播课详情
  1012. HomeLiveGroupModel *model = self.liveCourseArray[indexPath.row];
  1013. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  1014. NSString *url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/liveDetail?groupId=",model.courseGroupId];
  1015. ctrl.url = url;
  1016. [self.navigationController pushViewController:ctrl animated:YES];
  1017. }
  1018. }
  1019. // 老师风采
  1020. - (void)displayTeacherDetail:(NSString *)teacherId {
  1021. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  1022. ctrl.url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/teacherHome?teacherId=",teacherId];
  1023. [self.navigationController pushViewController:ctrl animated:YES];
  1024. }
  1025. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  1026. if (collectionView == self.albumCollectionView) {
  1027. return CGSizeMake(100, 140);
  1028. }
  1029. else if (collectionView == self.musicCollectionView) {
  1030. return CGSizeMake(KPortraitWidth * 0.83, 240);
  1031. }
  1032. else if (collectionView == self.talentCollectionView) {
  1033. return CGSizeMake(110, 146);
  1034. }
  1035. else if (collectionView == self.videoCollectionView) {
  1036. return CGSizeMake((KPortraitWidth - 28 - 11) / 2.0f, 153);
  1037. }
  1038. else {
  1039. return CGSizeMake((KPortraitWidth - 28 - 11) / 2.0f, 153);
  1040. }
  1041. }
  1042. #pragma mark ----- SDCycleScrollViewDelegate
  1043. - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
  1044. NoticeSourceModel *noticeModel = self.noticeArray[index];
  1045. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  1046. webCtrl.url = [NSString stringWithFormat:@"%@/#/helpCenterDetail?id=%@",WEBHOST, noticeModel.internalBaseClassIdentifier];
  1047. [self.navigationController pushViewController:webCtrl animated:YES];
  1048. }
  1049. #pragma mark ------- lazying
  1050. - (HomeNavSearchView *)navView {
  1051. if (!_navView) {
  1052. _navView = [HomeNavSearchView shareInstance];
  1053. MJWeakSelf;
  1054. [_navView homeNavSearchAction:^(HOMENAV_TAG action) {
  1055. [weakSelf homeNavAction:action];
  1056. }];
  1057. }
  1058. return _navView;
  1059. }
  1060. - (void)homeNavAction:(HOMENAV_TAG)action {
  1061. switch (action) {
  1062. case HOMENAV_TAG_SCAN: // 扫一扫
  1063. {
  1064. [self showScanView];
  1065. }
  1066. break;
  1067. case HOMENAV_TAG_MESSAGE: // 消息
  1068. {
  1069. NotiferMessageViewController *ctrl = [[NotiferMessageViewController alloc] init];
  1070. [self.navigationController pushViewController:ctrl animated:YES];
  1071. }
  1072. break;
  1073. case HOMENAV_TAG_SEARCH: // 搜索
  1074. {
  1075. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  1076. webCtrl.url = [NSString stringWithFormat:@"%@/music-songbook/search", WEBHOST];
  1077. [self.navigationController pushViewController:webCtrl animated:YES];
  1078. }
  1079. break;
  1080. default:
  1081. break;
  1082. }
  1083. }
  1084. - (void)showScanView {
  1085. // 判断是否有权限
  1086. PREMISSIONTYPE albumEnable = [RecordCheckManager checkCameraPremissionAvaiable:NO showInView:nil];
  1087. if (albumEnable == PREMISSIONTYPE_YES) { // 如果有权限
  1088. KSScanViewController *ctrl = [[KSScanViewController alloc] init];
  1089. [self.navigationController pushViewController:ctrl animated:YES];
  1090. }
  1091. else {
  1092. if (albumEnable == PREMISSIONTYPE_NO) {
  1093. [self showAlertWithMessage:@"请开启相机访问权限" type:CHECKDEVICETYPE_CAMREA];
  1094. }
  1095. }
  1096. }
  1097. - (dispatch_group_t)requestGroup {
  1098. if (!_requestGroup) {
  1099. _requestGroup = dispatch_group_create();
  1100. }
  1101. return _requestGroup;
  1102. }
  1103. - (UIView *)headView {
  1104. if (!_headView) {
  1105. _headView = [[UIView alloc] init];
  1106. _headView.backgroundColor = [UIColor clearColor];
  1107. }
  1108. return _headView;
  1109. }
  1110. - (NSMutableArray *)listViewArray {
  1111. if (!_listViewArray) {
  1112. _listViewArray = [NSMutableArray arrayWithArray:@[@"",@""]];
  1113. }
  1114. return _listViewArray;
  1115. }
  1116. - (HomeBannerView *)bannerView {
  1117. if (!_bannerView) {
  1118. _bannerView = [HomeBannerView shareInstance];
  1119. [_bannerView.bannerContentView addSubview:self.bannerScroll];
  1120. }
  1121. return _bannerView;
  1122. }
  1123. #pragma mark --- banner
  1124. - (TYCyclePagerView *)bannerScroll {
  1125. if (!_bannerScroll) {
  1126. _bannerScroll = [[TYCyclePagerView alloc] init];
  1127. _bannerScroll.backgroundColor = [UIColor clearColor];
  1128. _bannerScroll.frame = CGRectMake(0, 0, kScreenWidth - 28, (kScreenWidth - 28) / 347 * 132);
  1129. _bannerScroll.isInfiniteLoop = YES;
  1130. _bannerScroll.autoScrollInterval = 3.0f;
  1131. _bannerScroll.reloadDataNeedResetIndex = YES;
  1132. _bannerScroll.dataSource = self;
  1133. _bannerScroll.delegate = self;
  1134. [_bannerScroll registerNib:[UINib nibWithNibName:@"HomeBannerCell" bundle:nil] forCellWithReuseIdentifier:@"HomeBannerCell"];
  1135. if (@available(iOS 11.0, *)) {
  1136. _bannerScroll.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  1137. } else {
  1138. // Fallback on earlier versions
  1139. if (@available(iOS 13.0, *)) {
  1140. _bannerScroll.collectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
  1141. } else {
  1142. // Fallback on earlier versions
  1143. }
  1144. }
  1145. }
  1146. return _bannerScroll;
  1147. }
  1148. - (TYPageControl *)pageControl {
  1149. if (!_pageControl) {
  1150. _pageControl = [[TYPageControl alloc] init];
  1151. _pageControl.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  1152. _pageControl.pageIndicatorSpaing = 4.0f;
  1153. _pageControl.frame = CGRectMake(0, (kScreenWidth - 28) * 132 / 347 - 20, kScreenWidth-28 - 12, 12);
  1154. _pageControl.currentPageIndicatorTintColor = HexRGB(0xffffff);
  1155. _pageControl.pageIndicatorTintColor = HexRGB(0xffffff);
  1156. _pageControl.pageIndicatorSize = CGSizeMake(5, 5);
  1157. _pageControl.currentPageIndicatorSize = CGSizeMake(12, 5);
  1158. }
  1159. return _pageControl;
  1160. }
  1161. - (NSMutableArray *)bannerArray {
  1162. if (!_bannerArray) {
  1163. _bannerArray = [NSMutableArray array];
  1164. }
  1165. return _bannerArray;
  1166. }
  1167. #pragma mark ---- scroll view delegate
  1168. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  1169. if (scrollView == self.buttonScrollView) {
  1170. NSInteger index = (NSInteger)(scrollView.contentOffset.x / (KPortraitWidth - 28));
  1171. [UIView animateWithDuration:0.3f animations:^{
  1172. self.buttonContainer.buttonDotLeft.constant = index * self.buttonDotWidth;
  1173. }];
  1174. }
  1175. }
  1176. #pragma mark ---- button container
  1177. - (HomeButtonView *)buttonContainer {
  1178. if (!_buttonContainer) {
  1179. _buttonContainer = [HomeButtonView shareInstance];
  1180. [_buttonContainer.buttonContentView addSubview:self.buttonScrollView];
  1181. }
  1182. return _buttonContainer;
  1183. }
  1184. - (UIScrollView *)buttonScrollView {
  1185. if (!_buttonScrollView) {
  1186. _buttonScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, KPortraitWidth, BUTTONHEIGHT)];
  1187. _buttonScrollView.backgroundColor = [UIColor clearColor];
  1188. _buttonScrollView.pagingEnabled = YES;
  1189. _buttonScrollView.showsHorizontalScrollIndicator = NO;
  1190. _buttonScrollView.showsVerticalScrollIndicator = NO;
  1191. _buttonScrollView.delegate = self;
  1192. }
  1193. return _buttonScrollView;
  1194. }
  1195. #pragma mark ---- notice view
  1196. - (PublicNoticeView *)noticeView {
  1197. if (!_noticeView) {
  1198. _noticeView = [PublicNoticeView shareInstance];
  1199. MJWeakSelf;
  1200. [_noticeView moreCallback:^{
  1201. [weakSelf moreNotice];
  1202. }];
  1203. }
  1204. return _noticeView;
  1205. }
  1206. - (NSMutableArray *)noticeArray {
  1207. if (!_noticeArray) {
  1208. _noticeArray = [NSMutableArray array];
  1209. }
  1210. return _noticeArray;
  1211. }
  1212. - (NSMutableArray *)noticeTitleArray {
  1213. if (!_noticeTitleArray) {
  1214. _noticeTitleArray = [NSMutableArray array];
  1215. }
  1216. return _noticeTitleArray;
  1217. }
  1218. - (void)moreNotice {
  1219. if (self.noticeArray.count) {
  1220. NoticeSourceModel *bannerModel = self.noticeArray[0];
  1221. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  1222. webCtrl.url = [NSString stringWithFormat:@"%@/#/helpCenterDetail?id=%@",WEBHOST, bannerModel.internalBaseClassIdentifier];
  1223. [self.navigationController pushViewController:webCtrl animated:YES];
  1224. }
  1225. }
  1226. - (SDCycleScrollView *)noticeScrollView {
  1227. if (!_noticeScrollView) {
  1228. _noticeScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImage new]];
  1229. _noticeScrollView.onlyDisplayText = YES;
  1230. _noticeScrollView.autoScroll = NO;
  1231. _noticeScrollView.scrollEnabled = NO;
  1232. _noticeScrollView.scrollDirection = UICollectionViewScrollDirectionVertical;
  1233. _noticeScrollView.titleLabelTextColor = HexRGB(0x1a1a1a);
  1234. _noticeScrollView.titleLabelBackgroundColor = [UIColor clearColor];
  1235. _noticeScrollView.titleLabelTextFont = [UIFont systemFontOfSize:14];
  1236. _noticeScrollView.titlesGroup = self.noticeTitleArray;
  1237. }
  1238. return _noticeScrollView;
  1239. }
  1240. - (HomeRecentCourseView *)courseView {
  1241. if (!_courseView) {
  1242. _courseView = [HomeRecentCourseView shareInstance];
  1243. MJWeakSelf;
  1244. [_courseView joinRoom:^(RECENTCOURSE_TYPE type, RecentCourseModel * _Nonnull courseModel) {
  1245. [weakSelf joinRoomAction:type courseMessage:courseModel];
  1246. }];
  1247. }
  1248. return _courseView;
  1249. }
  1250. - (void)joinRoomAction:(RECENTCOURSE_TYPE)type courseMessage:(RecentCourseModel *)courseModel {
  1251. if (type == RECENTCOURSE_TYPE_ACCOMPANY) {
  1252. AccompanyDetailViewController *detailVC = [[AccompanyDetailViewController alloc] init];
  1253. detailVC.courseId = courseModel.courseId;
  1254. detailVC.courseGroupId = courseModel.courseGroupId;
  1255. detailVC.teacherId = courseModel.teacherId;
  1256. [self.navigationController pushViewController:detailVC animated:YES];
  1257. }
  1258. else if (type == RECENTCOURSE_TYPE_MUSICCLASS) { // 琴房课
  1259. MusicRoomDetailViewController *detailVC = [[MusicRoomDetailViewController alloc] init];
  1260. detailVC.courseId = courseModel.courseId;
  1261. detailVC.courseGroupId = courseModel.courseGroupId;
  1262. detailVC.teacherId = courseModel.teacherId;
  1263. [self.navigationController pushViewController:detailVC animated:YES];
  1264. }
  1265. else {
  1266. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  1267. NSString *url = [NSString stringWithFormat:@"%@/#/liveDetail?joinRoom=1&groupId=%@&classId=%@", WEBHOST,courseModel.courseGroupId,courseModel.courseId];
  1268. ctrl.url = url;
  1269. [self.navigationController pushViewController:ctrl animated:YES];
  1270. }
  1271. }
  1272. #pragma mark ----- 专辑
  1273. - (HomeHotAlbumView *)albumView {
  1274. if (!_albumView) {
  1275. _albumView = [HomeHotAlbumView shareInstance];
  1276. MJWeakSelf;
  1277. [_albumView homeAlbumMore:^{
  1278. [weakSelf moreAlbumDetail];
  1279. }];
  1280. [_albumView.albumContentView addSubview:self.albumCollectionView];
  1281. [self.albumCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  1282. make.left.right.bottom.top.mas_equalTo(_albumView.albumContentView);
  1283. }];
  1284. }
  1285. return _albumView;
  1286. }
  1287. - (UICollectionView *)albumCollectionView {
  1288. if (!_albumCollectionView) {
  1289. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  1290. layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
  1291. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  1292. _albumCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  1293. _albumCollectionView.backgroundColor = [UIColor clearColor];
  1294. _albumCollectionView.delegate = self;
  1295. _albumCollectionView.dataSource = self;
  1296. _albumCollectionView.showsVerticalScrollIndicator = NO;
  1297. _albumCollectionView.showsHorizontalScrollIndicator = NO;
  1298. if (@available(iOS 11.0, *)) {
  1299. _albumCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  1300. } else {
  1301. // Fallback on earlier versions
  1302. if (@available(iOS 13.0, *)) {
  1303. _albumCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
  1304. } else {
  1305. // Fallback on earlier versions
  1306. }
  1307. }
  1308. [_albumCollectionView registerNib:[UINib nibWithNibName:@"HomeHotAlbumCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotAlbumCell"];
  1309. }
  1310. return _albumCollectionView;
  1311. }
  1312. - (void)moreAlbumDetail {
  1313. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  1314. ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/music-album"];
  1315. [self.navigationController pushViewController:ctrl animated:YES];
  1316. }
  1317. #pragma mark ---- 热门曲目
  1318. - (HomeHotMusicView *)hotMusicView {
  1319. if (!_hotMusicView) {
  1320. _hotMusicView = [HomeHotMusicView shareInstance];
  1321. MJWeakSelf;
  1322. [_hotMusicView homeMusicMore:^{
  1323. [weakSelf moreHotMusic];
  1324. }];
  1325. [_hotMusicView.musicContentView addSubview:self.musicCollectionView];
  1326. [self.musicCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  1327. make.left.right.bottom.top.mas_equalTo(_hotMusicView.musicContentView);
  1328. }];
  1329. }
  1330. return _hotMusicView;
  1331. }
  1332. - (void)moreHotMusic {
  1333. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  1334. ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/music-list"];
  1335. [self.navigationController pushViewController:ctrl animated:YES];
  1336. }
  1337. - (UICollectionView *)musicCollectionView {
  1338. if (!_musicCollectionView) {
  1339. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  1340. layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
  1341. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  1342. _musicCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  1343. _musicCollectionView.backgroundColor = [UIColor clearColor];
  1344. _musicCollectionView.delegate = self;
  1345. _musicCollectionView.dataSource = self;
  1346. _musicCollectionView.showsVerticalScrollIndicator = NO;
  1347. _musicCollectionView.showsHorizontalScrollIndicator = NO;
  1348. if (@available(iOS 11.0, *)) {
  1349. _musicCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  1350. } else {
  1351. // Fallback on earlier versions
  1352. if (@available(iOS 13.0, *)) {
  1353. _musicCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
  1354. } else {
  1355. // Fallback on earlier versions
  1356. }
  1357. }
  1358. [_musicCollectionView registerNib:[UINib nibWithNibName:@"HomeHotMusicCollectionCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotMusicCollectionCell"];
  1359. }
  1360. return _musicCollectionView;
  1361. }
  1362. #pragma mark ---- talent view
  1363. - (HomeHotTalentView *)talentView {
  1364. if (!_talentView) {
  1365. _talentView = [HomeHotTalentView shareInstance];
  1366. [_talentView.talentContentView addSubview:self.talentCollectionView];
  1367. [self.talentCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  1368. make.left.right.bottom.top.mas_equalTo(_talentView.talentContentView);
  1369. }];
  1370. }
  1371. return _talentView;
  1372. }
  1373. - (UICollectionView *)talentCollectionView {
  1374. if (!_talentCollectionView) {
  1375. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  1376. layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
  1377. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  1378. _talentCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  1379. _talentCollectionView.backgroundColor = [UIColor clearColor];
  1380. _talentCollectionView.delegate = self;
  1381. _talentCollectionView.dataSource = self;
  1382. _talentCollectionView.showsVerticalScrollIndicator = NO;
  1383. _talentCollectionView.showsHorizontalScrollIndicator = NO;
  1384. if (@available(iOS 11.0, *)) {
  1385. _talentCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  1386. } else {
  1387. // Fallback on earlier versions
  1388. if (@available(iOS 13.0, *)) {
  1389. _talentCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
  1390. } else {
  1391. // Fallback on earlier versions
  1392. }
  1393. }
  1394. [_talentCollectionView registerNib:[UINib nibWithNibName:@"HomeHotTalentCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotTalentCell"];
  1395. }
  1396. return _talentCollectionView;
  1397. }
  1398. #pragma mark ----- video course
  1399. - (HomeHotVideoCourseView *)videoCourseView {
  1400. if (!_videoCourseView) {
  1401. _videoCourseView = [HomeHotVideoCourseView shareInstance];
  1402. MJWeakSelf;
  1403. [_videoCourseView homeVideoMore:^{
  1404. [weakSelf toVideoMorePage];
  1405. }];
  1406. [_videoCourseView.videoContentView addSubview:self.videoCollectionView];
  1407. [self.videoCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  1408. make.left.right.bottom.top.mas_equalTo(_videoCourseView.videoContentView);
  1409. }];
  1410. }
  1411. return _videoCourseView;
  1412. }
  1413. - (UICollectionView *)videoCollectionView {
  1414. if (!_videoCollectionView) {
  1415. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  1416. layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
  1417. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  1418. _videoCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  1419. _videoCollectionView.backgroundColor = [UIColor clearColor];
  1420. _videoCollectionView.delegate = self;
  1421. _videoCollectionView.dataSource = self;
  1422. _videoCollectionView.showsVerticalScrollIndicator = NO;
  1423. _videoCollectionView.showsHorizontalScrollIndicator = NO;
  1424. if (@available(iOS 11.0, *)) {
  1425. _videoCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  1426. } else {
  1427. // Fallback on earlier versions
  1428. if (@available(iOS 13.0, *)) {
  1429. _videoCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
  1430. } else {
  1431. // Fallback on earlier versions
  1432. }
  1433. }
  1434. [_videoCollectionView registerNib:[UINib nibWithNibName:@"HomeHotVideoCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotVideoCell"];
  1435. }
  1436. return _videoCollectionView;
  1437. }
  1438. - (void)toVideoMorePage {
  1439. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  1440. ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/videoClass"];
  1441. [self.navigationController pushViewController:ctrl animated:YES];
  1442. }
  1443. #pragma mark ----- live course
  1444. - (HomeHotLiveCourseView *)liveCourseView {
  1445. if (!_liveCourseView) {
  1446. _liveCourseView = [HomeHotLiveCourseView shareInstance];
  1447. MJWeakSelf;
  1448. [_liveCourseView homeLiveMore:^{
  1449. [weakSelf toLiveMorePage];
  1450. }];
  1451. [_liveCourseView.liveContentView addSubview:self.liveCollectionView];
  1452. [self.liveCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  1453. make.left.right.bottom.top.mas_equalTo(_liveCourseView.liveContentView);
  1454. }];
  1455. }
  1456. return _liveCourseView;
  1457. }
  1458. - (UICollectionView *)liveCollectionView {
  1459. if (!_liveCollectionView) {
  1460. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  1461. layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
  1462. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  1463. _liveCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  1464. _liveCollectionView.backgroundColor = [UIColor clearColor];
  1465. _liveCollectionView.delegate = self;
  1466. _liveCollectionView.dataSource = self;
  1467. _liveCollectionView.showsVerticalScrollIndicator = NO;
  1468. _liveCollectionView.showsHorizontalScrollIndicator = NO;
  1469. if (@available(iOS 11.0, *)) {
  1470. _liveCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  1471. } else {
  1472. // Fallback on earlier versions
  1473. if (@available(iOS 13.0, *)) {
  1474. _liveCollectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
  1475. } else {
  1476. // Fallback on earlier versions
  1477. }
  1478. }
  1479. [_liveCollectionView registerNib:[UINib nibWithNibName:@"HomeHotLiveCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotLiveCell"];
  1480. }
  1481. return _liveCollectionView;
  1482. }
  1483. // 更多直播课
  1484. - (void)toLiveMorePage {
  1485. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  1486. ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/liveClass"];
  1487. [self.navigationController pushViewController:ctrl animated:YES];
  1488. }
  1489. - (NSMutableArray *)informationArray {
  1490. if (!_informationArray) {
  1491. _informationArray = [NSMutableArray array];
  1492. }
  1493. return _informationArray;
  1494. }
  1495. - (NSMutableArray *)teacherArray {
  1496. if (!_teacherArray) {
  1497. _teacherArray = [NSMutableArray array];
  1498. }
  1499. return _teacherArray;
  1500. }
  1501. - (NSMutableArray *)liveListArray {
  1502. if (!_liveListArray) {
  1503. _liveListArray = [NSMutableArray array];
  1504. }
  1505. return _liveListArray;
  1506. }
  1507. /*
  1508. #pragma mark - Navigation
  1509. // In a storyboard-based application, you will often want to do a little preparation before navigation
  1510. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  1511. // Get the new view controller using [segue destinationViewController].
  1512. // Pass the selected object to the new view controller.
  1513. }
  1514. */
  1515. @end