|
@@ -51,11 +51,16 @@
|
|
|
#import "RecentCourseModel.h"
|
|
|
#import "AccompanyDetailViewController.h"
|
|
|
#import "InstrumentChooseViewController.h"
|
|
|
+#import "UserSettingViewController.h"
|
|
|
+
|
|
|
+#import "PublicNoticeView.h"
|
|
|
+#import "SDCycleScrollView.h"
|
|
|
+#import "NoticeSourceModel.h"
|
|
|
|
|
|
#define BUTTONWIDTH (65)
|
|
|
#define BUTTONHEIGHT (80)
|
|
|
|
|
|
-@interface HomeViewController ()<TYCyclePagerViewDataSource,TYCyclePagerViewDelegate,UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,UICollectionViewDelegate, UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,WMPlayerDelegate>
|
|
|
+@interface HomeViewController ()<TYCyclePagerViewDataSource,TYCyclePagerViewDelegate,UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,UICollectionViewDelegate, UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,WMPlayerDelegate,SDCycleScrollViewDelegate>
|
|
|
{
|
|
|
WMPlayer *_wmPlayer;
|
|
|
CGRect _playerFrame;
|
|
@@ -82,6 +87,11 @@
|
|
|
@property (nonatomic, assign) NSInteger buttonDotWidth;
|
|
|
@property (nonatomic, assign) CGFloat buttonViewHeight; // button view 高度
|
|
|
|
|
|
+@property (nonatomic, strong) PublicNoticeView *noticeView;
|
|
|
+@property (nonatomic, strong) SDCycleScrollView *noticeScrollView;
|
|
|
+@property (nonatomic, strong) NSMutableArray *noticeArray; // notice数据
|
|
|
+@property (nonatomic, strong) NSMutableArray *noticeTitleArray; // 标题数组
|
|
|
+
|
|
|
@property (nonatomic, strong) HomeHotAlbumView *albumView; // albumView container
|
|
|
@property (nonatomic, strong) NSMutableArray *albumArray; // 热门专辑
|
|
|
@property (nonatomic, strong) UICollectionView *albumCollectionView; // 专辑容器
|
|
@@ -117,6 +127,11 @@
|
|
|
|
|
|
@property (nonatomic, assign) BOOL isFirstLoad;
|
|
|
|
|
|
+@property (nonatomic, strong) dispatch_group_t requestGroup;
|
|
|
+
|
|
|
+@property (nonatomic, strong) HomeMessageModel *flashModel;
|
|
|
+
|
|
|
+@property (nonatomic, strong) RecentCourseModel *recentCourseModel;
|
|
|
@end
|
|
|
|
|
|
@implementation HomeViewController
|
|
@@ -181,137 +196,207 @@
|
|
|
}
|
|
|
|
|
|
- (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);
|
|
|
+ [self.view bringSubviewToFront:self.scrollView];
|
|
|
+ [self.view bringSubviewToFront:self.navView];
|
|
|
+ [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.right.mas_equalTo(self.view);
|
|
|
+ make.top.mas_equalTo(self.view.mas_top).offset(kNaviBarHeight);
|
|
|
+ make.bottom.mas_equalTo(self.view.mas_bottom);
|
|
|
}];
|
|
|
- if (@available(iOS 11.0, *)) {
|
|
|
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
- } else {
|
|
|
- // Fallback on earlier versions
|
|
|
- self.automaticallyAdjustsScrollViewInsets = NO;
|
|
|
- }
|
|
|
- self.tableView.tableHeaderView = self.tableHeaderView;
|
|
|
+ self.scrollView.backgroundColor = [UIColor clearColor];
|
|
|
MJWeakSelf;
|
|
|
- self.tableView.mj_header = [KSGifRefreshHeader headerWithRefreshingBlock:^{
|
|
|
+ self.scrollView.mj_header = [KSGifRefreshHeader headerWithRefreshingBlock:^{
|
|
|
[weakSelf requestData];
|
|
|
}];
|
|
|
-
|
|
|
- // 配置 首页显示
|
|
|
- [self addDisplayView];
|
|
|
}
|
|
|
|
|
|
-- (void)addDisplayView {
|
|
|
- CGFloat tableHeaderHeight = 0.0f;
|
|
|
- [self.tableHeaderView addSubview:self.bannerView];
|
|
|
+
|
|
|
+- (void)configUI {
|
|
|
+ [self.scrollView 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.left.right.mas_equalTo(self.view);
|
|
|
+ make.top.mas_equalTo(self.scrollView.mas_top);
|
|
|
make.height.mas_equalTo(self.bannerViewHeight);
|
|
|
}];
|
|
|
- // button
|
|
|
- [self.tableHeaderView addSubview:self.buttonContainer];
|
|
|
+
|
|
|
+ [self.scrollView addSubview:self.noticeView];
|
|
|
+ [self.noticeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.right.mas_equalTo(self.view);
|
|
|
+ make.top.mas_equalTo(self.bannerView.mas_bottom);
|
|
|
+ make.height.mas_equalTo(CGFLOAT_MIN);
|
|
|
+ }];
|
|
|
+ [self.noticeView.adView addSubview:self.noticeScrollView];
|
|
|
+ [self.noticeScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.left.right.bottom.mas_equalTo(self.noticeView.adView);
|
|
|
+ }];
|
|
|
+ self.noticeView.hidden = YES;
|
|
|
+
|
|
|
+ [self.scrollView 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.left.right.mas_equalTo(self.view);
|
|
|
+ make.top.mas_equalTo(self.noticeView.mas_bottom);
|
|
|
make.height.mas_equalTo(self.buttonViewHeight);
|
|
|
}];
|
|
|
- tableHeaderHeight += self.buttonViewHeight;
|
|
|
-
|
|
|
+
|
|
|
// 课程提醒
|
|
|
- [self.tableHeaderView addSubview:self.tipsCourseView];
|
|
|
+ [self.scrollView 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.left.right.mas_equalTo(self.view);
|
|
|
make.top.mas_equalTo(self.buttonContainer.mas_bottom);
|
|
|
make.height.mas_equalTo(self.tipsViewHeight);
|
|
|
}];
|
|
|
- tableHeaderHeight += self.tipsViewHeight;
|
|
|
// 专辑
|
|
|
- [self.tableHeaderView addSubview:self.albumView];
|
|
|
+ [self.scrollView addSubview:self.albumView];
|
|
|
self.albumViewHeight = [HomeHotAlbumView getViewHeight];
|
|
|
[self.albumView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.right.mas_equalTo(self.tableHeaderView);
|
|
|
+ make.left.right.mas_equalTo(self.view);
|
|
|
make.top.mas_equalTo(self.tipsCourseView.mas_bottom);
|
|
|
make.height.mas_equalTo(self.albumViewHeight);
|
|
|
}];
|
|
|
- tableHeaderHeight += self.albumViewHeight;
|
|
|
-
|
|
|
+
|
|
|
// 直播课
|
|
|
- [self.tableHeaderView addSubview:self.liveView];
|
|
|
+ [self.scrollView addSubview:self.liveView];
|
|
|
self.liveViewHeight = [self.liveView getViewHeightWithCount:10];
|
|
|
[self.liveView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.right.mas_equalTo(self.tableHeaderView);
|
|
|
+ make.left.right.mas_equalTo(self.view);
|
|
|
make.top.mas_equalTo(self.albumView.mas_bottom);
|
|
|
make.height.mas_equalTo(self.liveViewHeight);
|
|
|
}];
|
|
|
- tableHeaderHeight += self.liveViewHeight;
|
|
|
-
|
|
|
+
|
|
|
// 视频课
|
|
|
- [self.tableHeaderView addSubview:self.videoView];
|
|
|
+ [self.scrollView addSubview:self.videoView];
|
|
|
self.videoViewHeight = [self.videoView getViewHeightWithCount:10];
|
|
|
[self.videoView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.right.mas_equalTo(self.tableHeaderView);
|
|
|
+ make.left.right.mas_equalTo(self.view);
|
|
|
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.scrollView addSubview:self.teacherView];
|
|
|
+ self.teachViewHeight = [self.teacherView getViewHeightWithSourceCount:10];
|
|
|
+
|
|
|
[self.teacherView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.right.mas_equalTo(self.tableHeaderView);
|
|
|
+ make.left.right.mas_equalTo(self.view);
|
|
|
make.top.mas_equalTo(self.videoView.mas_bottom);
|
|
|
make.height.mas_equalTo(self.teachViewHeight);
|
|
|
}];
|
|
|
- tableHeaderHeight += self.teachViewHeight;
|
|
|
-
|
|
|
- [self.tableHeaderView addSubview:self.informationHeadView];
|
|
|
+ // 资讯头部
|
|
|
+ [self.scrollView addSubview:self.informationHeadView];
|
|
|
self.informationHeight = [HotInformationHeadView getViewHeight];
|
|
|
[self.informationHeadView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.right.mas_equalTo(self.tableHeaderView);
|
|
|
+ make.left.right.mas_equalTo(self.view);
|
|
|
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];
|
|
|
+
|
|
|
+ // 资讯列表
|
|
|
+ [self.scrollView addSubview:self.tableView];
|
|
|
+ CGFloat tableHeight = [self getTableHeightWithCount:4];
|
|
|
+ [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.right.mas_equalTo(self.view);
|
|
|
+ make.top.mas_equalTo(self.informationHeadView.mas_bottom);
|
|
|
+ make.bottom.mas_equalTo(self.scrollView.mas_bottom);
|
|
|
+ make.height.mas_equalTo(tableHeight);
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
-- (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];
|
|
|
+- (CGFloat)getTableHeightWithCount:(NSInteger)count {
|
|
|
+ return 108 * count + 10;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
- (void)requestData {
|
|
|
- [self requestNewsList]; //
|
|
|
+ [self showhud];
|
|
|
+ [self requestNewsList];
|
|
|
+ [self requestNotice];
|
|
|
[self requestCourseInfo];
|
|
|
[self requestTeacherStyle];
|
|
|
[self requestHotAlbum];
|
|
|
+
|
|
|
+ dispatch_group_notify(self.requestGroup, dispatch_get_main_queue(), ^{
|
|
|
+ [self removehub];
|
|
|
+ [self.scrollView.mj_header endRefreshing];
|
|
|
+ [self refreshView];
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+- (void)refreshView {
|
|
|
+ [self.bannerScroll reloadData];
|
|
|
+ [self showButtonMessage];
|
|
|
+ [self refreshNoticeView];
|
|
|
+ [self refreshAlbumView];
|
|
|
+ [self refreshCourseView:self.recentCourseModel];
|
|
|
+ [self refreshCourseView];
|
|
|
+ [self refreshTeachView];
|
|
|
+ [self refreshTableView];
|
|
|
+
|
|
|
+ if (self.flashModel) {
|
|
|
+ [self showNewsWithSource:self.flashModel];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)requestNotice {
|
|
|
+ dispatch_group_enter(self.requestGroup);
|
|
|
+ [KSNetworkingManager helpCenterContentListRequest:KS_POST success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
|
|
|
+ if (sourceArray.count) {
|
|
|
+ NSDictionary *parm = [sourceArray firstObject];
|
|
|
+ NoticeSourceModel *bannerModel = [[NoticeSourceModel alloc] initWithDictionary:parm];
|
|
|
+ [self.noticeArray addObject:bannerModel];
|
|
|
+ [self.noticeTitleArray addObject:bannerModel.title];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ self.bannerArray = [NSMutableArray array];
|
|
|
+ self.noticeTitleArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+- (void)refreshNoticeView {
|
|
|
+ if (self.noticeTitleArray.count) {
|
|
|
+ self.noticeView.hidden = NO;
|
|
|
+ [self.noticeView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.mas_equalTo(50.0f);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ self.noticeView.hidden = YES;
|
|
|
+ [self.noticeView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.mas_equalTo(CGFLOAT_MIN);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ self.noticeScrollView.titlesGroup = self.noticeTitleArray;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
- (void)requestNewsList {
|
|
|
+ dispatch_group_enter(self.requestGroup);
|
|
|
[KSNetworkingManager homeNewsList:KS_POST success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
NSDictionary *result = [dic dictionaryValueForKey:@"data"];
|
|
|
// banner
|
|
@@ -322,7 +407,6 @@
|
|
|
[bannerInfoArray addObject:model];
|
|
|
}
|
|
|
self.bannerArray = [NSMutableArray arrayWithArray:bannerInfoArray];
|
|
|
- [self.bannerScroll reloadData];
|
|
|
|
|
|
// button
|
|
|
NSArray *buttonArray = [result arrayValueForKey:@"appMenu"];
|
|
@@ -332,13 +416,11 @@
|
|
|
[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];
|
|
|
+ self.flashModel = [[HomeMessageModel alloc] initWithDictionary:[flashArray firstObject]];
|
|
|
}
|
|
|
|
|
|
// information
|
|
@@ -349,18 +431,27 @@
|
|
|
[informationInfoArray addObject:model];
|
|
|
}
|
|
|
self.dataArray = [NSMutableArray arrayWithArray:informationInfoArray];
|
|
|
- [self.tableView reloadData];
|
|
|
}
|
|
|
else {
|
|
|
[self MBPShow:MESSAGEKEY];
|
|
|
}
|
|
|
} faliure:^(NSError * _Nonnull error) {
|
|
|
-
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+- (void)refreshTableView {
|
|
|
+ CGFloat tableHeight = [self getTableHeightWithCount:self.dataArray.count];
|
|
|
+ [self.tableView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.mas_equalTo(tableHeight);
|
|
|
+ }];
|
|
|
+ [self.tableView reloadData];
|
|
|
+}
|
|
|
+
|
|
|
- (void)requestHotAlbum {
|
|
|
+ dispatch_group_enter(self.requestGroup);
|
|
|
[KSNetworkingManager HomeHotAlbumRequest:KS_POST page:1 rows:10 success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
|
|
|
NSMutableArray *albumArray = [NSMutableArray array];
|
|
@@ -373,10 +464,9 @@
|
|
|
else {
|
|
|
[self MBPShow:MESSAGEKEY];
|
|
|
}
|
|
|
- [self refreshAlbumView];
|
|
|
|
|
|
} faliure:^(NSError * _Nonnull error) {
|
|
|
-
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
}];
|
|
|
}
|
|
|
|
|
@@ -393,15 +483,13 @@
|
|
|
make.height.mas_equalTo(self.albumViewHeight);
|
|
|
}];
|
|
|
[self.albumCollectionView reloadData];
|
|
|
- [self refreshTableHeadHeight];
|
|
|
}
|
|
|
|
|
|
- (void)requestCourseInfo {
|
|
|
-
|
|
|
-// [self showhud];
|
|
|
+
|
|
|
+ dispatch_group_enter(self.requestGroup);
|
|
|
[KSNetworkingManager homeQueryLiveAndVideo:KS_GET success:^(NSDictionary * _Nonnull dic) {
|
|
|
-// [self removehub];
|
|
|
- [self.tableView.mj_header endRefreshing];
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
NSDictionary *sourceDic = [dic dictionaryValueForKey:@"data"];
|
|
|
NSArray *liveList = [sourceDic arrayValueForKey:@"liveList"];
|
|
@@ -423,20 +511,18 @@
|
|
|
// 最近课程
|
|
|
NSDictionary *parm = [sourceDic dictionaryValueForKey:@"recentCourses"];
|
|
|
if (parm == nil) {
|
|
|
- [self refreshCourseView:nil];
|
|
|
+ self.recentCourseModel = nil;
|
|
|
}
|
|
|
else {
|
|
|
- RecentCourseModel *model = [[RecentCourseModel alloc] initWithDictionary:parm];
|
|
|
- [self refreshCourseView:model];
|
|
|
+ self.recentCourseModel = [[RecentCourseModel alloc] initWithDictionary:parm];
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
[self MBPShow:MESSAGEKEY];
|
|
|
}
|
|
|
- [self refreshCourseView];
|
|
|
+
|
|
|
} faliure:^(NSError * _Nonnull error) {
|
|
|
- [self removehub];
|
|
|
- [self.tableView.mj_header endRefreshing];
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
}];
|
|
|
}
|
|
|
|
|
@@ -456,7 +542,6 @@
|
|
|
make.height.mas_equalTo(CGFLOAT_MIN);
|
|
|
}];
|
|
|
}
|
|
|
- [self refreshTableHeadHeight];
|
|
|
}
|
|
|
|
|
|
- (void)refreshCourseView {
|
|
@@ -486,7 +571,6 @@
|
|
|
|
|
|
[self.liveCourseTable reloadData];
|
|
|
[self.videoCourseTable reloadData];
|
|
|
- [self refreshTableHeadHeight];
|
|
|
}
|
|
|
|
|
|
- (void)requestUserInfo:(BOOL)checkSubject {
|
|
@@ -509,9 +593,9 @@
|
|
|
}
|
|
|
|
|
|
- (void)requestTeacherStyle {
|
|
|
-
|
|
|
+ dispatch_group_enter(self.requestGroup);
|
|
|
[KSNetworkingManager homeQueryTeacherStyle:KS_POST page:1 rows:10 success:^(NSDictionary * _Nonnull dic) {
|
|
|
-
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
|
|
|
NSMutableArray *styleArray = [NSMutableArray array];
|
|
@@ -525,9 +609,8 @@
|
|
|
[self MBPShow:MESSAGEKEY];
|
|
|
}
|
|
|
// 回调
|
|
|
- [self refreshTeachView];
|
|
|
} faliure:^(NSError * _Nonnull error) {
|
|
|
-
|
|
|
+ dispatch_group_leave(self.requestGroup);
|
|
|
}];
|
|
|
}
|
|
|
|
|
@@ -543,8 +626,8 @@
|
|
|
[self.teacherView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
make.height.mas_equalTo(self.teachViewHeight);
|
|
|
}];
|
|
|
+
|
|
|
[self.infoCollectionView reloadData];
|
|
|
- [self refreshTableHeadHeight];
|
|
|
}
|
|
|
|
|
|
- (void)refreshNavView:(BOOL)checkSubject {
|
|
@@ -680,7 +763,10 @@
|
|
|
HomeMessageModel *model = self.dataArray[indexPath.row];
|
|
|
HomeInformationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HomeInformationCell"];
|
|
|
ROWINDEX rowIndex = ROWINDEX_MIDDLE;
|
|
|
- if (indexPath.row == 0) {
|
|
|
+ if (indexPath.row == 0 && self.dataArray.count == 1) {
|
|
|
+ rowIndex = ROWINDEX_TOP_BOTTOM;
|
|
|
+ }
|
|
|
+ else if (indexPath.row == 0) {
|
|
|
rowIndex = ROWINDEX_TOP;
|
|
|
}
|
|
|
else if (indexPath.row == self.dataArray.count - 1) {
|
|
@@ -817,9 +903,23 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+#pragma mark ----- SDCycleScrollViewDelegate
|
|
|
+- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
|
|
|
+ NoticeSourceModel *noticeModel = self.noticeArray[index];
|
|
|
+ KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
|
|
|
+ webCtrl.url = [NSString stringWithFormat:@"%@/#/helpCenterDetail?id=%@",WEBHOST, noticeModel.internalBaseClassIdentifier];
|
|
|
+ [self.navigationController pushViewController:webCtrl animated:YES];
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
#pragma mark ---- lazying
|
|
|
+- (dispatch_group_t)requestGroup {
|
|
|
+ if (!_requestGroup) {
|
|
|
+ _requestGroup = dispatch_group_create();
|
|
|
+ }
|
|
|
+ return _requestGroup;
|
|
|
+}
|
|
|
+
|
|
|
- (NSMutableArray *)buttonArray {
|
|
|
if (!_buttonArray) {
|
|
|
_buttonArray = [NSMutableArray array];
|
|
@@ -861,6 +961,53 @@
|
|
|
}
|
|
|
return _teacherArray;
|
|
|
}
|
|
|
+
|
|
|
+#pragma mark ----- 公告
|
|
|
+- (PublicNoticeView *)noticeView {
|
|
|
+ if (!_noticeView) {
|
|
|
+ _noticeView = [PublicNoticeView shareInstance];
|
|
|
+ MJWeakSelf;
|
|
|
+ [_noticeView moreCallback:^{
|
|
|
+ [weakSelf moreNotice];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ return _noticeView;
|
|
|
+}
|
|
|
+#pragma mark -- lazying
|
|
|
+- (SDCycleScrollView *)noticeScrollView {
|
|
|
+ if (!_noticeScrollView) {
|
|
|
+ _noticeScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImage new]];
|
|
|
+ _noticeScrollView.onlyDisplayText = YES;
|
|
|
+ _noticeScrollView.autoScroll = NO;
|
|
|
+ _noticeScrollView.scrollEnabled = NO;
|
|
|
+ _noticeScrollView.scrollDirection = UICollectionViewScrollDirectionVertical;
|
|
|
+ _noticeScrollView.titleLabelTextColor = HexRGB(0x1a1a1a);
|
|
|
+ _noticeScrollView.titleLabelBackgroundColor = [UIColor whiteColor];
|
|
|
+ _noticeScrollView.titleLabelTextFont = [UIFont systemFontOfSize:14];
|
|
|
+ _noticeScrollView.titlesGroup = self.noticeTitleArray;
|
|
|
+ }
|
|
|
+ return _noticeScrollView;
|
|
|
+}
|
|
|
+
|
|
|
+- (NSMutableArray *)noticeArray {
|
|
|
+ if (!_noticeArray) {
|
|
|
+ _noticeArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+ return _noticeArray;
|
|
|
+}
|
|
|
+
|
|
|
+- (NSMutableArray *)noticeTitleArray {
|
|
|
+ if (!_noticeTitleArray) {
|
|
|
+ _noticeTitleArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+ return _noticeTitleArray;
|
|
|
+}
|
|
|
+- (void)moreNotice {
|
|
|
+ KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
|
|
|
+ webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/helpCenter?catalogType=2"];
|
|
|
+ [self.navigationController pushViewController:webCtrl animated:YES];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark ----- 最近上课
|
|
|
|
|
|
- (HomeCourseTipsView *)tipsCourseView {
|
|
@@ -909,7 +1056,7 @@
|
|
|
- (UICollectionView *)albumCollectionView {
|
|
|
if (!_albumCollectionView) {
|
|
|
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
|
-// layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
|
|
|
+ layout.sectionInset = UIEdgeInsetsMake(12, 14, 12, 14);
|
|
|
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
|
|
_albumCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
|
|
_albumCollectionView.backgroundColor = [UIColor clearColor];
|
|
@@ -1040,6 +1187,7 @@
|
|
|
if (!_infoCollectionView) {
|
|
|
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
|
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
|
|
|
+ layout.itemSize = CGSizeMake((KPortraitWidth - 28 - 11) / 2.0f, 164);
|
|
|
_infoCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
|
|
_infoCollectionView.backgroundColor = [UIColor clearColor];
|
|
|
_infoCollectionView.delegate = self;
|
|
@@ -1171,9 +1319,14 @@
|
|
|
return _navView;
|
|
|
}
|
|
|
|
|
|
+- (void)displayUserCenter {
|
|
|
+ UserSettingViewController *ctrl = [[UserSettingViewController alloc] init];
|
|
|
+ [self.navigationController pushViewController:ctrl animated:YES];
|
|
|
+}
|
|
|
+
|
|
|
- (void)navAction:(NAVACTION)action {
|
|
|
- if (action == NAVACTION_SUBJECT) {
|
|
|
- [self showInstrumentView:NO];
|
|
|
+ if (action == NAVACTION_USERCENTER) {
|
|
|
+ [self displayUserCenter];
|
|
|
}
|
|
|
else { // 消息中心
|
|
|
|