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