CommonHomeVC.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. //
  2. // CommonHomeVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/4/28.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "CommonHomeVC.h"
  9. #import "CommonListCell.h"
  10. #import "MyTDGroupView.h"
  11. #import "GHRefreshCollectionView.h"
  12. #import "CommonBarCell.h"
  13. #import "CommonBarModel.h"
  14. #import "CommonWorkVC.h"
  15. #import "CommonToolVC.h"
  16. #import "MyFavoriteVC.h"
  17. #import "CommonNoteVC.h"
  18. #import "ChatMsgListCell.h"
  19. #import "ChatMsgCollectionCell.h"
  20. #import "MoveViewController.h"
  21. #import "OtherFavoriteVC.h"
  22. #import "OtherNoteBookVC.h"
  23. #import "DownFileViewController.h"
  24. #import "WorkFlowDetailsController.h"
  25. #import "MyApprovalPageDetail.h"
  26. #import "CountDataVC.h"
  27. @interface CommonHomeVC ()<UITableViewDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource>
  28. @property (weak, nonatomic) IBOutlet UIView *NavBar;
  29. @property (strong, nonatomic) UIView *HeadView;
  30. @property (strong, nonatomic) UITableView *tableView;
  31. @property (strong, nonatomic) MyTDGroupView *SearchView;
  32. @property (strong, nonatomic) GHRefreshCollectionView *collectionView;
  33. @property (strong, nonatomic) NSMutableArray *collectionDataSource;
  34. @property (strong, nonatomic) NSMutableArray *dataArray;
  35. @property (nonatomic,assign) NSInteger currentPage;
  36. @property (nonatomic,assign) NSInteger totalPage;
  37. @end
  38. @implementation CommonHomeVC
  39. - (UIView *)HeadView
  40. {
  41. if (!_HeadView) {
  42. _HeadView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 46)];
  43. _HeadView.backgroundColor = [UIColor whiteColor];
  44. }
  45. return _HeadView;
  46. }
  47. //- (void)setTableRefresh
  48. //{
  49. // WS(weakSelf);
  50. // self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  51. // [weakSelf headRefresh];
  52. // }];
  53. // self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  54. // [weakSelf footerRefresh];
  55. // }];
  56. // [self.tableView.mj_header beginRefreshing];
  57. //}
  58. //- (void)headRefresh{
  59. // self.currentPage = 1;
  60. // self.totalPage = 1;
  61. // [self.dataArray removeAllObjects];
  62. // [self getDataList];
  63. //}
  64. //- (void)footerRefresh{
  65. // self.currentPage += 1;
  66. // if (self.totalPage == self.dataArray.count) {
  67. // self.currentPage --;
  68. // [self.tableView.mj_footer resetNoMoreData];
  69. // return ;
  70. // }
  71. // [self getDataList];
  72. //}
  73. - (void)viewWillAppear:(BOOL)animated
  74. {
  75. [super viewWillAppear:animated];
  76. [self getDataList];
  77. }
  78. - (void)viewDidLoad {
  79. [super viewDidLoad];
  80. // [self setTableRefresh];
  81. self.fd_prefersNavigationBarHidden = YES;
  82. self.view.backgroundColor = UIColorHex(0xffffff);
  83. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  84. [self.HeadView addSubview:self.SearchView];
  85. [self.SearchView mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.top.mas_offset(5);
  87. make.left.right.mas_equalTo(self.HeadView);
  88. make.height.mas_offset(36);
  89. }];
  90. [self.view addSubview:self.tableView];
  91. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.left.right.mas_equalTo(self.view);
  93. make.top.mas_equalTo(self.NavBar.mas_bottom);
  94. if (@available(iOS 11.0, *)) {
  95. make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
  96. } else {
  97. make.bottom.equalTo(self.view.mas_bottom);
  98. }
  99. }];
  100. self.tableView.tableHeaderView = self.HeadView;
  101. [self setBarData];
  102. [self.SearchView.button setAction:^{
  103. NSLog(@"点击搜索");
  104. }];
  105. self.tableView.delegate = self;
  106. self.tableView.dataSource = self;
  107. self.tableView.backgroundColor = [UIColor clearColor];
  108. }
  109. - (void)getDataList {
  110. WS(weakSelf);
  111. SHOWLOADING
  112. [self.dataArray removeAllObjects];
  113. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Collection_List) parameters:@{@"FolderId":@(0),@"Page":@(1),@"PerPage":@(99999999),@"VisitUserId":@(0)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  114. REMOVESHOW
  115. MyFavoriteModel *listModel = [[MyFavoriteModel alloc] initWithDictionary:responseObject error:nil];
  116. weakSelf.totalPage = listModel.Total;
  117. [weakSelf.dataArray addObjectsFromArray:listModel.Items];
  118. for (MyFavoriteSubModel *model in weakSelf.dataArray) {
  119. if (model.CollectionType == CollectModel_Text) {
  120. model.CollectionType = CollectModel_Aritle;
  121. }
  122. if (model.CollectionType == CollectModel_meet) {
  123. model.CollectionType = CollectModel_meetMian;
  124. }
  125. }
  126. [weakSelf changeMessageStatusWithNumber:weakSelf.dataArray.count];
  127. dispatch_async(dispatch_get_main_queue(), ^{
  128. [weakSelf.tableView reloadData];
  129. });
  130. } failure:^(NSError * _Nonnull error) {
  131. REMOVESHOW
  132. }];
  133. }
  134. - (BOOL)hidesBottomBarWhenPushed{
  135. return NO;
  136. }
  137. #pragma mark - UITableViewDelegate
  138. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  139. return 2;
  140. }
  141. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  142. switch (section) {
  143. case 0:{
  144. return 1;
  145. }break;
  146. default:{
  147. return self.dataArray.count;
  148. }break;
  149. }
  150. }
  151. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  152. switch (indexPath.section) {
  153. case 0:{
  154. return 74.f;
  155. }break;
  156. default:{
  157. return UITableViewAutomaticDimension;
  158. }break;
  159. }
  160. }
  161. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  162. {
  163. switch (section) {
  164. case 0:{
  165. return 0.f;
  166. }break;
  167. default:{
  168. return 36.f;
  169. }break;
  170. }
  171. }
  172. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  173. {
  174. switch (section) {
  175. case 0:{
  176. UIView * view = [UIView new];
  177. return view;
  178. }break;
  179. default:{
  180. UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
  181. view.backgroundColor = UIColorHex(0xF5F5F5);
  182. UILabel * label = [UILabel new];
  183. label.font = [UIFont systemFontOfSize:14];
  184. label.textColor = UIColorHex(0x888888);
  185. label.text = @"最新收藏";
  186. [view addSubview:label];
  187. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  188. make.left.mas_offset(15);
  189. make.centerY.mas_equalTo(view);
  190. }];
  191. return view;
  192. }break;
  193. }
  194. }
  195. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  196. switch (indexPath.section) {
  197. case 0:
  198. {
  199. ChatMsgListCell *cell = [ChatMsgListCell configCell1:tableView indexPath:indexPath];
  200. [cell.cell1ContentBgView addSubview:self.collectionView];
  201. self.collectionView.frame = CGRectMake(0, 0, SCREEN_WIDTH, cell.cell1ContentBgView.height);
  202. [self.collectionView reloadData];
  203. return cell;
  204. }
  205. break;
  206. default:
  207. {
  208. CommonListCell *cell = [CommonListCell configCell1:tableView indexPath:indexPath];
  209. MyFavoriteSubModel * model = [self.dataArray objectAtIndex:indexPath.row];
  210. [cell setCell1Data:model];
  211. return cell;
  212. }
  213. break;
  214. }
  215. }
  216. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  217. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  218. if (indexPath.section > 0) {
  219. MyFavoriteSubModel * model = [self.dataArray objectAtIndex:indexPath.row];
  220. switch (model.CollectionType) {
  221. case CollectModel_Aritle:{
  222. WEAKSELF
  223. [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%ld",Article_Detail_Get,(long)model.CollectionDataId] parameters:@{} success:^(id _Nonnull responseObject) {
  224. Item *itemModel = [[Item alloc]initWithDictionary:responseObject error:nil];
  225. // HomeDetailController *homeDetail = [[HomeDetailController alloc] init];
  226. // [homeDetail loadCurrentModel:itemModel];
  227. // [strongSelf.navigationController pushViewController:homeDetail animated:YES];
  228. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  229. vc.type = CollectModel_Aritle;
  230. vc.Id = itemModel.Id;
  231. [weakSelf.navigationController pushViewController:vc animated:YES];
  232. } failure:^(NSError * _Nonnull error) {
  233. SHOWERROR([ZYCTool handerResultData:error]);
  234. }];
  235. }break;
  236. case CollectModel_Toipc:
  237. {
  238. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  239. vc.type = CollectModel_Toipc;
  240. vc.Id = model.CollectionDataId;
  241. [self.navigationController pushViewController:vc animated:YES];
  242. }break;
  243. case CollectModel_NewTopic:
  244. {
  245. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  246. vc.type = CollectModel_NewTopic;
  247. vc.Id = model.CollectionDataId;
  248. [self.navigationController pushViewController:vc animated:YES];
  249. }break;
  250. case CollectModel_Collect:{
  251. }break;
  252. case CollectModel_NoteBook:{
  253. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  254. vc.type = CollectModel_NoteBook;
  255. vc.Id = model.CollectionDataId;
  256. vc.isNoteBook = YES;
  257. [self.navigationController pushViewController:vc animated:YES];
  258. }break;
  259. case CollectModel_CollectFile:{
  260. OtherFavoriteVC * vc = [OtherFavoriteVC initOtherFavoriteVC];
  261. vc.listType = model.CollectionDataId == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  262. vc.FolderId = model.CollectionDataId;
  263. vc.CollectionDataId = model.CollectionDataId;
  264. vc.CollectionType = model.CollectionType;
  265. vc.Author = model.Data.Author;
  266. vc.myTitle = model.Title;
  267. vc.VisitUserId = model.SourceUserId;
  268. [self.navigationController pushViewController:vc animated:YES];
  269. }break;
  270. case CollectModel_NoteFile: {
  271. OtherNoteBookVC * vc = [OtherNoteBookVC initOtherNoteBookVC];
  272. vc.listType = model.CollectionDataId == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  273. vc.FolderId = model.CollectionDataId;
  274. vc.CollectionDataId = model.CollectionDataId;
  275. vc.CollectionType = model.CollectionType;
  276. vc.Author = model.Data.Author;
  277. vc.myTitle = model.Title;
  278. vc.VisitUserId = model.SourceUserId;
  279. [self.navigationController pushViewController:vc animated:YES];
  280. }break;
  281. case CollectModel_Notice:{
  282. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  283. vc.type = CollectModel_Notice;
  284. vc.Id = model.CollectionDataId;
  285. [self.navigationController pushViewController:vc animated:YES];
  286. }break;
  287. case CollectModel_InterMail:{
  288. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  289. vc.type = CollectModel_InterMail;
  290. vc.Id = model.CollectionDataId;
  291. [self.navigationController pushViewController:vc animated:YES];
  292. }break;
  293. case CollectModel_file:{
  294. FlowAttachmentsModel *wMdoel = [[FlowAttachmentsModel alloc]init];
  295. wMdoel.Url = model.Data.File;
  296. wMdoel.MinUrl = model.Data.MinFile;
  297. wMdoel.Title = model.Data.Title;
  298. wMdoel.SoureId = model.Data.Id;
  299. wMdoel.SoureTypeId = CollectModel_file;
  300. wMdoel.Size = model.Data.FileSize;
  301. DownFileViewController *downFileViewController = [[DownFileViewController alloc]init];
  302. downFileViewController.model = wMdoel;
  303. [self.navigationController pushViewController:downFileViewController animated:YES];
  304. }break;
  305. case CollectModel_meetDetail:
  306. {
  307. WorkFlowDetailsController * vc = [[WorkFlowDetailsController alloc] initWithId:model.CollectionDataId];
  308. [self.navigationController pushViewController:vc animated:YES];
  309. }
  310. break;
  311. case CollectModel_work:
  312. {
  313. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  314. vc.pageType = Type_ONEC;
  315. vc.indexId = model.CollectionDataId;
  316. vc.title = model.Data.Title;
  317. vc.TodoId = model.CollectionDataId;
  318. [self.navigationController pushViewController:vc animated:YES];
  319. }
  320. case CollectModel_meetMian:{
  321. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  322. vc.Id = model.CollectionDataId;
  323. vc.type = CollectModel_meetMian;
  324. [self.navigationController pushViewController:vc animated:YES];
  325. }break;
  326. case CollectModel_financeCount:{
  327. CountDataVC *vc = [CountDataVC initCountDataVC];
  328. vc.index = 0;
  329. vc.titleStr = @"财务统计";
  330. [self.navigationController pushViewController:vc animated:YES];
  331. }break;
  332. case CollectModel_affairsCount:{
  333. CountDataVC *vc = [CountDataVC initCountDataVC];
  334. vc.index = 1;
  335. vc.titleStr = @"人事统计";
  336. [self.navigationController pushViewController:vc animated:YES];
  337. }break;
  338. case CollectModel_publishCount:{
  339. CountDataVC *vc = [CountDataVC initCountDataVC];
  340. vc.index = 2;
  341. vc.titleStr = @"出版统计";
  342. [self.navigationController pushViewController:vc animated:YES];
  343. }break;
  344. default:
  345. {
  346. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  347. vc.Id = model.CollectionDataId;
  348. vc.type = CollectModel_Toipc;
  349. [self.navigationController pushViewController:vc animated:YES];
  350. }
  351. break;
  352. }
  353. }
  354. }
  355. #pragma mark - load
  356. - (UITableView *)tableView
  357. {
  358. if (!_tableView) {
  359. _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  360. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  361. }
  362. return _tableView;
  363. }
  364. - (MyTDGroupView *)SearchView
  365. {
  366. if (!_SearchView) {
  367. _SearchView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
  368. }
  369. return _SearchView;
  370. }
  371. -(NSMutableArray *)dataArray{
  372. if(!_dataArray){
  373. _dataArray = [[NSMutableArray alloc] init];
  374. }
  375. return _dataArray;
  376. }
  377. -(NSMutableArray *)collectionDataSource{
  378. if(!_collectionDataSource){
  379. _collectionDataSource = [[NSMutableArray alloc] init];
  380. }
  381. return _collectionDataSource;
  382. }
  383. - (GHRefreshCollectionView *)collectionView {
  384. if (!_collectionView) {
  385. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  386. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  387. layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
  388. _collectionView = [[GHRefreshCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  389. _collectionView.delegate = self;
  390. _collectionView.dataSource = self;
  391. _collectionView.showsHorizontalScrollIndicator = NO;
  392. [_collectionView registerNib:[UINib nibWithNibName:@"ChatMsgCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"ChatMsgCollectionCell"];
  393. _collectionView.backgroundColor = [UIColor whiteColor];
  394. }
  395. return _collectionView;
  396. }
  397. #pragma mark UICollectionView
  398. - (NSInteger)numberOfSectionsInCollectionView:(GHRefreshCollectionView *)collectionView{
  399. return 1;
  400. }
  401. /**********************************************************************/
  402. #pragma mark -UICollectionViewDataSource
  403. /**********************************************************************/
  404. - (NSInteger)collectionView:(GHRefreshCollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  405. return self.collectionDataSource.count;
  406. }
  407. - (UICollectionViewCell *)collectionView:(GHRefreshCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  408. {
  409. MoreAppInfoModel *bean = [self.collectionDataSource objectAtIndex:indexPath.item];
  410. ChatMsgCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ChatMsgCollectionCell" forIndexPath:indexPath];
  411. cell.cell0IconImg.image = [UIImage imageNamed:bean.imgName];
  412. cell.cell0TitleLabel.text = bean.title;
  413. cell.imagH.constant = 25.f;
  414. cell.imagW.constant = 25.f;
  415. cell.titleConstant.constant = 8.f;
  416. switch (indexPath.item) {
  417. case 0:
  418. {
  419. cell.cell0ReadNumLabel.hidden = YES;
  420. NSString * count = @"0";
  421. cell.cell0ReadNumLabel.text = count;
  422. UILabel * label = [UILabel new];
  423. label.font = [UIFont systemFontOfSize:12];
  424. label.text = count;
  425. CGFloat width = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH, 16)].width;
  426. if ((width + 5) < 16) {
  427. cell.constant.constant = 16;
  428. }else{
  429. cell.constant.constant = width + 8;
  430. }
  431. }
  432. break;
  433. case 1:
  434. {
  435. cell.cell0ReadNumLabel.hidden = YES;
  436. NSString * count = @"0";
  437. cell.cell0ReadNumLabel.text = count;
  438. UILabel * label = [UILabel new];
  439. label.font = [UIFont systemFontOfSize:12];
  440. label.text = count;
  441. CGFloat width = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH, 16)].width;
  442. if ((width + 5) < 16) {
  443. cell.constant.constant = 16;
  444. }else{
  445. cell.constant.constant = width + 8;
  446. }
  447. }
  448. break;
  449. case 2:
  450. {
  451. cell.cell0ReadNumLabel.hidden = YES;
  452. NSString * count = @"0";
  453. cell.cell0ReadNumLabel.text = count;
  454. UILabel * label = [UILabel new];
  455. label.font = [UIFont systemFontOfSize:12];
  456. label.text = count;
  457. CGFloat width = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH, 16)].width;
  458. if ((width + 5) < 16) {
  459. cell.constant.constant = 16;
  460. }else{
  461. cell.constant.constant = width + 8;
  462. }
  463. }
  464. break;
  465. case 3:
  466. {
  467. cell.cell0ReadNumLabel.hidden = YES;
  468. NSString * count = @"0";
  469. cell.cell0ReadNumLabel.text = count;
  470. UILabel * label = [UILabel new];
  471. label.font = [UIFont systemFontOfSize:12];
  472. label.text = count;
  473. CGFloat width = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH, 16)].width;
  474. if ((width + 5) < 16) {
  475. cell.constant.constant = 16;
  476. }else{
  477. cell.constant.constant = width + 8;
  478. }
  479. }
  480. break;
  481. default:
  482. {
  483. cell.cell0ReadNumLabel.hidden = YES ;
  484. }
  485. break;
  486. }
  487. cell.cell0MengCengView.hidden = YES;
  488. return cell;
  489. }
  490. /****************************************************/
  491. #pragma mark --UICollectionViewDelegateFlowLayout
  492. /****************************************************/
  493. - (CGSize)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  494. {
  495. CGFloat width = (SCREEN_WIDTH - 20) / self.collectionDataSource.count;
  496. CGFloat height = 80;
  497. return CGSizeMake(width, height);
  498. }
  499. -(UIEdgeInsets)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  500. {
  501. CGFloat W = 10;
  502. return UIEdgeInsetsMake(0,W,0,W);
  503. }
  504. - (CGFloat)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
  505. return 0;
  506. }
  507. - (CGFloat)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
  508. return 0;
  509. }
  510. - (void)collectionView:(GHRefreshCollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  511. [collectionView deselectItemAtIndexPath:indexPath animated:YES];
  512. switch (indexPath.item) {
  513. case 0:
  514. {
  515. MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
  516. vc.listType = MyFavoriteListLevelTypeA;
  517. vc.FolderId = 0;
  518. vc.operationStateEnum = OperationStateEnum0;
  519. vc.myTitle = @"我的收藏";
  520. vc.hidesBottomBarWhenPushed = YES;
  521. [self.navigationController pushViewController:vc animated:YES];
  522. }
  523. break;
  524. case 1:
  525. {
  526. CommonNoteVC * vc = [CommonNoteVC initCommonNoteVC];
  527. vc.hidesBottomBarWhenPushed = YES;
  528. [self.navigationController pushViewController:vc animated:YES];
  529. }
  530. break;
  531. case 2:
  532. {
  533. CommonToolVC * vc = [CommonToolVC initCommonToolVC];
  534. vc.hidesBottomBarWhenPushed = YES;
  535. [self.navigationController pushViewController:vc animated:YES];
  536. }
  537. break;
  538. default:
  539. {
  540. CommonWorkVC * vc = [CommonWorkVC initCommonWorkVC];
  541. vc.hidesBottomBarWhenPushed = YES;
  542. [self.navigationController pushViewController:vc animated:YES];
  543. }
  544. break;
  545. }
  546. }
  547. - (void)setBarData
  548. {
  549. [self.collectionDataSource removeAllObjects];
  550. NSArray * titleArray = @[@"收藏",@"笔记",@"工具箱",@"工作台"];
  551. NSArray * imageArray = @[@"Common_collect",@"Common_note",@"Common_gjxiang",@"Common_gztai"];
  552. for (NSInteger i = 0; i < titleArray.count; i ++) {
  553. MoreAppInfoModel * model = [[MoreAppInfoModel alloc] init];
  554. model.title = titleArray[i];
  555. model.imgName = imageArray[i];
  556. [self.collectionDataSource addObject:model];
  557. }
  558. }
  559. #pragma Mark 左滑按钮 iOS8以上
  560. - (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){
  561. if (indexPath.section == 0) {
  562. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[]];
  563. actions.performsFirstActionWithFullSwipe = NO;
  564. return actions;
  565. }else{
  566. WEAKSELF
  567. MyFavoriteSubModel * model = [self.dataArray objectAtIndex:indexPath.row];
  568. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:@"转发" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
  569. [tableView setEditing:NO animated:YES];
  570. }];
  571. action1.backgroundColor = UIColorHex(#FF923A);
  572. UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:model.IsTop ? @"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
  573. [weakSelf topFind:model];
  574. }];
  575. action2.backgroundColor = UIColorHex(#9BA9CB);
  576. UIContextualAction *action3 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:@"移动" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
  577. [weakSelf launchMoveVC:@[@(model.Id)].mutableCopy];
  578. }];
  579. action3.backgroundColor = UIColorHex(#589AF1);
  580. UIContextualAction *action4 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
  581. [tableView setEditing:NO animated:YES];
  582. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
  583. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  584. [weakSelf.tableView reloadData];
  585. }];
  586. [ok setValue:k9 forKey:@"_titleTextColor"];
  587. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  588. [weakSelf deleteFind:@[model].mutableCopy indexPath:indexPath];
  589. }];
  590. [alertVC addAction:ok];
  591. [alertVC addAction:noOk];
  592. completionHandler(YES);
  593. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  594. }];
  595. action4.backgroundColor = UIColorHex(#F64A33);
  596. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action4,action3,action2,action1]];
  597. actions.performsFirstActionWithFullSwipe = NO;
  598. return actions;
  599. }
  600. }
  601. - (void)topFind:(MyFavoriteSubModel*)findModel{
  602. WEAKSELF
  603. [[HttpManager sharedHttpManager] PUTUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_APP_Collection_Top,(long)findModel.MiddleId] parameters:@{} success:^(id _Nonnull responseObject) {
  604. [weakSelf getDataList];
  605. } failure:^(NSError * _Nonnull error) {
  606. SHOWERROR([ZYCTool handerResultData:error]);
  607. }];
  608. }
  609. - (void)deleteFind:(NSMutableArray<MyFavoriteSubModel *>*)findModelArray indexPath:(NSIndexPath *)indexPath{
  610. NSMutableArray *MiddleIds = [NSMutableArray array];
  611. for (MyFavoriteSubModel *model in findModelArray) {
  612. [MiddleIds addObject:@(model.Id)];
  613. }
  614. NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
  615. [dic setValue:MiddleIds forKey:@"MiddleIds"];
  616. [dic setValue:@(3) forKey:@"FolderType"];
  617. WS(weakSelf);
  618. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
  619. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  620. dispatch_async(dispatch_get_main_queue(), ^{
  621. [weakSelf.tableView reloadData];
  622. });
  623. }];
  624. [ok setValue:k9 forKey:@"_titleTextColor"];
  625. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  626. [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_DeleteRecord) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
  627. [weakSelf getDataList];
  628. } failure:^(NSError * _Nonnull error) {
  629. SHOWERROR([ZYCTool handerResultData:error]);
  630. }];
  631. }];
  632. [alertVC addAction:ok];
  633. [alertVC addAction:noOk];
  634. [self presentViewController:alertVC animated:YES completion:nil];
  635. }
  636. - (void)launchMoveVC:(NSMutableArray<NSNumber*>*)selectIDArray{
  637. MoveViewController * vc = [MoveViewController initMoveViewController];
  638. vc.TypeId = CreateCollectionType;
  639. vc.collectType = CollectHanderType_Move;
  640. vc.ParentId = 0;
  641. vc.FolderIds = selectIDArray;
  642. vc.titleStr = @"移动";
  643. [self.navigationController pushViewController:vc animated:YES];
  644. }
  645. @end