IndexViewController.m 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911
  1. //
  2. // IndexViewController.m
  3. // TheoryNetwork
  4. //
  5. // Created by tederen on 2019/9/20.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. //#import "DrawerView.h"
  9. #import "IndexViewController.h"
  10. #import "SurfaceSearchView.h"
  11. #import "ChannelModel.h"
  12. #import "HomeSearchController.h"
  13. #import "AddChannelController.h"
  14. #import "HttpManager.h"
  15. #import "HomeDetailController.h"
  16. #import "APIPOPOPO.h"
  17. #import "MyApprovalPageDetail.h"
  18. #import "MailListDetailVC.h"
  19. #import "NavigationController.h"
  20. #import "UIAlertController+TapGesAlertController.h"
  21. #import "HomeArticleModel.h"
  22. #import "HomeListWorkCell.h"
  23. #import "HomeTableViewCell.h"
  24. #import "SLBannerView.h"
  25. #import "MyFavoriteVC.h"
  26. #import "OtherFavoriteVC.h"
  27. #import "NoteBookVC.h"
  28. #import "OtherNoteBookVC.h"
  29. #import "BookStoreHome.h"
  30. #import "HomeMusicCell.h"
  31. #import "HomeSchoolCell.h"
  32. #import "HomeUserPrivilegeCell.h"
  33. #import "HomeWeiCousreCell.h"
  34. #import "HomeProblemTopCell.h"
  35. #import "HomeGoodBookCell.h"
  36. #import "BookDetailVC.h"
  37. #import "BookSubArticeCell.h"
  38. #import "HomeTeacherCell.h"
  39. #import "BookTeacherListVC.h"
  40. #import "HKFloatManager.h"
  41. #import "HomeBigshotCell.h"
  42. #import "HomeSubModel.h"
  43. #import "HomeSubItemModel.h"
  44. #import "HomeRecommendVC.h"
  45. #import "HomeBigshotVC.h"
  46. #import "HomeDayGoodBookVC.h"
  47. #import "HomeDayGoodArticeVC.h"
  48. #import "HomeSpeakVC.h"
  49. #import "HomeWeiCousreVC.h"
  50. #import "HomeMingShiVC.h"
  51. #import "HomeUserVC.h"
  52. #import "HomeProblemVC.h"
  53. #import "WorkFlowDetailsController.h"
  54. @interface IndexViewController () <SLBannerViewDelegate,AddChannelControllerDelegate,EMChatManagerDelegate, EMGroupManagerDelegate, EMConversationsDelegate>
  55. @property (nonatomic, strong) UILabel *titleLabel;
  56. @property (nonatomic, strong) UIView *bannerBgV;
  57. @property (nonatomic, strong) SLBannerView *bannerView;
  58. @property (nonatomic, strong) SurfaceSearchView *searchView;
  59. @property (nonatomic, strong) NSMutableArray *bannerImgArr;
  60. @property (nonatomic, strong) NSMutableArray * tabConfigArray;
  61. @property (nonatomic, strong) NSMutableArray * bannerModelArray;
  62. @property (nonatomic, strong) HomeArticleModel *model;
  63. @property (nonatomic, strong) TDWaitWorkModel *waitModel;
  64. @property (nonatomic, assign) NSInteger currentPage;
  65. @property (nonatomic, assign) NSInteger totalPage;
  66. @property (nonatomic, assign) NSInteger currentChannel;
  67. @property (nonatomic, assign) NSInteger unReadCount;
  68. @property (nonatomic, strong) TDButton *addButton;
  69. @property (nonatomic, strong) TDButton *musicButtton;
  70. @property (nonatomic, strong) UIView *lineV;
  71. @property (nonatomic, strong) UIView *rightView;
  72. @property (nonatomic, strong) NSMutableDictionary *articleDic;
  73. @property (nonatomic, copy) NSMutableArray *dataSource;
  74. @property (strong, nonatomic) UIAlertController *alertVC;
  75. /// 我的频道
  76. @property (copy, nonatomic) NSMutableArray *myChannel;
  77. @property (copy, nonatomic) NSString *style;
  78. @property (strong, nonatomic) NSMutableArray *chatListIMArray;
  79. @property (strong, nonatomic) NSMutableArray *dataArray;
  80. @end
  81. @implementation IndexViewController
  82. - (void)viewWillAppear:(BOOL)animated
  83. {
  84. [super viewWillAppear:animated];
  85. [[EMClient sharedClient].chatManager addDelegate:self delegateQueue:nil];
  86. [[EMClient sharedClient].groupManager addDelegate:self delegateQueue:nil];
  87. [[EMConversationHelper shared] addDelegate:self];
  88. [self getUnreadCount];
  89. }
  90. #pragma mark - LifeCycle
  91. - (void)viewDidLoad {
  92. [super viewDidLoad];
  93. self.fd_prefersNavigationBarHidden = YES;
  94. [self loadStatusBarColor:[UIColor whiteColor]];
  95. self.view.backgroundColor = UIColorHex(F2F2F2);
  96. [self.view addSubview:self.titleLabel];
  97. [self.view addSubview:self.searchView];
  98. [self.searchView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 52)];
  99. self.bannerView = [[SLBannerView alloc] initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH - 30, 125)];
  100. self.bannerView.delegate = self;
  101. self.bannerView.durTimeInterval = 0.2;
  102. self.bannerView.imgStayTimeInterval = 2.5;
  103. self.bannerBgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 132)];
  104. self.bannerBgV.backgroundColor = [UIColor clearColor];
  105. [self.bannerBgV addSubview:self.bannerView];
  106. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.top.equalTo(self.statusBar.mas_bottom);
  108. make.left.right.equalTo(self.view);
  109. make.height.equalTo(@44);
  110. }];
  111. [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.top.mas_equalTo(self.titleLabel.mas_bottom);
  113. make.left.right.equalTo(self.view);
  114. make.height.mas_offset(52);
  115. }];
  116. [self getdata];
  117. WEAKSELF
  118. self.searchView.buttonBlock = ^(){
  119. HomeSearchController *homeSearch = [[HomeSearchController alloc] init];
  120. [weakSelf.navigationController pushViewController:homeSearch animated:YES];
  121. };
  122. self.searchView.bookBlock = ^(){
  123. BookStoreHome *vc = [BookStoreHome initBookStoreHome];
  124. vc.hidesBottomBarWhenPushed = YES;
  125. [weakSelf.navigationController pushViewController:vc animated:YES];
  126. };
  127. // self.channelScroll.ClickSelectChannelBlock = ^(NSInteger channelId, NSString * _Nonnull StyleCss) {
  128. // weakSelf.style = StyleCss;
  129. // weakSelf.currentChannel = channelId;
  130. // for (ChannelModel * model in weakSelf.myChannel) {
  131. // model.IsSelect = NO;
  132. // }
  133. // for (ChannelModel * model in weakSelf.myChannel) {
  134. // if (model.ArticleGroupId == channelId) {
  135. // model.IsSelect = YES;
  136. // }
  137. // }
  138. // dispatch_async(dispatch_get_main_queue(), ^{
  139. // [weakSelf collectReload];
  140. // });
  141. // };
  142. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tableViewScrollTop) name:HOMESCROLLVIEWTOTOP object:nil];
  143. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shareReturnAction:) name:SHARERETURNSUCCESS object:nil];
  144. }
  145. - (void)setCusPageVC
  146. {
  147. CGFloat height = SCREEN_HEIGHT - NAVH - 52 - self.tabBarController.tabBar.frame.size.height;
  148. WS(weakSelf);
  149. NSMutableArray * data = [NSMutableArray array];
  150. NSMutableArray * vcArr = [NSMutableArray array];
  151. for (NSInteger i = 0; i < self.myChannel.count; i ++) {
  152. ChannelModel * model = self.myChannel[i];
  153. if ([model.StyleCss isEqualToString:@"Commend"]) {
  154. [data addObject:model.ArticleGroupName];
  155. HomeRecommendVC * vc = [[HomeRecommendVC alloc] init];
  156. vc.height = height;
  157. vc.style = model.StyleCss;
  158. [vcArr addObject:vc];
  159. }
  160. if ([model.StyleCss isEqualToString:@"Cathedra"]) {
  161. [data addObject:model.ArticleGroupName];
  162. HomeBigshotVC * vc = [[HomeBigshotVC alloc] init];
  163. vc.height = height;
  164. vc.style = model.StyleCss;
  165. [vcArr addObject:vc];
  166. }
  167. if ([model.StyleCss isEqualToString:@"DayGoodBook"]) {
  168. [data addObject:model.ArticleGroupName];
  169. HomeDayGoodBookVC * vc = [[HomeDayGoodBookVC alloc] init];
  170. vc.height = height;
  171. vc.style = model.StyleCss;
  172. [vcArr addObject:vc];
  173. }
  174. if ([model.StyleCss isEqualToString:@"DayGoodText"]) {
  175. [data addObject:model.ArticleGroupName];
  176. HomeDayGoodArticeVC * vc = [[HomeDayGoodArticeVC alloc] init];
  177. vc.height = height;
  178. vc.style = model.StyleCss;
  179. [vcArr addObject:vc];
  180. }
  181. if ([model.StyleCss isEqualToString:@"ChatHearSpeak"]) {
  182. [data addObject:model.ArticleGroupName];
  183. HomeSpeakVC * vc = [[HomeSpeakVC alloc] init];
  184. vc.height = height;
  185. vc.style = model.StyleCss;
  186. [vcArr addObject:vc];
  187. }
  188. if ([model.StyleCss isEqualToString:@"DayWeBook"]) {
  189. [data addObject:model.ArticleGroupName];
  190. HomeWeiCousreVC * vc = [[HomeWeiCousreVC alloc] init];
  191. vc.height = height;
  192. vc.style = model.StyleCss;
  193. [vcArr addObject:vc];
  194. }
  195. if ([model.StyleCss isEqualToString:@"StarTeacher"]) {
  196. [data addObject:model.ArticleGroupName];
  197. HomeMingShiVC * vc = [[HomeMingShiVC alloc] init];
  198. vc.height = height;
  199. vc.style = model.StyleCss;
  200. [vcArr addObject:vc];
  201. }
  202. if ([model.StyleCss isEqualToString:@"VipSupply"]) {
  203. [data addObject:model.ArticleGroupName];
  204. HomeUserVC * vc = [[HomeUserVC alloc] init];
  205. vc.height = height;
  206. vc.style = model.StyleCss;
  207. [vcArr addObject:vc];
  208. }
  209. // if ([model.StyleCss isEqualToString:@"DayProblem"]) {///每日技能
  210. // [data addObject:model.ArticleGroupName];
  211. // HomeProblemVC * vc = [[HomeProblemVC alloc] init];
  212. // vc.height = height;
  213. // vc.style = model.StyleCss;
  214. // [vcArr addObject:vc];
  215. // }
  216. }
  217. WMZPageParam *param = PageParam()
  218. .wTitleArrSet(data)
  219. .wControllersSet(vcArr)
  220. //固定在所有子控制器底部 需要放在第一个控制器里 例如此例子
  221. .wFixFirstSet(YES)
  222. //悬浮开启
  223. .wTopSuspensionSet(YES)
  224. //等分
  225. .wMenuCellPaddingSet(45 - 21.5)
  226. .wMenuCellMarginSet(15)
  227. .wTopOffsetSet(-NAVH - 52)
  228. .wFromNaviSet(YES)
  229. .wMenuAnimalSet(PageTitleMenuNone)
  230. .wMenuTitleFontSet(15.f)
  231. .wMenuTitleSelectColorSet(UIColorHex(0x3979D3))
  232. .wMenuIndicatorYSet(6.f)
  233. .wMenuIndicatorColorSet(UIColorHex(0x3979D3))
  234. .wMenuTitleColorSet(UIColorHex(0x666666))
  235. .wMenuTitleSelectFontSet(15.f)
  236. .wMenuFixShadowSet(NO)
  237. .wMenuFixRightDataSet(@"sss")
  238. .wMenuFixWidthSet(88.5)
  239. //头部
  240. .wMenuHeadViewSet(^UIView *{
  241. return self.bannerBgV;
  242. });
  243. self.param = param;
  244. [self updatePageController];
  245. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  246. dispatch_async(dispatch_get_main_queue(), ^{
  247. for (UIView * view in weakSelf.view.subviews) {
  248. if ([view isKindOfClass:[WMZPageScroller class]]) {
  249. [view setFrame:CGRectMake(0, NAVH + 52, SCREEN_WIDTH, height)];
  250. }
  251. }
  252. UIView * view = [weakSelf setRightView];
  253. [weakSelf.upSc addSubview:view];
  254. [weakSelf.upSc bringSubviewToFront:view];
  255. [view setFrame:CGRectMake(SCREEN_WIDTH - 88.5, 0, 88.5, 45)];
  256. });
  257. });
  258. for (UIView * view in weakSelf.view.subviews) {
  259. if ([view isKindOfClass:[UIScrollView class]]) {
  260. NSLog(@"+++++++=====%@",view);
  261. UIScrollView * sView = (UIScrollView *)view;
  262. sView.showsVerticalScrollIndicator = NO;
  263. }
  264. }
  265. }
  266. - (void)getUnreadCount
  267. {
  268. WS(weakSelf);
  269. [[HttpManager sharedHttpManager] GETUrl:Host(API_APP_User_User_Uread_Count) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  270. NSDictionary *dic = responseObject;
  271. WorkNumberModel *numberModel = [[WorkNumberModel alloc] initWithDictionary:dic error:nil];
  272. weakSelf.unReadCount = numberModel.allNumber;
  273. dispatch_async(dispatch_get_main_queue(), ^{
  274. [weakSelf initChatMsgIMData];
  275. });
  276. } failure:^(NSError * _Nonnull error) {
  277. }];
  278. }
  279. -(void)initChatMsgIMData{
  280. self.chatListIMArray = [NSMutableArray array];
  281. WS(weakSelf);
  282. SHOWLOADING
  283. [[HttpManager sharedHttpManager] POSTUrl:Host(Often_Contact_List) parameters:@{@"IndividualGroupId":@(0)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  284. NSLog(@"%@",responseObject);
  285. REMOVESHOW
  286. if ([responseObject isKindOfClass:[NSArray class]]) {
  287. for (NSDictionary * dict in responseObject) {
  288. ChatMsgListImModel * model = [ChatMsgListImModel modelWithDictionary:dict];
  289. [weakSelf.chatListIMArray addObject:model];
  290. }
  291. }
  292. [weakSelf _loadAllConversationsFromDBWithIsShowHud:NO];
  293. } failure:^(NSError * _Nonnull error) {
  294. REMOVESHOW
  295. NSLog(@"%@",error);
  296. }];
  297. }
  298. - (void)_loadAllConversationsFromDBWithIsShowHud:(BOOL)aIsShowHUD
  299. {
  300. __weak typeof(self) weakself = self;
  301. self.dataArray = [NSMutableArray array];
  302. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  303. NSArray *conversations = [[EMClient sharedClient].chatManager getAllConversations];
  304. NSArray *sorted = [conversations sortedArrayUsingComparator:^(EMConversation *obj1, EMConversation *obj2) {
  305. EMMessage *message1 = [obj1 latestMessage];
  306. EMMessage *message2 = [obj2 latestMessage];
  307. if(message1.timestamp > message2.timestamp) {
  308. return(NSComparisonResult)NSOrderedAscending;
  309. } else {
  310. return(NSComparisonResult)NSOrderedDescending;
  311. }
  312. }];
  313. NSArray *models = [EMConversationHelper modelsFromEMConversations:sorted];
  314. [weakself.dataArray addObjectsFromArray:models];
  315. [weakself replaceChatData];
  316. });
  317. }
  318. - (void)replaceChatData
  319. {
  320. WS(weakSelf);
  321. [self.chatListIMArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  322. ChatMsgListImModel * chatModel = (ChatMsgListImModel *)obj;
  323. [weakSelf.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  324. EMConversationModel * model = (EMConversationModel *)obj;
  325. if (chatModel.ImId == [model.emModel.conversationId integerValue]) {
  326. if (!chatModel.IsDisturb) {
  327. chatModel.redNum = model.emModel.unreadMessagesCount;
  328. weakSelf.unReadCount += model.emModel.unreadMessagesCount;
  329. }
  330. }
  331. }];
  332. }];
  333. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  334. weakSelf.tabBarController.tabBar.items[2].badgeValue = weakSelf.unReadCount > 0 ? [NSString stringWithFormat:@"%ld",(long)weakSelf.unReadCount] : nil;
  335. });
  336. }
  337. - (void)conversationListDidUpdate:(NSArray *)aConversationList
  338. {
  339. [self _loadAllConversationsFromDBWithIsShowHud:NO];
  340. }
  341. - (void)messagesDidReceive:(NSArray *)aMessages
  342. {
  343. [self performSelector:@selector(getUnreadCount) withObject:nil afterDelay:0.8];
  344. }
  345. - (void)tableViewScrollTop
  346. {
  347. if (self.dataSource.count > 0) {
  348. [self.downSc scrollToTop];
  349. [self.downSc scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
  350. }
  351. }
  352. - (void)dealloc
  353. {
  354. [[EMClient sharedClient].chatManager removeDelegate:self];
  355. [[EMClient sharedClient].groupManager removeDelegate:self];
  356. [[EMConversationHelper shared] removeDelegate:self];
  357. [[NSNotificationCenter defaultCenter] removeObserver:self];
  358. }
  359. #pragma mark - NetRequest - 轮播
  360. - (void)getdata{
  361. [self loadChannelModel];
  362. WS(weakSelf);
  363. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  364. __block NSInteger httpFinishCount = 0;
  365. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  366. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,HomeSlideImages_GET] parameters: @{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  367. NSArray *arr = responseObject[@"Items"];
  368. NSLog(@"首页轮播数据%@",arr.firstObject);
  369. [weakSelf.bannerModelArray removeAllObjects];
  370. [weakSelf.bannerImgArr removeAllObjects];
  371. NSMutableArray *array = [NSMutableArray array];
  372. NSMutableArray *array2 = [NSMutableArray array];
  373. for (NSInteger i = 0; i < arr.count; i++) {
  374. NSDictionary *dic = arr[i];
  375. HomeTopImageModel *imageModel = [[HomeTopImageModel alloc] initWithDictionary:dic error:nil];
  376. [array2 addObject:imageModel];
  377. [array addObject:dic[@"ImageUrl"]];
  378. }
  379. weakSelf.bannerImgArr = array;
  380. weakSelf.bannerModelArray = array2;
  381. weakSelf.bannerView.slImages = array;
  382. if (++httpFinishCount == 2) {
  383. dispatch_semaphore_signal(sem);
  384. }
  385. } failure:^(NSError * _Nonnull error) {
  386. SHOWERROR([ZYCTool handerResultData:error]);
  387. }];
  388. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Pindao_User_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  389. NSLog(@"%@",responseObject);
  390. NSArray *array = responseObject;
  391. for (NSInteger i = 0 ; i < array.count; i ++) {
  392. NSDictionary *dic = array[i];
  393. ChannelModel *model = [ChannelModel modelWithDictionary:dic];
  394. if (model.ArticleGroupId == 0) {
  395. model.IsSelect = YES;
  396. }
  397. [weakSelf.myChannel addObject:model];
  398. }
  399. if (++httpFinishCount == 2) {
  400. dispatch_semaphore_signal(sem);
  401. }
  402. } failure:^(NSError * _Nonnull error) {
  403. SHOWERROR([ZYCTool handerResultData:error]);
  404. }];
  405. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  406. dispatch_async(dispatch_get_main_queue(), ^{
  407. [weakSelf setCusPageVC];
  408. });
  409. });
  410. }
  411. - (void)ReGetHomeListData:(NSInteger)channelId
  412. {
  413. WS(weakSelf);
  414. switch (channelId) {
  415. case 0:
  416. {
  417. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Notice_list_Post] parameters: @{@"page":@(self.currentPage),@"perPage":@10,@"GroupId":@(channelId)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  418. NSDictionary *dic = (NSDictionary *)responseObject;
  419. HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic];
  420. weakSelf.totalPage = model.Count;
  421. [weakSelf.dataSource addObjectsFromArray:model.Items];
  422. } failure:^(NSError * _Nonnull error) {
  423. }];
  424. }
  425. break;
  426. case 1:
  427. {
  428. NSDictionary * paraDict = @{@"Type":@"MyChecking",@"page":@(self.currentPage),@"perPage":@10};
  429. [[HttpManager sharedHttpManager] GETUrl:Host(WorkFlowAddApproval_Post) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  430. NSDictionary *dic = (NSDictionary *)responseObject;
  431. HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic];
  432. weakSelf.totalPage = model.Count;
  433. [weakSelf.dataSource addObjectsFromArray:model.Items];
  434. } failure:^(NSError * _Nonnull error) {
  435. SHOWERROR([ZYCTool handerResultData:error])
  436. }];
  437. }
  438. break;
  439. default:
  440. {
  441. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_PAGE_CATHEDRA) parameters:@{@"StyleCss":self.style,@"Page":@(self.currentPage),@"PerPage":@20} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  442. NSLog(@"%@",responseObject);
  443. } failure:^(NSError * _Nonnull error) {
  444. }];
  445. }
  446. break;
  447. }
  448. }
  449. - (BOOL)hidesBottomBarWhenPushed{
  450. return NO;
  451. }
  452. #pragma mark - UITableViewDataSource && UITableViewDelegate
  453. - (void)closeBtn_Click {
  454. [self.alertVC dismissViewControllerAnimated:YES completion:nil];
  455. }
  456. - (void)cellDidSelcet:(NSInteger )articleId{
  457. WEAKSELF
  458. UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  459. [closeBtn addTarget:self action:@selector(closeBtn_Click) forControlEvents:UIControlEventTouchUpInside];
  460. [closeBtn setImage:IMG(@"guanbi") forState:UIControlStateNormal];
  461. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"对此内容进行操作" message:@"" preferredStyle:UIAlertControllerStyleAlert];
  462. self.alertVC = alertVC;
  463. [alertVC.view addSubview:closeBtn];
  464. [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  465. make.right.equalTo(alertVC.view).offset(-10);
  466. make.top.equalTo(@10);
  467. make.size.mas_equalTo(CGSizeMake(22, 22));
  468. }];
  469. UIAlertAction *actionOK = [UIAlertAction actionWithTitle:@"屏蔽TA" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  470. STRONGSELF
  471. [strongSelf homeNewsHander:articleId withTypeId:1];
  472. }];
  473. [actionOK setValue:k9 forKey:@"_titleTextColor"];
  474. UIAlertAction *actionNO = [UIAlertAction actionWithTitle:@"不感兴趣" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  475. STRONGSELF
  476. [strongSelf homeNewsHander:articleId withTypeId:2];
  477. }];
  478. [alertVC addAction:actionOK];
  479. [alertVC addAction:actionNO];
  480. [self presentViewController:alertVC animated:YES completion:^{
  481. [alertVC tapGesAlert];
  482. }];
  483. }
  484. - (void)homeNewsHander:(NSInteger )articleId withTypeId:(NSInteger)blacklistType{
  485. WS(weakSelf);
  486. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@/%@",BaseUrl,Article_Hander_Post] parameters:@{@"ArticleId":@(articleId),@"BlacklistType":@(blacklistType)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  487. // [weakSelf headRefresh];
  488. } failure:^(NSError * _Nonnull error) {
  489. }];
  490. }
  491. #pragma mark - channelScroll Block
  492. - (void)didClickAddButtonChannel{
  493. AddChannelController *addChannel = [[AddChannelController alloc] init];
  494. addChannel.modalPresentationStyle = UIModalPresentationFullScreen;
  495. addChannel.delegate = self;
  496. [self presentViewController:addChannel animated:YES completion:nil];
  497. }
  498. #pragma mark - AddChannelControllerDelegate
  499. - (void)upadateChannel{
  500. WS(weakSelf);
  501. [self loadChannelModel];
  502. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Pindao_User_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  503. NSLog(@"%@",responseObject);
  504. NSArray *array = responseObject;
  505. for (NSInteger i = 0 ; i < array.count; i ++) {
  506. NSDictionary *dic = array[i];
  507. ChannelModel *model = [ChannelModel modelWithDictionary:dic];
  508. [weakSelf.myChannel addObject:model];
  509. }
  510. dispatch_async(dispatch_get_main_queue(), ^{
  511. [weakSelf setCusPageVC];
  512. });
  513. } failure:^(NSError * _Nonnull error) {
  514. }];
  515. }
  516. #pragma mark - SLBannerViewDelegate
  517. - (void)bannerView:(SLBannerView *)banner didClickImagesAtIndex:(NSInteger)index
  518. {
  519. [self getArticleDetail:index];
  520. }
  521. - (void)getArticleDetail:(NSInteger)index{
  522. HomeTopImageModel *model = self.bannerModelArray[index];
  523. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  524. vc.type = CollectModel_Aritle;
  525. vc.Id = model.MediaId;
  526. [self.navigationController pushViewController:vc animated:YES];
  527. }
  528. #pragma mark - Setter
  529. - (UILabel *)titleLabel {
  530. if (!_titleLabel) {
  531. _titleLabel = [UILabel new];
  532. _titleLabel.backgroundColor = [UIColor whiteColor];
  533. _titleLabel.text = @"首页";
  534. _titleLabel.font = [UIFont systemFontOfSize:16.f];
  535. _titleLabel.textColor = UIColorHex(1A1A1A);
  536. _titleLabel.textAlignment = NSTextAlignmentCenter;
  537. }
  538. return _titleLabel;
  539. }
  540. - (SurfaceSearchView *)searchView {
  541. if (!_searchView) {
  542. _searchView = [[SurfaceSearchView alloc] init];
  543. [_searchView setBgViewColor:[UIColor clearColor]];
  544. // [_searchView setPlaceHolderText:@"输入关键字搜索"];
  545. [_searchView setMainType];
  546. }
  547. return _searchView;
  548. }
  549. - (NSMutableArray *)dataSource
  550. {
  551. if (!_dataSource) {
  552. _dataSource = [NSMutableArray array];
  553. }
  554. return _dataSource;
  555. }
  556. - (NSMutableArray *)tabConfigArray{
  557. if (!_tabConfigArray) {
  558. _tabConfigArray = [NSMutableArray array];
  559. }
  560. return _tabConfigArray;
  561. }
  562. - (NSMutableDictionary *)articleDic{
  563. if (!_articleDic) {
  564. _articleDic = [NSMutableDictionary dictionary];
  565. }
  566. return _articleDic;
  567. }
  568. - (NSMutableArray *)myChannel {
  569. if (!_myChannel) {
  570. _myChannel = [NSMutableArray array];
  571. }
  572. return _myChannel;
  573. }
  574. - (void)loadChannelModel
  575. {
  576. [self.myChannel removeAllObjects];
  577. // ChannelModel * model = [[ChannelModel alloc] init];
  578. // model.ArticleGroupId = 0;
  579. // model.ArticleGroupName = @"推荐";
  580. // model.StyleCss = @"default";
  581. // model.IsSelect = YES;
  582. // [self.myChannel addObject:model];
  583. // ChannelModel * workModel = [[ChannelModel alloc] init];
  584. // workModel.ArticleGroupId = 1;
  585. // workModel.ArticleGroupName = @"待办工作";
  586. // workModel.IsSelect = NO;
  587. // [self.myChannel addObject:workModel];
  588. // ChannelModel * sModel = [[ChannelModel alloc] init];
  589. // sModel.ArticleGroupId = 2;
  590. // sModel.ArticleGroupName = @"信源听说";
  591. // sModel.IsSelect = NO;
  592. // [self.myChannel addObject:sModel];
  593. // ChannelModel * mModel = [[ChannelModel alloc] init];
  594. // mModel.ArticleGroupId = 3;
  595. // mModel.ArticleGroupName = @"名校";
  596. // mModel.IsSelect = NO;
  597. // [self.myChannel addObject:mModel];
  598. // ChannelModel * aModel = [[ChannelModel alloc] init];
  599. // aModel.ArticleGroupId = 4;
  600. // aModel.ArticleGroupName = @"会员特供";
  601. // aModel.IsSelect = NO;
  602. // [self.myChannel addObject:aModel];
  603. // ChannelModel * bModel = [[ChannelModel alloc] init];
  604. // bModel.ArticleGroupId = 5;
  605. // bModel.ArticleGroupName = @"每日微课";
  606. // bModel.IsSelect = NO;
  607. // [self.myChannel addObject:bModel];
  608. // ChannelModel * cModel = [[ChannelModel alloc] init];
  609. // cModel.ArticleGroupId = 6;
  610. // cModel.ArticleGroupName = @"每日技能";
  611. // cModel.IsSelect = NO;
  612. // [self.myChannel addObject:cModel];
  613. // ChannelModel * dModel = [[ChannelModel alloc] init];
  614. // dModel.ArticleGroupId = 7;
  615. // dModel.ArticleGroupName = @"每日好书";
  616. // dModel.IsSelect = NO;
  617. // [self.myChannel addObject:dModel];
  618. // ChannelModel * eModel = [[ChannelModel alloc] init];
  619. // eModel.ArticleGroupId = 8;
  620. // eModel.ArticleGroupName = @"每日好文";
  621. // eModel.IsSelect = NO;
  622. // [self.myChannel addObject:eModel];
  623. // ChannelModel * fModel = [[ChannelModel alloc] init];
  624. // fModel.ArticleGroupId = 9;
  625. // fModel.ArticleGroupName = @"名师";
  626. // fModel.IsSelect = NO;
  627. // [self.myChannel addObject:fModel];
  628. // ChannelModel * gModel = [[ChannelModel alloc] init];
  629. // gModel.ArticleGroupId = 10;
  630. // gModel.ArticleGroupName = @"大咖讲座";
  631. // gModel.IsSelect = NO;
  632. // [self.myChannel addObject:gModel];
  633. }
  634. #pragma mark - 分享成功跳转
  635. - (void)shareReturnAction:(NSNotification *)noti
  636. {
  637. NSDictionary * dic = noti.userInfo;
  638. CollectModelType type = [[dic objectForKey:@"type"] intValue];
  639. NSInteger Id = [[dic objectForKey:@"Id"] integerValue];
  640. NSInteger userId = [[dic objectForKey:@"userId"] integerValue];
  641. NSString* name = [[dic objectForKey:@"name"] stringByRemovingPercentEncoding];
  642. // NSString* describe = [[dic objectForKey:@"describe"] stringByRemovingPercentEncoding];
  643. switch (type) {
  644. case CollectModel_Aritle:
  645. {
  646. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  647. vc.type = CollectModel_Aritle;
  648. vc.Id = Id;
  649. vc.hidesBottomBarWhenPushed = YES;
  650. [self.navigationController pushViewController:vc animated:YES];
  651. }
  652. break;
  653. case CollectModel_work:
  654. {
  655. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  656. vc.indexId = Id;
  657. vc.title = name;
  658. vc.TodoId = Id;
  659. vc.hidesBottomBarWhenPushed = YES;
  660. [self.navigationController pushViewController:vc animated:YES];
  661. }
  662. break;
  663. case CollectModel_Toipc:
  664. {
  665. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  666. vc.Id = Id;
  667. vc.type = CollectModel_Toipc;
  668. vc.hidesBottomBarWhenPushed = YES;
  669. [self.navigationController pushViewController:vc animated:YES];
  670. }
  671. break;
  672. case CollectModel_NewTopic:
  673. {
  674. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  675. vc.Id = Id;
  676. vc.type = CollectModel_NewTopic;
  677. vc.hidesBottomBarWhenPushed = YES;
  678. [self.navigationController pushViewController:vc animated:YES];
  679. }
  680. break;
  681. case CollectModel_Notice:
  682. {
  683. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  684. vc.Id = Id;
  685. vc.type = CollectModel_Notice;
  686. vc.hidesBottomBarWhenPushed = YES;
  687. [self.navigationController pushViewController:vc animated:YES];
  688. }
  689. break;
  690. case CollectModel_InterMail:
  691. {
  692. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  693. vc.Id = Id;
  694. vc.type = CollectModel_InterMail;
  695. vc.hidesBottomBarWhenPushed = YES;
  696. [self.navigationController pushViewController:vc animated:YES];
  697. }
  698. break;
  699. case CollectModel_NoSignMail:
  700. {
  701. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  702. vc.Id = Id;
  703. vc.type = CollectModel_NoSignMail;
  704. vc.hidesBottomBarWhenPushed = YES;
  705. [self.navigationController pushViewController:vc animated:YES];
  706. }
  707. break;
  708. case CollectModel_NoteBook:
  709. {
  710. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  711. vc.Id = Id;
  712. vc.type = CollectModel_NoteBook;
  713. vc.hidesBottomBarWhenPushed = YES;
  714. [self.navigationController pushViewController:vc animated:YES];
  715. }
  716. break;
  717. case CollectModel_meetMian:
  718. {
  719. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  720. vc.Id = Id;
  721. vc.type = CollectModel_meetMian;
  722. vc.hidesBottomBarWhenPushed = YES;
  723. [self.navigationController pushViewController:vc animated:YES];
  724. }
  725. break;
  726. case CollectModel_meetDetail:
  727. {
  728. WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:Id];
  729. vc.hidesBottomBarWhenPushed = YES;
  730. [self.navigationController pushViewController:vc animated:YES];
  731. }
  732. break;
  733. case CollectModel_CollectFile:{
  734. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  735. MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
  736. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  737. vc.ParentId = Id;
  738. vc.FolderId = Id;
  739. vc.myTitle = name;
  740. vc.hidesBottomBarWhenPushed = YES;
  741. [self.navigationController pushViewController:vc animated:YES];
  742. }else{
  743. OtherFavoriteVC *vc = [OtherFavoriteVC initOtherFavoriteVC];
  744. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  745. vc.ParentId = Id;
  746. vc.FolderId = Id;
  747. vc.myTitle = name;
  748. vc.VisitUserId = userId;
  749. vc.hidesBottomBarWhenPushed = YES;
  750. [self.navigationController pushViewController:vc animated:YES];
  751. }
  752. }break;
  753. case CollectModel_NoteFile:{
  754. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  755. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  756. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  757. vc.ParentId = Id;
  758. vc.FolderId = Id;
  759. vc.myTitle = name;
  760. vc.VisitUserId = 0;
  761. [self.navigationController pushViewController:vc animated:YES];
  762. }else{
  763. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  764. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  765. vc.ParentId = Id;
  766. vc.FolderId = Id;
  767. vc.myTitle = name;
  768. vc.VisitUserId = userId;
  769. vc.hidesBottomBarWhenPushed = YES;
  770. [self.navigationController pushViewController:vc animated:YES];
  771. }
  772. }break;
  773. case CollectModel_TopicBooK:{
  774. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  775. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  776. vc.listType = MyFavoriteListLevelTypeA;
  777. vc.ParentId = 0;
  778. vc.FolderId = Id;
  779. vc.myTitle = name;
  780. vc.VisitUserId = 0;
  781. vc.TypeValue = 1;
  782. [self.navigationController pushViewController:vc animated:YES];
  783. }else{
  784. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  785. vc.listType = MyFavoriteListLevelTypeA;
  786. vc.ParentId = 0;
  787. vc.FolderId = Id;
  788. vc.myTitle = name;
  789. vc.VisitUserId = userId;
  790. vc.TypeValue = 1;
  791. vc.hidesBottomBarWhenPushed = YES;
  792. [self.navigationController pushViewController:vc animated:YES];
  793. }
  794. }break;
  795. case CollectModel_TopicSubBooK:{
  796. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  797. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  798. vc.listType = MyFavoriteListLevelTypeB;
  799. vc.ParentId = Id;
  800. vc.FolderId = Id;
  801. vc.myTitle = name;
  802. vc.VisitUserId = 0;
  803. vc.TypeValue = 1;
  804. [self.navigationController pushViewController:vc animated:YES];
  805. }else{
  806. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  807. vc.listType = MyFavoriteListLevelTypeB;
  808. vc.ParentId = Id;
  809. vc.FolderId = Id;
  810. vc.myTitle = name;
  811. vc.VisitUserId = userId;
  812. vc.TypeValue = 1;
  813. vc.hidesBottomBarWhenPushed = YES;
  814. [self.navigationController pushViewController:vc animated:YES];
  815. }
  816. }break;
  817. default:
  818. break;
  819. }
  820. }
  821. - (void)addChannelAction:(UIButton *)sender
  822. {
  823. [self didClickAddButtonChannel];
  824. }
  825. - (void)musicAction:(UIButton *)sender
  826. {
  827. [[HKFloatManager shared] showVideo];
  828. }
  829. - (TDButton *)addButton {
  830. if (!_addButton) {
  831. _addButton = [TDButton buttonWithType:UIButtonTypeCustom];
  832. [_addButton setImage:IMG(@"home_pdAdd_icon") forState:UIControlStateNormal];
  833. [_addButton addTarget:self action:@selector(addChannelAction:) forControlEvents:UIControlEventTouchUpInside];
  834. [_addButton setCurrentButtonHotSize:CGSizeZero];
  835. }
  836. return _addButton;
  837. }
  838. - (TDButton *)musicButtton {
  839. if (!_musicButtton) {
  840. _musicButtton = [TDButton buttonWithType:UIButtonTypeCustom];
  841. [_musicButtton setImage:IMG(@"home_music_icon") forState:UIControlStateNormal];
  842. [_musicButtton addTarget:self action:@selector(musicAction:) forControlEvents:UIControlEventTouchUpInside];
  843. [_musicButtton setCurrentButtonHotSize:CGSizeZero];
  844. }
  845. return _musicButtton;
  846. }
  847. - (UIView *)lineV
  848. {
  849. if (!_lineV) {
  850. _lineV = [UIView new];
  851. _lineV.backgroundColor = UIColorHex(0xD8D8D8);
  852. }
  853. return _lineV;
  854. }
  855. - (UIView *)rightView
  856. {
  857. if (!_rightView) {
  858. _rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 88.5, 45)];
  859. _rightView.backgroundColor = UIColorHex(0xFFFFFF);
  860. }
  861. return _rightView;
  862. }
  863. - (UIView *)setRightView
  864. {
  865. [self.rightView removeAllSubviews];
  866. [self.rightView addSubview:self.addButton];
  867. [self.rightView addSubview:self.musicButtton];
  868. [self.rightView addSubview:self.lineV];
  869. [self.addButton setFrame:CGRectMake(0, 0, 44, 45)];
  870. [self.lineV setFrame:CGRectMake(44, 13.5, 0.5, 18)];
  871. [self.musicButtton setFrame:CGRectMake(44.5, 0, 44, 45)];
  872. return self.rightView;
  873. }
  874. @end