1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282 |
- //
- // HomeViewController.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/17.
- //
- #import "HomeViewController.h"
- #import "KSBaseWKWebViewController.h"
- #import "NotiferMessageViewController.h"
- #import "HomeNavView.h"
- #import "HomeBannerView.h"
- #import <UIButton+WebCache.h>
- #import "TYCyclePagerView.h"
- #import "TYPageControl.h"
- #import "HomeBannerCell.h"
- #import "HomeBannerView.h"
- #import "HomeBannerCell.h"
- #import "HomeButtonView.h"
- #import "KSHomeButton.h"
- #import "HomeHotAlbumView.h"
- #import "HomeHotAlbumCell.h"
- #import "HomeAlbumModel.h"
- #import "HomeIntroduceView.h"
- #import "TeacherShowCell.h"
- #import "HotInformationHeadView.h"
- #import "TeacherStyleModel.h"
- #import "HomeInformationCell.h"
- #import "HomeMessageModel.h"
- #import "StudentInfoModel.h"
- #import "UserInfoManager.h"
- #import "HomeCourseTipsView.h"
- #import "HomeLiveCourseView.h"
- #import "HomeVideoCourseView.h"
- #import "HomeLiveCouseCell.h"
- #import "HomeLiveGroupModel.h"
- #import "HomeVideoCourseCell.h"
- #import "HomeVideoGroupModel.h"
- #import "WMPlayer.h" // 播放相关
- #import "AppDelegate.h"
- #import "KSNewsAlert.h"
- #import "RecentCourseModel.h"
- #import "AccompanyDetailViewController.h"
- #import "KSOrderManager.h"
- #import "InstrumentChooseViewController.h"
- #define BUTTONWIDTH (65)
- #define BUTTONHEIGHT (80)
- @interface HomeViewController ()<TYCyclePagerViewDataSource,TYCyclePagerViewDelegate,UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,UICollectionViewDelegate, UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,WMPlayerDelegate>
- {
- WMPlayer *_wmPlayer;
- CGRect _playerFrame;
- }
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, assign) BOOL isRatation;
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) HomeNavView *navView;
- @property (nonatomic, strong) UIView *tableHeaderView; // headView;
- @property (nonatomic, strong) TYPageControl *pageControl;
- @property (nonatomic, strong) HomeBannerView *bannerView; // banner container
- @property (nonatomic, strong) TYCyclePagerView *bannerScroll; // 活动
- @property (nonatomic, strong) NSMutableArray *bannerArray; // banner 数据
- @property (nonatomic, assign) CGFloat bannerViewHeight; // banner 高度
- @property (nonatomic, strong) HomeButtonView *buttonContainer; // button container
- @property (nonatomic, strong) UIScrollView *buttonScrollView;
- @property (nonatomic, strong) NSMutableArray *buttonArray; // button 内容
- @property (nonatomic, assign) NSInteger buttonDotWidth;
- @property (nonatomic, assign) CGFloat buttonViewHeight; // button view 高度
- @property (nonatomic, strong) HomeHotAlbumView *albumView; // albumView container
- @property (nonatomic, strong) NSMutableArray *albumArray; // 热门专辑
- @property (nonatomic, strong) UICollectionView *albumCollectionView; // 专辑容器
- @property (nonatomic, assign) CGFloat albumViewHeight; // album 高度
- @property (nonatomic, strong) HomeLiveCourseView *liveView;
- @property (nonatomic, strong) HomeVideoCourseView *videoView;
- @property (nonatomic, strong) UITableView *liveCourseTable; // 直播课table
- @property (nonatomic, strong) UITableView *videoCourseTable; // 视频课table
- @property (nonatomic, strong) NSMutableArray *videoCourseArray;
- @property (nonatomic, strong) NSMutableArray *liveCourseArray;
- @property (nonatomic, assign) CGFloat liveViewHeight;
- @property (nonatomic, assign) CGFloat videoViewHeight;
- @property (nonatomic, strong) HomeIntroduceView *teacherView; // teacher container
- @property (nonatomic, strong) UICollectionView *infoCollectionView; // 老师风采简介
- @property (nonatomic, strong) NSMutableArray *teacherArray;
- @property (nonatomic, assign) CGFloat teachViewHeight;
- @property (nonatomic, strong) HotInformationHeadView *informationHeadView; // information Header
- @property (nonatomic, assign) CGFloat informationHeight;
- @property (nonatomic, strong) StudentInfoModel *mineInfo;
- @property (nonatomic, assign) BOOL hasCourseTips;
- @property (nonatomic, strong) HomeCourseTipsView *tipsCourseView;
- @property (nonatomic, assign) CGFloat tipsViewHeight;
- @property (nonatomic, assign) BOOL isChooseLive; // 是否选择直播课
- @property (nonatomic, assign) NSInteger courseCount;
- @property (nonatomic, assign) BOOL isFirstLoad;
- @end
- @implementation HomeViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- self.isChooseLive = YES;
- self.isFirstLoad = YES;
- [self configNavView];
- [self configUI];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- if (self.isFirstLoad == YES) {
- [self requestUserInfo:YES]; // 获取声部
-
- }
- else {
- [self requestUserInfo:NO];
- }
-
- [self requestUnreadCount];
- }
- - (void)requestUnreadCount {
- [KSNetworkingManager queryCountOfUnreadRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *countArray = [dic arrayValueForKey:@"data"];
- NSInteger courseCount = 0;
- NSInteger sysCount = 0;
- for (NSDictionary *parm in countArray) {
- if ([[parm stringValueForKey:@"key"] isEqualToString:@"COURSE"]) {
- courseCount = [parm integerValueForKey:@"value"];
- }
- if ([[parm stringValueForKey:@"key"] isEqualToString:@"SYSTEM"]) {
- sysCount = [parm integerValueForKey:@"value"];
- }
- }
- if (courseCount != 0 || sysCount != 0) {
- self.navView.dotView.hidden = NO;
- }
- else {
- self.navView.dotView.hidden = YES;
- }
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)configNavView {
- [self.scrollView removeFromSuperview];
- [self.view addSubview:self.navView];
- [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.mas_equalTo(self.view);
- make.height.mas_equalTo(kNaviBarHeight);
- }];
- }
- - (void)configUI {
- [self.scrollView removeFromSuperview];
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.mas_equalTo(self.view);
- make.top.mas_equalTo(self.navView.mas_bottom);
- }];
- if (@available(iOS 11.0, *)) {
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- // Fallback on earlier versions
- self.automaticallyAdjustsScrollViewInsets = NO;
- }
- self.tableView.tableHeaderView = self.tableHeaderView;
- MJWeakSelf;
- self.tableView.mj_header = [KSGifRefreshHeader headerWithRefreshingBlock:^{
- [weakSelf requestData];
- }];
-
- // 配置 首页显示
- [self addDisplayView];
- }
- - (void)addDisplayView {
- CGFloat tableHeaderHeight = 0.0f;
- [self.tableHeaderView addSubview:self.bannerView];
- // banner
- self.bannerViewHeight = [HomeBannerView getViewHeight];
- tableHeaderHeight += self.bannerViewHeight;
- [self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.tableHeaderView);
- make.top.mas_equalTo(self.tableHeaderView.mas_top);
- make.height.mas_equalTo(self.bannerViewHeight);
- }];
- // button
- [self.tableHeaderView addSubview:self.buttonContainer];
- self.buttonViewHeight = [HomeButtonView getViewHeight];
- [self.buttonContainer mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.tableHeaderView);
- make.top.mas_equalTo(self.bannerView.mas_bottom);
- make.height.mas_equalTo(self.buttonViewHeight);
- }];
- tableHeaderHeight += self.buttonViewHeight;
-
- // 课程提醒
- [self.tableHeaderView addSubview:self.tipsCourseView];
- self.tipsViewHeight = CGFLOAT_MIN;
- self.tipsCourseView.hidden = YES;
- [self.tipsCourseView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.tableHeaderView);
- make.top.mas_equalTo(self.buttonContainer.mas_bottom);
- make.height.mas_equalTo(self.tipsViewHeight);
- }];
- tableHeaderHeight += self.tipsViewHeight;
- // 专辑
- [self.tableHeaderView addSubview:self.albumView];
- self.albumViewHeight = [HomeHotAlbumView getViewHeight];
- [self.albumView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.tableHeaderView);
- make.top.mas_equalTo(self.tipsCourseView.mas_bottom);
- make.height.mas_equalTo(self.albumViewHeight);
- }];
- tableHeaderHeight += self.albumViewHeight;
-
- // 直播课
- [self.tableHeaderView addSubview:self.liveView];
- self.liveViewHeight = [self.liveView getViewHeightWithCount:10];
- [self.liveView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.tableHeaderView);
- make.top.mas_equalTo(self.albumView.mas_bottom);
- make.height.mas_equalTo(self.liveViewHeight);
- }];
- tableHeaderHeight += self.liveViewHeight;
-
- // 视频课
- [self.tableHeaderView addSubview:self.videoView];
- self.videoViewHeight = [self.videoView getViewHeightWithCount:10];
- [self.videoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.tableHeaderView);
- make.top.mas_equalTo(self.liveView.mas_bottom);
- make.height.mas_equalTo(self.videoViewHeight);
- }];
- tableHeaderHeight += self.videoViewHeight;
-
- // 老师风采
- [self.tableHeaderView addSubview:self.teacherView];
- self.teachViewHeight = [self.teacherView getViewHeightWithSourceCount:4];
-
- [self.teacherView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.tableHeaderView);
- make.top.mas_equalTo(self.videoView.mas_bottom);
- make.height.mas_equalTo(self.teachViewHeight);
- }];
- tableHeaderHeight += self.teachViewHeight;
-
- [self.tableHeaderView addSubview:self.informationHeadView];
- self.informationHeight = [HotInformationHeadView getViewHeight];
- [self.informationHeadView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.tableHeaderView);
- make.top.mas_equalTo(self.teacherView.mas_bottom);
- make.height.mas_equalTo(self.informationHeight);
- }];
- tableHeaderHeight += self.informationHeight;
- self.tableHeaderView.frame = CGRectMake(0, 0, KPortraitWidth, tableHeaderHeight);
- [self.tableView reloadData];
- }
- - (void)refreshTableHeadHeight {
- CGFloat tableHeaderHeight = self.bannerViewHeight + self.buttonViewHeight + self.tipsViewHeight + self.albumViewHeight + self.liveViewHeight + self.videoViewHeight + self.teachViewHeight + self.informationHeight;
- self.tableHeaderView.frame = CGRectMake(0, 0, KPortraitWidth, tableHeaderHeight);
- [self.tableView reloadData];
- }
- - (void)requestData {
- [self requestNewsList]; //
- [self requestCourseInfo];
- [self requestTeacherStyle];
- [self requestHotAlbum];
- }
- - (void)requestNewsList {
- [KSNetworkingManager homeNewsList:KS_POST success:^(NSDictionary * _Nonnull dic) {
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSDictionary *result = [dic dictionaryValueForKey:@"data"];
- // banner
- NSArray *bannerArray = [result arrayValueForKey:@"banner"];
- NSMutableArray *bannerInfoArray = [NSMutableArray array];
- for (NSDictionary *parm in bannerArray) {
- HomeMessageModel *model = [[HomeMessageModel alloc] initWithDictionary:parm];
- [bannerInfoArray addObject:model];
- }
- self.bannerArray = [NSMutableArray arrayWithArray:bannerInfoArray];
- [self.bannerScroll reloadData];
-
- // button
- NSArray *buttonArray = [result arrayValueForKey:@"appMenu"];
- NSMutableArray *buttonInfoArray = [NSMutableArray array];
- for (NSDictionary *parm in buttonArray) {
- HomeMessageModel *model = [[HomeMessageModel alloc] initWithDictionary:parm];
- [buttonInfoArray addObject:model];
- }
- self.buttonArray = [NSMutableArray arrayWithArray:buttonInfoArray];
- [self showButtonMessage];
-
- // news
- NSArray *flashArray = [result arrayValueForKey:@"flashPage"];
- if (flashArray.count) {
- HomeMessageModel *newsModel = [[HomeMessageModel alloc] initWithDictionary:[flashArray firstObject]];
- [self showNewsWithSource:newsModel];
- }
-
- // information
- NSArray *information = [result arrayValueForKey:@"information"];
- NSMutableArray *informationInfoArray = [NSMutableArray array];
- for (NSDictionary *parm in information) {
- HomeMessageModel *model = [[HomeMessageModel alloc] initWithDictionary:parm];
- [informationInfoArray addObject:model];
- }
- self.dataArray = [NSMutableArray arrayWithArray:informationInfoArray];
- [self.tableView reloadData];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)requestHotAlbum {
- [KSNetworkingManager HomeHotAlbumRequest:KS_POST page:1 rows:10 success:^(NSDictionary * _Nonnull dic) {
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
- NSMutableArray *albumArray = [NSMutableArray array];
- for (NSDictionary *parm in sourceArray) {
- HomeAlbumModel *model = [[HomeAlbumModel alloc] initWithDictionary:parm];
- [albumArray addObject:model];
- }
- self.albumArray = [NSMutableArray arrayWithArray:albumArray];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- [self refreshAlbumView];
-
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)refreshAlbumView {
- if (self.albumArray.count) {
- self.albumViewHeight = [HomeHotAlbumView getViewHeight];
- self.albumView.hidden = NO;
- }
- else {
- self.albumViewHeight = CGFLOAT_MIN;
- self.albumView.hidden = YES;
- }
- [self.albumView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(self.albumViewHeight);
- }];
- [self.albumCollectionView reloadData];
- [self refreshTableHeadHeight];
- }
- - (void)requestCourseInfo {
-
- // [self showhud];
- [KSNetworkingManager homeQueryLiveAndVideo:KS_GET success:^(NSDictionary * _Nonnull dic) {
- // [self removehub];
- [self.tableView.mj_header endRefreshing];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSDictionary *sourceDic = [dic dictionaryValueForKey:@"data"];
- NSArray *liveList = [sourceDic arrayValueForKey:@"liveList"];
- NSMutableArray *liveCourse = [NSMutableArray array];
- for (NSDictionary *parm in liveList) {
- HomeLiveGroupModel *model = [[HomeLiveGroupModel alloc] initWithDictionary:parm];
- [liveCourse addObject:model];
- }
- self.liveCourseArray = [NSMutableArray arrayWithArray:liveCourse];
-
- NSArray *videoList = [sourceDic arrayValueForKey:@"videoList"];
- NSMutableArray *videoCourse = [NSMutableArray array];
- for (NSDictionary *parm in videoList) {
- HomeVideoGroupModel *model = [[HomeVideoGroupModel alloc] initWithDictionary:parm];
- [videoCourse addObject:model];
- }
- self.videoCourseArray = [NSMutableArray arrayWithArray:videoCourse];
-
- // 最近课程
- NSDictionary *parm = [sourceDic dictionaryValueForKey:@"recentCourses"];
- if (parm == nil) {
- [self refreshCourseView:nil];
- }
- else {
- RecentCourseModel *model = [[RecentCourseModel alloc] initWithDictionary:parm];
- [self refreshCourseView:model];
- }
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- [self refreshCourseView];
- } faliure:^(NSError * _Nonnull error) {
- [self removehub];
- [self.tableView.mj_header endRefreshing];
- }];
- }
- - (void)refreshCourseView:(RecentCourseModel *)model {
- if (model) {
- self.tipsViewHeight = 80.0f;
- [self.tipsCourseView configWithCourseMessage:model];
- self.tipsCourseView.hidden = NO;
- [self.tipsCourseView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(80.0f);
- }];
- }
- else {
- self.tipsViewHeight = CGFLOAT_MIN;
- self.tipsCourseView.hidden = YES;
- [self.tipsCourseView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(CGFLOAT_MIN);
- }];
- }
- [self refreshTableHeadHeight];
- }
- - (void)refreshCourseView {
- // 课程
- if (self.liveCourseArray.count) {
- self.liveViewHeight = [self.liveView getViewHeightWithCount:self.liveCourseArray.count];
- self.liveView.hidden = NO;
- }
- else {
- self.liveViewHeight = CGFLOAT_MIN;
- self.liveView.hidden = YES;
- }
- [self.liveView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(self.liveViewHeight);
- }];
- if (self.videoCourseArray.count) {
- self.videoViewHeight = [self.videoView getViewHeightWithCount:self.videoCourseArray.count];
- self.videoView.hidden = NO;
- }
- else {
- self.videoViewHeight = CGFLOAT_MIN;
- self.videoView.hidden = YES;
- }
- [self.videoView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(self.videoViewHeight);
- }];
-
- [self.liveCourseTable reloadData];
- [self.videoCourseTable reloadData];
- [self refreshTableHeadHeight];
- }
- - (void)requestUserInfo:(BOOL)checkSubject {
- self.isFirstLoad = NO;
- [KSNetworkingManager queryStudentInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- self.mineInfo = [[StudentInfoModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
- NSString *rongToken = UserDefault(RongTokenKey);
- if ([NSString isEmptyString:rongToken]) {
- [USER_MANAGER queryUserInfoConnectRongCloud:YES];
- }
- [self refreshNavView:checkSubject];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)requestTeacherStyle {
-
- [KSNetworkingManager homeQueryTeacherStyle:KS_POST page:1 rows:10 success:^(NSDictionary * _Nonnull dic) {
-
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
- NSMutableArray *styleArray = [NSMutableArray array];
- for (NSDictionary *parm in sourceArray) {
- TeacherStyleModel *model = [[TeacherStyleModel alloc] initWithDictionary:parm];
- [styleArray addObject:model];
- }
- self.teacherArray = [NSMutableArray arrayWithArray:styleArray];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- // 回调
- [self refreshTeachView];
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)refreshTeachView {
- if (self.teacherArray.count) {
- self.teachViewHeight = [self.teacherView getViewHeightWithSourceCount:self.teacherArray.count];
- self.teacherView.hidden = NO;
- }
- else {
- self.teachViewHeight = CGFLOAT_MIN;
- self.teacherView.hidden = YES;
- }
- [self.teacherView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(self.teachViewHeight);
- }];
- [self.infoCollectionView reloadData];
- [self refreshTableHeadHeight];
- }
- - (void)refreshNavView:(BOOL)checkSubject {
- if (checkSubject) {
- if ([NSString isEmptyString:self.mineInfo.subjectName]) {
- [self showInstrumentView:YES];
- }
- else {
- [self requestData];
- }
- }
-
- [self.navView.userAvatal sd_setImageWithURL:[NSURL URLWithString:[self.mineInfo.heardUrl getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
- NSString *userName = @"";
- if ([NSString isEmptyString:self.mineInfo.username]) {
- userName = [NSString stringWithFormat:@"游客%@",self.mineInfo.userId];
- }
- else {
- userName = self.mineInfo.username;
- }
- self.navView.userName.text = userName;
- }
- - (void)refreshBannaerView {
- if (self.bannerArray.count > 1) {
- self.bannerScroll.autoScrollInterval = 3.0f;
- [self.bannerScroll addSubview:self.pageControl];
- }
- else {
- self.bannerScroll.autoScrollInterval = 0;
- [self.pageControl removeFromSuperview];
- }
- _pageControl.numberOfPages = self.bannerArray.count;
- [self.bannerScroll reloadData];
- }
- - (void)showButtonMessage {
- // 添加按钮
- if (self.buttonArray.count > 5) { // 大于4个显示底部滚动视图
- self.buttonContainer.buttonPageCtrl.hidden = NO;
- self.buttonContainer.buttonDotLeft.constant = 0;
- NSInteger addPage = (self.buttonArray.count % 5) > 0 ? 1 : 0;
- NSInteger pageCount = self.buttonArray.count / 5 + addPage;
- self.buttonDotWidth = 36 / pageCount;
- self.buttonContainer.buttonDotWidth.constant = self.buttonDotWidth;
- self.buttonScrollView.contentSize = CGSizeMake(kScreenWidth * pageCount, BUTTONHEIGHT);
- }
- else {
- self.buttonContainer.buttonPageCtrl.hidden = YES;
- self.buttonScrollView.contentSize = CGSizeMake(kScreenWidth, BUTTONHEIGHT);
- }
-
- self.buttonScrollView.contentOffset = CGPointMake(0, 0);
- [self.buttonScrollView removeAllSubViews];
- CGFloat buttonSpace = (kScreenWidth - 5 * BUTTONWIDTH) / 6;
- for (NSInteger i = 0; i < self.buttonArray.count; i++) {
- HomeMessageModel *model = self.buttonArray[i];
- KSHomeButton *buttonView = [KSHomeButton shareInstance];
-
- [buttonView.buttonImage sd_setImageWithURL:[NSURL URLWithString:[model.coverImage getUrlEndcodeString]]];
- buttonView.buttonTitle.text = model.title;
- buttonView.frame = CGRectMake(buttonSpace + (i % 5) * (BUTTONWIDTH + buttonSpace) + (i / 5) * KPortraitWidth, 0, BUTTONWIDTH, BUTTONHEIGHT);
- buttonView.actionButton.tag = 3000 + i;
- [buttonView.actionButton addTarget:self action:@selector(HomeTopButtonAction:) forControlEvents:UIControlEventTouchUpInside];
- [self.buttonScrollView addSubview:buttonView];
- }
- }
- - (void)HomeTopButtonAction:(UIButton *)sender {
- NSInteger index = sender.tag - 3000;
- if ([self checkIsLoginToLoginView:YES]) {
- HomeMessageModel *model = self.buttonArray[index];
- if (![NSString isEmptyString:model.linkUrl]) {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = model.linkUrl;
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- }
- }
- #pragma mark - TYCyclePagerViewDataSource代理
- - (NSInteger)numberOfItemsInPagerView:(TYCyclePagerView *)pageView {
- return self.bannerArray.count;
- }
- - (UICollectionViewCell *)pagerView:(TYCyclePagerView *)pagerView cellForItemAtIndex:(NSInteger)index {
- HomeMessageModel *model = self.bannerArray[index];
- HomeBannerCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"HomeBannerCell" forIndex:index];
- [cell configCellWithModel:model];
- return cell;
- }
- - (TYCyclePagerViewLayout *)layoutForPagerView:(TYCyclePagerView *)pageView {
- TYCyclePagerViewLayout *layout = [[TYCyclePagerViewLayout alloc]init];
- layout.itemSize = CGSizeMake(CGRectGetWidth(pageView.frame), CGRectGetHeight(pageView.frame));
- layout.itemSpacing = 0;
- return layout;
-
- }
- - (void)pagerView:(TYCyclePagerView *)pageView didScrollFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex {
- if (pageView == self.bannerScroll) {
- [self.pageControl setCurrentPage:toIndex animate:YES];
- }
- }
- - (void)pagerView:(TYCyclePagerView *)pageView didSelectedItemCell:(__kindof UICollectionViewCell *)cell atIndex:(NSInteger)index {
-
- HomeMessageModel *model = self.bannerArray[index];
- if (![NSString isEmptyString:model.linkUrl]) {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = model.linkUrl;
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- }
- #pragma mark ----- table data source
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- if (tableView == self.tableView) { // 资讯
- return self.dataArray.count;
- }
- else if (tableView == self.liveCourseTable) { // 直播课列表
- return self.liveCourseArray.count;
- }
- else { // 视频课列表
- return self.videoCourseArray.count;
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (tableView == self.tableView) {
- HomeMessageModel *model = self.dataArray[indexPath.row];
- HomeInformationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HomeInformationCell"];
- ROWINDEX rowIndex = ROWINDEX_MIDDLE;
- if (indexPath.row == 0) {
- rowIndex = ROWINDEX_TOP;
- }
- else if (indexPath.row == self.dataArray.count - 1) {
- rowIndex = ROWINDEX_BOTTOM;
- }
- [cell configCellWithSource:model rowIndex:rowIndex];
- return cell;
- }
- else if (tableView == self.liveCourseTable) {
- HomeLiveGroupModel *model = self.liveCourseArray[indexPath.row];
- HomeLiveCouseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HomeLiveCouseCell"];
- [cell configWithSource:model];
- return cell;
- }
- else {
- HomeVideoGroupModel *model = self.videoCourseArray[indexPath.row];
- HomeVideoCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HomeVideoCourseCell"];
- [cell configWithSource:model];
- return cell;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- if (tableView == self.tableView) {
- HomeMessageModel *model = self.dataArray[indexPath.row];
- if (![NSString isEmptyString:model.linkUrl]) {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = model.linkUrl;
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- else {
- // 跳转
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@%@",WEBHOST,@"/#/specialdetail?id=",model.internalBaseClassIdentifier];
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- }
- else if (tableView == self.liveCourseTable) { // 直播课详情
- HomeLiveGroupModel *model = self.liveCourseArray[indexPath.row];
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- NSString *url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/liveDetail?groupId=",model.courseGroupId];
- ctrl.url = url;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- else if (tableView == self.videoCourseTable) { //
- HomeVideoGroupModel *model = self.videoCourseArray[indexPath.row];
- NSString *url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/videoDetail?groupId=",model.videoGroupId];
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = url;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- }
- #pragma mark ---- collection data source
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- if (collectionView == self.albumCollectionView) {
- return self.albumArray.count;
- }
- else { // 老师风采
- return self.teacherArray.count;
- }
- }
- - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- if (collectionView == self.albumCollectionView) {
- HomeAlbumModel *model = self.albumArray[indexPath.item];
- HomeHotAlbumCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHotAlbumCell" forIndexPath:indexPath];
- [cell configWithAlbumModel:model];
- return cell;
- }
- else {
- TeacherStyleModel *model = self.teacherArray[indexPath.item];
- TeacherShowCell *showCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TeacherShowCell" forIndexPath:indexPath];
- MJWeakSelf;
- [showCell configWithStyleModel:model callback:^(NSString *videoUrl) {
- [weakSelf playVideo:videoUrl];
- }];
- return showCell;
- }
- }
- - (void)playVideo:(NSString *)videoUrl {
- if ([NSString isEmptyString:videoUrl]) {
- return;
- }
- // 播放视频
- [self playVideoWithUrl:videoUrl];
-
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- if (collectionView == self.albumCollectionView) { // 专辑详情
- HomeAlbumModel *model = self.albumArray[indexPath.item];
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/music-album-detail/",model.internalBaseClassIdentifier];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- else { // 老师风采详情
- TeacherStyleModel *model = self.teacherArray[indexPath.item];
- [self displayTeacherDetail:model.userId];
- }
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
- if (collectionView == self.albumCollectionView) {
- return CGSizeMake(110, 140);
- }
- else {
- return CGSizeMake((KPortraitWidth - 28 - 11) / 2.0f, 164);
- }
- }
- // 老师风采
- - (void)displayTeacherDetail:(NSString *)teacherId {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/teacherHome?teacherId=",teacherId];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- #pragma mark ---- scroll view delegate
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- if (scrollView == self.buttonScrollView) {
- NSInteger index = (NSInteger)(scrollView.contentOffset.x / kScreenWidth);
-
- [UIView animateWithDuration:0.3f animations:^{
- self.buttonContainer.buttonDotLeft.constant = index * self.buttonDotWidth;
- }];
- }
- }
-
- #pragma mark ---- lazying
- - (NSMutableArray *)buttonArray {
- if (!_buttonArray) {
- _buttonArray = [NSMutableArray array];
- }
- return _buttonArray;
- }
- - (NSMutableArray *)bannerArray {
- if (!_bannerArray) {
- _bannerArray = [NSMutableArray array];
- }
- return _bannerArray;
- }
- - (NSMutableArray *)albumArray {
- if (!_albumArray) {
- _albumArray = [NSMutableArray array];
- }
- return _albumArray;
- }
- - (NSMutableArray *)liveCourseArray {
- if (!_liveCourseArray) {
- _liveCourseArray = [NSMutableArray array];
- }
- return _liveCourseArray;
- }
- - (NSMutableArray *)videoCourseArray {
- if (!_videoCourseArray) {
- _videoCourseArray = [NSMutableArray array];
- }
- return _videoCourseArray;
- }
- - (NSMutableArray *)teacherArray {
- if (!_teacherArray) {
- _teacherArray = [NSMutableArray array];
- }
- return _teacherArray;
- }
- #pragma mark ----- 最近上课
- - (HomeCourseTipsView *)tipsCourseView {
- if (!_tipsCourseView) {
- _tipsCourseView = [HomeCourseTipsView shareInstance];
- MJWeakSelf;
- [_tipsCourseView joinRoomCallback:^(COURSETYPE type, RecentCourseModel * _Nonnull courseModel) {
- [weakSelf joinRoomAction:type courseMessage:courseModel];
- }];
- }
- return _tipsCourseView;
- }
- - (void)joinRoomAction:(COURSETYPE)type courseMessage:(RecentCourseModel *)courseModel {
- if (type == COURSETYPE_ACCOMPANY) { // 陪练课详情
- AccompanyDetailViewController *detailVC = [[AccompanyDetailViewController alloc] init];
- detailVC.courseId = courseModel.courseId;
- detailVC.courseGroupId = courseModel.courseGroupId;
- detailVC.teacherId = courseModel.teacherId;
- [self.navigationController pushViewController:detailVC animated:YES];
- }
- else { // 直播课详情
-
- }
- }
- #pragma mark ----- 专辑
- - (HomeHotAlbumView *)albumView {
- if (!_albumView) {
- _albumView = [HomeHotAlbumView shareInstance];
- MJWeakSelf;
- [_albumView homeAlbumMore:^{
- [weakSelf moreAlbumDetail];
- }];
- [_albumView.albumContentView addSubview:self.albumCollectionView];
- [self.albumCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.top.mas_equalTo(_albumView.albumContentView);
- }];
- }
- return _albumView;
- }
- - (UICollectionView *)albumCollectionView {
- if (!_albumCollectionView) {
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
- layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
- _albumCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
- _albumCollectionView.backgroundColor = [UIColor clearColor];
- _albumCollectionView.delegate = self;
- _albumCollectionView.dataSource = self;
- _albumCollectionView.showsVerticalScrollIndicator = NO;
- _albumCollectionView.showsHorizontalScrollIndicator = NO;
- [_albumCollectionView registerNib:[UINib nibWithNibName:@"HomeHotAlbumCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomeHotAlbumCell"];
- }
- return _albumCollectionView;
- }
- - (void)moreAlbumDetail {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/music-album"];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- #pragma mark ------ 推荐课程
- - (HomeLiveCourseView *)liveView {
- if (!_liveView) {
- _liveView = [HomeLiveCourseView shareInstance];
- MJWeakSelf;
- [_liveView hotLiveMore:^{
- [weakSelf toLiveMorePage];
- }];
- [_liveView addSubview:self.liveCourseTable];
- [self.liveCourseTable mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.top.mas_equalTo(_liveView.liveContainer);
- }];
- }
- return _liveView;
- }
- // 更多直播
- - (void)toLiveMorePage {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/liveClass"];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (HomeVideoCourseView *)videoView {
- if (!_videoView) {
- _videoView = [HomeVideoCourseView shareInstance];
- MJWeakSelf;
- [_videoView moreHotVideo:^{
- [weakSelf toLiveMorePage];
- }];
- [_videoView addSubview:self.videoCourseTable];
- [self.videoCourseTable mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.top.mas_equalTo(_videoView.videoContainer);
- }];
- }
- return _videoView;
- }
- - (void)toVideoMorePage {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/videoClass"];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (UITableView *)liveCourseTable {
- if (!_liveCourseTable) {
- _liveCourseTable = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _liveCourseTable.delegate = self;
- _liveCourseTable.dataSource = self;
- _liveCourseTable.rowHeight = 126;
- _liveCourseTable.separatorStyle = UITableViewCellSeparatorStyleNone;
- _liveCourseTable.backgroundColor = [UIColor clearColor];
- _liveCourseTable.showsVerticalScrollIndicator = NO;
- [_liveCourseTable registerNib:[UINib nibWithNibName:@"HomeLiveCouseCell" bundle:nil] forCellReuseIdentifier:@"HomeLiveCouseCell"];
- _liveCourseTable.scrollEnabled = NO;
- }
- return _liveCourseTable;
- }
- - (UITableView *)videoCourseTable {
- if (!_videoCourseTable) {
- _videoCourseTable = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _videoCourseTable.delegate = self;
- _videoCourseTable.dataSource = self;
- _videoCourseTable.rowHeight = 126;
- _videoCourseTable.separatorStyle = UITableViewCellSeparatorStyleNone;
- _videoCourseTable.backgroundColor = [UIColor clearColor];
- _videoCourseTable.showsVerticalScrollIndicator = NO;
- [_videoCourseTable registerNib:[UINib nibWithNibName:@"HomeVideoCourseCell" bundle:nil] forCellReuseIdentifier:@"HomeVideoCourseCell"];
- _videoCourseTable.scrollEnabled = NO;
- }
- return _videoCourseTable;
- }
- #pragma mark --- 老师风采
- - (HomeIntroduceView *)teacherView {
- if (!_teacherView) {
- _teacherView = [HomeIntroduceView shareInstance];
- MJWeakSelf;
- [_teacherView introduceMore:^{
- [weakSelf teacherMoreIntorduce];
- }];
- [_teacherView.teacherContainer addSubview:self.infoCollectionView];
- [self.infoCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.top.mas_equalTo(_teacherView.teacherContainer);
- make.left.mas_equalTo(_teacherView.mas_left).offset(14);
- make.right.mas_equalTo(_teacherView.mas_right).offset(-14);
- }];
- }
- return _teacherView;
- }
- - (void)teacherMoreIntorduce {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherElegant"];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (UICollectionView *)infoCollectionView {
- if (!_infoCollectionView) {
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- layout.scrollDirection = UICollectionViewScrollDirectionVertical;
- _infoCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
- _infoCollectionView.backgroundColor = [UIColor clearColor];
- _infoCollectionView.delegate = self;
- _infoCollectionView.dataSource = self;
- _infoCollectionView.showsVerticalScrollIndicator = NO;
- _infoCollectionView.showsHorizontalScrollIndicator = NO;
- [_infoCollectionView registerNib:[UINib nibWithNibName:@"TeacherShowCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"TeacherShowCell"];
- }
- return _infoCollectionView;
- }
- #pragma mark ---- button container
- - (HomeButtonView *)buttonContainer {
- if (!_buttonContainer) {
- _buttonContainer = [HomeButtonView shareInstance];
- [_buttonContainer.buttonContentView addSubview:self.buttonScrollView];
- }
- return _buttonContainer;
- }
- - (UIScrollView *)buttonScrollView {
- if (!_buttonScrollView) {
- _buttonScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, KPortraitWidth, BUTTONHEIGHT)];
- _buttonScrollView.backgroundColor = [UIColor clearColor];
- _buttonScrollView.pagingEnabled = YES;
- _buttonScrollView.showsHorizontalScrollIndicator = NO;
- _buttonScrollView.showsVerticalScrollIndicator = NO;
- _buttonScrollView.delegate = self;
- }
- return _buttonScrollView;
- }
- - (UIView *)tableHeaderView {
- if (!_tableHeaderView) {
- _tableHeaderView = [[UIView alloc] initWithFrame:CGRectZero];
- _tableHeaderView.backgroundColor = [UIColor clearColor];
- }
- return _tableHeaderView;
- }
- - (HomeBannerView *)bannerView {
- if (!_bannerView) {
- _bannerView = [HomeBannerView shareInstance];
- [_bannerView.bannerContentView addSubview:self.bannerScroll];
- }
- return _bannerView;
- }
- - (TYCyclePagerView *)bannerScroll {
- if (!_bannerScroll) {
- _bannerScroll = [[TYCyclePagerView alloc] init];
- _bannerScroll.backgroundColor = [UIColor clearColor];
- _bannerScroll.frame = CGRectMake(0, 0, kScreenWidth - 28, (kScreenWidth - 28) / 347 * 132);
- _bannerScroll.isInfiniteLoop = YES;
- _bannerScroll.autoScrollInterval = 3.0f;
- _bannerScroll.reloadDataNeedResetIndex = YES;
- _bannerScroll.dataSource = self;
- _bannerScroll.delegate = self;
- [_bannerScroll registerNib:[UINib nibWithNibName:@"HomeBannerCell" bundle:nil] forCellWithReuseIdentifier:@"HomeBannerCell"];
- }
- return _bannerScroll;
- }
- #pragma mark ---- 更多资讯
- - (HotInformationHeadView *)informationHeadView {
- if (!_informationHeadView) {
- _informationHeadView = [HotInformationHeadView shareInstance];
-
- MJWeakSelf;
- [_informationHeadView moreInformationCallback:^{
- [weakSelf moreInformation];
- }];
- }
- return _informationHeadView;
- }
- - (void)moreInformation {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/special"];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.rowHeight = 108;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.backgroundColor = [UIColor clearColor];
- _tableView.showsVerticalScrollIndicator = NO;
- [_tableView registerNib:[UINib nibWithNibName:@"HomeInformationCell" bundle:nil] forCellReuseIdentifier:@"HomeInformationCell"];
- UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
- bottomView.backgroundColor = [UIColor clearColor];
- _tableView.tableFooterView = bottomView;
- }
- return _tableView;
- }
- - (HomeNavView *)navView {
- if (!_navView) {
- _navView = [HomeNavView shareInstance];
- MJWeakSelf;
- [_navView homeNavAction:^(NAVACTION action) {
- [weakSelf navAction:action];
- }];
- }
- return _navView;
- }
- - (void)navAction:(NAVACTION)action {
- if (action == NAVACTION_SUBJECT) {
- [self showInstrumentView:NO];
- }
- else { // 消息中心
- // [KSOrderManager dealWithAliSDK:@"alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=2021000119694065&biz_content=%7B%22out_trade_no%22%3A%2222052519503900001%22%2C%22total_amount%22%3A%220.01%22%2C%22subject%22%3A%22VIP%E6%9C%88%E5%8D%A1%E8%B4%AD%E4%B9%B0%22%2C%22goods_detail%22%3A%5B%7B%22goods_name%22%3A%22VIP%E6%9C%88%E5%8D%A1%E8%B4%AD%E4%B9%B0%22%2C%22quantity%22%3A1%2C%22price%22%3A%220.01%22%2C%22goods_id%22%3A%22446%22%7D%5D%2C%22merchant_order_no%22%3A%2222052519495600001%22%7D&charset=UTF-8&format=json&method=alipay.trade.app.pay¬ify_url=http%3A%2F%2F47.114.1.200%3A8000%2Fapi-student%2Fpayment%2Fcallback%2FORIGINAL%2Fali_app%2FexecutePayment&sign=QdyUZnRs%2BY5HLzJbx42aXQHtg7zk1RCx609Fz%2F5tyjBrUP6lTkpfw5o4gZNRgveZGUTf8007m2jiCrRn%2BMOubJyIBW6pVVyTmQ8FbmnZa0bvHrNLh4yNRehEL2fIn40zMgosiQE2YibfZN9v5IGbHFT56O4KFBCeb1jzrPDlEaCBRealKEclYFMPKm9JSZ0roEB84gq6n9nHQP%2BlY%2FIkpjtcD1LWdBb1YSAHvrZpX%2F%2FX71seqzTPJhx8Kik9aGiMptfcursaenYHtV8UMiNiU1Vv7BoLsUM5Q31p0bDfWYogaDHMatPUKoP6x20S%2BRrJzZbSORA5xG6Qnrafnu2OLw%3D%3D&sign_type=RSA2×tamp=2022-05-25+19%3A50%3A39&version=1.0"];
-
- NotiferMessageViewController *ctrl = [[NotiferMessageViewController alloc] init];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- }
- - (void)showInstrumentView:(BOOL)hideBackButton {
- InstrumentChooseViewController *ctrl = [[InstrumentChooseViewController alloc] init];
- MJWeakSelf;
- [ctrl chooseCallback:^{
- [weakSelf requestUserInfo:NO];
- [weakSelf requestData];
- }];
- if (hideBackButton) {
- ctrl.isModalPresent = YES;
- CustomNavViewController *navCrtl = [[CustomNavViewController alloc] initWithRootViewController:ctrl];
- navCrtl.modalPresentationStyle = UIModalPresentationFullScreen;
- [self.navigationController presentViewController:navCrtl animated:YES completion:nil];
- }
- else {
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- }
- #pragma mark ------ WMPlayer
- - (void)playVideoWithUrl:(NSString *)fileUrl {
- fileUrl = [fileUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
- _playerFrame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
- _wmPlayer = [[WMPlayer alloc] initWithFrame:_playerFrame];
- WMPlayerModel *playModel = [[WMPlayerModel alloc] init];
- playModel.videoURL = [NSURL URLWithString:fileUrl];
- _wmPlayer.playerModel = playModel;
- _wmPlayer.delegate = self;
- _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
- _bgView.backgroundColor = [UIColor blackColor];
- [[UIApplication sharedApplication].keyWindow addSubview:_bgView];
- [[UIApplication sharedApplication].keyWindow addSubview:_wmPlayer];
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:_wmPlayer];
-
- [_wmPlayer play];
- }
- - (void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)backBtn {
- [wmplayer removePlayer];
- [_bgView removeFromSuperview];
- [self setNeedsStatusBarAppearanceUpdate];
- }
- - (void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn {
- self.isRatation = !self.isRatation;
-
- if (self.isRatation) {
- [wmplayer removeFromSuperview];
- [UIView animateWithDuration:1.0f animations:^{
- wmplayer.transform = CGAffineTransformMakeRotation(M_PI_2);
-
- } completion:^(BOOL finished) {
- wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
- [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
- }];
- }
- else {
- [wmplayer removeFromSuperview];
-
- [UIView animateWithDuration:1.0f animations:^{
- // 复原
- wmplayer.transform = CGAffineTransformIdentity;
-
- } completion:^(BOOL finished) {
- wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
- [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
- }];
- }
- }
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- - (void)showNewsWithSource:(HomeMessageModel *)sourceModel {
- // 登录之后才弹窗
- // if ([self checkIsLoginToLoginView:NO]) {
- // NSString *useId = UserDefault(UIDKey);
- // NSMutableArray *newArray = UserDefault(useId);
- // if (newArray.count) {
- // if ([newArray containsObject:sourceModel.coverImage]) {
- // return;
- // }
- // else {
- // [self displayAlert:sourceModel];
- // }
- // }
- // else {
- // [self displayAlert:sourceModel];
- // }
- // }
- [self displayAlert:sourceModel];
- }
- - (void)displayAlert:(HomeMessageModel *)sourceModel {
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
- if (appDelegate.isShowMemoAlert) {
- return;
- }
- NSString *useId = UserDefault(UIDKey);
- UserDefaultRemoveObjectForKey(useId);
- NSMutableArray *sourceArray = [NSMutableArray arrayWithArray:UserDefault(useId)];
- [sourceArray addObject:sourceModel.coverImage];
- UserDefaultSetObjectForKey(sourceArray, useId);
- KSNewsAlert *newAlert = [KSNewsAlert shareInstance];
- MJWeakSelf;
- [newAlert evaluateWithMessage:sourceModel.coverImage linkUrl:sourceModel.linkUrl callbackAction:^(BOOL isSure, NSString * _Nonnull linkUrl) {
- appDelegate.isShowFlashAlert = NO;
- if (isSure) {
- if (![NSString isEmptyString:linkUrl]) {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = linkUrl;
- [weakSelf.navigationController pushViewController:webCtrl animated:YES];
- }
- }
- [appDelegate showMemoAlert]; // 检测是否需要弹窗版本更新
- }];
- [newAlert showAlert];
- appDelegate.isShowFlashAlert = YES;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|