SourceHomeVC.m 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648
  1. //
  2. // SourceHomeVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/5/6.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "SourceHomeVC.h"
  9. #import "MyTDGroupView.h"
  10. #import "GHRefreshCollectionView.h"
  11. #import "ChatMsgListCell.h"
  12. #import "ChatMsgCollectionCell.h"
  13. #import "TDGroupInfoListModel.h"
  14. #import "TDGroupInfoListCell.h"
  15. #import "NoteBookVC.h"
  16. #import "OtherNoteBookVC.h"
  17. #import "MailListDetailVC.h"
  18. #import "MyFavoriteVC.h"
  19. #import "MyTDGroupViewController.h"
  20. #import "MoveViewController.h"
  21. #import "OtherFavoriteVC.h"
  22. #import "TDGroupInfoListVC.h"
  23. #import "WorkFlowDetailsController.h"
  24. #import "MyApprovalPageDetail.h"
  25. #import "DownFileViewController.h"
  26. #import "ShareListVC.h"
  27. #import "TDInterLeterHomeViewController.h"
  28. #import "MyTDTopicViewController.h"
  29. #import "MailListVC.h"
  30. #import "WaitWorkVC.h"
  31. #import "MyTDTopicSearchVC.h"
  32. #import "NoteBookShareVC.h"
  33. #import "SourceGroupVC.h"
  34. #import "ChatMsgListVC.h"
  35. #import "ShowBtn.h"
  36. #import "MenuListView.h"
  37. #import "TopicGroupManageModel.h"
  38. #import "MyTDTopicGroupManageVC.h"
  39. #import "WorkNumberModel.h"
  40. #import "MyTDTopicBookVC.h"
  41. @interface SourceHomeVC ()<UITableViewDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource,NoteBookShareVCDelegate,UIScrollViewDelegate,EMChatManagerDelegate, EMGroupManagerDelegate, EMConversationsDelegate>
  42. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  43. @property (strong, nonatomic) UIView *HeadView;
  44. @property (strong, nonatomic) MyTDGroupView *SearchView;
  45. @property (strong, nonatomic) NSMutableArray *dataArray;
  46. @property (strong, nonatomic) NSMutableArray *collectionDataSource;
  47. @property (strong, nonatomic) NSMutableArray *selectGIdArray;
  48. @property (strong, nonatomic) NSMutableArray *groupListArray;
  49. @property (nonatomic, strong) GHRefreshCollectionView *collectionView;
  50. @property (strong, nonatomic) NoteBookShareVC *noteBookShareVC;
  51. @property (copy, nonatomic) FlowAttachmentsModel *sendModel;
  52. @property (assign, nonatomic) BOOL isReturn;
  53. @property (strong, nonatomic) ShowBtn *showBtn;
  54. @property (strong, nonatomic) MenuListView *menuListView;
  55. @property (assign, nonatomic) BOOL menuIsShow;
  56. @property (assign, nonatomic) CGFloat setY;
  57. @property (strong, nonatomic) UIView *sectionView;
  58. @property (assign, nonatomic) NSInteger currentPage;
  59. @property (assign, nonatomic) NSInteger totalPage;
  60. @property (strong, nonatomic) NSMutableArray *chatListIMArray;
  61. @property (strong, nonatomic) NSMutableArray *ImArray;
  62. @property (assign, nonatomic) NSInteger unReadCount;
  63. @property (strong, nonatomic) WorkNumberModel * numModel;
  64. @property (copy, nonatomic) NSString * listName;
  65. @end
  66. @implementation SourceHomeVC
  67. - (void)viewWillDisappear:(BOOL)animated
  68. {
  69. [super viewWillDisappear:animated];
  70. [self.showBtn dismissCom];
  71. self.menuIsShow = NO;
  72. [self.menuListView dismiss];
  73. }
  74. - (BOOL)hidesBottomBarWhenPushed{
  75. return NO;
  76. }
  77. - (UIView *)HeadView
  78. {
  79. if (!_HeadView) {
  80. _HeadView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 46)];
  81. _HeadView.backgroundColor = [UIColor whiteColor];
  82. }
  83. return _HeadView;
  84. }
  85. - (MyTDGroupView *)SearchView
  86. {
  87. if (!_SearchView) {
  88. _SearchView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
  89. }
  90. return _SearchView;
  91. }
  92. -(NSMutableArray *)collectionDataSource{
  93. if(!_collectionDataSource){
  94. _collectionDataSource = [[NSMutableArray alloc] init];
  95. }
  96. return _collectionDataSource;
  97. }
  98. -(NSMutableArray *)dataArray{
  99. if(!_dataArray){
  100. _dataArray = [[NSMutableArray alloc] init];
  101. }
  102. return _dataArray;
  103. }
  104. -(NSMutableArray *)selectGIdArray{
  105. if(!_selectGIdArray){
  106. _selectGIdArray = [[NSMutableArray alloc] init];
  107. }
  108. return _selectGIdArray;
  109. }
  110. -(NSMutableArray *)groupListArray{
  111. if(!_groupListArray){
  112. _groupListArray = [[NSMutableArray alloc] init];
  113. }
  114. return _groupListArray;
  115. }
  116. - (ShowBtn *)showBtn
  117. {
  118. if (!_showBtn) {
  119. _showBtn = [ShowBtn new];
  120. }
  121. return _showBtn;
  122. }
  123. - (GHRefreshCollectionView *)collectionView {
  124. if (!_collectionView) {
  125. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  126. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  127. layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
  128. _collectionView = [[GHRefreshCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  129. _collectionView.delegate = self;
  130. _collectionView.dataSource = self;
  131. _collectionView.showsHorizontalScrollIndicator = NO;
  132. [_collectionView registerNib:[UINib nibWithNibName:@"ChatMsgCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"ChatMsgCollectionCell"];
  133. _collectionView.backgroundColor = [UIColor whiteColor];
  134. }
  135. return _collectionView;
  136. }
  137. - (void)getUnreadCount
  138. {
  139. WS(weakSelf);
  140. [[HttpManager sharedHttpManager] GETUrl:Host(API_APP_User_User_Uread_Count) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  141. NSDictionary *dic = responseObject;
  142. weakSelf.numModel = [[WorkNumberModel alloc] initWithDictionary:dic error:nil];
  143. dispatch_async(dispatch_get_main_queue(), ^{
  144. [weakSelf initChatMsgIMData];
  145. });
  146. } failure:^(NSError * _Nonnull error) {
  147. }];
  148. }
  149. -(void)initChatMsgIMData{
  150. self.chatListIMArray = [NSMutableArray array];
  151. WS(weakSelf);
  152. SHOWLOADING
  153. [[HttpManager sharedHttpManager] POSTUrl:Host(Often_Contact_List) parameters:@{@"IndividualGroupId":@(0)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  154. NSLog(@"%@",responseObject);
  155. REMOVESHOW
  156. if ([responseObject isKindOfClass:[NSArray class]]) {
  157. for (NSDictionary * dict in responseObject) {
  158. ChatMsgListImModel * model = [ChatMsgListImModel modelWithDictionary:dict];
  159. [weakSelf.chatListIMArray addObject:model];
  160. }
  161. }
  162. [weakSelf _loadAllConversationsFromDBWithIsShowHud:NO];
  163. } failure:^(NSError * _Nonnull error) {
  164. REMOVESHOW
  165. NSLog(@"%@",error);
  166. }];
  167. }
  168. - (void)_loadAllConversationsFromDBWithIsShowHud:(BOOL)aIsShowHUD
  169. {
  170. __weak typeof(self) weakself = self;
  171. self.ImArray = [NSMutableArray array];
  172. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  173. NSArray *conversations = [[EMClient sharedClient].chatManager getAllConversations];
  174. NSArray *sorted = [conversations sortedArrayUsingComparator:^(EMConversation *obj1, EMConversation *obj2) {
  175. EMMessage *message1 = [obj1 latestMessage];
  176. EMMessage *message2 = [obj2 latestMessage];
  177. if(message1.timestamp > message2.timestamp) {
  178. return(NSComparisonResult)NSOrderedAscending;
  179. } else {
  180. return(NSComparisonResult)NSOrderedDescending;
  181. }}];
  182. NSArray *models = [EMConversationHelper modelsFromEMConversations:sorted];
  183. [weakself.ImArray addObjectsFromArray:models];
  184. [weakself replaceChatData];
  185. });
  186. }
  187. - (void)replaceChatData
  188. {
  189. WS(weakSelf);
  190. self.unReadCount = 0;
  191. [self.chatListIMArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  192. ChatMsgListImModel * chatModel = (ChatMsgListImModel *)obj;
  193. [weakSelf.ImArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  194. EMConversationModel * model = (EMConversationModel *)obj;
  195. if (chatModel.ImId == [model.emModel.conversationId integerValue]) {
  196. if (!chatModel.IsDisturb) {
  197. chatModel.redNum = model.emModel.unreadMessagesCount;
  198. weakSelf.unReadCount += model.emModel.unreadMessagesCount;
  199. }
  200. }
  201. }];
  202. }];
  203. dispatch_async(dispatch_get_main_queue(), ^{
  204. weakSelf.numModel.messageUnCount = weakSelf.unReadCount;
  205. NSInteger count = weakSelf.numModel.allNumber + weakSelf.unReadCount;
  206. weakSelf.tabBarController.tabBar.items[2].badgeValue = count > 0 ? [NSString stringWithFormat:@"%ld",(long)count] : nil;
  207. [weakSelf initCollectionData:weakSelf.numModel];
  208. });
  209. }
  210. - (void)viewWillAppear:(BOOL)animated
  211. {
  212. [super viewWillAppear:animated];
  213. [self getUnreadCount];
  214. }
  215. - (void)conversationListDidUpdate:(NSArray *)aConversationList
  216. {
  217. [self _loadAllConversationsFromDBWithIsShowHud:NO];
  218. }
  219. - (void)messagesDidReceive:(NSArray *)aMessages
  220. {
  221. [self performSelector:@selector(getUnreadCount) withObject:nil afterDelay:0.8];
  222. }
  223. - (void)setTableRefresh
  224. {
  225. WS(weakSelf);
  226. self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  227. [weakSelf headRefresh];
  228. }];
  229. self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  230. [weakSelf footerRefresh];
  231. }];
  232. [self.tableView.mj_header beginRefreshing];
  233. }
  234. - (void)headRefresh{
  235. self.currentPage = 1;
  236. self.totalPage = 1;
  237. [self.dataArray removeAllObjects];
  238. [self getData];
  239. }
  240. - (void)footerRefresh{
  241. self.currentPage += 1;
  242. if (self.totalPage == self.dataArray.count) {
  243. self.currentPage --;
  244. [self.tableView.mj_footer endRefreshingWithNoMoreData];
  245. self.tableView.mj_footer.hidden = YES;
  246. return;
  247. }
  248. [self getData];
  249. }
  250. - (void)viewDidLoad {
  251. [super viewDidLoad];
  252. [self setTableRefresh];
  253. [[EMClient sharedClient].chatManager addDelegate:self delegateQueue:nil];
  254. [[EMClient sharedClient].groupManager addDelegate:self delegateQueue:nil];
  255. [[EMConversationHelper shared] addDelegate:self];
  256. self.fd_prefersNavigationBarHidden = YES;
  257. self.view.backgroundColor = RGB(240, 239, 244);
  258. self.tableView.delegate = self;
  259. self.tableView.dataSource = self;
  260. self.tableView.backgroundColor = [UIColor whiteColor];
  261. [self.HeadView addSubview:self.SearchView];
  262. [self.SearchView mas_makeConstraints:^(MASConstraintMaker *make) {
  263. make.top.mas_offset(5);
  264. make.left.right.mas_equalTo(self.HeadView);
  265. make.height.mas_offset(36);
  266. }];
  267. WS(weakSelf);
  268. [self.SearchView.button setAction:^{
  269. [weakSelf pushSearchVC];
  270. }];
  271. self.tableView.tableHeaderView = self.HeadView;
  272. [self setShowData];
  273. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushSubViewController:) name:DRAWERPUSHVC object:nil];
  274. }
  275. - (void)getData
  276. {
  277. WS(weakSelf);
  278. NSDictionary * paraDict = @{@"ParentId":@(0),
  279. @"UserId":@([AppUserModel sharedAppUserModel].Id),
  280. @"Keyword": @"",
  281. @"Page":@(self.currentPage),
  282. @"TopicGroupIds": self.selectGIdArray,
  283. @"PerPage": @(10),
  284. @"Sort":@""
  285. };
  286. SHOWLOADING
  287. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_List_Page) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  288. NSLog(@"%@",responseObject);
  289. REMOVESHOW
  290. [weakSelf.tableView.mj_header endRefreshing];
  291. [weakSelf.tableView.mj_footer endRefreshing];
  292. TopicListModel * model = [TopicListModel modelWithDictionary:responseObject];
  293. weakSelf.totalPage = model.Total;
  294. [weakSelf.dataArray addObjectsFromArray:model.Items];
  295. dispatch_async(dispatch_get_main_queue(), ^{
  296. [weakSelf.tableView reloadData];
  297. [weakSelf.collectionView reloadData];
  298. });
  299. } failure:^(NSError * _Nonnull error) {
  300. REMOVESHOW
  301. [weakSelf.tableView.mj_header endRefreshing];
  302. [weakSelf.tableView.mj_footer endRefreshing];
  303. }];
  304. }
  305. -(void)initCollectionData:(WorkNumberModel *)numModel{
  306. [self.collectionDataSource removeAllObjects];
  307. NSMutableArray * array = [NSMutableArray array];
  308. for (int i= 0;i < 4; i++) {
  309. MoreAppInfoModel *model = [[MoreAppInfoModel alloc] init];
  310. switch (i) {
  311. case 0:{
  312. model.title = @"收件箱";
  313. model.imgName = @"chatmsg_znx_icon";
  314. model.notImgName = @"chatmsg_tz_hui_icon";
  315. model.type = ChatMenuZhanXinType;
  316. model.readNum = numModel.FlowAuditUReadCount + numModel.FlowSendUReadCount + numModel.FlowCcUReadCount + numModel.noticeCount + numModel.missiveCount;
  317. model.showEditFlag = YES;
  318. }break;
  319. case 1:{
  320. model.title = @"小组";
  321. model.imgName = @"chatmsg_xiaozu_icon";
  322. model.notImgName = @"chatmsg_tz_hui_icon";
  323. model.type = ChatMenuGroupType;
  324. model.readNum = 0;
  325. model.showEditFlag = YES;
  326. }break;
  327. case 2:{
  328. model.title = @"待办事项";
  329. model.imgName = @"chatmsg_dbsx_icon";
  330. model.notImgName = @"chatmsg_tz_hui_icon";
  331. model.type = ChatMenuWaitType;
  332. model.readNum = numModel.WaitHandleUFinishCount;
  333. model.showEditFlag = YES;
  334. }break;
  335. default:{
  336. model.title = @"私信";
  337. model.imgName = @"Common_sixin_icon";
  338. model.notImgName = @"Common_sixin_icon";
  339. model.type = ChatMenuSiXinType;
  340. model.readNum = numModel.messageUnCount;
  341. model.showEditFlag = YES;
  342. }break;
  343. }
  344. [array addObject:model];
  345. }
  346. self.collectionDataSource = array;
  347. [self.collectionView reloadData];
  348. }
  349. #pragma mark - UITableViewDelegate
  350. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  351. if (self.dataArray.count > 0) {
  352. return 2;
  353. }
  354. return 1;
  355. }
  356. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  357. switch (section) {
  358. case 0:{
  359. return 1;
  360. }break;
  361. default:{
  362. return self.dataArray.count;
  363. }break;
  364. }
  365. }
  366. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  367. switch (indexPath.section) {
  368. case 0:{
  369. return 80.f;
  370. }break;
  371. default:{
  372. return UITableViewAutomaticDimension;
  373. }break;
  374. }
  375. }
  376. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  377. {
  378. switch (section) {
  379. case 0:{
  380. return 0.f;
  381. }break;
  382. default:{
  383. return 36.f;
  384. }break;
  385. }
  386. }
  387. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  388. {
  389. WS(weakSelf);
  390. CGFloat width = (SCREEN_WIDTH - 20) / (self.collectionDataSource.count > 0 ? self.collectionDataSource.count : 1);
  391. UILabel * testL = [UILabel new];
  392. testL.font = [UIFont systemFontOfSize:15];
  393. testL.text = @"收件箱";
  394. UILabel * testBtnL = [UILabel new];
  395. testBtnL.font = [UIFont systemFontOfSize:15];
  396. testBtnL.text = @"私信";
  397. switch (section) {
  398. case 0:{
  399. UIView * view = [UIView new];
  400. return view;
  401. }break;
  402. default:{
  403. self.sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
  404. self.sectionView.backgroundColor = UIColorHex(0xF5F5F5);
  405. UILabel * label = [UILabel new];
  406. label.font = [UIFont systemFontOfSize:15];
  407. label.textColor = UIColorHex(0x009AFF);
  408. label.text = @"话题本";
  409. [self.sectionView addSubview:label];
  410. CGFloat w = [testL sizeThatFits:CGSizeMake(SCREEN_WIDTH, 20)].width;
  411. CGFloat left = (width - w) * 0.5 + 10;
  412. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  413. make.left.mas_offset(left);
  414. make.centerY.mas_equalTo(self.sectionView);
  415. }];
  416. UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
  417. MyTDTopicBookVC * vc = [MyTDTopicBookVC initMyTDTopicBookVC];
  418. [weakSelf.navigationController pushViewController:vc animated:YES];
  419. }];
  420. label.userInteractionEnabled = YES;
  421. [label addGestureRecognizer:tap];
  422. UIButton * btn = [UIButton new];
  423. [self.sectionView addSubview:btn];
  424. [btn setImage:IMG(@"ChatMsg_topic_create") forState:UIControlStateNormal];
  425. CGFloat r = [testBtnL sizeThatFits:CGSizeMake(SCREEN_WIDTH, 20)].width;
  426. CGFloat right = (width - r) * 0.5 - 0.5;
  427. [btn mas_makeConstraints:^(MASConstraintMaker *make) {
  428. make.right.mas_offset(-right);
  429. make.centerY.mas_equalTo(self.sectionView);
  430. make.size.mas_offset(CGSizeMake(36, 36));
  431. }];
  432. WS(weakSelf);
  433. [btn setAction:^{
  434. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  435. vc.hidesBottomBarWhenPushed = YES;
  436. vc.type = CollectModel_NewTopic;
  437. vc.upDateBlock = ^{
  438. [weakSelf headRefresh];
  439. };
  440. [weakSelf.navigationController pushViewController:vc animated:YES];
  441. }];
  442. [self autoSizeBtn:self.listName.length > 0 ? self.listName : @"全部"];
  443. [self.sectionView addSubview:self.showBtn];
  444. [self.showBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  445. make.center.mas_equalTo(self.sectionView);
  446. }];
  447. return self.sectionView;
  448. }break;
  449. }
  450. }
  451. - (void)autoSizeBtn:(NSString *)title
  452. {
  453. [self.showBtn setcomTitle:title];
  454. }
  455. - (void)setShowData
  456. {
  457. [self getGroupList];
  458. self.menuIsShow = NO;
  459. WS(weakSelf);
  460. [self.showBtn setAction:^{
  461. if (!weakSelf.menuIsShow) {
  462. [weakSelf.menuListView show];
  463. [weakSelf.showBtn showCom];
  464. weakSelf.menuListView.SelectBtnblock = ^(NSArray * _Nonnull array) {
  465. [weakSelf.showBtn dismissCom];
  466. [weakSelf.selectGIdArray removeAllObjects];
  467. NSMutableString * showName = [[NSMutableString alloc] init];
  468. for (NSArray * subArray in array) {
  469. for (TopicGroupManageModel * model in subArray) {
  470. if (model.isSelect) {
  471. [showName appendString:model.Name];
  472. // [showName appendString:@"、"];
  473. [weakSelf.selectGIdArray addObject:@(model.Id)];
  474. }
  475. }
  476. }
  477. // if (showName.length > 1) {
  478. // [showName deleteCharactersInRange:NSMakeRange(showName.length - 1, 1)];
  479. // if (showName.length >= 10) {
  480. // NSRange range1 = NSMakeRange(8, showName.length - 8);
  481. // NSString *resultStr1 = [showName stringByReplacingCharactersInRange:range1 withString:@"..."];
  482. // [weakSelf autoSizeBtn:resultStr1];
  483. // }else{
  484. // [weakSelf autoSizeBtn:showName];
  485. // }
  486. // }
  487. weakSelf.listName = showName;
  488. // [weakSelf autoSizeBtn:showName];
  489. if (weakSelf.selectGIdArray.count > 0) {
  490. [weakSelf headRefresh];
  491. }
  492. };
  493. weakSelf.menuListView.dismissBlock = ^{
  494. [weakSelf.showBtn dismissCom];
  495. };
  496. weakSelf.menuListView.SelectGroupblock = ^{
  497. [weakSelf.showBtn dismissCom];
  498. weakSelf.menuIsShow = NO;
  499. [weakSelf.menuListView dismiss];
  500. MyTDTopicGroupManageVC * vc = [MyTDTopicGroupManageVC initMyTDTopicGroupManageVC];
  501. vc.RefreshListBlock = ^{
  502. [weakSelf getGroupList];
  503. };
  504. [weakSelf.navigationController pushViewController:vc animated:YES];
  505. };
  506. weakSelf.menuIsShow = YES;
  507. }else{
  508. weakSelf.menuIsShow = NO;
  509. [weakSelf.showBtn dismissCom];
  510. [weakSelf.menuListView dismiss];
  511. }
  512. }];
  513. }
  514. - (void)getGroupList
  515. {
  516. WS(weakSelf);
  517. [[HttpManager sharedHttpManager] GETUrl:Host(APP_Topic_Group) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  518. NSLog(@"======%@",responseObject);
  519. [weakSelf.groupListArray removeAllObjects];
  520. NSArray * array = responseObject;
  521. [array enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  522. NSDictionary * dict = (NSDictionary *)obj;
  523. TopicGroupManageModel * model = [TopicGroupManageModel modelWithDictionary:dict];
  524. [weakSelf.groupListArray addObject:model];
  525. }];
  526. dispatch_async(dispatch_get_main_queue(), ^{
  527. weakSelf.menuListView = [MenuListView MenuListViewaddArray:@[weakSelf.groupListArray] height:162 + NAVH MenuType:MenuMoreSelectType];
  528. });
  529. } failure:^(NSError * _Nonnull error) {
  530. }];
  531. }
  532. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  533. WS(weakSelf);
  534. switch (indexPath.section) {
  535. case 0:
  536. {
  537. ChatMsgListCell *cell = [ChatMsgListCell configCell1:tableView indexPath:indexPath];
  538. [cell.cell1ContentBgView addSubview:self.collectionView];
  539. self.collectionView.frame = CGRectMake(0, 0, SCREEN_WIDTH, cell.cell1ContentBgView.height);
  540. [self.collectionView reloadData];
  541. return cell;
  542. }
  543. break;
  544. default:
  545. {
  546. TopicListItemModel * model = [self.dataArray objectAtIndex:indexPath.row];
  547. if (!model) {
  548. return [TDGroupInfoListCell configCell1:tableView indexPath:indexPath];
  549. }
  550. switch (model.DataType) {
  551. case TopiclistCellImage:
  552. {
  553. TDGroupInfoListCell * cell;
  554. switch (model.Data.count) {
  555. case 1:
  556. {
  557. cell = [TDGroupInfoListCell configCell1:tableView indexPath:indexPath];
  558. cell.cellImagV1.hidden = NO;
  559. cell.cellImagV2.hidden = YES;
  560. cell.cellImagV3.hidden = YES;
  561. cell.cellImagV4.hidden = YES;
  562. cell.cellImagV5.hidden = YES;
  563. cell.cellImagV6.hidden = YES;
  564. cell.cellImagV7.hidden = YES;
  565. cell.cellImagV8.hidden = YES;
  566. cell.cellImagV9.hidden = YES;
  567. TopicListSubModel * subModel0 = model.Data[0];
  568. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  569. }
  570. break;
  571. case 2:
  572. {
  573. cell = [TDGroupInfoListCell configCell1:tableView indexPath:indexPath];
  574. cell.cellImagV1.hidden = NO;
  575. cell.cellImagV2.hidden = NO;
  576. cell.cellImagV3.hidden = YES;
  577. cell.cellImagV4.hidden = YES;
  578. cell.cellImagV5.hidden = YES;
  579. cell.cellImagV6.hidden = YES;
  580. cell.cellImagV7.hidden = YES;
  581. cell.cellImagV8.hidden = YES;
  582. cell.cellImagV9.hidden = YES;
  583. TopicListSubModel * subModel0 = model.Data[0];
  584. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  585. TopicListSubModel * subModel1 = model.Data[1];
  586. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  587. }
  588. break;
  589. case 3:
  590. {
  591. cell = [TDGroupInfoListCell configCell2:tableView indexPath:indexPath];
  592. cell.cellImagV1.hidden = NO;
  593. cell.cellImagV2.hidden = NO;
  594. cell.cellImagV3.hidden = NO;
  595. cell.cellImagV4.hidden = YES;
  596. cell.cellImagV5.hidden = YES;
  597. cell.cellImagV6.hidden = YES;
  598. cell.cellImagV7.hidden = YES;
  599. cell.cellImagV8.hidden = YES;
  600. cell.cellImagV9.hidden = YES;
  601. TopicListSubModel * subModel0 = model.Data[0];
  602. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  603. TopicListSubModel * subModel1 = model.Data[1];
  604. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  605. TopicListSubModel * subModel2 = model.Data[2];
  606. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  607. }
  608. break;
  609. case 4:
  610. {
  611. cell = [TDGroupInfoListCell configCell3:tableView indexPath:indexPath];
  612. cell.cellImagV1.hidden = NO;
  613. cell.cellImagV2.hidden = NO;
  614. cell.cellImagV3.hidden = NO;
  615. cell.cellImagV4.hidden = NO;
  616. cell.cellImagV5.hidden = YES;
  617. cell.cellImagV6.hidden = YES;
  618. cell.cellImagV7.hidden = YES;
  619. cell.cellImagV8.hidden = YES;
  620. cell.cellImagV9.hidden = YES;
  621. TopicListSubModel * subModel0 = model.Data[0];
  622. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  623. TopicListSubModel * subModel1 = model.Data[1];
  624. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  625. TopicListSubModel * subModel2 = model.Data[2];
  626. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  627. TopicListSubModel * subModel3 = model.Data[3];
  628. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  629. }
  630. break;
  631. case 5:
  632. {
  633. cell = [TDGroupInfoListCell configCell4:tableView indexPath:indexPath];
  634. cell.cellImagV1.hidden = NO;
  635. cell.cellImagV2.hidden = NO;
  636. cell.cellImagV3.hidden = NO;
  637. cell.cellImagV4.hidden = NO;
  638. cell.cellImagV5.hidden = NO;
  639. cell.cellImagV6.hidden = YES;
  640. cell.cellImagV7.hidden = YES;
  641. cell.cellImagV8.hidden = YES;
  642. cell.cellImagV9.hidden = YES;
  643. TopicListSubModel * subModel0 = model.Data[0];
  644. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  645. TopicListSubModel * subModel1 = model.Data[1];
  646. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  647. TopicListSubModel * subModel2 = model.Data[2];
  648. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  649. TopicListSubModel * subModel3 = model.Data[3];
  650. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  651. TopicListSubModel * subModel4 = model.Data[4];
  652. [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  653. }
  654. break;
  655. case 6:
  656. {
  657. cell = [TDGroupInfoListCell configCell4:tableView indexPath:indexPath];
  658. cell.cellImagV1.hidden = NO;
  659. cell.cellImagV2.hidden = NO;
  660. cell.cellImagV3.hidden = NO;
  661. cell.cellImagV4.hidden = NO;
  662. cell.cellImagV5.hidden = NO;
  663. cell.cellImagV6.hidden = NO;
  664. cell.cellImagV7.hidden = YES;
  665. cell.cellImagV8.hidden = YES;
  666. cell.cellImagV9.hidden = YES;
  667. TopicListSubModel * subModel0 = model.Data[0];
  668. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  669. TopicListSubModel * subModel1 = model.Data[1];
  670. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  671. TopicListSubModel * subModel2 = model.Data[2];
  672. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  673. TopicListSubModel * subModel3 = model.Data[3];
  674. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  675. TopicListSubModel * subModel4 = model.Data[4];
  676. [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  677. TopicListSubModel * subModel5 = model.Data[5];
  678. [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  679. }
  680. break;
  681. case 7:
  682. {
  683. cell = [TDGroupInfoListCell configCell5:tableView indexPath:indexPath];
  684. cell.cellImagV1.hidden = NO;
  685. cell.cellImagV2.hidden = NO;
  686. cell.cellImagV3.hidden = NO;
  687. cell.cellImagV4.hidden = NO;
  688. cell.cellImagV5.hidden = NO;
  689. cell.cellImagV6.hidden = NO;
  690. cell.cellImagV7.hidden = NO;
  691. cell.cellImagV8.hidden = YES;
  692. cell.cellImagV9.hidden = YES;
  693. TopicListSubModel * subModel0 = model.Data[0];
  694. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  695. TopicListSubModel * subModel1 = model.Data[1];
  696. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  697. TopicListSubModel * subModel2 = model.Data[2];
  698. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  699. TopicListSubModel * subModel3 = model.Data[3];
  700. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  701. TopicListSubModel * subModel4 = model.Data[4];
  702. [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  703. TopicListSubModel * subModel5 = model.Data[5];
  704. [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  705. TopicListSubModel * subModel6 = model.Data[6];
  706. [cell.cellImagV7 sd_setImageWithURL:[NSURL URLWithString:subModel6.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  707. }
  708. break;
  709. case 8:
  710. {
  711. cell = [TDGroupInfoListCell configCell5:tableView indexPath:indexPath];
  712. cell.cellImagV1.hidden = NO;
  713. cell.cellImagV2.hidden = NO;
  714. cell.cellImagV3.hidden = NO;
  715. cell.cellImagV4.hidden = NO;
  716. cell.cellImagV5.hidden = NO;
  717. cell.cellImagV6.hidden = NO;
  718. cell.cellImagV7.hidden = NO;
  719. cell.cellImagV8.hidden = NO;
  720. cell.cellImagV9.hidden = YES;
  721. TopicListSubModel * subModel0 = model.Data[0];
  722. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  723. TopicListSubModel * subModel1 = model.Data[1];
  724. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  725. TopicListSubModel * subModel2 = model.Data[2];
  726. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  727. TopicListSubModel * subModel3 = model.Data[3];
  728. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  729. TopicListSubModel * subModel4 = model.Data[4];
  730. [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  731. TopicListSubModel * subModel5 = model.Data[5];
  732. [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  733. TopicListSubModel * subModel6 = model.Data[6];
  734. [cell.cellImagV7 sd_setImageWithURL:[NSURL URLWithString:subModel6.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  735. TopicListSubModel * subModel7 = model.Data[7];
  736. [cell.cellImagV8 sd_setImageWithURL:[NSURL URLWithString:subModel7.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  737. }
  738. break;
  739. default:
  740. {
  741. cell = [TDGroupInfoListCell configCell5:tableView indexPath:indexPath];
  742. cell.cellImagV1.hidden = NO;
  743. cell.cellImagV2.hidden = NO;
  744. cell.cellImagV3.hidden = NO;
  745. cell.cellImagV4.hidden = NO;
  746. cell.cellImagV5.hidden = NO;
  747. cell.cellImagV6.hidden = NO;
  748. cell.cellImagV7.hidden = NO;
  749. cell.cellImagV8.hidden = NO;
  750. cell.cellImagV9.hidden = NO;
  751. TopicListSubModel * subModel0 = model.Data[0];
  752. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  753. TopicListSubModel * subModel1 = model.Data[1];
  754. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  755. TopicListSubModel * subModel2 = model.Data[2];
  756. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  757. TopicListSubModel * subModel3 = model.Data[3];
  758. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  759. TopicListSubModel * subModel4 = model.Data[4];
  760. [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  761. TopicListSubModel * subModel5 = model.Data[5];
  762. [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  763. TopicListSubModel * subModel6 = model.Data[6];
  764. [cell.cellImagV7 sd_setImageWithURL:[NSURL URLWithString:subModel6.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  765. TopicListSubModel * subModel7 = model.Data[7];
  766. [cell.cellImagV8 sd_setImageWithURL:[NSURL URLWithString:subModel7.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  767. TopicListSubModel * subModel8 = model.Data[8];
  768. [cell.cellImagV9 sd_setImageWithURL:[NSURL URLWithString:subModel8.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  769. }
  770. break;
  771. }
  772. [cell.cellIconV sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  773. [cell.fileBtn setTitle:model.FolderResult.FolderName forState:UIControlStateNormal];
  774. [cell.fileBtn setAction:^{
  775. [weakSelf enterFileWithModel:model];
  776. }];
  777. cell.ClickUserBlock = ^{
  778. [weakSelf showUserInfo:model.UserId];
  779. };
  780. cell.cellTimeL.text = [model.CreatedDate substringWithRange:NSMakeRange(5, 11)];
  781. cell.celltitleL.attributedText = [self setTitleWithStr:model.Title];
  782. cell.cellContentL.attributedText = [self setTextWithStr:model.Content];
  783. cell.cellNameL.text = model.UserName;
  784. cell.cellReadNumL.text = [NSString stringWithFormat:@"阅读:%ld",(long)model.ReadCount];
  785. [cell.cellLikeBtn setAction:^{
  786. [weakSelf likeAction:model withBtn:cell.cellLikeBtn index:indexPath];
  787. }];
  788. if (model.CommentCount > 0) {
  789. [cell.cellPingBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.CommentCount] forState:UIControlStateNormal];
  790. }else{
  791. [cell.cellPingBtn setTitle:@"评论" forState:UIControlStateNormal];
  792. }
  793. if (model.PraiseCount > 0) {
  794. [cell.cellLikeBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.PraiseCount] forState:UIControlStateNormal];
  795. }else{
  796. [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
  797. }
  798. if (model.IsPraise) {
  799. [cell.cellLikeBtn setTitleColor:UIColorHex(#009AFF) forState:UIControlStateNormal];
  800. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞_select"] forState:UIControlStateNormal];
  801. }else{
  802. [cell.cellLikeBtn setTitleColor:UIColorHex(#999999) forState:UIControlStateNormal];
  803. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞"] forState:UIControlStateNormal];
  804. }
  805. [cell.cellPingBtn setAction:^{
  806. [weakSelf CommentPush:model];
  807. }];
  808. [cell.cellSendBtn setAction:^{
  809. [weakSelf reSend:model];
  810. }];
  811. if (model.Title.length == 0) {
  812. cell.TitleConstant.constant = 0;
  813. }else{
  814. cell.TitleConstant.constant = 10.f;
  815. }
  816. if (model.Content.length == 0) {
  817. cell.subTitleContant.constant = 0.f;
  818. }else{
  819. cell.subTitleContant.constant = 7.5f;
  820. }
  821. cell.fileContant.constant = 0.f;
  822. return cell;
  823. }
  824. break;
  825. case TopiclistCellFile:
  826. {
  827. TDGroupInfoListCell * cell = [TDGroupInfoListCell configCell6:tableView indexPath:indexPath];
  828. [cell.cellIconV sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  829. [cell.fileBtn setTitle:model.FolderResult.FolderName forState:UIControlStateNormal];
  830. [cell.fileBtn setAction:^{
  831. [weakSelf enterFileWithModel:model];
  832. }];
  833. [cell.ClickFileAction setAction:^{
  834. [weakSelf pushFileWithModel:model.Data.firstObject];
  835. }];
  836. cell.cellNameL.text = model.UserName;
  837. cell.cellTimeL.text = [model.CreatedDate substringWithRange:NSMakeRange(5, 11)];
  838. cell.celltitleL.attributedText = [self setTitleWithStr:model.Title];
  839. cell.cellContentL.attributedText = [self setTextWithStr:model.Content];
  840. [cell setDataWithCell6:model.Data.firstObject];
  841. cell.cellReadNumL.text = [NSString stringWithFormat:@"阅读:%ld",(long)model.ReadCount];
  842. [cell.cellLikeBtn setAction:^{
  843. [weakSelf likeAction:model withBtn:cell.cellLikeBtn index:indexPath];
  844. }];
  845. if (model.CommentCount > 0) {
  846. [cell.cellPingBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.CommentCount] forState:UIControlStateNormal];
  847. }else{
  848. [cell.cellPingBtn setTitle:@"评论" forState:UIControlStateNormal];
  849. }
  850. if (model.PraiseCount > 0) {
  851. [cell.cellLikeBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.PraiseCount] forState:UIControlStateNormal];
  852. }else{
  853. [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
  854. }
  855. if (model.IsPraise) {
  856. [cell.cellLikeBtn setTitleColor:UIColorHex(#009AFF) forState:UIControlStateNormal];
  857. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞_select"] forState:UIControlStateNormal];
  858. }else{
  859. [cell.cellLikeBtn setTitleColor:UIColorHex(#999999) forState:UIControlStateNormal];
  860. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞"] forState:UIControlStateNormal];
  861. }
  862. [cell.cellPingBtn setAction:^{
  863. [weakSelf CommentPush:model];
  864. }];
  865. [cell.cellSendBtn setAction:^{
  866. [weakSelf reSend:model];
  867. }];
  868. if (model.Title.length == 0) {
  869. cell.TitleConstant.constant = 0;
  870. }else{
  871. cell.TitleConstant.constant = 10.f;
  872. }
  873. if (model.Content.length == 0) {
  874. cell.subTitleContant.constant = 0.f;
  875. }else{
  876. cell.subTitleContant.constant = 7.5f;
  877. }
  878. cell.ClickUserBlock = ^{
  879. [weakSelf showUserInfo:model.UserId];
  880. };
  881. return cell;
  882. }
  883. break;
  884. default:///TopiclistCellNone
  885. {
  886. TDGroupInfoListCell * cell = [TDGroupInfoListCell configCell0:tableView indexPath:indexPath];
  887. [cell.cellIconV sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  888. [cell.fileBtn setTitle:model.FolderResult.FolderName forState:UIControlStateNormal];
  889. [cell.fileBtn setAction:^{
  890. [weakSelf enterFileWithModel:model];
  891. }];
  892. cell.cellNameL.text = model.UserName;
  893. cell.cellTimeL.text = [model.CreatedDate substringWithRange:NSMakeRange(5, 11)];
  894. cell.celltitleL.attributedText = [self setTitleWithStr:model.Title];
  895. cell.cellContentL.attributedText = [self setTextWithStr:model.Content];
  896. cell.cellReadNumL.text = [NSString stringWithFormat:@"阅读:%ld",(long)model.ReadCount];
  897. [cell.cellLikeBtn setAction:^{
  898. [weakSelf likeAction:model withBtn:cell.cellLikeBtn index:indexPath];
  899. }];
  900. if (model.CommentCount > 0) {
  901. [cell.cellPingBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.CommentCount] forState:UIControlStateNormal];
  902. }else{
  903. [cell.cellPingBtn setTitle:@"评论" forState:UIControlStateNormal];
  904. }
  905. if (model.PraiseCount > 0) {
  906. [cell.cellLikeBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.PraiseCount] forState:UIControlStateNormal];
  907. }else{
  908. [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
  909. }
  910. if (model.IsPraise) {
  911. [cell.cellLikeBtn setTitleColor:UIColorHex(#009AFF) forState:UIControlStateNormal];
  912. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞_select"] forState:UIControlStateNormal];
  913. }else{
  914. [cell.cellLikeBtn setTitleColor:UIColorHex(#999999) forState:UIControlStateNormal];
  915. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞"] forState:UIControlStateNormal];
  916. }
  917. [cell.cellPingBtn setAction:^{
  918. [weakSelf CommentPush:model];
  919. }];
  920. [cell.cellSendBtn setAction:^{
  921. [weakSelf reSend:model];
  922. }];
  923. if (model.Title.length == 0) {
  924. cell.TitleConstant.constant = 0;
  925. }else{
  926. cell.TitleConstant.constant = 10.f;
  927. }
  928. if (model.Content.length == 0) {
  929. cell.subTitleContant.constant = 0.f;
  930. }else{
  931. cell.subTitleContant.constant = 7.5f;
  932. }
  933. cell.ClickUserBlock = ^{
  934. [weakSelf showUserInfo:model.UserId];
  935. };
  936. return cell;
  937. }
  938. break;
  939. }
  940. }
  941. break;
  942. }
  943. }
  944. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  945. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  946. WS(weakSelf);
  947. if (indexPath.section > 0) {
  948. TopicListItemModel * model = [self.dataArray objectAtIndex:indexPath.row];
  949. if (model) {
  950. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  951. vc.type = CollectModel_NewTopic;
  952. vc.RefreshTopicBlock = ^{
  953. [weakSelf headRefresh];
  954. };
  955. vc.Id = model.Id;
  956. [self.navigationController pushViewController:vc animated:YES];
  957. }
  958. }
  959. }
  960. - (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){// delete action
  961. WS(weakSelf);
  962. TopicListItemModel * model = [self.dataArray objectAtIndex:indexPath.row];
  963. if (model.UserId == [AppUserModel sharedAppUserModel].Id) {
  964. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  965. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
  966. UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  967. [weakSelf deleteFind:model.Id row:indexPath.row];
  968. }];
  969. UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  970. dispatch_async(dispatch_get_main_queue(), ^{
  971. [weakSelf.tableView reloadData];
  972. });
  973. }];
  974. [alert addAction:sureAction];
  975. [alert addAction:cancelAction];
  976. [weakSelf presentViewController:alert animated:YES completion:^{
  977. }];
  978. }];
  979. action1.backgroundColor = UIColorHex(#F64A33);
  980. UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"编辑" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
  981. [weakSelf eidtorNoteBook:model];
  982. }];
  983. action2.backgroundColor = UIColorHex(#FF923A);
  984. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1,action2]];
  985. actions.performsFirstActionWithFullSwipe = NO;
  986. return actions;
  987. }else{
  988. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[]];
  989. actions.performsFirstActionWithFullSwipe = NO;
  990. return actions;
  991. }
  992. }
  993. - (void)eidtorNoteBook:(TopicListItemModel *)model{
  994. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  995. vc.type = CollectModel_NewTopic;
  996. vc.FolderId = model.FolderId;
  997. vc.FolderName = model.FolderName;
  998. vc.Id = model.Id;
  999. vc.isEdit = YES;
  1000. [self.navigationController pushViewController:vc animated:YES];
  1001. }
  1002. - (void)deleteFind:(NSInteger)Id row:(NSInteger)row{
  1003. WEAKSELF
  1004. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_APP_Note_Top),Id];
  1005. [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  1006. [weakSelf.dataArray removeObjectAtIndex:row];
  1007. dispatch_async(dispatch_get_main_queue(), ^{
  1008. [weakSelf.tableView reloadData];
  1009. });
  1010. } failure:^(NSError * _Nonnull error) {
  1011. }];
  1012. }
  1013. #pragma mark -UICollectionViewDataSource
  1014. /**********************************************************************/
  1015. - (NSInteger)collectionView:(GHRefreshCollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  1016. return self.collectionDataSource.count;
  1017. }
  1018. - (UICollectionViewCell *)collectionView:(GHRefreshCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  1019. {
  1020. MoreAppInfoModel *bean = [self.collectionDataSource objectAtIndex:indexPath.item];
  1021. ChatMsgCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ChatMsgCollectionCell" forIndexPath:indexPath];
  1022. cell.cell0IconImg.image = [UIImage imageNamed:bean.imgName];
  1023. cell.cell0TitleLabel.text = bean.title;
  1024. cell.imagH.constant = 25.f;
  1025. cell.imagW.constant = 25.f;
  1026. switch (bean.type) {
  1027. case ChatMenuNoticeType:
  1028. {
  1029. NSString * count = [NSString stringWithFormat:@"%ld",bean.readNum];
  1030. cell.cell0ReadNumLabel.text = count;
  1031. cell.cell0ReadNumLabel.hidden = bean.readNum > 0 ? NO : YES;
  1032. UILabel * label = [UILabel new];
  1033. label.font = [UIFont systemFontOfSize:12];
  1034. label.text = count;
  1035. CGFloat width = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH, 16)].width;
  1036. if ((width + 5) < 16) {
  1037. cell.constant.constant = 16;
  1038. }else{
  1039. cell.constant.constant = width + 8;
  1040. }
  1041. }
  1042. break;
  1043. case ChatMenuZhanXinType:
  1044. {
  1045. NSString * count = [NSString stringWithFormat:@"%ld",bean.readNum];
  1046. cell.cell0ReadNumLabel.text = count;
  1047. cell.cell0ReadNumLabel.hidden = bean.readNum > 0 ? NO : YES;
  1048. UILabel * label = [UILabel new];
  1049. label.font = [UIFont systemFontOfSize:12];
  1050. label.text = count;
  1051. CGFloat width = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH, 16)].width;
  1052. if ((width + 5) < 16) {
  1053. cell.constant.constant = 16;
  1054. }else{
  1055. cell.constant.constant = width + 8;
  1056. }
  1057. }
  1058. break;
  1059. case ChatMenuWaitType:
  1060. {
  1061. NSString * count = [NSString stringWithFormat:@"%ld",bean.readNum];
  1062. cell.cell0ReadNumLabel.text = count;
  1063. cell.cell0ReadNumLabel.hidden = bean.readNum > 0 ? NO : YES;
  1064. UILabel * label = [UILabel new];
  1065. label.font = [UIFont systemFontOfSize:12];
  1066. label.text = count;
  1067. CGFloat width = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH, 16)].width;
  1068. if ((width + 5) < 16) {
  1069. cell.constant.constant = 16;
  1070. }else{
  1071. cell.constant.constant = width + 8;
  1072. }
  1073. }
  1074. break;
  1075. default:
  1076. {
  1077. NSString * count = [NSString stringWithFormat:@"%ld",bean.readNum];
  1078. cell.cell0ReadNumLabel.text = count;
  1079. cell.cell0ReadNumLabel.hidden = bean.readNum > 0 ? NO : YES;
  1080. }
  1081. break;
  1082. }
  1083. cell.cell0MengCengView.hidden = YES;
  1084. return cell;
  1085. }
  1086. /****************************************************/
  1087. #pragma mark --UICollectionViewDelegateFlowLayout
  1088. /****************************************************/
  1089. - (CGSize)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  1090. {
  1091. CGFloat width = (SCREEN_WIDTH - 20) / self.collectionDataSource.count;
  1092. CGFloat height = 80;
  1093. return CGSizeMake(width, height);
  1094. }
  1095. -(UIEdgeInsets)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  1096. {
  1097. CGFloat W = 10;
  1098. return UIEdgeInsetsMake(0,W,0,W);
  1099. }
  1100. - (CGFloat)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
  1101. return 0;
  1102. }
  1103. - (CGFloat)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
  1104. return 0;
  1105. }
  1106. - (void)collectionView:(GHRefreshCollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  1107. [collectionView deselectItemAtIndexPath:indexPath animated:YES];
  1108. MoreAppInfoModel * model = [self.collectionDataSource objectAtIndex:indexPath.item];
  1109. switch (model.type) {
  1110. case ChatMenuZhanXinType:{
  1111. TDInterLeterHomeViewController *vc = [TDInterLeterHomeViewController initChatMsgNoticeVC];
  1112. vc.hidesBottomBarWhenPushed = YES;
  1113. vc.interLeterFolderId = 0;
  1114. vc.isHome = YES;
  1115. [self.navigationController pushViewController:vc animated:YES];
  1116. }break;
  1117. case ChatMenuGroupType:{
  1118. SourceGroupVC *vc = [SourceGroupVC initSourceGroupVC];
  1119. vc.hidesBottomBarWhenPushed = YES;
  1120. [self.navigationController pushViewController:vc animated:YES];
  1121. }break;
  1122. case ChatMenuWaitType:{
  1123. WaitWorkVC *vc = [WaitWorkVC initWaitWorkVC];
  1124. vc.hidesBottomBarWhenPushed = YES;
  1125. [self.navigationController pushViewController:vc animated:YES];
  1126. }break;
  1127. case ChatMenuSiXinType:{
  1128. ChatMsgListVC * vc = [ChatMsgListVC initChatMsgListVC];
  1129. vc.hidesBottomBarWhenPushed = YES;
  1130. [self.navigationController pushViewController:vc animated:YES];
  1131. }break;
  1132. default:
  1133. break;
  1134. }
  1135. }
  1136. - (void)enterFileWithModel:(TopicListItemModel *)model
  1137. {
  1138. if (model.UserId == [AppUserModel sharedAppUserModel].Id) {
  1139. if (model.FolderResult.Id == 0) {
  1140. MyTDTopicBookVC * vc = [MyTDTopicBookVC initMyTDTopicBookVC];
  1141. [self.navigationController pushViewController:vc animated:YES];
  1142. }else{
  1143. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  1144. vc.listType = MyFavoriteListLevelTypeB;
  1145. vc.FolderId = model.FolderResult.Id;
  1146. vc.ParentId = model.FolderResult.Id;
  1147. vc.myTitle = model.FolderResult.FolderName;
  1148. vc.TypeValue = 1;
  1149. vc.isSubVC = YES;
  1150. vc.hidesBottomBarWhenPushed = YES;
  1151. [self.navigationController pushViewController:vc animated:YES];
  1152. }
  1153. }else{
  1154. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  1155. vc.listType = MyFavoriteListLevelTypeB;
  1156. vc.FolderId = model.FolderResult.Id;
  1157. vc.Author = model.UserName;
  1158. vc.myTitle = model.FolderResult.FolderName;
  1159. vc.VisitUserId = model.UserId;
  1160. vc.TypeValue = 1;
  1161. vc.hidesBottomBarWhenPushed = YES;
  1162. [self.navigationController pushViewController:vc animated:YES];
  1163. }
  1164. }
  1165. - (void)showUserInfo:(NSInteger)userId
  1166. {
  1167. MailListDetailVC * vc = [MailListDetailVC initMailListDetailVC];
  1168. vc.indexId = userId;
  1169. vc.hidesBottomBarWhenPushed = YES;
  1170. [self.navigationController pushViewController:vc animated:YES];
  1171. }
  1172. #pragma mark - 点击评论
  1173. - (void)likeAction:(TopicListItemModel *)model withBtn:(UIButton *)btn index:(NSIndexPath *)indexPath
  1174. {
  1175. WS(weakSelf);
  1176. NSDictionary * paraDict = @{@"SourceId":@(model.Id),
  1177. @"TypeValue":@(-4),///
  1178. @"AnalyzeType":@(1)
  1179. };
  1180. btn.enabled = NO;
  1181. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  1182. btn.enabled = YES;
  1183. model.IsPraise = !model.IsPraise;
  1184. model.PraiseCount = model.IsPraise ? (model.PraiseCount + 1) : (model.PraiseCount - 1);
  1185. dispatch_async(dispatch_get_main_queue(), ^{
  1186. if (weakSelf.dataArray.count > 0) {
  1187. [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  1188. }
  1189. });
  1190. } failure:^(NSError * _Nonnull error) {
  1191. btn.enabled = YES;
  1192. }];
  1193. }
  1194. - (void)CommentPush:(TopicListItemModel *)model
  1195. {
  1196. WS(weakSelf);
  1197. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1198. vc.type = CollectModel_NewTopic;
  1199. vc.RefreshTopicBlock = ^{
  1200. [weakSelf headRefresh];
  1201. };
  1202. vc.Id = model.Id;
  1203. vc.isComment = YES;
  1204. vc.hidesBottomBarWhenPushed = YES;
  1205. [self.navigationController pushViewController:vc animated:YES];
  1206. }
  1207. - (void)reSend:(TopicListItemModel *)model
  1208. {
  1209. FlowAttachmentsModel * topicModel = [[FlowAttachmentsModel alloc] init];
  1210. topicModel.SoureTypeId = CollectModel_NewTopic;
  1211. topicModel.Title = model.Title;
  1212. topicModel.SoureId = model.Id;
  1213. topicModel.Title = model.Title;
  1214. topicModel.Author = model.UserName;
  1215. self.sendModel = topicModel;
  1216. [self.noteBookShareVC initNoteBookShareData];
  1217. self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden;
  1218. }
  1219. - (NoteBookShareVC *)noteBookShareVC{
  1220. if (_noteBookShareVC == nil) {
  1221. _noteBookShareVC = [NoteBookShareVC initNoteBookShareVC];
  1222. [_noteBookShareVC.view setFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT)];
  1223. [_noteBookShareVC.view setHidden:YES];
  1224. _noteBookShareVC.delegate = self;
  1225. }
  1226. return _noteBookShareVC;
  1227. }
  1228. - (void)userSelectType:(NSString *)typeName WithIndexPath:(NSIndexPath *)indexPath
  1229. {
  1230. self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden;
  1231. if ([typeName isEqualToString:@"发给微信好友"]) {
  1232. [self returnToWechatSession];
  1233. }else if ([typeName isEqualToString:@"发到朋友圈"]){
  1234. [self returnToWechatTimeLine];
  1235. }else if ([typeName isEqualToString:@"发到微博"]){
  1236. [self returnToSina];
  1237. }else if ([typeName isEqualToString:@"发给QQ好友"]){
  1238. [self returnToQQ];
  1239. }else if ([typeName isEqualToString:@"发到消息"]){
  1240. [self returnToMessage];
  1241. }else if ([typeName isEqualToString:@"发到小组"]){
  1242. [self returnToGroup];
  1243. }else if ([typeName isEqualToString:@"发到笔记"]){
  1244. [self returnToNote];
  1245. }else if ([typeName isEqualToString:@"发到话题"]){
  1246. [self returnToTopic];
  1247. }else{
  1248. }
  1249. }
  1250. - (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType title:(NSString *)title desc:(NSString *)desc url:(NSString *)url
  1251. {
  1252. //创建分享消息对象
  1253. UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
  1254. messageObject.title = title;
  1255. //创建网页内容对象
  1256. UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:title descr:desc thumImage:IMG(@"logo_60")];
  1257. //设置网页地址
  1258. shareObject.webpageUrl = url;
  1259. //分享消息对象设置分享内容对象
  1260. messageObject.shareObject = shareObject;
  1261. //调用分享接口
  1262. [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
  1263. if (error) {
  1264. NSLog(@"************Share fail with error %@*********",error);
  1265. }else{
  1266. NSLog(@"response data is %@",data);
  1267. }
  1268. }];
  1269. }
  1270. - (void)returnToWechatSession
  1271. {
  1272. [self shareWebPageToPlatformType:UMSocialPlatformType_WechatSession title:self.sendModel.Title desc:[NSString stringWithFormat:@"来自-%@",self.sendModel.Author] url:[self returnUrl]];
  1273. }
  1274. - (void)returnToWechatTimeLine
  1275. {
  1276. [self shareWebPageToPlatformType:UMSocialPlatformType_WechatTimeLine title:self.sendModel.Title desc:[NSString stringWithFormat:@"来自-%@",self.sendModel.Author] url:[self returnUrl]];
  1277. }
  1278. - (void)returnToSina
  1279. {
  1280. [self shareWebPageToPlatformType:UMSocialPlatformType_Sina title:self.sendModel.Title desc:[NSString stringWithFormat:@"来自-%@",self.sendModel.Author] url:[self returnUrl]];
  1281. }
  1282. - (void)returnToQQ
  1283. {
  1284. [self shareWebPageToPlatformType:UMSocialPlatformType_QQ title:self.sendModel.Title desc:[NSString stringWithFormat:@"来自-%@",self.sendModel.Author] url:[self returnUrl]];
  1285. }
  1286. - (NSString *)returnUrl
  1287. {
  1288. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(@"/admin/mobile/noteDetailsWx?"),(long)self.sendModel.Id];
  1289. return url;
  1290. }
  1291. #pragma mark - 分享功能
  1292. - (void)returnToMessage
  1293. {
  1294. ShareListVC * vc = [ShareListVC initShareListVC];
  1295. vc.sendModel = self.sendModel;
  1296. vc.isReturn = YES;
  1297. vc.hidesBottomBarWhenPushed = YES;
  1298. [self.navigationController pushViewController:vc animated:YES];
  1299. }
  1300. - (void)returnToGroup
  1301. {
  1302. MyTDGroupViewController * vc = [[MyTDGroupViewController alloc] init];
  1303. vc.type = CollectModel_Group;
  1304. vc.sendModel = self.sendModel;
  1305. vc.isReturn = YES;
  1306. vc.hidesBottomBarWhenPushed = YES;
  1307. [self.navigationController pushViewController:vc animated:YES];
  1308. }
  1309. - (void)returnToNote
  1310. {
  1311. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  1312. vc.type = CollectModel_NoteBook;
  1313. vc.sendModel = self.sendModel;
  1314. vc.isReturn = YES;
  1315. vc.hidesBottomBarWhenPushed = YES;
  1316. [self.navigationController pushViewController:vc animated:YES];
  1317. }
  1318. - (void)returnToTopic
  1319. {
  1320. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  1321. vc.type = CollectModel_NewTopic;
  1322. vc.sendModel = self.sendModel;
  1323. vc.isReturn = YES;
  1324. vc.hidesBottomBarWhenPushed = YES;
  1325. [self.navigationController pushViewController:vc animated:YES];
  1326. }
  1327. #pragma mark - 点击文件跳转
  1328. - (void)pushFileWithModel:(TopicListSubModel *)model
  1329. {
  1330. WS(weakSelf);
  1331. switch (model.Type) {
  1332. case CollectModel_Aritle:
  1333. {
  1334. SHOWLOADING
  1335. [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%ld",Article_Detail_Get,(long)model.Id] parameters:@{} success:^(id _Nonnull responseObject) {
  1336. REMOVESHOW;
  1337. Item *itemModel = [[Item alloc]initWithDictionary:responseObject error:nil];
  1338. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1339. vc.type = CollectModel_Aritle;
  1340. vc.Id = itemModel.Id;
  1341. vc.hidesBottomBarWhenPushed = YES;
  1342. [weakSelf.navigationController pushViewController:vc animated:YES];
  1343. } failure:^(NSError * _Nonnull error) {
  1344. SHOWERROR([ZYCTool handerResultData:error]);
  1345. }];
  1346. }
  1347. break;
  1348. case CollectModel_Toipc:
  1349. {
  1350. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1351. vc.type = CollectModel_Toipc;
  1352. vc.Id = model.Id;
  1353. vc.hidesBottomBarWhenPushed = YES;
  1354. [self.navigationController pushViewController:vc animated:YES];
  1355. }
  1356. break;
  1357. case CollectModel_NewTopic:
  1358. {
  1359. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1360. vc.type = CollectModel_NewTopic;
  1361. vc.Id = model.Id;
  1362. vc.hidesBottomBarWhenPushed = YES;
  1363. [self.navigationController pushViewController:vc animated:YES];
  1364. }
  1365. break;
  1366. case CollectModel_Collect:
  1367. {
  1368. }
  1369. break;
  1370. case CollectModel_NoteBook:
  1371. {
  1372. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1373. vc.type = CollectModel_NoteBook;
  1374. vc.Id = model.Id;
  1375. vc.hidesBottomBarWhenPushed = YES;
  1376. [self.navigationController pushViewController:vc animated:YES];
  1377. }
  1378. break;
  1379. case CollectModel_CollectFile:{
  1380. if (model.SourceUserId == [AppUserModel sharedAppUserModel].Id) {
  1381. MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
  1382. vc.listType = model.Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  1383. vc.ParentId = 0;
  1384. vc.FolderId = model.Id;
  1385. vc.myTitle = model.Title;
  1386. vc.hidesBottomBarWhenPushed = YES;
  1387. [self.navigationController pushViewController:vc animated:YES];
  1388. }else{
  1389. OtherFavoriteVC *vc = [OtherFavoriteVC initOtherFavoriteVC];
  1390. vc.listType = model.Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  1391. vc.ParentId = 0;
  1392. vc.FolderId = model.Id;
  1393. vc.myTitle = model.Title;
  1394. vc.VisitUserId = model.SourceUserId;
  1395. vc.hidesBottomBarWhenPushed = YES;
  1396. [self.navigationController pushViewController:vc animated:YES];
  1397. }
  1398. }break;
  1399. case CollectModel_NoteFile:{
  1400. if (model.SourceUserId == [AppUserModel sharedAppUserModel].Id) {
  1401. NoteBookVC *vc = [NoteBookVC initNoteBookVC];
  1402. vc.listType = model.Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  1403. vc.ParentId = 0;
  1404. vc.FolderId = model.Id;
  1405. vc.myTitle = model.Title;
  1406. vc.VisitUserId = 0;
  1407. vc.hidesBottomBarWhenPushed = YES;
  1408. [self.navigationController pushViewController:vc animated:YES];
  1409. }else{
  1410. OtherNoteBookVC *vc = [OtherNoteBookVC initOtherNoteBookVC];
  1411. vc.listType = model.Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  1412. vc.FolderId = model.Id;
  1413. vc.myTitle = model.Title;
  1414. vc.VisitUserId = model.SourceUserId;
  1415. vc.TypeValue = 1;
  1416. vc.hidesBottomBarWhenPushed = YES;
  1417. [self.navigationController pushViewController:vc animated:YES];
  1418. }
  1419. }break;
  1420. case CollectModel_Notice:
  1421. {
  1422. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1423. vc.type = CollectModel_Notice;
  1424. vc.Id = model.Id;
  1425. vc.hidesBottomBarWhenPushed = YES;
  1426. [self.navigationController pushViewController:vc animated:YES];
  1427. }
  1428. break;
  1429. case CollectModel_InterMail:
  1430. {
  1431. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1432. vc.type = CollectModel_InterMail;
  1433. vc.Id = model.Id;
  1434. vc.hidesBottomBarWhenPushed = YES;
  1435. [self.navigationController pushViewController:vc animated:YES];
  1436. }
  1437. break;
  1438. case CollectModel_Group:
  1439. {
  1440. TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC];
  1441. vc.GroupId = model.Id;
  1442. vc.titleStr = model.Title;
  1443. vc.hidesBottomBarWhenPushed = YES;
  1444. [self.navigationController pushViewController:vc animated:YES];
  1445. }
  1446. break;
  1447. case CollectModel_meetMian:
  1448. {
  1449. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  1450. vc.type = CollectModel_meetMian;
  1451. vc.Id = model.Id;
  1452. vc.hidesBottomBarWhenPushed = YES;
  1453. [self.navigationController pushViewController:vc animated:YES];
  1454. }
  1455. break;
  1456. case CollectModel_meetDetail:
  1457. {
  1458. WorkFlowDetailsController * vc = [[WorkFlowDetailsController alloc] initWithId:model.Id];
  1459. vc.hidesBottomBarWhenPushed = YES;
  1460. [self.navigationController pushViewController:vc animated:YES];
  1461. }
  1462. break;
  1463. case CollectModel_work:
  1464. {
  1465. MyApprovalPageDetail * vc = [[MyApprovalPageDetail alloc]init];
  1466. vc.pageType = Type_ONEC;
  1467. vc.indexId = model.Id;
  1468. vc.title = model.Title;
  1469. vc.TodoId = model.Id;
  1470. vc.hidesBottomBarWhenPushed = YES;
  1471. [self.navigationController pushViewController:vc animated:YES];
  1472. }
  1473. break;
  1474. default:
  1475. {
  1476. DownFileViewController *vc = [[DownFileViewController alloc]init];
  1477. FlowAttachmentsModel * fmodel = [[FlowAttachmentsModel alloc] init];
  1478. fmodel.SoureId = model.Id;
  1479. fmodel.Title = model.Title;
  1480. fmodel.Url = model.File;
  1481. vc.model = fmodel;
  1482. vc.hidesBottomBarWhenPushed = YES;
  1483. [self.navigationController pushViewController:vc animated:YES];
  1484. }
  1485. break;
  1486. }
  1487. }
  1488. - (void)pushSearchVC
  1489. {
  1490. MyTDTopicSearchVC * vc = [[MyTDTopicSearchVC alloc] init];
  1491. vc.searchType = TDTopicSearch;
  1492. vc.hidesBottomBarWhenPushed = YES;
  1493. [self.navigationController pushViewController:vc animated:YES];
  1494. }
  1495. - (NSAttributedString *)setTextWithStr:(NSString *)str
  1496. {
  1497. if (str.length == 0) {
  1498. return [[NSAttributedString alloc] initWithString:@""];
  1499. }
  1500. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
  1501. [attributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"PingFang SC" size:16] range:NSMakeRange(0, str.length)];
  1502. [attributedString addAttribute:NSForegroundColorAttributeName value:UIColorHex(#484848) range:NSMakeRange(0, str.length)];
  1503. NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc]init];
  1504. paraStyle.alignment = NSTextAlignmentJustified;//两端对齐
  1505. [paraStyle setLineSpacing:5];//行间距
  1506. [attributedString addAttribute:NSParagraphStyleAttributeName value:paraStyle range:NSMakeRange(0, str.length)];
  1507. [attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleNone] range:NSMakeRange(0, str.length)];
  1508. return attributedString;
  1509. }
  1510. - (NSAttributedString *)setTitleWithStr:(NSString *)str
  1511. {
  1512. if (str.length == 0) {
  1513. return [[NSAttributedString alloc] initWithString:@""];
  1514. }
  1515. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
  1516. [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0, str.length)];
  1517. [attributedString addAttribute:NSForegroundColorAttributeName value:UIColorHex(0x0a0a0a) range:NSMakeRange(0, str.length)];
  1518. NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc]init];
  1519. paraStyle.alignment = NSTextAlignmentJustified;//两端对齐
  1520. [paraStyle setLineSpacing:5];//行间距
  1521. [attributedString addAttribute:NSParagraphStyleAttributeName value:paraStyle range:NSMakeRange(0, str.length)];
  1522. [attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleNone] range:NSMakeRange(0, str.length)];
  1523. return attributedString;
  1524. }
  1525. #pragma mark - 接收Drawer通知跳转到对应的子页面
  1526. - (void)pushSubViewController:(NSNotification *)notification
  1527. {
  1528. ///@"站内信", @"通知", @"收藏",@"笔记", @"设置"
  1529. NSInteger index = [[notification.userInfo objectForKey:VCINDEX] integerValue];
  1530. switch (index) {
  1531. case 0:
  1532. {
  1533. [self pushInterLeterVC];
  1534. }
  1535. break;
  1536. case 1:
  1537. {
  1538. [self pushChatMsgNoticeVC];
  1539. }
  1540. break;
  1541. default:
  1542. break;
  1543. }
  1544. }
  1545. #pragma mark - 跳转到站内信、通知页面
  1546. - (void)pushInterLeterVC
  1547. {
  1548. TDInterLeterHomeViewController *vc = [TDInterLeterHomeViewController initChatMsgNoticeVC];
  1549. vc.interLeterFolderId = 0;
  1550. vc.hidesBottomBarWhenPushed = YES;
  1551. [self.navigationController pushViewController:vc animated:YES];
  1552. }
  1553. - (void)pushChatMsgNoticeVC
  1554. {
  1555. ChatMsgListVC *vc = [ChatMsgListVC initChatMsgListVC];
  1556. vc.hidesBottomBarWhenPushed = YES;
  1557. [self.navigationController pushViewController:vc animated:YES];
  1558. }
  1559. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  1560. {
  1561. self.setY = scrollView.contentOffset.y;
  1562. if (self.setY > 126) {
  1563. [self.menuListView setViewHeight:NAVH + 36];
  1564. }else{
  1565. [self.menuListView setViewHeight:162 - self.setY + NAVH];
  1566. }
  1567. }
  1568. - (void)dealloc
  1569. {
  1570. [[EMClient sharedClient].chatManager removeDelegate:self];
  1571. [[EMClient sharedClient].groupManager removeDelegate:self];
  1572. [[EMConversationHelper shared] removeDelegate:self];
  1573. [[NSNotificationCenter defaultCenter] removeObserver:self];
  1574. }
  1575. //- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
  1576. //{
  1577. // NSLog(@"13413141414124134");
  1578. // [self configSwipeButton];
  1579. //}
  1580. //
  1581. //- (void)configSwipeButton
  1582. //{
  1583. // if (IOS13_OR_LATER) {
  1584. // for (UIView *supView in self.tableView.subviews){
  1585. // if ([supView isKindOfClass:NSClassFromString(@"_UITableViewCellSwipeContainerView")]){
  1586. // for (UIView * view in supView.subviews) {
  1587. //// NSLog(@"%@",[view description]);
  1588. // if ([view isKindOfClass:NSClassFromString(@"UISwipeActionPullView")]) {
  1589. // CGRect rect = view.frame;
  1590. // CGPoint center = view.center;
  1591. // if (view.frame.size.height > 80) {
  1592. // rect.size.height = 80;
  1593. // }
  1594. // view.frame = rect;
  1595. // view.center = center;
  1596. // }
  1597. // }
  1598. // }
  1599. // }
  1600. // }else{
  1601. // for (UIView *view in self.tableView.subviews){
  1602. // if ([view isKindOfClass:NSClassFromString(@"UISwipeActionPullView")]) {
  1603. // CGRect rect = view.frame;
  1604. // CGPoint center = view.center;
  1605. // if (view.frame.size.height > 80) {
  1606. // rect.size.height = 80;
  1607. // }
  1608. // view.frame = rect;
  1609. // view.center = center;
  1610. // }
  1611. // }
  1612. // }
  1613. //}
  1614. @end