// // HomeViewController.m // KulexiuForTeacher // // Created by Kyle on 2022/3/17. // #import "HomeViewController.h" #import "KSBaseWKWebViewController.h" #import "NotiferMessageViewController.h" #import "SubjectChooseViewController.h" #import "HomeNavView.h" #import "HomeBannerView.h" #import #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 "HomeHotCourseView.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 "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" #define BUTTONWIDTH (65) #define BUTTONHEIGHT (80) @interface HomeViewController () { 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) HomeHotCourseView *courseView; // course container @property (nonatomic, strong) UIScrollView *courseScroll; // 课程scroll @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 courseViewHeight; @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; NSInteger noticeCount = 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 ([[parm stringValueForKey:@"key"] isEqualToString:@"NOTICE"]) { noticeCount = [parm integerValueForKey:@"value"]; } } if (courseCount != 0 || sysCount != 0 || noticeCount != 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.courseView]; self.courseViewHeight = [self.courseView getViewHeightWithCount:10]; [self.courseView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(self.tableHeaderView); make.top.mas_equalTo(self.albumView.mas_bottom); make.height.mas_equalTo(self.courseViewHeight); }]; self.courseScroll.contentSize = CGSizeMake(KPortraitWidth * 2, self.courseViewHeight - 59); [self.courseScroll addSubview:self.liveCourseTable]; [self.liveCourseTable mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.courseScroll); make.top.bottom.mas_equalTo(self.courseView.courseContainer); make.width.mas_equalTo(KPortraitWidth); }]; [self.courseScroll addSubview:self.videoCourseTable]; [self.videoCourseTable mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(_courseScroll.mas_left).offset(KPortraitWidth); make.top.bottom.mas_equalTo(self.courseView.courseContainer); make.width.mas_equalTo(KPortraitWidth); }]; tableHeaderHeight += self.courseViewHeight; // 老师风采 [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.courseView.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.courseViewHeight + 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.videoCourseArray.count) { self.courseCount = self.liveCourseArray.count >= self.videoCourseArray.count ? self.videoCourseArray.count : self.liveCourseArray.count; // 根据课程返回数据显示高度 self.courseViewHeight = [self.courseView getViewHeightWithCount:self.courseCount]; } else { self.courseViewHeight = CGFLOAT_MIN; } [self.courseView mas_updateConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(self.courseViewHeight); }]; [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.courseCount; } else { // 视频课列表 return self.courseCount; } } - (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; }]; } else if (scrollView == self.courseScroll) { } } #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 ------ 推荐课程 - (HomeHotCourseView *)courseView { if (!_courseView) { _courseView = [HomeHotCourseView shareInstance]; MJWeakSelf; [_courseView courseActionCallback:^(COURSE_ACTION action) { [weakSelf homeCourseChooseAction:action]; }]; [_courseView.courseContainer addSubview:self.courseScroll]; [self.courseScroll mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.top.mas_equalTo(_courseView.courseContainer); }]; } return _courseView; } - (UIScrollView *)courseScroll { if (!_courseScroll) { _courseScroll = [[UIScrollView alloc] initWithFrame:CGRectZero]; _courseScroll.pagingEnabled = YES; _courseScroll.scrollEnabled = NO; _courseScroll.showsHorizontalScrollIndicator = NO; _courseScroll.showsVerticalScrollIndicator = NO; _courseScroll.delegate = self; } return _courseScroll; } - (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; } - (void)homeCourseChooseAction:(COURSE_ACTION)action { switch (action) { case COURSE_ACTION_LIVE: { if (self.isChooseLive == YES) { return; } self.isChooseLive = YES; } break; case COURSE_ACTION_VIDEO: { if (self.isChooseLive == NO) { return; } self.isChooseLive = NO; } break; case COURSE_ACTION_MORE: // 更多 { NSString *url = @""; if (self.isChooseLive) { // 直播课 列表 url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/liveClass"]; } else { // 视频课列表 url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/videoClass"]; } KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init]; ctrl.url = url; [self.navigationController pushViewController:ctrl animated:YES]; } break; default: break; } } - (void)setIsChooseLive:(BOOL)isChooseLive { _isChooseLive = isChooseLive; // 切换 [UIView animateWithDuration:0.3f animations:^{ if (isChooseLive) { [self.courseScroll setContentOffset:CGPointZero animated:YES]; } else { [self.courseScroll setContentOffset:CGPointMake(KPortraitWidth, 0) animated:YES]; } }]; } #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 { // 消息中心 NotiferMessageViewController *ctrl = [[NotiferMessageViewController alloc] init]; [self.navigationController pushViewController:ctrl animated:YES]; } } - (void)showInstrumentView:(BOOL)hideBackButton { SubjectChooseViewController *ctrl = [[SubjectChooseViewController alloc] init]; MJWeakSelf; [ctrl chooseSubjectCallback:^{ [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]; } } } - (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 getUrlEndcodeString]; [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