HomeViewController.m 58 KB

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