IndexViewController.m 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  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.1 * 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. [[HttpManager sharedHttpManager] POSTUrl:Host(Often_Contact_List) parameters:@{@"IndividualGroupId":@(0)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  322. NSLog(@"%@",responseObject);
  323. if ([responseObject isKindOfClass:[NSArray class]]) {
  324. for (NSDictionary * dict in responseObject) {
  325. ChatMsgListImModel * model = [ChatMsgListImModel modelWithDictionary:dict];
  326. [weakSelf.chatListIMArray addObject:model];
  327. }
  328. }
  329. [weakSelf _loadAllConversationsFromDBWithIsShowHud:NO];
  330. } failure:^(NSError * _Nonnull error) {
  331. NSLog(@"%@",error);
  332. }];
  333. }
  334. - (void)_loadAllConversationsFromDBWithIsShowHud:(BOOL)aIsShowHUD
  335. {
  336. __weak typeof(self) weakself = self;
  337. self.dataArray = [NSMutableArray array];
  338. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  339. NSArray *conversations = [[EMClient sharedClient].chatManager getAllConversations];
  340. NSArray *sorted = [conversations sortedArrayUsingComparator:^(EMConversation *obj1, EMConversation *obj2) {
  341. EMMessage *message1 = [obj1 latestMessage];
  342. EMMessage *message2 = [obj2 latestMessage];
  343. if(message1.timestamp > message2.timestamp) {
  344. return(NSComparisonResult)NSOrderedAscending;
  345. } else {
  346. return(NSComparisonResult)NSOrderedDescending;
  347. }
  348. }];
  349. NSArray *models = [EMConversationHelper modelsFromEMConversations:sorted];
  350. [weakself.dataArray addObjectsFromArray:models];
  351. [weakself replaceChatData];
  352. });
  353. }
  354. - (void)replaceChatData
  355. {
  356. WS(weakSelf);
  357. [self.chatListIMArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  358. ChatMsgListImModel * chatModel = (ChatMsgListImModel *)obj;
  359. [weakSelf.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  360. EMConversationModel * model = (EMConversationModel *)obj;
  361. if (chatModel.ImId == [model.emModel.conversationId integerValue]) {
  362. if (!chatModel.IsDisturb) {
  363. chatModel.redNum = model.emModel.unreadMessagesCount;
  364. weakSelf.unReadCount += model.emModel.unreadMessagesCount;
  365. }
  366. }
  367. }];
  368. }];
  369. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  370. weakSelf.tabBarController.tabBar.items[1].badgeValue = weakSelf.unReadCount > 0 ? [NSString stringWithFormat:@"%ld",(long)weakSelf.unReadCount] : nil;
  371. });
  372. }
  373. - (void)conversationListDidUpdate:(NSArray *)aConversationList
  374. {
  375. [self _loadAllConversationsFromDBWithIsShowHud:NO];
  376. }
  377. - (void)messagesDidReceive:(NSArray *)aMessages
  378. {
  379. [self performSelector:@selector(getUnreadCount) withObject:nil afterDelay:0.8];
  380. }
  381. - (void)tableViewScrollTop
  382. {
  383. if (self.dataSource.count > 0) {
  384. [self.downSc scrollToTop];
  385. [self.downSc scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
  386. }
  387. }
  388. - (void)dealloc
  389. {
  390. [[EMClient sharedClient].chatManager removeDelegate:self];
  391. [[EMClient sharedClient].groupManager removeDelegate:self];
  392. [[EMConversationHelper shared] removeDelegate:self];
  393. [[NSNotificationCenter defaultCenter] removeObserver:self];
  394. }
  395. #pragma mark - NetRequest - 轮播
  396. - (void)getdata{
  397. [self loadChannelModel];
  398. WS(weakSelf);
  399. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  400. __block NSInteger httpFinishCount = 0;
  401. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  402. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,HomeSlideImages_GET] parameters: @{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  403. NSArray *arr = responseObject[@"Items"];
  404. NSLog(@"首页轮播数据%@",arr.firstObject);
  405. [weakSelf.bannerModelArray removeAllObjects];
  406. [weakSelf.bannerImgArr removeAllObjects];
  407. NSMutableArray *array = [NSMutableArray array];
  408. NSMutableArray *array2 = [NSMutableArray array];
  409. for (NSInteger i = 0; i < arr.count; i++) {
  410. NSDictionary *dic = arr[i];
  411. HomeTopImageModel *imageModel = [[HomeTopImageModel alloc] initWithDictionary:dic error:nil];
  412. [array2 addObject:imageModel];
  413. [array addObject:dic[@"ImageUrl"]];
  414. }
  415. weakSelf.bannerImgArr = array;
  416. weakSelf.bannerModelArray = array2;
  417. weakSelf.bannerView.slImages = array;
  418. if (++httpFinishCount == 2) {
  419. dispatch_semaphore_signal(sem);
  420. }
  421. } failure:^(NSError * _Nonnull error) {
  422. // if (++httpFinishCount == 2) {
  423. // dispatch_semaphore_signal(sem);
  424. // }
  425. SHOWERROR([ZYCTool handerResultData:error]);
  426. }];
  427. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Pindao_User_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  428. NSLog(@"%@",responseObject);
  429. NSArray *array = responseObject;
  430. for (NSInteger i = 0 ; i < array.count; i ++) {
  431. NSDictionary *dic = array[i];
  432. ChannelModel *model = [ChannelModel modelWithDictionary:dic];
  433. if (model.ArticleGroupId == 0) {
  434. model.IsSelect = YES;
  435. }
  436. [weakSelf.myChannel addObject:model];
  437. }
  438. if (++httpFinishCount == 2) {
  439. dispatch_semaphore_signal(sem);
  440. }
  441. } failure:^(NSError * _Nonnull error) {
  442. // if (++httpFinishCount == 2) {
  443. // dispatch_semaphore_signal(sem);
  444. // }
  445. SHOWERROR([ZYCTool handerResultData:error]);
  446. }];
  447. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  448. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  449. dispatch_async(dispatch_get_main_queue(), ^{
  450. [weakSelf setCusPageVC];
  451. });
  452. });
  453. });
  454. }
  455. - (void)ReGetHomeListData:(NSInteger)channelId
  456. {
  457. WS(weakSelf);
  458. switch (channelId) {
  459. case 0:
  460. {
  461. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Notice_list_Post] parameters: @{@"page":@(self.currentPage),@"perPage":@10,@"GroupId":@(channelId)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  462. NSDictionary *dic = (NSDictionary *)responseObject;
  463. HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic];
  464. weakSelf.totalPage = model.Count;
  465. [weakSelf.dataSource addObjectsFromArray:model.Items];
  466. } failure:^(NSError * _Nonnull error) {
  467. }];
  468. }
  469. break;
  470. case 1:
  471. {
  472. NSDictionary * paraDict = @{@"Type":@"MyChecking",@"page":@(self.currentPage),@"perPage":@10};
  473. [[HttpManager sharedHttpManager] GETUrl:Host(WorkFlowAddApproval_Post) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  474. NSDictionary *dic = (NSDictionary *)responseObject;
  475. HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic];
  476. weakSelf.totalPage = model.Count;
  477. [weakSelf.dataSource addObjectsFromArray:model.Items];
  478. } failure:^(NSError * _Nonnull error) {
  479. SHOWERROR([ZYCTool handerResultData:error])
  480. }];
  481. }
  482. break;
  483. default:
  484. {
  485. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_PAGE_CATHEDRA) parameters:@{@"StyleCss":self.style,@"Page":@(self.currentPage),@"PerPage":@20} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  486. NSLog(@"%@",responseObject);
  487. } failure:^(NSError * _Nonnull error) {
  488. }];
  489. }
  490. break;
  491. }
  492. }
  493. - (BOOL)hidesBottomBarWhenPushed
  494. {
  495. [self.tabBarController.tabBar setHidden:NO];
  496. return NO;
  497. }
  498. #pragma mark - UITableViewDataSource && UITableViewDelegate
  499. - (void)closeBtn_Click {
  500. [self.alertVC dismissViewControllerAnimated:YES completion:nil];
  501. }
  502. - (void)cellDidSelcet:(NSInteger )articleId{
  503. WEAKSELF
  504. UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  505. [closeBtn addTarget:self action:@selector(closeBtn_Click) forControlEvents:UIControlEventTouchUpInside];
  506. [closeBtn setImage:IMG(@"guanbi") forState:UIControlStateNormal];
  507. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"对此内容进行操作" message:@"" preferredStyle:UIAlertControllerStyleAlert];
  508. self.alertVC = alertVC;
  509. [alertVC.view addSubview:closeBtn];
  510. [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  511. make.right.equalTo(alertVC.view).offset(-10);
  512. make.top.equalTo(@10);
  513. make.size.mas_equalTo(CGSizeMake(22, 22));
  514. }];
  515. UIAlertAction *actionOK = [UIAlertAction actionWithTitle:@"屏蔽TA" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  516. STRONGSELF
  517. [strongSelf homeNewsHander:articleId withTypeId:1];
  518. }];
  519. [actionOK setValue:k9 forKey:@"_titleTextColor"];
  520. UIAlertAction *actionNO = [UIAlertAction actionWithTitle:@"不感兴趣" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  521. STRONGSELF
  522. [strongSelf homeNewsHander:articleId withTypeId:2];
  523. }];
  524. [alertVC addAction:actionOK];
  525. [alertVC addAction:actionNO];
  526. [self presentViewController:alertVC animated:YES completion:^{
  527. [alertVC tapGesAlert];
  528. }];
  529. }
  530. - (void)homeNewsHander:(NSInteger )articleId withTypeId:(NSInteger)blacklistType{
  531. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@/%@",BaseUrl,Article_Hander_Post] parameters:@{@"ArticleId":@(articleId),@"BlacklistType":@(blacklistType)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  532. // [weakSelf headRefresh];
  533. } failure:^(NSError * _Nonnull error) {
  534. }];
  535. }
  536. #pragma mark - channelScroll Block
  537. - (void)didClickAddButtonChannel{
  538. AddChannelController *addChannel = [[AddChannelController alloc] init];
  539. addChannel.modalPresentationStyle = UIModalPresentationFullScreen;
  540. addChannel.delegate = self;
  541. [self presentViewController:addChannel animated:YES completion:nil];
  542. }
  543. #pragma mark - AddChannelControllerDelegate
  544. - (void)upadateChannel{
  545. WS(weakSelf);
  546. [self loadChannelModel];
  547. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Pindao_User_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  548. NSLog(@"%@",responseObject);
  549. NSArray *array = responseObject;
  550. for (NSInteger i = 0 ; i < array.count; i ++) {
  551. NSDictionary *dic = array[i];
  552. ChannelModel *model = [ChannelModel modelWithDictionary:dic];
  553. [weakSelf.myChannel addObject:model];
  554. }
  555. dispatch_async(dispatch_get_main_queue(), ^{
  556. [weakSelf setCusPageVC];
  557. });
  558. } failure:^(NSError * _Nonnull error) {
  559. }];
  560. }
  561. #pragma mark - SLBannerViewDelegate
  562. - (void)bannerView:(SLBannerView *)banner didClickImagesAtIndex:(NSInteger)index
  563. {
  564. [self getArticleDetail:index];
  565. }
  566. - (void)getArticleDetail:(NSInteger)index{
  567. HomeTopImageModel *model = self.bannerModelArray[index];
  568. switch (model.MediaType) {
  569. case CollectModel_StoreBook:
  570. {
  571. BookListDetailVC * vc = [BookListDetailVC initBookListDetailVC];
  572. vc.Id = model.MediaId;
  573. vc.hidesBottomBarWhenPushed = YES;
  574. [self.navigationController pushViewController:vc animated:YES];
  575. }
  576. break;
  577. case CollectModel_StoreVideo:
  578. {
  579. BookWCDetailVC * vc = [BookWCDetailVC initBookWCDetailVC];
  580. vc.Id = model.MediaId;
  581. vc.hidesBottomBarWhenPushed = YES;
  582. [self.navigationController pushViewController:vc animated:YES];
  583. }
  584. break;
  585. case CollectModel_StoreSound:
  586. {
  587. BookListenVC * vc = [BookListenVC initBookListenVC];
  588. vc.Id = model.MediaId;
  589. vc.MediaType = MediaMusicType;
  590. vc.hidesBottomBarWhenPushed = YES;
  591. [self.navigationController pushViewController:vc animated:YES];
  592. }
  593. break;
  594. case CollectModel_Teacher:
  595. {
  596. BookTeacherDetailVC * vc = [BookTeacherDetailVC initBookTeacherDetailVC];
  597. vc.Id = model.MediaId;
  598. vc.hidesBottomBarWhenPushed = YES;
  599. [self.navigationController pushViewController:vc animated:YES];
  600. }
  601. break;
  602. case CollectModel_Organization:
  603. {
  604. }
  605. break;
  606. default:
  607. {
  608. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  609. vc.type = model.MediaType;
  610. vc.Id = model.MediaId;
  611. [self.navigationController pushViewController:vc animated:YES];
  612. }
  613. break;
  614. }
  615. }
  616. #pragma mark - Setter
  617. - (UILabel *)titleLabel {
  618. if (!_titleLabel) {
  619. _titleLabel = [UILabel new];
  620. _titleLabel.backgroundColor = [UIColor whiteColor];
  621. _titleLabel.text = @"首页";
  622. _titleLabel.font = [UIFont systemFontOfSize:16.f];
  623. _titleLabel.textColor = UIColorHex(1A1A1A);
  624. _titleLabel.textAlignment = NSTextAlignmentCenter;
  625. }
  626. return _titleLabel;
  627. }
  628. - (UIButton *)scanBtn {
  629. if (!_scanBtn) {
  630. _scanBtn = [UIButton new];
  631. [_scanBtn setImage:IMG(@"home_scan") forState:UIControlStateNormal];
  632. }
  633. return _scanBtn;
  634. }
  635. - (SurfaceSearchView *)searchView {
  636. if (!_searchView) {
  637. _searchView = [[SurfaceSearchView alloc] init];
  638. [_searchView setBgViewColor:[UIColor clearColor]];
  639. // [_searchView setPlaceHolderText:@"输入关键字搜索"];
  640. [_searchView setMainType];
  641. }
  642. return _searchView;
  643. }
  644. - (NSMutableArray *)dataSource
  645. {
  646. if (!_dataSource) {
  647. _dataSource = [NSMutableArray array];
  648. }
  649. return _dataSource;
  650. }
  651. - (NSMutableArray *)tabConfigArray{
  652. if (!_tabConfigArray) {
  653. _tabConfigArray = [NSMutableArray array];
  654. }
  655. return _tabConfigArray;
  656. }
  657. - (NSMutableDictionary *)articleDic{
  658. if (!_articleDic) {
  659. _articleDic = [NSMutableDictionary dictionary];
  660. }
  661. return _articleDic;
  662. }
  663. - (NSMutableArray *)myChannel {
  664. if (!_myChannel) {
  665. _myChannel = [NSMutableArray array];
  666. }
  667. return _myChannel;
  668. }
  669. - (void)loadChannelModel
  670. {
  671. [self.myChannel removeAllObjects];
  672. // ChannelModel * model = [[ChannelModel alloc] init];
  673. // model.ArticleGroupId = 0;
  674. // model.ArticleGroupName = @"推荐";
  675. // model.StyleCss = @"default";
  676. // model.IsSelect = YES;
  677. // [self.myChannel addObject:model];
  678. // ChannelModel * workModel = [[ChannelModel alloc] init];
  679. // workModel.ArticleGroupId = 1;
  680. // workModel.ArticleGroupName = @"待办工作";
  681. // workModel.IsSelect = NO;
  682. // [self.myChannel addObject:workModel];
  683. // ChannelModel * sModel = [[ChannelModel alloc] init];
  684. // sModel.ArticleGroupId = 2;
  685. // sModel.ArticleGroupName = @"信源听说";
  686. // sModel.IsSelect = NO;
  687. // [self.myChannel addObject:sModel];
  688. // ChannelModel * mModel = [[ChannelModel alloc] init];
  689. // mModel.ArticleGroupId = 3;
  690. // mModel.ArticleGroupName = @"名校";
  691. // mModel.IsSelect = NO;
  692. // [self.myChannel addObject:mModel];
  693. // ChannelModel * aModel = [[ChannelModel alloc] init];
  694. // aModel.ArticleGroupId = 4;
  695. // aModel.ArticleGroupName = @"会员特供";
  696. // aModel.IsSelect = NO;
  697. // [self.myChannel addObject:aModel];
  698. // ChannelModel * bModel = [[ChannelModel alloc] init];
  699. // bModel.ArticleGroupId = 5;
  700. // bModel.ArticleGroupName = @"每日微课";
  701. // bModel.IsSelect = NO;
  702. // [self.myChannel addObject:bModel];
  703. // ChannelModel * cModel = [[ChannelModel alloc] init];
  704. // cModel.ArticleGroupId = 6;
  705. // cModel.ArticleGroupName = @"每日技能";
  706. // cModel.IsSelect = NO;
  707. // [self.myChannel addObject:cModel];
  708. // ChannelModel * dModel = [[ChannelModel alloc] init];
  709. // dModel.ArticleGroupId = 7;
  710. // dModel.ArticleGroupName = @"每日好书";
  711. // dModel.IsSelect = NO;
  712. // [self.myChannel addObject:dModel];
  713. // ChannelModel * eModel = [[ChannelModel alloc] init];
  714. // eModel.ArticleGroupId = 8;
  715. // eModel.ArticleGroupName = @"每日好文";
  716. // eModel.IsSelect = NO;
  717. // [self.myChannel addObject:eModel];
  718. // ChannelModel * fModel = [[ChannelModel alloc] init];
  719. // fModel.ArticleGroupId = 9;
  720. // fModel.ArticleGroupName = @"名师";
  721. // fModel.IsSelect = NO;
  722. // [self.myChannel addObject:fModel];
  723. // ChannelModel * gModel = [[ChannelModel alloc] init];
  724. // gModel.ArticleGroupId = 10;
  725. // gModel.ArticleGroupName = @"大咖讲座";
  726. // gModel.IsSelect = NO;
  727. // [self.myChannel addObject:gModel];
  728. }
  729. #pragma mark - 分享成功跳转
  730. - (void)shareReturnAction:(NSNotification *)noti
  731. {
  732. NSDictionary * dic = noti.userInfo;
  733. CollectModelType type = [[dic objectForKey:@"type"] intValue];
  734. NSInteger Id = [[dic objectForKey:@"Id"] integerValue];
  735. NSInteger userId = [[dic objectForKey:@"userId"] integerValue];
  736. NSString* name = [[dic objectForKey:@"name"] stringByRemovingPercentEncoding];
  737. // NSString* describe = [[dic objectForKey:@"describe"] stringByRemovingPercentEncoding];
  738. switch (type) {
  739. case CollectModel_Aritle:
  740. {
  741. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  742. vc.type = CollectModel_Aritle;
  743. vc.Id = Id;
  744. vc.hidesBottomBarWhenPushed = YES;
  745. [self.navigationController pushViewController:vc animated:YES];
  746. }
  747. break;
  748. case CollectModel_work:
  749. {
  750. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  751. vc.indexId = Id;
  752. vc.title = name;
  753. vc.TodoId = Id;
  754. vc.hidesBottomBarWhenPushed = YES;
  755. [self.navigationController pushViewController:vc animated:YES];
  756. }
  757. break;
  758. case CollectModel_Toipc:
  759. {
  760. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  761. vc.Id = Id;
  762. vc.type = CollectModel_Toipc;
  763. vc.hidesBottomBarWhenPushed = YES;
  764. [self.navigationController pushViewController:vc animated:YES];
  765. }
  766. break;
  767. case CollectModel_NewTopic:
  768. {
  769. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  770. vc.Id = Id;
  771. vc.type = CollectModel_NewTopic;
  772. vc.hidesBottomBarWhenPushed = YES;
  773. [self.navigationController pushViewController:vc animated:YES];
  774. }
  775. break;
  776. case CollectModel_Notice:
  777. {
  778. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  779. vc.Id = Id;
  780. vc.type = CollectModel_Notice;
  781. vc.hidesBottomBarWhenPushed = YES;
  782. [self.navigationController pushViewController:vc animated:YES];
  783. }
  784. break;
  785. case CollectModel_InterMail:
  786. {
  787. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  788. vc.Id = Id;
  789. vc.type = CollectModel_InterMail;
  790. vc.hidesBottomBarWhenPushed = YES;
  791. [self.navigationController pushViewController:vc animated:YES];
  792. }
  793. break;
  794. case CollectModel_NoSignMail:
  795. {
  796. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  797. vc.Id = Id;
  798. vc.type = CollectModel_NoSignMail;
  799. vc.hidesBottomBarWhenPushed = YES;
  800. [self.navigationController pushViewController:vc animated:YES];
  801. }
  802. break;
  803. case CollectModel_NoteBook:
  804. {
  805. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  806. vc.Id = Id;
  807. vc.type = CollectModel_NoteBook;
  808. vc.hidesBottomBarWhenPushed = YES;
  809. [self.navigationController pushViewController:vc animated:YES];
  810. }
  811. break;
  812. case CollectModel_meetMian:
  813. {
  814. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  815. vc.Id = Id;
  816. vc.type = CollectModel_meetMian;
  817. vc.hidesBottomBarWhenPushed = YES;
  818. [self.navigationController pushViewController:vc animated:YES];
  819. }
  820. break;
  821. case CollectModel_meetDetail:
  822. {
  823. WorkFlowDetailsController *vc = [[WorkFlowDetailsController alloc] initWithId:Id];
  824. vc.hidesBottomBarWhenPushed = YES;
  825. [self.navigationController pushViewController:vc animated:YES];
  826. }
  827. break;
  828. case CollectModel_CollectFile:{
  829. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  830. MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
  831. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  832. vc.ParentId = Id;
  833. vc.FolderId = Id;
  834. vc.myTitle = name;
  835. vc.hidesBottomBarWhenPushed = YES;
  836. [self.navigationController pushViewController:vc animated:YES];
  837. }else{
  838. OtherFavoriteVC *vc = [OtherFavoriteVC initOtherFavoriteVC];
  839. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  840. vc.ParentId = Id;
  841. vc.FolderId = Id;
  842. vc.myTitle = name;
  843. vc.VisitUserId = userId;
  844. vc.hidesBottomBarWhenPushed = YES;
  845. [self.navigationController pushViewController:vc animated:YES];
  846. }
  847. }break;
  848. case CollectModel_NoteFile:{
  849. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  850. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  851. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  852. vc.ParentId = Id;
  853. vc.FolderId = Id;
  854. vc.myTitle = name;
  855. vc.VisitUserId = 0;
  856. [self.navigationController pushViewController:vc animated:YES];
  857. }else{
  858. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  859. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  860. vc.ParentId = Id;
  861. vc.FolderId = Id;
  862. vc.myTitle = name;
  863. vc.VisitUserId = userId;
  864. vc.hidesBottomBarWhenPushed = YES;
  865. [self.navigationController pushViewController:vc animated:YES];
  866. }
  867. }break;
  868. case CollectModel_TopicBooK:{
  869. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  870. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  871. vc.listType = MyFavoriteListLevelTypeA;
  872. vc.ParentId = 0;
  873. vc.FolderId = Id;
  874. vc.myTitle = name;
  875. vc.VisitUserId = 0;
  876. vc.TypeValue = 1;
  877. [self.navigationController pushViewController:vc animated:YES];
  878. }else{
  879. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  880. vc.listType = MyFavoriteListLevelTypeA;
  881. vc.ParentId = 0;
  882. vc.FolderId = Id;
  883. vc.myTitle = name;
  884. vc.VisitUserId = userId;
  885. vc.TypeValue = 1;
  886. vc.hidesBottomBarWhenPushed = YES;
  887. [self.navigationController pushViewController:vc animated:YES];
  888. }
  889. }break;
  890. case CollectModel_TopicSubBooK:{
  891. if (userId == [AppUserModel sharedAppUserModel].Id || userId == 0) {
  892. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  893. vc.listType = MyFavoriteListLevelTypeB;
  894. vc.ParentId = Id;
  895. vc.FolderId = Id;
  896. vc.myTitle = name;
  897. vc.VisitUserId = 0;
  898. vc.TypeValue = 1;
  899. [self.navigationController pushViewController:vc animated:YES];
  900. }else{
  901. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  902. vc.listType = MyFavoriteListLevelTypeB;
  903. vc.ParentId = Id;
  904. vc.FolderId = Id;
  905. vc.myTitle = name;
  906. vc.VisitUserId = userId;
  907. vc.TypeValue = 1;
  908. vc.hidesBottomBarWhenPushed = YES;
  909. [self.navigationController pushViewController:vc animated:YES];
  910. }
  911. }break;
  912. default:
  913. break;
  914. }
  915. }
  916. - (void)addChannelAction:(UIButton *)sender
  917. {
  918. [self didClickAddButtonChannel];
  919. }
  920. - (void)musicAction:(UIButton *)sender
  921. {
  922. [[HKFloatManager shared] showVideo];
  923. }
  924. - (TDButton *)addButton {
  925. if (!_addButton) {
  926. _addButton = [TDButton buttonWithType:UIButtonTypeCustom];
  927. [_addButton setImage:IMG(@"home_pdAdd_icon") forState:UIControlStateNormal];
  928. [_addButton addTarget:self action:@selector(addChannelAction:) forControlEvents:UIControlEventTouchUpInside];
  929. [_addButton setCurrentButtonHotSize:CGSizeZero];
  930. }
  931. return _addButton;
  932. }
  933. - (TDButton *)musicButtton {
  934. if (!_musicButtton) {
  935. _musicButtton = [TDButton buttonWithType:UIButtonTypeCustom];
  936. [_musicButtton setImage:IMG(@"home_music_icon") forState:UIControlStateNormal];
  937. [_musicButtton addTarget:self action:@selector(musicAction:) forControlEvents:UIControlEventTouchUpInside];
  938. [_musicButtton setCurrentButtonHotSize:CGSizeZero];
  939. }
  940. return _musicButtton;
  941. }
  942. - (UIView *)lineV
  943. {
  944. if (!_lineV) {
  945. _lineV = [UIView new];
  946. _lineV.backgroundColor = UIColorHex(0xD8D8D8);
  947. }
  948. return _lineV;
  949. }
  950. - (UIView *)rightView
  951. {
  952. if (!_rightView) {
  953. _rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 88.5, 45)];
  954. _rightView.backgroundColor = UIColorHex(0xFFFFFF);
  955. }
  956. return _rightView;
  957. }
  958. - (UIView *)setRightView
  959. {
  960. [self.rightView removeAllSubviews];
  961. [self.rightView addSubview:self.addButton];
  962. [self.rightView addSubview:self.musicButtton];
  963. [self.rightView addSubview:self.lineV];
  964. [self.addButton setFrame:CGRectMake(0, 0, 44, 45)];
  965. [self.lineV setFrame:CGRectMake(44, 13.5, 0.5, 18)];
  966. [self.musicButtton setFrame:CGRectMake(44.5, 0, 44, 45)];
  967. return self.rightView;
  968. }
  969. #pragma mark - JPushToVC
  970. - (void)JPushToVC:(NSNotification *)noti
  971. {
  972. PushModel * model = [PushModel modelWithDictionary:noti.userInfo];
  973. switch (model.mediaType) {
  974. case CollectModel_work:
  975. {
  976. [self pushWorkVCwithModel:model];
  977. }
  978. break;
  979. case CollectModel_MeShen:
  980. {
  981. [self pushWorkVCwithModel:model];
  982. }
  983. break;
  984. case CollectModel_MeChao:
  985. {
  986. [self pushWorkVCwithModel:model];
  987. }
  988. break;
  989. case CollectModel_System:
  990. {
  991. [self pushWorkVCwithModel:model];
  992. }
  993. break;
  994. case CollectModel_Verify:
  995. {
  996. ChatTestingVC * vc = [ChatTestingVC initChatTestingVC];
  997. vc.hidesBottomBarWhenPushed = YES;
  998. [self.navigationController pushViewController:vc animated:YES];
  999. }
  1000. break;
  1001. case CollectModel_ReplayMe:
  1002. {
  1003. ReplayMeVC * vc = [ReplayMeVC initReplayMeVC];
  1004. vc.hidesBottomBarWhenPushed = YES;
  1005. [self.navigationController pushViewController:vc animated:YES];
  1006. }
  1007. break;
  1008. default:
  1009. {
  1010. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1011. vc.Id = model.sourceId;
  1012. vc.type = model.mediaType;
  1013. vc.hidesBottomBarWhenPushed = YES;
  1014. [self.navigationController pushViewController:vc animated:YES];
  1015. }
  1016. break;
  1017. }
  1018. }
  1019. - (void)pushWorkVCwithModel:(PushModel *)model
  1020. {
  1021. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  1022. vc.pageType = Type_ONEC;
  1023. vc.indexId = model.sourceId;
  1024. [self.navigationController pushViewController:vc animated:YES];
  1025. }
  1026. #pragma mark - ScanResult
  1027. - (void)scanResult:(NSString *)scanStr{
  1028. ScanResultModel *model = [[ScanResultModel alloc]initWithString:scanStr error:nil];
  1029. NSLog(@"%@",model);
  1030. WEAKSELF
  1031. switch (model.key) {
  1032. case 1:// 用户
  1033. {
  1034. [self scanNetWork:model.value urlStrong:SaoYiSao_Post ScanKey:@"Guid" success:^(id responseObject) {
  1035. NSDictionary *dic = responseObject;
  1036. AddressUserModel *model = [[AddressUserModel alloc] initWithDictionary:dic error:nil];
  1037. dispatch_async(dispatch_get_main_queue(), ^{
  1038. MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
  1039. vc.indexId = model.Id;
  1040. vc.isAdd = YES;
  1041. [weakSelf.navigationController pushViewController:vc animated:YES];
  1042. });
  1043. } failure:^(NSError *error) {
  1044. SHOWERROR([ZYCTool handerResultData:error]);
  1045. }];
  1046. }
  1047. break;
  1048. case 2:// 群聊
  1049. {
  1050. [self scanToNetWork:model.value urlStrong:SaoYiSao2_Post success:^(id responseObject) {
  1051. ChatJoinGroupVC * vc = [ChatJoinGroupVC initChatJoinGroupVC];
  1052. vc.dict = responseObject;
  1053. [weakSelf.navigationController pushViewController:vc animated:YES];
  1054. } failure:^(NSError *error) {
  1055. SHOWERROR([ZYCTool handerResultData:error]);
  1056. }];
  1057. }
  1058. break;
  1059. case 3://小组
  1060. {
  1061. [self scanToNetWork:model.value urlStrong:SaoYiSao3_Post success:^(id responseObject) {
  1062. if ([responseObject[@"IsUser"] boolValue]) {
  1063. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  1064. vc.GroupId = [responseObject[@"Id"] integerValue];
  1065. vc.titleStr = responseObject[@"Name"];
  1066. [weakSelf.navigationController pushViewController:vc animated:YES];
  1067. }else{
  1068. dispatch_async(dispatch_get_main_queue(), ^{
  1069. TDQrJoinVC * vc = [TDQrJoinVC initTDQrJoinVC];
  1070. vc.dict = responseObject;
  1071. [weakSelf.navigationController pushViewController:vc animated:YES];
  1072. });
  1073. }
  1074. } failure:^(NSError *error) {
  1075. SHOWERROR([ZYCTool handerResultData:error]);
  1076. }];
  1077. }
  1078. break;
  1079. case 4://扫码登录
  1080. {
  1081. LoginPCVC * vc = [LoginPCVC initLoginPCVC];
  1082. vc.key = model.value;
  1083. vc.modalPresentationStyle = UIModalPresentationFullScreen;
  1084. [self presentViewController:vc animated:YES completion:^{
  1085. }];
  1086. }
  1087. break;
  1088. default:
  1089. break;
  1090. }
  1091. }
  1092. - (void)scanNetWork:(NSString *)scanStr urlStrong:(NSString *)urlstring ScanKey:(NSString*)key success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{
  1093. SHOWLOADING
  1094. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,urlstring] parameters:@{key:scanStr} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  1095. successful(responseObject);
  1096. REMOVESHOW
  1097. } failure:^(NSError * _Nonnull error) {
  1098. REMOVESHOW
  1099. failure(error);
  1100. }];
  1101. }
  1102. - (void)scanToNetWork:(NSString *)scanStr urlStrong:(NSString *)urlstring success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure{
  1103. SHOWLOADING
  1104. NSString * url = [NSString stringWithFormat:@"%@%@",Host(urlstring),scanStr];
  1105. [[HttpManager sharedHttpManager] GETUrl:url parameters:@{} success:^(id _Nonnull responseObject) {
  1106. REMOVESHOW
  1107. successful(responseObject);
  1108. } failure:^(NSError * _Nonnull error) {
  1109. REMOVESHOW
  1110. }];
  1111. }
  1112. @end