TDGroupDraftSearchVC.m 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. //
  2. // MyTDTopicSearchVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2019/12/19.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "TDGroupDraftSearchVC.h"
  9. #import "TDGroupInfoDetailVC.h"
  10. #import "TDGroupInfoListModel.h"
  11. #import "TDGroupInfoListCell.h"
  12. #import "TopicListModel.h"
  13. #import "MyTDGroupView.h"
  14. #import "MyTDTopicDetailVC.h"
  15. #import "MyTDTopicSearchVC.h"
  16. #import "MyTDGroupViewController.h"
  17. #import "TDGroupInfoListVC.h"
  18. #import "WorkFlowDetailsController.h"
  19. #import "MyApprovalPageDetail.h"
  20. #import "DownFileViewController.h"
  21. #import "MailListDetailVC.h"
  22. #import "ShareListVC.h"
  23. #import "TopicBookCell.h"
  24. @interface TDGroupDraftSearchVC ()<UITableViewDelegate,UITableViewDataSource>
  25. @property (nonatomic, assign) NSUInteger currentPage;
  26. @property (nonatomic, assign) NSUInteger totalPage;
  27. @property (nonatomic, assign) NSUInteger totalRecord;
  28. @property (nonatomic, assign) BOOL isFresh;
  29. @property (strong, nonatomic) NSMutableArray * groupListArray;
  30. @property (strong, nonatomic) NSMutableArray * dataArray;
  31. @end
  32. @implementation TDGroupDraftSearchVC
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35. self.fd_prefersNavigationBarHidden = YES;
  36. self.view.backgroundColor = RGB(255, 255, 255);
  37. self.tableView.delegate = self;
  38. self.tableView.dataSource = self;
  39. [self setTableViewRefresh];
  40. self.historySearchType = HistorySearchType_GroupDraft;
  41. [self addObserver:self forKeyPath:@"searchText" options:NSKeyValueObservingOptionNew context:nil];
  42. }
  43. - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
  44. {
  45. id obj = [change objectForKey:@"new"];
  46. NSString * text = @"";
  47. if ([obj isKindOfClass:[NSString class]]) {
  48. text = obj;
  49. }else{
  50. text = [obj stringValue];
  51. }
  52. if (text.length > 0) {
  53. [self headRefresh];
  54. }
  55. }
  56. #pragma mark - UItableView刷新
  57. - (NSMutableArray *)dataArray
  58. {
  59. if (!_dataArray) {
  60. _dataArray = [NSMutableArray array];
  61. }
  62. return _dataArray;
  63. }
  64. - (void)setTableViewRefresh{
  65. WeakSelf(self)
  66. self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  67. [weakself headRefresh];
  68. }];
  69. self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
  70. [weakself footerRefresh];
  71. }];
  72. }
  73. - (void)headRefresh{
  74. self.currentPage = 1;
  75. self.totalPage = 0;
  76. [self.dataArray removeAllObjects];
  77. [self getData];
  78. }
  79. - (void)footerRefresh{
  80. self.currentPage += 1;
  81. if (self.totalRecord == self.dataArray.count) {
  82. self.currentPage --;
  83. [self.tableView.mj_footer endRefreshing];
  84. return ;
  85. }
  86. [self getData];
  87. }
  88. #pragma mark - 网络请求
  89. - (void)getData
  90. {
  91. WS(weakSelf);
  92. NSDictionary * paraDict = @{@"GroupIds":@[@(self.GroupId)],
  93. @"UserId":@([AppUserModel sharedAppUserModel].Id),
  94. @"Key": self.searchText,
  95. @"Page":@(self.currentPage),
  96. @"PerPage": @(10),
  97. @"Sort":@"",
  98. @"IsDraft":@(1)
  99. };
  100. SHOWLOADING
  101. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Topic_Page) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  102. REMOVESHOW
  103. TopicListModel * model = [TopicListModel modelWithDictionary:responseObject];
  104. weakSelf.totalRecord = model.Total;
  105. [weakSelf.dataArray addObjectsFromArray:model.Items];
  106. [weakSelf.tableView.mj_header endRefreshing];
  107. [weakSelf.tableView.mj_footer endRefreshing];
  108. dispatch_async(dispatch_get_main_queue(), ^{
  109. [weakSelf.tableView reloadData];
  110. });
  111. } failure:^(NSError * _Nonnull error) {
  112. REMOVESHOW
  113. }];
  114. }
  115. #pragma mark - UITableViewDelegate
  116. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  117. {
  118. return self.dataArray.count;
  119. }
  120. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  121. {
  122. return 1;
  123. }
  124. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  125. {
  126. WS(weakSelf);
  127. TopicListItemModel * model = [self.dataArray objectAtIndex:(indexPath.section)];
  128. switch (model.DataType) {
  129. case TopiclistCellImage:
  130. {
  131. TDGroupInfoListCell * cell;
  132. switch (model.Data.count) {
  133. case 1:
  134. {
  135. cell = [TDGroupInfoListCell configCell1:tableView indexPath:indexPath];
  136. cell.cellImagV1.hidden = NO;
  137. cell.cellImagV2.hidden = YES;
  138. cell.cellImagV3.hidden = YES;
  139. cell.cellImagV4.hidden = YES;
  140. cell.cellImagV5.hidden = YES;
  141. cell.cellImagV6.hidden = YES;
  142. cell.cellImagV7.hidden = YES;
  143. cell.cellImagV8.hidden = YES;
  144. cell.cellImagV9.hidden = YES;
  145. TopicListSubModel * subModel0 = model.Data[0];
  146. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  147. }
  148. break;
  149. case 2:
  150. {
  151. cell = [TDGroupInfoListCell configCell1:tableView indexPath:indexPath];
  152. cell.cellImagV1.hidden = NO;
  153. cell.cellImagV2.hidden = NO;
  154. cell.cellImagV3.hidden = YES;
  155. cell.cellImagV4.hidden = YES;
  156. cell.cellImagV5.hidden = YES;
  157. cell.cellImagV6.hidden = YES;
  158. cell.cellImagV7.hidden = YES;
  159. cell.cellImagV8.hidden = YES;
  160. cell.cellImagV9.hidden = YES;
  161. TopicListSubModel * subModel0 = model.Data[0];
  162. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  163. TopicListSubModel * subModel1 = model.Data[1];
  164. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  165. }
  166. break;
  167. case 3:
  168. {
  169. cell = [TDGroupInfoListCell configCell2:tableView indexPath:indexPath];
  170. cell.cellImagV1.hidden = NO;
  171. cell.cellImagV2.hidden = NO;
  172. cell.cellImagV3.hidden = NO;
  173. cell.cellImagV4.hidden = YES;
  174. cell.cellImagV5.hidden = YES;
  175. cell.cellImagV6.hidden = YES;
  176. cell.cellImagV7.hidden = YES;
  177. cell.cellImagV8.hidden = YES;
  178. cell.cellImagV9.hidden = YES;
  179. TopicListSubModel * subModel0 = model.Data[0];
  180. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  181. TopicListSubModel * subModel1 = model.Data[1];
  182. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  183. TopicListSubModel * subModel2 = model.Data[2];
  184. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  185. }
  186. break;
  187. case 4:
  188. {
  189. cell = [TDGroupInfoListCell configCell3:tableView indexPath:indexPath];
  190. cell.cellImagV1.hidden = NO;
  191. cell.cellImagV2.hidden = NO;
  192. cell.cellImagV3.hidden = NO;
  193. cell.cellImagV4.hidden = NO;
  194. cell.cellImagV5.hidden = YES;
  195. cell.cellImagV6.hidden = YES;
  196. cell.cellImagV7.hidden = YES;
  197. cell.cellImagV8.hidden = YES;
  198. cell.cellImagV9.hidden = YES;
  199. TopicListSubModel * subModel0 = model.Data[0];
  200. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  201. TopicListSubModel * subModel1 = model.Data[1];
  202. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  203. TopicListSubModel * subModel2 = model.Data[2];
  204. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  205. TopicListSubModel * subModel3 = model.Data[3];
  206. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  207. }
  208. break;
  209. case 5:
  210. {
  211. cell = [TDGroupInfoListCell configCell4:tableView indexPath:indexPath];
  212. cell.cellImagV1.hidden = NO;
  213. cell.cellImagV2.hidden = NO;
  214. cell.cellImagV3.hidden = NO;
  215. cell.cellImagV4.hidden = NO;
  216. cell.cellImagV5.hidden = NO;
  217. cell.cellImagV6.hidden = YES;
  218. cell.cellImagV7.hidden = YES;
  219. cell.cellImagV8.hidden = YES;
  220. cell.cellImagV9.hidden = YES;
  221. TopicListSubModel * subModel0 = model.Data[0];
  222. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  223. TopicListSubModel * subModel1 = model.Data[1];
  224. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  225. TopicListSubModel * subModel2 = model.Data[2];
  226. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  227. TopicListSubModel * subModel3 = model.Data[3];
  228. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  229. TopicListSubModel * subModel4 = model.Data[4];
  230. [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  231. }
  232. break;
  233. case 6:
  234. {
  235. cell = [TDGroupInfoListCell configCell4:tableView indexPath:indexPath];
  236. cell.cellImagV1.hidden = NO;
  237. cell.cellImagV2.hidden = NO;
  238. cell.cellImagV3.hidden = NO;
  239. cell.cellImagV4.hidden = NO;
  240. cell.cellImagV5.hidden = NO;
  241. cell.cellImagV6.hidden = NO;
  242. cell.cellImagV7.hidden = YES;
  243. cell.cellImagV8.hidden = YES;
  244. cell.cellImagV9.hidden = YES;
  245. TopicListSubModel * subModel0 = model.Data[0];
  246. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  247. TopicListSubModel * subModel1 = model.Data[1];
  248. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  249. TopicListSubModel * subModel2 = model.Data[2];
  250. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  251. TopicListSubModel * subModel3 = model.Data[3];
  252. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  253. TopicListSubModel * subModel4 = model.Data[4];
  254. [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  255. TopicListSubModel * subModel5 = model.Data[5];
  256. [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  257. }
  258. break;
  259. case 7:
  260. {
  261. cell = [TDGroupInfoListCell configCell5:tableView indexPath:indexPath];
  262. cell.cellImagV1.hidden = NO;
  263. cell.cellImagV2.hidden = NO;
  264. cell.cellImagV3.hidden = NO;
  265. cell.cellImagV4.hidden = NO;
  266. cell.cellImagV5.hidden = NO;
  267. cell.cellImagV6.hidden = NO;
  268. cell.cellImagV7.hidden = NO;
  269. cell.cellImagV8.hidden = YES;
  270. cell.cellImagV9.hidden = YES;
  271. TopicListSubModel * subModel0 = model.Data[0];
  272. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  273. TopicListSubModel * subModel1 = model.Data[1];
  274. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  275. TopicListSubModel * subModel2 = model.Data[2];
  276. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  277. TopicListSubModel * subModel3 = model.Data[3];
  278. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  279. TopicListSubModel * subModel4 = model.Data[4];
  280. [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  281. TopicListSubModel * subModel5 = model.Data[5];
  282. [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  283. TopicListSubModel * subModel6 = model.Data[6];
  284. [cell.cellImagV7 sd_setImageWithURL:[NSURL URLWithString:subModel6.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  285. }
  286. break;
  287. case 8:
  288. {
  289. cell = [TDGroupInfoListCell configCell5:tableView indexPath:indexPath];
  290. cell.cellImagV1.hidden = NO;
  291. cell.cellImagV2.hidden = NO;
  292. cell.cellImagV3.hidden = NO;
  293. cell.cellImagV4.hidden = NO;
  294. cell.cellImagV5.hidden = NO;
  295. cell.cellImagV6.hidden = NO;
  296. cell.cellImagV7.hidden = NO;
  297. cell.cellImagV8.hidden = NO;
  298. cell.cellImagV9.hidden = YES;
  299. TopicListSubModel * subModel0 = model.Data[0];
  300. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  301. TopicListSubModel * subModel1 = model.Data[1];
  302. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  303. TopicListSubModel * subModel2 = model.Data[2];
  304. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  305. TopicListSubModel * subModel3 = model.Data[3];
  306. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  307. TopicListSubModel * subModel4 = model.Data[4];
  308. [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  309. TopicListSubModel * subModel5 = model.Data[5];
  310. [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  311. TopicListSubModel * subModel6 = model.Data[6];
  312. [cell.cellImagV7 sd_setImageWithURL:[NSURL URLWithString:subModel6.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  313. TopicListSubModel * subModel7 = model.Data[7];
  314. [cell.cellImagV8 sd_setImageWithURL:[NSURL URLWithString:subModel7.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  315. }
  316. break;
  317. default:
  318. {
  319. cell = [TDGroupInfoListCell configCell5:tableView indexPath:indexPath];
  320. cell.cellImagV1.hidden = NO;
  321. cell.cellImagV2.hidden = NO;
  322. cell.cellImagV3.hidden = NO;
  323. cell.cellImagV4.hidden = NO;
  324. cell.cellImagV5.hidden = NO;
  325. cell.cellImagV6.hidden = NO;
  326. cell.cellImagV7.hidden = NO;
  327. cell.cellImagV8.hidden = NO;
  328. cell.cellImagV9.hidden = NO;
  329. TopicListSubModel * subModel0 = model.Data[0];
  330. [cell.cellImagV1 sd_setImageWithURL:[NSURL URLWithString:subModel0.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  331. TopicListSubModel * subModel1 = model.Data[1];
  332. [cell.cellImagV2 sd_setImageWithURL:[NSURL URLWithString:subModel1.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  333. TopicListSubModel * subModel2 = model.Data[2];
  334. [cell.cellImagV3 sd_setImageWithURL:[NSURL URLWithString:subModel2.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  335. TopicListSubModel * subModel3 = model.Data[3];
  336. [cell.cellImagV4 sd_setImageWithURL:[NSURL URLWithString:subModel3.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  337. TopicListSubModel * subModel4 = model.Data[4];
  338. [cell.cellImagV5 sd_setImageWithURL:[NSURL URLWithString:subModel4.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  339. TopicListSubModel * subModel5 = model.Data[5];
  340. [cell.cellImagV6 sd_setImageWithURL:[NSURL URLWithString:subModel5.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  341. TopicListSubModel * subModel6 = model.Data[6];
  342. [cell.cellImagV7 sd_setImageWithURL:[NSURL URLWithString:subModel6.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  343. TopicListSubModel * subModel7 = model.Data[7];
  344. [cell.cellImagV8 sd_setImageWithURL:[NSURL URLWithString:subModel7.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  345. TopicListSubModel * subModel8 = model.Data[8];
  346. [cell.cellImagV9 sd_setImageWithURL:[NSURL URLWithString:subModel8.File] placeholderImage:IMG(@"img_placeHolderVertical")];
  347. }
  348. break;
  349. }
  350. [cell.cellIconV sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  351. cell.fileBtn.hidden = YES;
  352. cell.rightView.hidden = YES;
  353. cell.cellTimeL.text = [model.CreatedDate substringWithRange:NSMakeRange(5, 11)];
  354. cell.celltitleL.attributedText = [self setTitleWithStr:model.Title];
  355. cell.cellContentL.attributedText = [self setTextWithStr:model.Content];
  356. cell.cellNameL.text = model.UserName;
  357. cell.cellReadNumL.text = [NSString stringWithFormat:@"阅读:%ld",(long)model.ReadCount];
  358. [cell.cellLikeBtn setAction:^{
  359. NSDictionary * paraDict = @{@"SourceId":@(model.Id),
  360. @"TypeValue":@(2),
  361. @"AnalyzeType":@(1)
  362. };
  363. cell.cellLikeBtn.enabled = NO;
  364. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  365. cell.cellLikeBtn.enabled = YES;
  366. model.IsPraise = !model.IsPraise;
  367. model.PraiseCount = model.IsPraise ? (model.PraiseCount + 1) : (model.PraiseCount - 1);
  368. dispatch_async(dispatch_get_main_queue(), ^{
  369. [weakSelf.tableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
  370. });
  371. } failure:^(NSError * _Nonnull error) {
  372. cell.cellLikeBtn.enabled = YES;
  373. }];
  374. }];
  375. if (model.CommentCount > 0) {
  376. [cell.cellPingBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.CommentCount] forState:UIControlStateNormal];
  377. }else{
  378. [cell.cellPingBtn setTitle:@"评论" forState:UIControlStateNormal];
  379. }
  380. if (model.PraiseCount > 0) {
  381. if (!model.IsPraise) {
  382. [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
  383. }else{
  384. [cell.cellLikeBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.PraiseCount] forState:UIControlStateNormal];
  385. }
  386. }else{
  387. [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
  388. }
  389. if (model.IsPraise) {
  390. [cell.cellLikeBtn setTitleColor:UIColorHex(#009AFF) forState:UIControlStateNormal];
  391. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞_select"] forState:UIControlStateNormal];
  392. }else{
  393. [cell.cellLikeBtn setTitleColor:UIColorHex(#999999) forState:UIControlStateNormal];
  394. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞"] forState:UIControlStateNormal];
  395. }
  396. [cell.cellPingBtn setAction:^{
  397. }];
  398. [cell.cellSendBtn setAction:^{
  399. }];
  400. if (model.Title.length == 0) {
  401. cell.TitleConstant.constant = 0;
  402. }else{
  403. cell.TitleConstant.constant = 10.f;
  404. }
  405. if (model.Content.length == 0) {
  406. cell.subTitleContant.constant = 0.f;
  407. }else{
  408. cell.subTitleContant.constant = 7.5f;
  409. }
  410. cell.ClickUserBlock = ^{
  411. [weakSelf showUserInfo:model.UserId];
  412. };
  413. cell.bottomView.hidden = YES;
  414. cell.bottomHeight.constant = 0.f;
  415. return cell;
  416. }
  417. break;
  418. case TopiclistCellNone:
  419. {
  420. TDGroupInfoListCell * cell = [TDGroupInfoListCell configCell0:tableView indexPath:indexPath];
  421. [cell.cellIconV sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  422. cell.fileBtn.hidden = YES;
  423. cell.rightView.hidden = YES;
  424. cell.cellNameL.text = model.UserName;
  425. cell.cellTimeL.text = [model.CreatedDate substringWithRange:NSMakeRange(5, 11)];
  426. cell.celltitleL.attributedText = [self setTitleWithStr:model.Title];
  427. cell.cellContentL.attributedText = [self setTextWithStr:model.Content];
  428. cell.cellReadNumL.text = [NSString stringWithFormat:@"阅读:%ld",(long)model.ReadCount];
  429. [cell.cellLikeBtn setAction:^{
  430. NSDictionary * paraDict = @{@"SourceId":@(model.Id),
  431. @"TypeValue":@(2),
  432. @"AnalyzeType":@(1)
  433. };
  434. cell.cellLikeBtn.enabled = NO;
  435. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  436. cell.cellLikeBtn.enabled = YES;
  437. model.IsPraise = !model.IsPraise;
  438. model.PraiseCount = model.IsPraise ? (model.PraiseCount + 1) : (model.PraiseCount - 1);
  439. dispatch_async(dispatch_get_main_queue(), ^{
  440. [weakSelf.tableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
  441. });
  442. } failure:^(NSError * _Nonnull error) {
  443. cell.cellLikeBtn.enabled = YES;
  444. }];
  445. }];
  446. if (model.CommentCount > 0) {
  447. [cell.cellPingBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.CommentCount] forState:UIControlStateNormal];
  448. }else{
  449. [cell.cellPingBtn setTitle:@"评论" forState:UIControlStateNormal];
  450. }
  451. if (model.PraiseCount > 0) {
  452. if (!model.IsPraise) {
  453. [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
  454. }else{
  455. [cell.cellLikeBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.PraiseCount] forState:UIControlStateNormal];
  456. }
  457. }else{
  458. [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
  459. }
  460. if (model.IsPraise) {
  461. [cell.cellLikeBtn setTitleColor:UIColorHex(#009AFF) forState:UIControlStateNormal];
  462. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞_select"] forState:UIControlStateNormal];
  463. }else{
  464. [cell.cellLikeBtn setTitleColor:UIColorHex(#999999) forState:UIControlStateNormal];
  465. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞"] forState:UIControlStateNormal];
  466. }
  467. [cell.cellPingBtn setAction:^{
  468. }];
  469. [cell.cellSendBtn setAction:^{
  470. }];
  471. if (model.Title.length == 0) {
  472. cell.TitleConstant.constant = 0;
  473. }else{
  474. cell.TitleConstant.constant = 10.f;
  475. }
  476. if (model.Content.length == 0) {
  477. cell.subTitleContant.constant = 0.f;
  478. }else{
  479. cell.subTitleContant.constant = 7.5f;
  480. }
  481. cell.ClickUserBlock = ^{
  482. [weakSelf showUserInfo:model.UserId];
  483. };
  484. cell.bottomView.hidden = YES;
  485. cell.bottomHeight.constant = 0.f;
  486. return cell;
  487. }
  488. break;
  489. case TopiclistCellFile:
  490. {
  491. TDGroupInfoListCell * cell = [TDGroupInfoListCell configCell6:tableView indexPath:indexPath];
  492. [cell.cellIconV sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
  493. cell.fileBtn.hidden = YES;
  494. cell.rightView.hidden = YES;
  495. cell.cellNameL.text = model.UserName;
  496. cell.cellTimeL.text = [model.CreatedDate substringWithRange:NSMakeRange(5, 11)];
  497. cell.celltitleL.attributedText = [self setTitleWithStr:model.Title];
  498. cell.cellContentL.attributedText = [self setTextWithStr:model.Content];
  499. cell.cellReadNumL.text = [NSString stringWithFormat:@"阅读:%ld",(long)model.ReadCount];
  500. [cell.cellLikeBtn setAction:^{
  501. NSDictionary * paraDict = @{@"SourceId":@(model.Id),
  502. @"TypeValue":@(2),
  503. @"AnalyzeType":@(1)
  504. };
  505. cell.cellLikeBtn.enabled = NO;
  506. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:paraDict responseStyle:DATA success:^(id _Nonnull responseObject) {
  507. cell.cellLikeBtn.enabled = YES;
  508. model.IsPraise = !model.IsPraise;
  509. model.PraiseCount = model.IsPraise ? (model.PraiseCount + 1) : (model.PraiseCount - 1);
  510. dispatch_async(dispatch_get_main_queue(), ^{
  511. [weakSelf.tableView reloadRow:indexPath.row inSection:indexPath.section withRowAnimation:UITableViewRowAnimationNone];
  512. });
  513. } failure:^(NSError * _Nonnull error) {
  514. cell.cellLikeBtn.enabled = YES;
  515. }];
  516. }];
  517. [cell.ClickFileAction setAction:^{
  518. }];
  519. [cell setDataWithCell6:model.Data.firstObject];
  520. if (model.CommentCount > 0) {
  521. [cell.cellPingBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.CommentCount] forState:UIControlStateNormal];
  522. }else{
  523. [cell.cellPingBtn setTitle:@"评论" forState:UIControlStateNormal];
  524. }
  525. if (model.PraiseCount > 0) {
  526. if (!model.IsPraise) {
  527. [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
  528. }else{
  529. [cell.cellLikeBtn setTitle:[NSString stringWithFormat:@"%ld",(long)model.PraiseCount] forState:UIControlStateNormal];
  530. }
  531. }else{
  532. [cell.cellLikeBtn setTitle:@"赞" forState:UIControlStateNormal];
  533. }
  534. if (model.IsPraise) {
  535. [cell.cellLikeBtn setTitleColor:UIColorHex(#009AFF) forState:UIControlStateNormal];
  536. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞_select"] forState:UIControlStateNormal];
  537. }else{
  538. [cell.cellLikeBtn setTitleColor:UIColorHex(#999999) forState:UIControlStateNormal];
  539. [cell.cellLikeBtn setImage:[UIImage imageNamed:@"收藏_赞"] forState:UIControlStateNormal];
  540. }
  541. [cell.cellPingBtn setAction:^{
  542. }];
  543. [cell.cellSendBtn setAction:^{
  544. }];
  545. if (model.Title.length == 0) {
  546. cell.TitleConstant.constant = 0;
  547. }else{
  548. cell.TitleConstant.constant = 10.f;
  549. }
  550. if (model.Content.length == 0) {
  551. cell.subTitleContant.constant = 0.f;
  552. }else{
  553. cell.subTitleContant.constant = 7.5f;
  554. }
  555. cell.ClickUserBlock = ^{
  556. [weakSelf showUserInfo:model.UserId];
  557. };
  558. cell.bottomView.hidden = YES;
  559. cell.bottomHeight.constant = 0.f;
  560. return cell;
  561. }
  562. break;
  563. default:
  564. {
  565. TopicBookCell * cell = [TopicBookCell configCell0:tableView indexPath:indexPath];
  566. cell.titleL.text = model.Title;
  567. cell.imagV.image = IMG(@"Draft_Icon");
  568. cell.countL.text = [NSString stringWithFormat:@"%ld",model.FileCount];
  569. cell.enterBtn.hidden = YES;
  570. return cell;
  571. }
  572. break;
  573. }
  574. }
  575. - (void)showUserInfo:(NSInteger)userId
  576. {
  577. MailListDetailVC * vc = [MailListDetailVC initMailListDetailVC];
  578. vc.indexId = userId;
  579. [self.navigationController pushViewController:vc animated:YES];
  580. }
  581. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  582. {
  583. return 0.01f;
  584. }
  585. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  586. {
  587. return 8.f;
  588. }
  589. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  590. {
  591. return [UIView new];
  592. }
  593. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  594. {
  595. UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 8)];
  596. view.backgroundColor = UIColorHex(#F5F6F8);
  597. return view;
  598. }
  599. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  600. {
  601. WS(weakSelf);
  602. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  603. TopicListItemModel * model = [self.dataArray objectAtIndex:(indexPath.section)];
  604. MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
  605. vc.type = CollectModel_Toipc;
  606. vc.isEdit = YES;
  607. vc.replayType = MailReplayEdit;
  608. vc.Id = model.Id;
  609. vc.FolderId = model.GroupId;
  610. vc.isFromDraft = YES;
  611. vc.upDateBlock = ^{
  612. [weakSelf headRefresh];
  613. };
  614. [self.navigationController pushViewController:vc animated:YES];
  615. }
  616. #pragma mark - UISwipeActionsConfiguration
  617. - (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){
  618. WS(weakSelf);
  619. TopicListItemModel * model = [self.dataArray objectAtIndex:(indexPath.section)];
  620. UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
  621. [tableView setEditing:NO animated:YES];
  622. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"删除草稿后将无法恢复" preferredStyle:UIAlertControllerStyleAlert];
  623. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  624. dispatch_async(dispatch_get_main_queue(), ^{
  625. [weakSelf.tableView reloadData];
  626. });
  627. }];
  628. [ok setValue:k9 forKey:@"_titleTextColor"];
  629. UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  630. [weakSelf deleteFind:model indexPath:indexPath];
  631. }];
  632. [noOk setValue:UIColorHex(0x0F7FD9) forKey:@"_titleTextColor"];
  633. [alertVC addAction:ok];
  634. [alertVC addAction:noOk];
  635. [weakSelf presentViewController:alertVC animated:YES completion:nil];
  636. completionHandler(YES);
  637. }];
  638. action1.backgroundColor = RGB(255, 59, 47);
  639. UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1]];
  640. actions.performsFirstActionWithFullSwipe = NO;
  641. return actions;
  642. }
  643. - (void)deleteFind:(TopicListItemModel *)model indexPath:(NSIndexPath *)indexPath{
  644. WS(weakSelf);
  645. NSString * url = [NSString stringWithFormat:@"%@%ld",Host(APP_Topic_User_Get),model.Id];
  646. [[HttpManager sharedHttpManager] DeleteUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
  647. [weakSelf.dataArray removeObjectAtIndex:indexPath.row];
  648. dispatch_async(dispatch_get_main_queue(), ^{
  649. [weakSelf.tableView reloadData];
  650. });
  651. } failure:^(NSError * _Nonnull error) {
  652. }];
  653. }
  654. - (NSAttributedString *)setTextWithStr:(NSString *)str
  655. {
  656. if (str.length == 0) {
  657. return [[NSAttributedString alloc] initWithString:@""];
  658. }
  659. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
  660. [attributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"PingFang SC" size:16] range:NSMakeRange(0, str.length)];
  661. [attributedString addAttribute:NSForegroundColorAttributeName value:UIColorHex(#484848) range:NSMakeRange(0, str.length)];
  662. [attributedString addAttribute:(NSString *)NSForegroundColorAttributeName
  663. value:UIColorHex(0xFF5252)
  664. range:[str rangeOfString:self.searchText]];
  665. NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc]init];
  666. paraStyle.alignment = NSTextAlignmentJustified;//两端对齐
  667. [paraStyle setLineSpacing:5];//行间距
  668. [attributedString addAttribute:NSParagraphStyleAttributeName value:paraStyle range:NSMakeRange(0, str.length)];
  669. [attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleNone] range:NSMakeRange(0, str.length)];
  670. return attributedString;
  671. }
  672. - (NSAttributedString *)setTitleWithStr:(NSString *)str
  673. {
  674. if (str.length == 0) {
  675. return [[NSAttributedString alloc] initWithString:@""];
  676. }
  677. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
  678. [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0, str.length)];
  679. [attributedString addAttribute:NSForegroundColorAttributeName value:UIColorHex(0x0a0a0a) range:NSMakeRange(0, str.length)];
  680. [attributedString addAttribute:(NSString *)NSForegroundColorAttributeName
  681. value:UIColorHex(0xFF5252)
  682. range:[str rangeOfString:self.searchText]];
  683. NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc]init];
  684. paraStyle.alignment = NSTextAlignmentJustified;//两端对齐
  685. [paraStyle setLineSpacing:5];//行间距
  686. [attributedString addAttribute:NSParagraphStyleAttributeName value:paraStyle range:NSMakeRange(0, str.length)];
  687. [attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleNone] range:NSMakeRange(0, str.length)];
  688. return attributedString;
  689. }
  690. @end