IndexViewController.m 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  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 "HomeSchoolVC.h"
  53. #import "HomeProblemVC.h"
  54. #import "WorkFlowDetailsController.h"
  55. #import "IndexSearchVC.h"
  56. #import "BookListDetailVC.h"
  57. #import "BookWCDetailVC.h"
  58. #import "BookListenVC.h"
  59. #import "BookTeacherDetailVC.h"
  60. #import "PushModel.h"
  61. #import "ChatMsgListVC.h"
  62. #import "ChatTestingVC.h"
  63. #import "ReplayMeVC.h"
  64. #import "SWQRCodeViewController.h"
  65. #import "ChatJoinGroupVC.h"
  66. #import "TDGroupInfoListVC.h"
  67. #import "LoginPCVC.h"
  68. #import "TDQrJoinVC.h"
  69. @interface IndexViewController () <SLBannerViewDelegate,AddChannelControllerDelegate,EMChatManagerDelegate, EMGroupManagerDelegate, EMConversationsDelegate,SWQRCodeViewControllerDelegate>
  70. @property (nonatomic, strong) UILabel *titleLabel;
  71. @property (nonatomic, strong) UIButton *scanBtn;
  72. @property (nonatomic, strong) UIView *bannerBgV;
  73. @property (nonatomic, strong) SLBannerView *bannerView;
  74. @property (nonatomic, strong) SurfaceSearchView *searchView;
  75. @property (nonatomic, strong) NSMutableArray *bannerImgArr;
  76. @property (nonatomic, strong) NSMutableArray *tabConfigArray;
  77. @property (nonatomic, strong) NSMutableArray *bannerModelArray;
  78. @property (nonatomic, strong) HomeArticleModel *model;
  79. @property (nonatomic, strong) TDWaitWorkModel *waitModel;
  80. @property (nonatomic, assign) NSInteger currentPage;
  81. @property (nonatomic, assign) NSInteger totalPage;
  82. @property (nonatomic, assign) NSInteger currentChannel;
  83. @property (nonatomic, assign) NSInteger unReadCount;
  84. @property (nonatomic, strong) TDButton *addButton;
  85. @property (nonatomic, strong) TDButton *musicButtton;
  86. @property (nonatomic, strong) UIView *lineV;
  87. @property (nonatomic, strong) UIView *rightView;
  88. @property (nonatomic, strong) NSMutableDictionary *articleDic;
  89. @property (nonatomic, copy) NSMutableArray *dataSource;
  90. @property (strong, nonatomic) UIAlertController *alertVC;
  91. /// 我的频道
  92. @property (copy, nonatomic) NSMutableArray *myChannel;
  93. @property (copy, nonatomic) NSString *style;
  94. @property (strong, nonatomic) NSMutableArray *chatListIMArray;
  95. @property (strong, nonatomic) NSMutableArray *dataArray;
  96. @end
  97. @implementation IndexViewController
  98. - (void)viewWillAppear:(BOOL)animated
  99. {
  100. [super viewWillAppear:animated];
  101. [[EMClient sharedClient].chatManager addDelegate:self delegateQueue:nil];
  102. [[EMClient sharedClient].groupManager addDelegate:self delegateQueue:nil];
  103. [[EMConversationHelper shared] addDelegate:self];
  104. [self getUnreadCount];
  105. }
  106. #pragma mark - LifeCycle
  107. - (void)viewDidLoad {
  108. [super viewDidLoad];
  109. self.fd_prefersNavigationBarHidden = YES;
  110. [self loadStatusBarColor:[UIColor whiteColor]];
  111. self.view.backgroundColor = UIColorHex(F2F2F2);
  112. [self.view addSubview:self.titleLabel];
  113. [self.view addSubview:self.scanBtn];
  114. [self.view addSubview:self.searchView];
  115. [self.searchView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 52)];
  116. self.bannerView = [[SLBannerView alloc] initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH - 30, 125)];
  117. self.bannerView.delegate = self;
  118. self.bannerView.durTimeInterval = 0.2;
  119. self.bannerView.imgStayTimeInterval = 2.5;
  120. self.bannerBgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 132)];
  121. self.bannerBgV.backgroundColor = [UIColor clearColor];
  122. [self.bannerBgV addSubview:self.bannerView];
  123. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  124. make.top.equalTo(self.statusBar.mas_bottom);
  125. make.left.right.equalTo(self.view);
  126. make.height.equalTo(@44);
  127. }];
  128. [self.scanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  129. make.top.equalTo(self.statusBar.mas_bottom);
  130. make.right.mas_equalTo(self.view.mas_right).offset(-10);
  131. make.size.mas_offset(CGSizeMake(44, 44));
  132. }];
  133. [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
  134. make.top.mas_equalTo(self.titleLabel.mas_bottom);
  135. make.left.right.equalTo(self.view);
  136. make.height.mas_offset(52);
  137. }];
  138. [self getdata];
  139. WEAKSELF
  140. self.searchView.buttonBlock = ^(){
  141. // HomeSearchController *homeSearch = [[HomeSearchController alloc] init];
  142. // [weakSelf.navigationController pushViewController:homeSearch animated:YES];
  143. IndexSearchVC * vc = [[IndexSearchVC alloc] init];
  144. vc.hidesBottomBarWhenPushed = YES;
  145. [weakSelf.navigationController pushViewController:vc animated:YES];
  146. };
  147. self.searchView.bookBlock = ^(){
  148. BookStoreHome *vc = [BookStoreHome initBookStoreHome];
  149. vc.hidesBottomBarWhenPushed = YES;
  150. [weakSelf.navigationController pushViewController:vc animated:YES];
  151. };
  152. // self.channelScroll.ClickSelectChannelBlock = ^(NSInteger channelId, NSString * _Nonnull StyleCss) {
  153. // weakSelf.style = StyleCss;
  154. // weakSelf.currentChannel = channelId;
  155. // for (ChannelModel * model in weakSelf.myChannel) {
  156. // model.IsSelect = NO;
  157. // }
  158. // for (ChannelModel * model in weakSelf.myChannel) {
  159. // if (model.ArticleGroupId == channelId) {
  160. // model.IsSelect = YES;
  161. // }
  162. // }
  163. // dispatch_async(dispatch_get_main_queue(), ^{
  164. // [weakSelf collectReload];
  165. // });
  166. // };
  167. [self.scanBtn setAction:^{
  168. SWQRCodeConfig *config = [[SWQRCodeConfig alloc]init];
  169. config.scannerType = SWScannerTypeBoth;
  170. SWQRCodeViewController *qrcodeVC = [[SWQRCodeViewController alloc]init];
  171. qrcodeVC.codeConfig = config;
  172. qrcodeVC.delegate = weakSelf;
  173. [weakSelf.navigationController pushViewController:qrcodeVC animated:YES];
  174. }];
  175. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tableViewScrollTop) name:HOMESCROLLVIEWTOTOP object:nil];
  176. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shareReturnAction:) name:SHARERETURNSUCCESS object:nil];
  177. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(JPushToVC:) name:JPUSHSUCCESS object:nil];
  178. }
  179. - (void)setCusPageVC
  180. {
  181. CGFloat height = SCREEN_HEIGHT - NAVH - 52 - self.tabBarController.tabBar.frame.size.height;
  182. WS(weakSelf);
  183. NSMutableArray * data = [NSMutableArray array];
  184. NSMutableArray * vcArr = [NSMutableArray array];
  185. for (NSInteger i = 0; i < self.myChannel.count; i ++) {
  186. ChannelModel * model = self.myChannel[i];
  187. if ([model.StyleCss isEqualToString:@"Commend"]) {
  188. [data addObject:model.ArticleGroupName];
  189. HomeRecommendVC * vc = [[HomeRecommendVC alloc] init];
  190. vc.height = height;
  191. vc.style = model.StyleCss;
  192. [vcArr addObject:vc];
  193. }
  194. if ([model.StyleCss isEqualToString:@"Cathedra"]) {
  195. [data addObject:model.ArticleGroupName];
  196. HomeBigshotVC * vc = [[HomeBigshotVC alloc] init];
  197. vc.height = height;
  198. vc.style = model.StyleCss;
  199. [vcArr addObject:vc];
  200. }
  201. if ([model.StyleCss isEqualToString:@"DayGoodBook"]) {
  202. [data addObject:model.ArticleGroupName];
  203. HomeDayGoodBookVC * vc = [[HomeDayGoodBookVC alloc] init];
  204. vc.height = height;
  205. vc.style = model.StyleCss;
  206. [vcArr addObject:vc];
  207. }
  208. if ([model.StyleCss isEqualToString:@"DayGoodText"]) {
  209. [data addObject:model.ArticleGroupName];
  210. HomeDayGoodArticeVC * vc = [[HomeDayGoodArticeVC alloc] init];
  211. vc.height = height;
  212. vc.style = model.StyleCss;
  213. [vcArr addObject:vc];
  214. }
  215. if ([model.StyleCss isEqualToString:@"ChatHearSpeak"]) {
  216. [data addObject:model.ArticleGroupName];
  217. HomeSpeakVC * vc = [[HomeSpeakVC alloc] init];
  218. vc.height = height;
  219. vc.style = model.StyleCss;
  220. [vcArr addObject:vc];
  221. }
  222. if ([model.StyleCss isEqualToString:@"DayWeBook"]) {
  223. [data addObject:model.ArticleGroupName];
  224. HomeWeiCousreVC * vc = [[HomeWeiCousreVC alloc] init];
  225. vc.height = height;
  226. vc.style = model.StyleCss;
  227. [vcArr addObject:vc];
  228. }
  229. if ([model.StyleCss isEqualToString:@"StarTeacher"]) {
  230. [data addObject:model.ArticleGroupName];
  231. HomeMingShiVC * vc = [[HomeMingShiVC alloc] init];
  232. vc.height = height;
  233. vc.style = model.StyleCss;
  234. [vcArr addObject:vc];
  235. }
  236. if ([model.StyleCss isEqualToString:@"VipSupply"]) {
  237. [data addObject:model.ArticleGroupName];
  238. HomeUserVC * vc = [[HomeUserVC alloc] init];
  239. vc.height = height;
  240. vc.style = model.StyleCss;
  241. [vcArr addObject:vc];
  242. }
  243. if ([model.StyleCss isEqualToString:@"StarSchool"]) {
  244. [data addObject:model.ArticleGroupName];
  245. HomeSchoolVC * vc = [[HomeSchoolVC alloc] init];
  246. vc.height = height;
  247. vc.style = model.StyleCss;
  248. [vcArr addObject:vc];
  249. }
  250. if ([model.StyleCss isEqualToString:@"DayProblem"]) {///每日技能
  251. [data addObject:model.ArticleGroupName];
  252. HomeProblemVC * vc = [[HomeProblemVC alloc] init];
  253. vc.height = height;
  254. vc.style = model.StyleCss;
  255. [vcArr addObject:vc];
  256. }
  257. }
  258. WMZPageParam *param = PageParam()
  259. .wTitleArrSet(data)
  260. .wControllersSet(vcArr)
  261. //固定在所有子控制器底部 需要放在第一个控制器里 例如此例子
  262. .wFixFirstSet(YES)
  263. //悬浮开启
  264. .wTopSuspensionSet(YES)
  265. //等分
  266. .wMenuCellPaddingSet(45 - 21.5)
  267. .wMenuCellMarginSet(15)
  268. .wTopOffsetSet(52 + NAVH)
  269. .wFromNaviSet(YES)
  270. .wMenuAnimalSet(PageTitleMenuNone)
  271. .wMenuTitleFontSet(15.f)
  272. .wMenuTitleSelectColorSet(UIColorHex(0x3979D3))
  273. .wMenuIndicatorYSet(6.f)
  274. .wMenuIndicatorColorSet(UIColorHex(0x3979D3))
  275. .wMenuTitleColorSet(UIColorHex(0x666666))
  276. .wMenuTitleSelectFontSet(15.f)
  277. .wMenuFixShadowSet(NO)
  278. .wMenuFixRightDataSet(@" ")
  279. .wMenuFixWidthSet(88.5)
  280. //头部
  281. .wMenuHeadViewSet(^UIView *{
  282. return self.bannerBgV;
  283. });
  284. self.param = param;
  285. [self updatePageController];
  286. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  287. dispatch_async(dispatch_get_main_queue(), ^{
  288. for (UIView * view in weakSelf.view.subviews) {
  289. if ([view isKindOfClass:[WMZPageScroller class]]) {
  290. [view setFrame:CGRectMake(0, NAVH + 52, SCREEN_WIDTH, height)];
  291. }
  292. if ([view isKindOfClass:[UIScrollView class]]) {
  293. UIScrollView * sView = (UIScrollView *)view;
  294. sView.showsVerticalScrollIndicator = NO;
  295. }
  296. }
  297. UIView * view = [weakSelf setRightView];
  298. [weakSelf.upSc addSubview:view];
  299. [weakSelf.upSc bringSubviewToFront:view];
  300. [view setFrame:CGRectMake(SCREEN_WIDTH - 88.5, 0, 88.5, 45)];
  301. // [weakSelf updateController];
  302. });
  303. });
  304. }
  305. - (void)getUnreadCount
  306. {
  307. WS(weakSelf);
  308. [[HttpManager sharedHttpManager] GETUrl:Host(API_APP_User_User_Uread_Count) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  309. NSDictionary *dic = responseObject;
  310. WorkNumberModel *numberModel = [[WorkNumberModel alloc] initWithDictionary:dic error:nil];
  311. weakSelf.unReadCount = numberModel.allNumber;
  312. dispatch_async(dispatch_get_main_queue(), ^{
  313. [weakSelf initChatMsgIMData];
  314. });
  315. } failure:^(NSError * _Nonnull error) {
  316. }];
  317. }
  318. -(void)initChatMsgIMData{
  319. self.chatListIMArray = [NSMutableArray array];
  320. WS(weakSelf);
  321. SHOWLOADING
  322. [[HttpManager sharedHttpManager] POSTUrl:Host(Often_Contact_List) parameters:@{@"IndividualGroupId":@(0)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  323. NSLog(@"%@",responseObject);
  324. REMOVESHOW
  325. if ([responseObject isKindOfClass:[NSArray class]]) {
  326. for (NSDictionary * dict in responseObject) {
  327. ChatMsgListImModel * model = [ChatMsgListImModel modelWithDictionary:dict];
  328. [weakSelf.chatListIMArray addObject:model];
  329. }
  330. }
  331. [weakSelf _loadAllConversationsFromDBWithIsShowHud:NO];
  332. } failure:^(NSError * _Nonnull error) {
  333. REMOVESHOW
  334. NSLog(@"%@",error);
  335. }];
  336. }
  337. - (void)_loadAllConversationsFromDBWithIsShowHud:(BOOL)aIsShowHUD
  338. {
  339. __weak typeof(self) weakself = self;
  340. self.dataArray = [NSMutableArray array];
  341. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  342. NSArray *conversations = [[EMClient sharedClient].chatManager getAllConversations];
  343. NSArray *sorted = [conversations sortedArrayUsingComparator:^(EMConversation *obj1, EMConversation *obj2) {
  344. EMMessage *message1 = [obj1 latestMessage];
  345. EMMessage *message2 = [obj2 latestMessage];
  346. if(message1.timestamp > message2.timestamp) {
  347. return(NSComparisonResult)NSOrderedAscending;
  348. } else {
  349. return(NSComparisonResult)NSOrderedDescending;
  350. }
  351. }];
  352. NSArray *models = [EMConversationHelper modelsFromEMConversations:sorted];
  353. [weakself.dataArray addObjectsFromArray:models];
  354. [weakself replaceChatData];
  355. });
  356. }
  357. - (void)replaceChatData
  358. {
  359. WS(weakSelf);
  360. [self.chatListIMArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  361. ChatMsgListImModel * chatModel = (ChatMsgListImModel *)obj;
  362. [weakSelf.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  363. EMConversationModel * model = (EMConversationModel *)obj;
  364. if (chatModel.ImId == [model.emModel.conversationId integerValue]) {
  365. if (!chatModel.IsDisturb) {
  366. chatModel.redNum = model.emModel.unreadMessagesCount;
  367. weakSelf.unReadCount += model.emModel.unreadMessagesCount;
  368. }
  369. }
  370. }];
  371. }];
  372. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  373. weakSelf.tabBarController.tabBar.items[2].badgeValue = weakSelf.unReadCount > 0 ? [NSString stringWithFormat:@"%ld",(long)weakSelf.unReadCount] : nil;
  374. });
  375. }
  376. - (void)conversationListDidUpdate:(NSArray *)aConversationList
  377. {
  378. [self _loadAllConversationsFromDBWithIsShowHud:NO];
  379. }
  380. - (void)messagesDidReceive:(NSArray *)aMessages
  381. {
  382. [self performSelector:@selector(getUnreadCount) withObject:nil afterDelay:0.8];
  383. }
  384. - (void)tableViewScrollTop
  385. {
  386. if (self.dataSource.count > 0) {
  387. [self.downSc scrollToTop];
  388. [self.downSc scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
  389. }
  390. }
  391. - (void)dealloc
  392. {
  393. [[EMClient sharedClient].chatManager removeDelegate:self];
  394. [[EMClient sharedClient].groupManager removeDelegate:self];
  395. [[EMConversationHelper shared] removeDelegate:self];
  396. [[NSNotificationCenter defaultCenter] removeObserver:self];
  397. }
  398. #pragma mark - NetRequest - 轮播
  399. - (void)getdata{
  400. [self loadChannelModel];
  401. WS(weakSelf);
  402. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  403. __block NSInteger httpFinishCount = 0;
  404. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  405. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,HomeSlideImages_GET] parameters: @{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  406. NSArray *arr = responseObject[@"Items"];
  407. NSLog(@"首页轮播数据%@",arr.firstObject);
  408. [weakSelf.bannerModelArray removeAllObjects];
  409. [weakSelf.bannerImgArr removeAllObjects];
  410. NSMutableArray *array = [NSMutableArray array];
  411. NSMutableArray *array2 = [NSMutableArray array];
  412. for (NSInteger i = 0; i < arr.count; i++) {
  413. NSDictionary *dic = arr[i];
  414. HomeTopImageModel *imageModel = [[HomeTopImageModel alloc] initWithDictionary:dic error:nil];
  415. [array2 addObject:imageModel];
  416. [array addObject:dic[@"ImageUrl"]];
  417. }
  418. weakSelf.bannerImgArr = array;
  419. weakSelf.bannerModelArray = array2;
  420. weakSelf.bannerView.slImages = array;
  421. if (++httpFinishCount == 2) {
  422. dispatch_semaphore_signal(sem);
  423. }
  424. } failure:^(NSError * _Nonnull error) {
  425. // if (++httpFinishCount == 2) {
  426. // dispatch_semaphore_signal(sem);
  427. // }
  428. SHOWERROR([ZYCTool handerResultData:error]);
  429. }];
  430. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Pindao_User_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  431. NSLog(@"%@",responseObject);
  432. NSArray *array = responseObject;
  433. for (NSInteger i = 0 ; i < array.count; i ++) {
  434. NSDictionary *dic = array[i];
  435. ChannelModel *model = [ChannelModel modelWithDictionary:dic];
  436. if (model.ArticleGroupId == 0) {
  437. model.IsSelect = YES;
  438. }
  439. [weakSelf.myChannel addObject:model];
  440. }
  441. if (++httpFinishCount == 2) {
  442. dispatch_semaphore_signal(sem);
  443. }
  444. } failure:^(NSError * _Nonnull error) {
  445. // if (++httpFinishCount == 2) {
  446. // dispatch_semaphore_signal(sem);
  447. // }
  448. SHOWERROR([ZYCTool handerResultData:error]);
  449. }];
  450. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  451. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  452. dispatch_async(dispatch_get_main_queue(), ^{
  453. [weakSelf setCusPageVC];
  454. });
  455. });
  456. });
  457. }
  458. - (void)ReGetHomeListData:(NSInteger)channelId
  459. {
  460. WS(weakSelf);
  461. switch (channelId) {
  462. case 0:
  463. {
  464. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Notice_list_Post] parameters: @{@"page":@(self.currentPage),@"perPage":@10,@"GroupId":@(channelId)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  465. NSDictionary *dic = (NSDictionary *)responseObject;
  466. HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic];
  467. weakSelf.totalPage = model.Count;
  468. [weakSelf.dataSource addObjectsFromArray:model.Items];
  469. } failure:^(NSError * _Nonnull error) {
  470. }];
  471. }
  472. break;
  473. case 1:
  474. {
  475. NSDictionary * paraDict = @{@"Type":@"MyChecking",@"page":@(self.currentPage),@"perPage":@10};
  476. [[HttpManager sharedHttpManager] GETUrl:Host(WorkFlowAddApproval_Post) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  477. NSDictionary *dic = (NSDictionary *)responseObject;
  478. HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic];
  479. weakSelf.totalPage = model.Count;
  480. [weakSelf.dataSource addObjectsFromArray:model.Items];
  481. } failure:^(NSError * _Nonnull error) {
  482. SHOWERROR([ZYCTool handerResultData:error])
  483. }];
  484. }
  485. break;
  486. default:
  487. {
  488. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_PAGE_CATHEDRA) parameters:@{@"StyleCss":self.style,@"Page":@(self.currentPage),@"PerPage":@20} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  489. NSLog(@"%@",responseObject);
  490. } failure:^(NSError * _Nonnull error) {
  491. }];
  492. }
  493. break;
  494. }
  495. }
  496. - (BOOL)hidesBottomBarWhenPushed{
  497. return NO;
  498. }
  499. #pragma mark - UITableViewDataSource && UITableViewDelegate
  500. - (void)closeBtn_Click {
  501. [self.alertVC dismissViewControllerAnimated:YES completion:nil];
  502. }
  503. - (void)cellDidSelcet:(NSInteger )articleId{
  504. WEAKSELF
  505. UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  506. [closeBtn addTarget:self action:@selector(closeBtn_Click) forControlEvents:UIControlEventTouchUpInside];
  507. [closeBtn setImage:IMG(@"guanbi") forState:UIControlStateNormal];
  508. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"对此内容进行操作" message:@"" preferredStyle:UIAlertControllerStyleAlert];
  509. self.alertVC = alertVC;
  510. [alertVC.view addSubview:closeBtn];
  511. [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  512. make.right.equalTo(alertVC.view).offset(-10);
  513. make.top.equalTo(@10);
  514. make.size.mas_equalTo(CGSizeMake(22, 22));
  515. }];
  516. UIAlertAction *actionOK = [UIAlertAction actionWithTitle:@"屏蔽TA" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  517. STRONGSELF
  518. [strongSelf homeNewsHander:articleId withTypeId:1];
  519. }];
  520. [actionOK setValue:k9 forKey:@"_titleTextColor"];
  521. UIAlertAction *actionNO = [UIAlertAction actionWithTitle:@"不感兴趣" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  522. STRONGSELF
  523. [strongSelf homeNewsHander:articleId withTypeId:2];
  524. }];
  525. [alertVC addAction:actionOK];
  526. [alertVC addAction:actionNO];
  527. [self presentViewController:alertVC animated:YES completion:^{
  528. [alertVC tapGesAlert];
  529. }];
  530. }
  531. - (void)homeNewsHander:(NSInteger )articleId withTypeId:(NSInteger)blacklistType{
  532. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@/%@",BaseUrl,Article_Hander_Post] parameters:@{@"ArticleId":@(articleId),@"BlacklistType":@(blacklistType)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  533. // [weakSelf headRefresh];
  534. } failure:^(NSError * _Nonnull error) {
  535. }];
  536. }
  537. #pragma mark - channelScroll Block
  538. - (void)didClickAddButtonChannel{
  539. AddChannelController *addChannel = [[AddChannelController alloc] init];
  540. addChannel.modalPresentationStyle = UIModalPresentationFullScreen;
  541. addChannel.delegate = self;
  542. [self presentViewController:addChannel animated:YES completion:nil];
  543. }
  544. #pragma mark - AddChannelControllerDelegate
  545. - (void)upadateChannel{
  546. WS(weakSelf);
  547. [self loadChannelModel];
  548. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Pindao_User_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  549. NSLog(@"%@",responseObject);
  550. NSArray *array = responseObject;
  551. for (NSInteger i = 0 ; i < array.count; i ++) {
  552. NSDictionary *dic = array[i];
  553. ChannelModel *model = [ChannelModel modelWithDictionary:dic];
  554. [weakSelf.myChannel addObject:model];
  555. }
  556. dispatch_async(dispatch_get_main_queue(), ^{
  557. [weakSelf setCusPageVC];
  558. });
  559. } failure:^(NSError * _Nonnull error) {
  560. }];
  561. }
  562. #pragma mark - SLBannerViewDelegate
  563. - (void)bannerView:(SLBannerView *)banner didClickImagesAtIndex:(NSInteger)index
  564. {
  565. [self getArticleDetail:index];
  566. }
  567. - (void)getArticleDetail:(NSInteger)index{
  568. HomeTopImageModel *model = self.bannerModelArray[index];
  569. switch (model.MediaType) {
  570. case CollectModel_StoreBook:
  571. {
  572. BookListDetailVC * vc = [BookListDetailVC initBookListDetailVC];
  573. vc.Id = model.MediaId;
  574. vc.hidesBottomBarWhenPushed = YES;
  575. [self.navigationController pushViewController:vc animated:YES];
  576. }
  577. break;
  578. case CollectModel_StoreVideo:
  579. {
  580. BookWCDetailVC * vc = [BookWCDetailVC initBookWCDetailVC];
  581. vc.Id = model.MediaId;
  582. vc.hidesBottomBarWhenPushed = YES;
  583. [self.navigationController pushViewController:vc animated:YES];
  584. }
  585. break;
  586. case CollectModel_StoreSound:
  587. {
  588. BookListenVC * vc = [BookListenVC initBookListenVC];
  589. vc.Id = model.MediaId;
  590. vc.MediaType = MediaMusicType;
  591. vc.hidesBottomBarWhenPushed = YES;
  592. [self.navigationController pushViewController:vc animated:YES];
  593. }
  594. break;
  595. case CollectModel_Teacher:
  596. {
  597. BookTeacherDetailVC * vc = [BookTeacherDetailVC initBookTeacherDetailVC];
  598. vc.Id = model.MediaId;
  599. vc.hidesBottomBarWhenPushed = YES;
  600. [self.navigationController pushViewController:vc animated:YES];
  601. }
  602. break;
  603. case CollectModel_Organization:
  604. {
  605. }
  606. break;
  607. default:
  608. {
  609. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  610. vc.type = model.MediaType;
  611. vc.Id = model.MediaId;
  612. [self.navigationController pushViewController:vc animated:YES];
  613. }
  614. break;
  615. }
  616. }
  617. #pragma mark - Setter
  618. - (UILabel *)titleLabel {
  619. if (!_titleLabel) {
  620. _titleLabel = [UILabel new];
  621. _titleLabel.backgroundColor = [UIColor whiteColor];
  622. _titleLabel.text = @"首页";
  623. _titleLabel.font = [UIFont systemFontOfSize:16.f];
  624. _titleLabel.textColor = UIColorHex(1A1A1A);
  625. _titleLabel.textAlignment = NSTextAlignmentCenter;
  626. }
  627. return _titleLabel;
  628. }
  629. - (UIButton *)scanBtn {
  630. if (!_scanBtn) {
  631. _scanBtn = [UIButton new];
  632. [_scanBtn setImage:IMG(@"home_scan") forState:UIControlStateNormal];
  633. }
  634. return _scanBtn;
  635. }
  636. - (SurfaceSearchView *)searchView {
  637. if (!_searchView) {
  638. _searchView = [[SurfaceSearchView alloc] init];
  639. [_searchView setBgViewColor:[UIColor clearColor]];
  640. // [_searchView setPlaceHolderText:@"输入关键字搜索"];
  641. [_searchView setMainType];
  642. }
  643. return _searchView;
  644. }
  645. - (NSMutableArray *)dataSource
  646. {
  647. if (!_dataSource) {
  648. _dataSource = [NSMutableArray array];
  649. }
  650. return _dataSource;
  651. }
  652. - (NSMutableArray *)tabConfigArray{
  653. if (!_tabConfigArray) {
  654. _tabConfigArray = [NSMutableArray array];
  655. }
  656. return _tabConfigArray;
  657. }
  658. - (NSMutableDictionary *)articleDic{
  659. if (!_articleDic) {
  660. _articleDic = [NSMutableDictionary dictionary];
  661. }
  662. return _articleDic;
  663. }
  664. - (NSMutableArray *)myChannel {
  665. if (!_myChannel) {
  666. _myChannel = [NSMutableArray array];
  667. }
  668. return _myChannel;
  669. }
  670. - (void)loadChannelModel
  671. {
  672. [self.myChannel removeAllObjects];
  673. // ChannelModel * model = [[ChannelModel alloc] init];
  674. // model.ArticleGroupId = 0;
  675. // model.ArticleGroupName = @"推荐";
  676. // model.StyleCss = @"default";
  677. // model.IsSelect = YES;
  678. // [self.myChannel addObject:model];
  679. // ChannelModel * workModel = [[ChannelModel alloc] init];
  680. // workModel.ArticleGroupId = 1;
  681. // workModel.ArticleGroupName = @"待办工作";
  682. // workModel.IsSelect = NO;
  683. // [self.myChannel addObject:workModel];
  684. // ChannelModel * sModel = [[ChannelModel alloc] init];
  685. // sModel.ArticleGroupId = 2;
  686. // sModel.ArticleGroupName = @"信源听说";
  687. // sModel.IsSelect = NO;
  688. // [self.myChannel addObject:sModel];
  689. // ChannelModel * mModel = [[ChannelModel alloc] init];
  690. // mModel.ArticleGroupId = 3;
  691. // mModel.ArticleGroupName = @"名校";
  692. // mModel.IsSelect = NO;
  693. // [self.myChannel addObject:mModel];
  694. // ChannelModel * aModel = [[ChannelModel alloc] init];
  695. // aModel.ArticleGroupId = 4;
  696. // aModel.ArticleGroupName = @"会员特供";
  697. // aModel.IsSelect = NO;
  698. // [self.myChannel addObject:aModel];
  699. // ChannelModel * bModel = [[ChannelModel alloc] init];
  700. // bModel.ArticleGroupId = 5;
  701. // bModel.ArticleGroupName = @"每日微课";
  702. // bModel.IsSelect = NO;
  703. // [self.myChannel addObject:bModel];
  704. // ChannelModel * cModel = [[ChannelModel alloc] init];
  705. // cModel.ArticleGroupId = 6;
  706. // cModel.ArticleGroupName = @"每日技能";
  707. // cModel.IsSelect = NO;
  708. // [self.myChannel addObject:cModel];
  709. // ChannelModel * dModel = [[ChannelModel alloc] init];
  710. // dModel.ArticleGroupId = 7;
  711. // dModel.ArticleGroupName = @"每日好书";
  712. // dModel.IsSelect = NO;
  713. // [self.myChannel addObject:dModel];
  714. // ChannelModel * eModel = [[ChannelModel alloc] init];
  715. // eModel.ArticleGroupId = 8;
  716. // eModel.ArticleGroupName = @"每日好文";
  717. // eModel.IsSelect = NO;
  718. // [self.myChannel addObject:eModel];
  719. // ChannelModel * fModel = [[ChannelModel alloc] init];
  720. // fModel.ArticleGroupId = 9;
  721. // fModel.ArticleGroupName = @"名师";
  722. // fModel.IsSelect = NO;
  723. // [self.myChannel addObject:fModel];
  724. // ChannelModel * gModel = [[ChannelModel alloc] init];
  725. // gModel.ArticleGroupId = 10;
  726. // gModel.ArticleGroupName = @"大咖讲座";
  727. // gModel.IsSelect = NO;
  728. // [self.myChannel addObject:gModel];
  729. }
  730. #pragma mark - 分享成功跳转
  731. - (void)shareReturnAction:(NSNotification *)noti
  732. {
  733. NSDictionary * dic = noti.userInfo;
  734. CollectModelType type = [[dic objectForKey:@"type"] intValue];
  735. NSInteger Id = [[dic objectForKey:@"Id"] integerValue];
  736. NSInteger userId = [[dic objectForKey:@"userId"] integerValue];
  737. NSString* name = [[dic objectForKey:@"name"] stringByRemovingPercentEncoding];
  738. // NSString* describe = [[dic objectForKey:@"describe"] stringByRemovingPercentEncoding];
  739. switch (type) {
  740. case CollectModel_Aritle:
  741. {
  742. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  743. vc.type = CollectModel_Aritle;
  744. vc.Id = Id;
  745. vc.hidesBottomBarWhenPushed = YES;
  746. [self.navigationController pushViewController:vc animated:YES];
  747. }
  748. break;
  749. case CollectModel_work:
  750. {
  751. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  752. vc.indexId = Id;
  753. vc.title = name;
  754. vc.TodoId = Id;
  755. vc.hidesBottomBarWhenPushed = YES;
  756. [self.navigationController pushViewController:vc animated:YES];
  757. }
  758. break;
  759. case CollectModel_Toipc:
  760. {
  761. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  762. vc.Id = Id;
  763. vc.type = CollectModel_Toipc;
  764. vc.hidesBottomBarWhenPushed = YES;
  765. [self.navigationController pushViewController:vc animated:YES];
  766. }
  767. break;
  768. case CollectModel_NewTopic:
  769. {
  770. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  771. vc.Id = Id;
  772. vc.type = CollectModel_NewTopic;
  773. vc.hidesBottomBarWhenPushed = YES;
  774. [self.navigationController pushViewController:vc animated:YES];
  775. }
  776. break;
  777. case CollectModel_Notice:
  778. {
  779. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  780. vc.Id = Id;
  781. vc.type = CollectModel_Notice;
  782. vc.hidesBottomBarWhenPushed = YES;
  783. [self.navigationController pushViewController:vc animated:YES];
  784. }
  785. break;
  786. case CollectModel_InterMail:
  787. {
  788. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  789. vc.Id = Id;
  790. vc.type = CollectModel_InterMail;
  791. vc.hidesBottomBarWhenPushed = YES;
  792. [self.navigationController pushViewController:vc animated:YES];
  793. }
  794. break;
  795. case CollectModel_NoSignMail:
  796. {
  797. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  798. vc.Id = Id;
  799. vc.type = CollectModel_NoSignMail;
  800. vc.hidesBottomBarWhenPushed = YES;
  801. [self.navigationController pushViewController:vc animated:YES];
  802. }
  803. break;
  804. case CollectModel_NoteBook:
  805. {
  806. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  807. vc.Id = Id;
  808. vc.type = CollectModel_NoteBook;
  809. vc.hidesBottomBarWhenPushed = YES;
  810. [self.navigationController pushViewController:vc animated:YES];
  811. }
  812. break;
  813. case CollectModel_meetMian:
  814. {
  815. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  816. vc.Id = Id;
  817. vc.type = CollectModel_meetMian;
  818. vc.hidesBottomBarWhenPushed = YES;
  819. [self.navigationController pushViewController:vc animated:YES];
  820. }
  821. break;
  822. case CollectModel_meetDetail:
  823. {
  824. WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:Id];
  825. vc.hidesBottomBarWhenPushed = YES;
  826. [self.navigationController pushViewController:vc animated:YES];
  827. }
  828. break;
  829. case CollectModel_CollectFile:{
  830. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  831. MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
  832. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  833. vc.ParentId = Id;
  834. vc.FolderId = Id;
  835. vc.myTitle = name;
  836. vc.hidesBottomBarWhenPushed = YES;
  837. [self.navigationController pushViewController:vc animated:YES];
  838. }else{
  839. OtherFavoriteVC *vc = [OtherFavoriteVC initOtherFavoriteVC];
  840. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  841. vc.ParentId = Id;
  842. vc.FolderId = Id;
  843. vc.myTitle = name;
  844. vc.VisitUserId = userId;
  845. vc.hidesBottomBarWhenPushed = YES;
  846. [self.navigationController pushViewController:vc animated:YES];
  847. }
  848. }break;
  849. case CollectModel_NoteFile:{
  850. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  851. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  852. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  853. vc.ParentId = Id;
  854. vc.FolderId = Id;
  855. vc.myTitle = name;
  856. vc.VisitUserId = 0;
  857. [self.navigationController pushViewController:vc animated:YES];
  858. }else{
  859. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  860. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  861. vc.ParentId = Id;
  862. vc.FolderId = Id;
  863. vc.myTitle = name;
  864. vc.VisitUserId = userId;
  865. vc.hidesBottomBarWhenPushed = YES;
  866. [self.navigationController pushViewController:vc animated:YES];
  867. }
  868. }break;
  869. case CollectModel_TopicBooK:{
  870. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  871. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  872. vc.listType = MyFavoriteListLevelTypeA;
  873. vc.ParentId = 0;
  874. vc.FolderId = Id;
  875. vc.myTitle = name;
  876. vc.VisitUserId = 0;
  877. vc.TypeValue = 1;
  878. [self.navigationController pushViewController:vc animated:YES];
  879. }else{
  880. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  881. vc.listType = MyFavoriteListLevelTypeA;
  882. vc.ParentId = 0;
  883. vc.FolderId = Id;
  884. vc.myTitle = name;
  885. vc.VisitUserId = userId;
  886. vc.TypeValue = 1;
  887. vc.hidesBottomBarWhenPushed = YES;
  888. [self.navigationController pushViewController:vc animated:YES];
  889. }
  890. }break;
  891. case CollectModel_TopicSubBooK:{
  892. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  893. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  894. vc.listType = MyFavoriteListLevelTypeB;
  895. vc.ParentId = Id;
  896. vc.FolderId = Id;
  897. vc.myTitle = name;
  898. vc.VisitUserId = 0;
  899. vc.TypeValue = 1;
  900. [self.navigationController pushViewController:vc animated:YES];
  901. }else{
  902. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  903. vc.listType = MyFavoriteListLevelTypeB;
  904. vc.ParentId = Id;
  905. vc.FolderId = Id;
  906. vc.myTitle = name;
  907. vc.VisitUserId = userId;
  908. vc.TypeValue = 1;
  909. vc.hidesBottomBarWhenPushed = YES;
  910. [self.navigationController pushViewController:vc animated:YES];
  911. }
  912. }break;
  913. default:
  914. break;
  915. }
  916. }
  917. - (void)addChannelAction:(UIButton *)sender
  918. {
  919. [self didClickAddButtonChannel];
  920. }
  921. - (void)musicAction:(UIButton *)sender
  922. {
  923. [[HKFloatManager shared] showVideo];
  924. }
  925. - (TDButton *)addButton {
  926. if (!_addButton) {
  927. _addButton = [TDButton buttonWithType:UIButtonTypeCustom];
  928. [_addButton setImage:IMG(@"home_pdAdd_icon") forState:UIControlStateNormal];
  929. [_addButton addTarget:self action:@selector(addChannelAction:) forControlEvents:UIControlEventTouchUpInside];
  930. [_addButton setCurrentButtonHotSize:CGSizeZero];
  931. }
  932. return _addButton;
  933. }
  934. - (TDButton *)musicButtton {
  935. if (!_musicButtton) {
  936. _musicButtton = [TDButton buttonWithType:UIButtonTypeCustom];
  937. [_musicButtton setImage:IMG(@"home_music_icon") forState:UIControlStateNormal];
  938. [_musicButtton addTarget:self action:@selector(musicAction:) forControlEvents:UIControlEventTouchUpInside];
  939. [_musicButtton setCurrentButtonHotSize:CGSizeZero];
  940. }
  941. return _musicButtton;
  942. }
  943. - (UIView *)lineV
  944. {
  945. if (!_lineV) {
  946. _lineV = [UIView new];
  947. _lineV.backgroundColor = UIColorHex(0xD8D8D8);
  948. }
  949. return _lineV;
  950. }
  951. - (UIView *)rightView
  952. {
  953. if (!_rightView) {
  954. _rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 88.5, 45)];
  955. _rightView.backgroundColor = UIColorHex(0xFFFFFF);
  956. }
  957. return _rightView;
  958. }
  959. - (UIView *)setRightView
  960. {
  961. [self.rightView removeAllSubviews];
  962. [self.rightView addSubview:self.addButton];
  963. [self.rightView addSubview:self.musicButtton];
  964. [self.rightView addSubview:self.lineV];
  965. [self.addButton setFrame:CGRectMake(0, 0, 44, 45)];
  966. [self.lineV setFrame:CGRectMake(44, 13.5, 0.5, 18)];
  967. [self.musicButtton setFrame:CGRectMake(44.5, 0, 44, 45)];
  968. return self.rightView;
  969. }
  970. #pragma mark - JPushToVC
  971. - (void)JPushToVC:(NSNotification *)noti
  972. {
  973. PushModel * model = [PushModel modelWithDictionary:noti.userInfo];
  974. switch (model.mediaType) {
  975. case CollectModel_Chat:
  976. {
  977. ChatMsgListVC * vc = [ChatMsgListVC initChatMsgListVC];
  978. vc.pModel = model;
  979. vc.isPush = YES;
  980. vc.hidesBottomBarWhenPushed = YES;
  981. [self.navigationController pushViewController:vc animated:NO];
  982. }
  983. break;
  984. case CollectModel_work:
  985. {
  986. [self pushWorkVCwithModel:model];
  987. }
  988. break;
  989. case CollectModel_MeShen:
  990. {
  991. [self pushWorkVCwithModel:model];
  992. }
  993. break;
  994. case CollectModel_MeChao:
  995. {
  996. [self pushWorkVCwithModel:model];
  997. }
  998. break;
  999. case CollectModel_System:
  1000. {
  1001. [self pushWorkVCwithModel:model];
  1002. }
  1003. break;
  1004. case CollectModel_Verify:
  1005. {
  1006. ChatTestingVC * vc = [ChatTestingVC initChatTestingVC];
  1007. vc.hidesBottomBarWhenPushed = YES;
  1008. [self.navigationController pushViewController:vc animated:YES];
  1009. }
  1010. break;
  1011. case CollectModel_ReplayMe:
  1012. {
  1013. ReplayMeVC * vc = [ReplayMeVC initReplayMeVC];
  1014. vc.hidesBottomBarWhenPushed = YES;
  1015. [self.navigationController pushViewController:vc animated:YES];
  1016. }
  1017. break;
  1018. default:
  1019. {
  1020. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1021. vc.Id = model.sourceId;
  1022. vc.type = model.mediaType;
  1023. vc.hidesBottomBarWhenPushed = YES;
  1024. [self.navigationController pushViewController:vc animated:YES];
  1025. }
  1026. break;
  1027. }
  1028. }
  1029. - (void)pushWorkVCwithModel:(PushModel *)model
  1030. {
  1031. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  1032. vc.pageType = Type_ONEC;
  1033. vc.indexId = model.sourceId;
  1034. [self.navigationController pushViewController:vc animated:YES];
  1035. }
  1036. #pragma mark - ScanResult
  1037. - (void)scanResult:(NSString *)scanStr{
  1038. ScanResultModel *model = [[ScanResultModel alloc]initWithString:scanStr error:nil];
  1039. NSLog(@"%@",model);
  1040. WEAKSELF
  1041. switch (model.key) {
  1042. case 1:// 用户
  1043. {
  1044. [self scanNetWork:model.value urlStrong:SaoYiSao_Post ScanKey:@"Guid" success:^(id responseObject) {
  1045. NSDictionary *dic = responseObject;
  1046. AddressUserModel *model = [[AddressUserModel alloc] initWithDictionary:dic error:nil];
  1047. dispatch_async(dispatch_get_main_queue(), ^{
  1048. MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
  1049. vc.indexId = model.Id;
  1050. vc.isAdd = YES;
  1051. [weakSelf.navigationController pushViewController:vc animated:YES];
  1052. });
  1053. } failure:^(NSError *error) {
  1054. SHOWERROR([ZYCTool handerResultData:error]);
  1055. }];
  1056. }
  1057. break;
  1058. case 2:// 群聊
  1059. {
  1060. [self scanToNetWork:model.value urlStrong:SaoYiSao2_Post success:^(id responseObject) {
  1061. ChatJoinGroupVC * vc = [ChatJoinGroupVC initChatJoinGroupVC];
  1062. vc.dict = responseObject;
  1063. [weakSelf.navigationController pushViewController:vc animated:YES];
  1064. } failure:^(NSError *error) {
  1065. SHOWERROR([ZYCTool handerResultData:error]);
  1066. }];
  1067. }
  1068. break;
  1069. case 3://小组
  1070. {
  1071. [self scanToNetWork:model.value urlStrong:SaoYiSao3_Post success:^(id responseObject) {
  1072. if ([responseObject[@"IsUser"] boolValue]) {
  1073. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  1074. vc.GroupId = [responseObject[@"Id"] integerValue];
  1075. vc.titleStr = responseObject[@"Name"];
  1076. [weakSelf.navigationController pushViewController:vc animated:YES];
  1077. }else{
  1078. dispatch_async(dispatch_get_main_queue(), ^{
  1079. TDQrJoinVC * vc = [TDQrJoinVC initTDQrJoinVC];
  1080. vc.dict = responseObject;
  1081. [weakSelf.navigationController pushViewController:vc animated:YES];
  1082. });
  1083. }
  1084. } failure:^(NSError *error) {
  1085. SHOWERROR([ZYCTool handerResultData:error]);
  1086. }];
  1087. }
  1088. break;
  1089. case 4://扫码登录
  1090. {
  1091. LoginPCVC * vc = [[LoginPCVC alloc] init];
  1092. vc.key = model.value;
  1093. vc.modalPresentationStyle = UIModalPresentationFullScreen;
  1094. [self presentViewController:vc animated:YES completion:^{
  1095. }];
  1096. }
  1097. break;
  1098. default:
  1099. break;
  1100. }
  1101. }
  1102. - (void)scanNetWork:(NSString *)scanStr urlStrong:(NSString *)urlstring ScanKey:(NSString*)key success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{
  1103. SHOWLOADING
  1104. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,urlstring] parameters:@{key:scanStr} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  1105. successful(responseObject);
  1106. REMOVESHOW
  1107. } failure:^(NSError * _Nonnull error) {
  1108. REMOVESHOW
  1109. failure(error);
  1110. }];
  1111. }
  1112. - (void)scanToNetWork:(NSString *)scanStr urlStrong:(NSString *)urlstring success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{
  1113. SHOWLOADING
  1114. NSString * url = [NSString stringWithFormat:@"%@%@",Host(urlstring),scanStr];
  1115. [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} success:^(id _Nonnull responseObject) {
  1116. REMOVESHOW
  1117. successful(responseObject);
  1118. } failure:^(NSError * _Nonnull error) {
  1119. REMOVESHOW
  1120. }];
  1121. }
  1122. @end