HomeViewController.m 61 KB

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