CommonListCell.m 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. //
  2. // CommonListCell.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/4/28.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "CommonListCell.h"
  9. @implementation CommonListCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.iconShowL.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(3, 3)];
  13. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  14. maskLayer.frame = self.iconShowL.bounds;
  15. maskLayer.path = maskPath.CGPath;
  16. self.iconShowL.layer.mask = maskLayer;
  17. }
  18. + (CGFloat)configCell0Height{
  19. return 72;
  20. }
  21. + (CommonListCell *)configCell0:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
  22. static NSString *cellIdentifer = @"CommonListCell0";
  23. CommonListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
  24. if (cell == nil) {
  25. cell = [[[NSBundle mainBundle] loadNibNamed:@"CommonListCell" owner:nil options:nil] objectAtIndex:0];
  26. }
  27. return cell;
  28. }
  29. + (CommonListCell *)configCell1:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
  30. static NSString *cellIdentifer = @"CommonListCell1";
  31. CommonListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
  32. if (cell == nil) {
  33. cell = [[[NSBundle mainBundle] loadNibNamed:@"CommonListCell" owner:nil options:nil] objectAtIndex:1];
  34. }
  35. return cell;
  36. }
  37. + (CommonListCell *)configCell2:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
  38. static NSString *cellIdentifer = @"CommonListCell2";
  39. CommonListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
  40. if (cell == nil) {
  41. cell = [[[NSBundle mainBundle] loadNibNamed:@"CommonListCell" owner:nil options:nil] objectAtIndex:2];
  42. }
  43. return cell;
  44. }
  45. - (void)setCell1Data:(MyFavoriteSubModel *)model
  46. {
  47. WS(weakSelf);
  48. self.nameL.hidden = NO;
  49. self.iconShowL.hidden = YES;
  50. self.comeBtn.hidden = YES;
  51. self.isTopV.hidden = !model.IsTop;
  52. [self.iconV removeAllSubviews];
  53. [self.titleL mas_remakeConstraints:^(MASConstraintMaker *make) {
  54. make.left.mas_equalTo(self.iconV.mas_right).offset(15);
  55. make.top.mas_offset(model.CollectionType == CollectModel_TopicBooK ? 40.25 : 15);
  56. make.height.mas_greaterThanOrEqualTo(20);
  57. make.width.mas_lessThanOrEqualTo(SCREEN_WIDTH - (model.IsTop ? 125 : 85));
  58. }];
  59. self.titleL.text = [model.Data.Title length] > 0 ? model.Data.Title : model.Title;
  60. self.nameL.text = [model.Data.Author length] > 0 ? model.Data.Author : @" ";
  61. [self.desBtn setTitle:[model.FolderName length] > 0 ? model.FolderName : @" " forState:UIControlStateNormal];
  62. switch (model.CollectionType) {
  63. // 文章
  64. case CollectModel_Aritle:{
  65. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  66. if (image) {
  67. weakSelf.iconShowL.hidden = NO;
  68. }
  69. }];
  70. }break;
  71. case CollectModel_MediaAritle:{
  72. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  73. if (image) {
  74. weakSelf.iconShowL.hidden = NO;
  75. }
  76. }];
  77. }break;
  78. // 话题 || 小组
  79. case CollectModel_Toipc:
  80. {
  81. self.iconV.image = IMG(@"话题");
  82. self.comeBtn.hidden = NO;
  83. [self.comeBtn setAttributedTitle:[self comeGroup:model.Data.GroupName] forState:UIControlStateNormal];
  84. }break;
  85. case CollectModel_NewTopic:
  86. {
  87. self.iconV.image = IMG(@"话题");
  88. }break;
  89. case CollectModel_Group:{
  90. self.iconV.image = IMG(@"笔记小组");
  91. }break;
  92. // 收藏
  93. case CollectModel_Collect:{
  94. self.iconV.image = IMG(@"收藏");
  95. }break;
  96. // 笔记
  97. case CollectModel_NoteBook: {
  98. self.iconV.image = IMG(@"noteBook_icon");
  99. }break;
  100. case CollectModel_CollectFile:{
  101. self.titleL.text = model.Title;
  102. self.iconV.image = IMG(@"find_1");
  103. self.comeBtn.hidden = NO;
  104. self.nameL.text = @"";
  105. self.comeLeft.constant = 0.f;
  106. [self.comeBtn setAttributedTitle:[self comeGroup:[NSString stringWithFormat:@"%@的收藏",model.Data.Author]] forState:UIControlStateNormal];
  107. }break;
  108. case CollectModel_NoteFile: {
  109. self.iconV.image = IMG(@"find_1");
  110. }break;
  111. case CollectModel_TopicSubBooK: {
  112. self.iconV.image = IMG(@"find_1");
  113. }break;
  114. // 通知 || 站内信
  115. case CollectModel_Notice:
  116. {
  117. self.iconV.image = IMG(@"通知图标");
  118. }break;
  119. case CollectModel_InterMail:{
  120. self.iconV.image = IMG(@"站内信");
  121. }break;
  122. // 会议
  123. case CollectModel_meetMian:
  124. {
  125. self.iconV.image = IMG(@"会议纪要");
  126. }
  127. break;
  128. case CollectModel_meetDetail:
  129. {
  130. self.iconV.image = IMG(@"会议");
  131. }
  132. break;
  133. case CollectModel_file:{
  134. NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName];
  135. if (imageStr.length == 0) {
  136. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.File]];
  137. }else{
  138. self.iconV.image = IMG(imageStr);
  139. }
  140. }break;
  141. case CollectModel_work:
  142. {
  143. self.iconV.image = IMG(@"审批");
  144. }
  145. break;
  146. case CollectModel_StoreSound:
  147. {
  148. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_audio") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  149. dispatch_async(dispatch_get_main_queue(), ^{
  150. UIImageView * clearV = [UIImageView new];
  151. [weakSelf.iconV addSubview:clearV];
  152. clearV.image = IMG(@"clear_audio");
  153. [clearV mas_makeConstraints:^(MASConstraintMaker *make) {
  154. make.edges.mas_equalTo(weakSelf.iconV);
  155. }];
  156. });
  157. }];
  158. }
  159. break;
  160. case CollectModel_StoreVideo:
  161. {
  162. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_video") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  163. dispatch_async(dispatch_get_main_queue(), ^{
  164. UIImageView * clearV = [UIImageView new];
  165. [weakSelf.iconV addSubview:clearV];
  166. clearV.image = IMG(@"clear_video");
  167. [clearV mas_makeConstraints:^(MASConstraintMaker *make) {
  168. make.edges.mas_equalTo(weakSelf.iconV);
  169. }];
  170. });
  171. }];
  172. }
  173. break;
  174. case CollectModel_Organization:
  175. {
  176. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")];
  177. }
  178. break;
  179. case CollectModel_financeCount:
  180. {
  181. self.iconV.image = IMG(@"报表");
  182. }
  183. break;
  184. case CollectModel_affairsCount:
  185. {
  186. self.iconV.image = IMG(@"报表");
  187. }
  188. break;
  189. case CollectModel_publishCount:
  190. {
  191. self.iconV.image = IMG(@"报表");
  192. }
  193. break;
  194. case CollectModel_StoreBook:{
  195. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  196. if (image) {
  197. weakSelf.iconShowL.hidden = NO;
  198. weakSelf.iconShowL.text = @"图 书";
  199. }
  200. }];
  201. self.nameL.text = [NSString stringWithFormat:@"%@ %@",model.Data.Author,ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  202. }break;
  203. case CollectModel_StoreMing:{
  204. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  205. if (image) {
  206. weakSelf.iconShowL.hidden = NO;
  207. weakSelf.iconShowL.text = @"名 栏";
  208. }
  209. }];
  210. self.nameL.text = [NSString stringWithFormat:@"名栏: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  211. }break;
  212. case CollectModel_StoreQiKan:{
  213. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  214. if (image) {
  215. weakSelf.iconShowL.hidden = NO;
  216. weakSelf.iconShowL.text = @"期 刊";
  217. }
  218. }];
  219. self.nameL.text = [NSString stringWithFormat:@"主办单位: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  220. }break;
  221. case CollectModel_StoreGongzh:{
  222. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  223. if (image) {
  224. weakSelf.iconShowL.hidden = NO;
  225. weakSelf.iconShowL.text = @"公众号";
  226. }
  227. }];
  228. self.nameL.text = [NSString stringWithFormat:@"公众号: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  229. }break;
  230. default:{
  231. NSString * imageStr = [ZYCTool getFileNameImage:model.Title];
  232. if (imageStr.length == 0) {
  233. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]];
  234. }else{
  235. self.iconV.image = IMG(imageStr);
  236. }
  237. }break;
  238. }
  239. }
  240. - (void)image:(UIImage *)image clearImage:(NSString *)clearImage IconV:(UIImageView *)imgV {
  241. UIImage *image1 = [UIImage imageNamed:clearImage];
  242. CGSize size = CGSizeMake([UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height);
  243. UIGraphicsBeginImageContext(size);
  244. [image drawInRect:CGRectMake(0, 0, 40,40)];
  245. [image1 drawInRect:CGRectMake(0, 0, 40,40)];
  246. UIImage *ZImage = UIGraphicsGetImageFromCurrentImageContext();
  247. UIGraphicsEndImageContext();
  248. imgV.image = ZImage;
  249. }
  250. - (void)setCalayerImage:(UIImageView *)imgV image:(NSString *)image
  251. {
  252. CALayer *mask = [CALayer layer];
  253. mask.contents = (id)[[UIImage imageNamed:image] CGImage];
  254. mask.frame = CGRectMake(0, 0, 40, 40);
  255. imgV.layer.mask = mask;
  256. imgV.layer.masksToBounds = YES;
  257. }
  258. - (void)setCellTopicBookData:(MyFavoriteSubModel *)model
  259. {
  260. self.iconV.image = IMG(@"topicBook");
  261. self.isTopV.hidden = !model.IsTop;
  262. self.titleL.text = model.Data.Title;
  263. [self.desBtn setTitle:[model.FolderName length] > 0 ? model.FolderName : @" " forState:UIControlStateNormal];
  264. }
  265. - (void)setCellNoAuthorData:(MyFavoriteSubModel *)model
  266. {
  267. WS(weakSelf);
  268. self.nameL.hidden = NO;
  269. self.iconShowL.hidden = YES;
  270. self.comeBtn.hidden = YES;
  271. self.isTopV.hidden = !model.IsTop;
  272. self.titleL.text = [model.Data.Title length] > 0 ? model.Data.Title : model.Title;
  273. [self.desBtn setTitle:[model.FolderName length] > 0 ? model.FolderName : @"" forState:UIControlStateNormal];
  274. [self.iconV removeAllSubviews];
  275. switch (model.CollectionType) {
  276. // 文章
  277. case CollectModel_Aritle:{
  278. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  279. if (image) {
  280. weakSelf.iconShowL.hidden = NO;
  281. weakSelf.iconShowL.text = @"文 章";
  282. }
  283. }];
  284. }break;
  285. case CollectModel_Toipc: // 话题 || 小组
  286. {
  287. self.iconV.image = IMG(@"话题");
  288. self.comeBtn.hidden = NO;
  289. [self.comeBtn setAttributedTitle:[self comeGroup:model.Data.GroupName] forState:UIControlStateNormal];
  290. }break;
  291. case CollectModel_NewTopic:
  292. {
  293. self.iconV.image = IMG(@"话题");
  294. }break;
  295. case CollectModel_Group:{
  296. self.iconV.image = IMG(@"笔记小组");
  297. }break;
  298. // 收藏
  299. case CollectModel_Collect:{
  300. self.iconV.image = IMG(@"收藏");
  301. }break;
  302. // 笔记
  303. case CollectModel_NoteBook: {
  304. self.iconV.image = IMG(@"noteBook_icon");
  305. }break;
  306. case CollectModel_CollectFile:{
  307. self.titleL.text = model.Title;
  308. self.iconV.image = IMG(@"find_1");
  309. self.comeBtn.hidden = NO;
  310. self.nameL.text = @"";
  311. self.comeLeft.constant = 0.f;
  312. [self.comeBtn setAttributedTitle:[self comeGroup:[NSString stringWithFormat:@"%@的收藏",model.Data.Author]] forState:UIControlStateNormal];
  313. }break;
  314. case CollectModel_NoteFile: {
  315. self.iconV.image = IMG(@"find_1");
  316. }break;
  317. case CollectModel_TopicSubBooK: {
  318. self.iconV.image = IMG(@"find_1");
  319. }break;
  320. // 通知 || 站内信
  321. case CollectModel_Notice:
  322. {
  323. self.iconV.image = IMG(@"通知图标");
  324. }break;
  325. case CollectModel_InterMail:{
  326. self.iconV.image = IMG(@"站内信");
  327. }break;
  328. // 会议
  329. case CollectModel_meetMian:
  330. {
  331. self.iconV.image = IMG(@"会议纪要");
  332. }
  333. break;
  334. case CollectModel_meetDetail:
  335. {
  336. self.iconV.image = IMG(@"会议");
  337. }
  338. break;
  339. case CollectModel_file:{
  340. NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName];
  341. if (imageStr.length == 0) {
  342. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.File]];
  343. }else{
  344. self.iconV.image = IMG(imageStr);
  345. }
  346. }
  347. break;
  348. case CollectModel_work:
  349. {
  350. self.iconV.image = IMG(@"审批");
  351. }
  352. break;
  353. case CollectModel_financeCount:
  354. {
  355. self.iconV.image = IMG(@"报表");
  356. }
  357. break;
  358. case CollectModel_StoreBook:{
  359. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  360. if (image) {
  361. weakSelf.iconShowL.hidden = NO;
  362. weakSelf.iconShowL.text = @"图 书";
  363. }
  364. }];
  365. self.nameL.text = [NSString stringWithFormat:@"%@ %@",model.Data.Author,ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  366. }break;
  367. case CollectModel_StoreMing:{
  368. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  369. if (image) {
  370. weakSelf.iconShowL.hidden = NO;
  371. weakSelf.iconShowL.text = @"名 栏";
  372. }
  373. }];
  374. self.nameL.text = [NSString stringWithFormat:@"名栏: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  375. }break;
  376. case CollectModel_StoreQiKan:{
  377. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  378. if (image) {
  379. weakSelf.iconShowL.hidden = NO;
  380. weakSelf.iconShowL.text = @"期 刊";
  381. }
  382. }];
  383. self.nameL.text = [NSString stringWithFormat:@"主办单位: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  384. }break;
  385. case CollectModel_StoreGongzh:{
  386. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  387. if (image) {
  388. weakSelf.iconShowL.hidden = NO;
  389. weakSelf.iconShowL.text = @"公众号";
  390. }
  391. }];
  392. self.nameL.text = [NSString stringWithFormat:@"公众号: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  393. }break;
  394. case CollectModel_StoreSound:
  395. {
  396. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_audio") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  397. dispatch_async(dispatch_get_main_queue(), ^{
  398. UIImageView * clearV = [UIImageView new];
  399. [weakSelf.iconV addSubview:clearV];
  400. clearV.image = IMG(@"clear_audio");
  401. [clearV mas_makeConstraints:^(MASConstraintMaker *make) {
  402. make.edges.mas_equalTo(weakSelf.iconV);
  403. }];
  404. });
  405. }];
  406. }
  407. break;
  408. case CollectModel_StoreVideo:
  409. {
  410. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_video") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  411. dispatch_async(dispatch_get_main_queue(), ^{
  412. UIImageView * clearV = [UIImageView new];
  413. [weakSelf.iconV addSubview:clearV];
  414. clearV.image = IMG(@"clear_video");
  415. [clearV mas_makeConstraints:^(MASConstraintMaker *make) {
  416. make.edges.mas_equalTo(weakSelf.iconV);
  417. }];
  418. });
  419. }];
  420. }
  421. break;
  422. case CollectModel_Teacher:
  423. {
  424. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")];
  425. self.titleL.text = model.Data.Author;
  426. self.nameL.hidden = YES;
  427. }
  428. break;
  429. case CollectModel_Organization:
  430. {
  431. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")];
  432. self.titleL.text = model.Data.Author;
  433. self.nameL.hidden = YES;
  434. }
  435. break;
  436. case CollectModel_affairsCount:
  437. {
  438. self.iconV.image = IMG(@"报表");
  439. }
  440. break;
  441. case CollectModel_publishCount:
  442. {
  443. self.iconV.image = IMG(@"报表");
  444. }
  445. break;
  446. default:{
  447. NSString * imageStr = [ZYCTool getFileNameImage:model.Title];
  448. if (imageStr.length == 0) {
  449. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]];
  450. }else{
  451. self.iconV.image = IMG(imageStr);
  452. }
  453. }break;
  454. }
  455. }
  456. - (void)setCellNoAuthorData:(MyFavoriteSubModel *)model withText:(NSString *)text
  457. {
  458. WS(weakSelf);
  459. self.nameL.hidden = NO;
  460. self.iconShowL.hidden = YES;
  461. self.comeBtn.hidden = YES;
  462. self.isTopV.hidden = !model.IsTop;
  463. self.titleL.attributedText = [ZYCTool checkOfString:model.Data.Title withSearchText:text withColor:UIColorHex(0xFF5252)];
  464. self.nameL.attributedText = [model.Data.Author length] > 0 ? [ZYCTool checkOfString:model.Data.Author withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "];
  465. [self.desBtn setAttributedTitle:[model.FolderName length] > 0 ? [ZYCTool checkOfString:model.FolderName withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "] forState:UIControlStateNormal];
  466. [self.iconV removeAllSubviews];
  467. switch (model.CollectionType) {
  468. // 文章
  469. case CollectModel_Aritle:{
  470. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章")];
  471. }break;
  472. // 话题 || 小组
  473. case CollectModel_Toipc:
  474. {
  475. self.iconV.image = IMG(@"话题");
  476. self.comeBtn.hidden = NO;
  477. [self.comeBtn setAttributedTitle:[self comeGroup:model.GroupName] forState:UIControlStateNormal];
  478. }break;
  479. case CollectModel_NewTopic:
  480. {
  481. self.iconV.image = IMG(@"话题");
  482. }break;
  483. case CollectModel_Group:{
  484. self.iconV.image = IMG(@"笔记小组");
  485. }break;
  486. // 收藏
  487. case CollectModel_Collect:{
  488. self.iconV.image = IMG(@"收藏");
  489. }break;
  490. // 笔记
  491. case CollectModel_NoteBook: {
  492. self.iconV.image = IMG(@"noteBook_icon");
  493. }break;
  494. case CollectModel_CollectFile:{
  495. self.titleL.attributedText = [ZYCTool checkOfString:model.Title withSearchText:text withColor:UIColorHex(0xFF5252)];
  496. self.iconV.image = IMG(@"find_1");
  497. self.comeBtn.hidden = NO;
  498. self.nameL.text = @"";
  499. self.comeLeft.constant = 0.f;
  500. [self.comeBtn setAttributedTitle:[self comeGroup:[NSString stringWithFormat:@"%@的收藏",model.Data.Author]] forState:UIControlStateNormal];
  501. }break;
  502. case CollectModel_NoteFile: {
  503. self.iconV.image = IMG(@"find_1");
  504. }break;
  505. case CollectModel_TopicBooK:{
  506. self.iconV.image = IMG(@"topicBook");
  507. }break;
  508. case CollectModel_TopicSubBooK: {
  509. self.iconV.image = IMG(@"find_1");
  510. }break;
  511. // 通知 || 站内信
  512. case CollectModel_Notice:
  513. {
  514. self.iconV.image = IMG(@"通知图标");
  515. }break;
  516. case CollectModel_InterMail:{
  517. self.iconV.image = IMG(@"站内信");
  518. }break;
  519. // 会议
  520. case CollectModel_meetMian:
  521. {
  522. self.iconV.image = IMG(@"会议纪要");
  523. }
  524. break;
  525. case CollectModel_meetDetail:
  526. {
  527. self.iconV.image = IMG(@"会议");
  528. }
  529. break;
  530. case CollectModel_file:{
  531. NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName];
  532. if (imageStr.length == 0) {
  533. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.File]];
  534. }else{
  535. self.iconV.image = IMG(imageStr);
  536. }
  537. }break;
  538. case CollectModel_work:
  539. {
  540. self.iconV.image = IMG(@"审批");
  541. }
  542. break;
  543. case CollectModel_StoreSound:
  544. {
  545. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_audio") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  546. dispatch_async(dispatch_get_main_queue(), ^{
  547. UIImageView * clearV = [UIImageView new];
  548. [weakSelf.iconV addSubview:clearV];
  549. clearV.image = IMG(@"clear_audio");
  550. [clearV mas_makeConstraints:^(MASConstraintMaker *make) {
  551. make.edges.mas_equalTo(weakSelf.iconV);
  552. }];
  553. });
  554. }];
  555. }
  556. break;
  557. case CollectModel_StoreVideo:
  558. {
  559. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_video") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  560. dispatch_async(dispatch_get_main_queue(), ^{
  561. UIImageView * clearV = [UIImageView new];
  562. [weakSelf.iconV addSubview:clearV];
  563. clearV.image = IMG(@"clear_video");
  564. [clearV mas_makeConstraints:^(MASConstraintMaker *make) {
  565. make.edges.mas_equalTo(weakSelf.iconV);
  566. }];
  567. });
  568. }];
  569. }
  570. break;
  571. case CollectModel_Teacher:
  572. {
  573. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")];
  574. self.titleL.attributedText = [model.Data.Author length] > 0 ? [ZYCTool checkOfString:model.Data.Author withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "];
  575. self.nameL.hidden = YES;
  576. }
  577. break;
  578. case CollectModel_Organization:
  579. {
  580. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")];
  581. }
  582. break;
  583. case CollectModel_financeCount:
  584. {
  585. self.iconV.image = IMG(@"报表");
  586. }
  587. break;
  588. case CollectModel_affairsCount:
  589. {
  590. self.iconV.image = IMG(@"报表");
  591. }
  592. break;
  593. case CollectModel_publishCount:
  594. {
  595. self.iconV.image = IMG(@"报表");
  596. }
  597. break;
  598. case CollectModel_StoreBook:{
  599. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  600. if (image) {
  601. weakSelf.iconShowL.hidden = NO;
  602. weakSelf.iconShowL.text = @"图 书";
  603. }
  604. }];
  605. self.nameL.text = [NSString stringWithFormat:@"%@ %@",model.Data.Author,ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  606. }break;
  607. case CollectModel_StoreMing:{
  608. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  609. if (image) {
  610. weakSelf.iconShowL.hidden = NO;
  611. weakSelf.iconShowL.text = @"名 栏";
  612. }
  613. }];
  614. self.nameL.text = [NSString stringWithFormat:@"名栏: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  615. }break;
  616. case CollectModel_StoreQiKan:{
  617. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  618. if (image) {
  619. weakSelf.iconShowL.hidden = NO;
  620. weakSelf.iconShowL.text = @"期 刊";
  621. }
  622. }];
  623. self.nameL.text = [NSString stringWithFormat:@"主办单位: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  624. }break;
  625. case CollectModel_StoreGongzh:{
  626. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  627. if (image) {
  628. weakSelf.iconShowL.hidden = NO;
  629. weakSelf.iconShowL.text = @"公众号";
  630. }
  631. }];
  632. self.nameL.text = [NSString stringWithFormat:@"公众号: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  633. }break;
  634. default:{
  635. NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName];
  636. if (imageStr.length == 0) {
  637. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]];
  638. }else{
  639. self.iconV.image = IMG(imageStr);
  640. }
  641. }break;
  642. }
  643. }
  644. - (void)setCellData:(MyFavoriteSubModel *)model withText:(NSString *)text
  645. {
  646. WS(weakSelf);
  647. self.nameL.hidden = NO;
  648. self.iconShowL.hidden = YES;
  649. self.comeBtn.hidden = YES;
  650. self.isTopV.hidden = !model.IsTop;
  651. self.isTopV.hidden = !model.IsTop;
  652. self.titleL.attributedText = [ZYCTool checkOfString:model.Data.Title withSearchText:text withColor:UIColorHex(0xFF5252)];
  653. self.nameL.attributedText = [model.Data.Author length] > 0 ? [ZYCTool checkOfString:model.Data.Author withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "];
  654. [self.desBtn setAttributedTitle:[model.FolderName length] > 0 ? [ZYCTool checkOfString:model.FolderName withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "] forState:UIControlStateNormal];
  655. self.comeBtn.hidden = YES;
  656. switch (model.CollectionType) {
  657. // 文章
  658. case CollectModel_Aritle:{
  659. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"文章")];
  660. }break;
  661. // 话题 || 小组
  662. case CollectModel_Toipc:
  663. {
  664. self.iconV.image = IMG(@"话题");
  665. self.comeBtn.hidden = NO;
  666. [self.comeBtn setAttributedTitle:[self comeGroup:model.GroupName] forState:UIControlStateNormal];
  667. }break;
  668. case CollectModel_NewTopic:
  669. {
  670. self.iconV.image = IMG(@"话题");
  671. }break;
  672. case CollectModel_Group:{
  673. self.iconV.image = IMG(@"笔记小组");
  674. }break;
  675. // 收藏
  676. case CollectModel_Collect:{
  677. self.iconV.image = IMG(@"收藏");
  678. }break;
  679. // 笔记
  680. case CollectModel_NoteBook: {
  681. self.iconV.image = IMG(@"noteBook_icon");
  682. }break;
  683. case CollectModel_CollectFile:{
  684. self.titleL.attributedText = [ZYCTool checkOfString:model.Title withSearchText:text withColor:UIColorHex(0xFF5252)];
  685. self.iconV.image = IMG(@"find_1");
  686. self.comeBtn.hidden = NO;
  687. self.nameL.text = @"";
  688. self.comeLeft.constant = 0.f;
  689. [self.comeBtn setAttributedTitle:[self comeGroup:[NSString stringWithFormat:@"%@的收藏",model.Data.Author]] forState:UIControlStateNormal];
  690. }break;
  691. case CollectModel_NoteFile: {
  692. self.iconV.image = IMG(@"find_1");
  693. }break;
  694. case CollectModel_TopicBooK:{
  695. self.iconV.image = IMG(@"topicBook");
  696. }break;
  697. case CollectModel_TopicSubBooK: {
  698. self.iconV.image = IMG(@"find_1");
  699. }break;
  700. // 通知 || 站内信
  701. case CollectModel_Notice:
  702. {
  703. self.iconV.image = IMG(@"通知图标");
  704. }break;
  705. case CollectModel_InterMail:{
  706. self.iconV.image = IMG(@"站内信");
  707. }break;
  708. // 会议
  709. case CollectModel_meetMian:
  710. {
  711. self.iconV.image = IMG(@"会议纪要");
  712. }
  713. break;
  714. case CollectModel_meetDetail:
  715. {
  716. self.iconV.image = IMG(@"会议");
  717. }
  718. break;
  719. case CollectModel_file:{
  720. NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName];
  721. if (imageStr.length == 0) {
  722. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.File]];
  723. }else{
  724. self.iconV.image = IMG(imageStr);
  725. }
  726. }break;
  727. case CollectModel_work:
  728. {
  729. self.iconV.image = IMG(@"审批");
  730. }
  731. break;
  732. case CollectModel_StoreSound:
  733. {
  734. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_audio") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  735. dispatch_async(dispatch_get_main_queue(), ^{
  736. UIImageView * clearV = [UIImageView new];
  737. [weakSelf.iconV addSubview:clearV];
  738. clearV.image = IMG(@"clear_audio");
  739. [clearV mas_makeConstraints:^(MASConstraintMaker *make) {
  740. make.edges.mas_equalTo(weakSelf.iconV);
  741. }];
  742. });
  743. }];
  744. }
  745. break;
  746. case CollectModel_StoreVideo:
  747. {
  748. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:IMG(@"default_video") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  749. dispatch_async(dispatch_get_main_queue(), ^{
  750. UIImageView * clearV = [UIImageView new];
  751. [weakSelf.iconV addSubview:clearV];
  752. clearV.image = IMG(@"clear_video");
  753. [clearV mas_makeConstraints:^(MASConstraintMaker *make) {
  754. make.edges.mas_equalTo(weakSelf.iconV);
  755. }];
  756. });
  757. }];
  758. }
  759. break;
  760. case CollectModel_Teacher:
  761. {
  762. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")];
  763. self.titleL.attributedText = [model.Data.Author length] > 0 ? [ZYCTool checkOfString:model.Data.Author withSearchText:text withColor:UIColorHex(0xFF5252)] : [[NSAttributedString alloc] initWithString:@" "];
  764. self.nameL.hidden = YES;
  765. }
  766. break;
  767. case CollectModel_Organization:
  768. {
  769. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:IMG(@"icon_weizhiwenjian")];
  770. }
  771. break;
  772. case CollectModel_financeCount:
  773. {
  774. self.iconV.image = IMG(@"报表");
  775. }
  776. break;
  777. case CollectModel_affairsCount:
  778. {
  779. self.iconV.image = IMG(@"报表");
  780. }
  781. break;
  782. case CollectModel_publishCount:
  783. {
  784. self.iconV.image = IMG(@"报表");
  785. }
  786. break;
  787. case CollectModel_StoreBook:{
  788. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.ArticleImgUrl.firstObject] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  789. if (image) {
  790. weakSelf.iconShowL.hidden = NO;
  791. weakSelf.iconShowL.text = @"图 书";
  792. }
  793. }];
  794. self.nameL.text = [NSString stringWithFormat:@"%@ %@",model.Data.Author,ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  795. }break;
  796. case CollectModel_StoreMing:{
  797. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  798. if (image) {
  799. weakSelf.iconShowL.hidden = NO;
  800. weakSelf.iconShowL.text = @"名 栏";
  801. }
  802. }];
  803. self.nameL.text = [NSString stringWithFormat:@"名栏: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  804. }break;
  805. case CollectModel_StoreQiKan:{
  806. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  807. if (image) {
  808. weakSelf.iconShowL.hidden = NO;
  809. weakSelf.iconShowL.text = @"期 刊";
  810. }
  811. }];
  812. self.nameL.text = [NSString stringWithFormat:@"主办单位: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  813. }break;
  814. case CollectModel_StoreGongzh:{
  815. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.AvatarUrl] placeholderImage:kPlaceHolderImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  816. if (image) {
  817. weakSelf.iconShowL.hidden = NO;
  818. weakSelf.iconShowL.text = @"公众号";
  819. }
  820. }];
  821. self.nameL.text = [NSString stringWithFormat:@"公众号: %@",ISEmpty(model.Data.Press) ? @"" :model.Data.Press];
  822. }break;
  823. default:{
  824. NSString * imageStr = [ZYCTool getFileNameImage:model.Data.FileName];
  825. if (imageStr.length == 0) {
  826. [self.iconV sd_setImageWithURL:[NSURL URLWithString:model.Data.MinFile]];
  827. }else{
  828. self.iconV.image = IMG(imageStr);
  829. }
  830. }break;
  831. }
  832. }
  833. - (NSAttributedString *)comeGroup:(NSString *)name
  834. {
  835. NSString * comStr = [NSString stringWithFormat:@"来自-%@",name];
  836. return [self checkOfString:comStr withSearchText:name];
  837. }
  838. - (NSMutableAttributedString *)checkOfString:(NSString *)infoStr withSearchText:(NSString *)text
  839. {
  840. if (infoStr.length == 0 || text.length == 0) {
  841. return nil;
  842. }
  843. NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:infoStr];
  844. [attrString addAttribute:(NSString *)NSForegroundColorAttributeName
  845. value:UIColorHex(0x999999)
  846. range:[infoStr rangeOfString:infoStr]];
  847. [attrString addAttribute:(NSString *)NSForegroundColorAttributeName
  848. value:UIColorHex(0x1F87DB)
  849. range:[infoStr rangeOfString:text]];
  850. return attrString;
  851. }
  852. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  853. [super setSelected:selected animated:animated];
  854. // Configure the view for the selected state
  855. }
  856. @end