JXSiDaiCell.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //
  2. // JXSiDaiCell.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/6/4.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXSiDaiCell.h"
  9. #import "UIButton+WebCache.h"
  10. #import "MJPhotoBrowser.h"
  11. #import "MJPhoto.h"
  12. @interface JXSiDaiCell()
  13. @property (weak, nonatomic) IBOutlet UIImageView *iconIMG;
  14. @property (weak, nonatomic) IBOutlet UILabel *titleName;
  15. @property (weak, nonatomic) IBOutlet UILabel *techerName;
  16. @property (weak, nonatomic) IBOutlet UILabel *techerLevel;
  17. @property (nonatomic,weak) IBOutlet UILabel *titleL;
  18. @property (nonatomic,weak) IBOutlet UILabel *awreResultL;
  19. @property (nonatomic,weak) IBOutlet UIButton *yuyueBtn;
  20. /**战果展示*/
  21. @property (weak, nonatomic) IBOutlet UIView *awarView;
  22. @property (weak, nonatomic) IBOutlet UILabel *kechenPriceL;
  23. /**左边背景*/
  24. @property (weak, nonatomic) IBOutlet UIView *leftView;
  25. //右边背景
  26. @property (weak, nonatomic) IBOutlet UIView *kecView;
  27. @property (weak, nonatomic) IBOutlet UIView *zhanguoView;
  28. @end
  29. @implementation JXSiDaiCell
  30. - (void)awakeFromNib {
  31. [super awakeFromNib];
  32. // Initialization code\
  33. _leftView.layer.cornerRadius=5;
  34. _leftView.layer.masksToBounds=YES;
  35. _kecView.layer.cornerRadius=5;
  36. _kecView.layer.masksToBounds=YES;
  37. _yuyueBtn.layer.cornerRadius=3;
  38. _yuyueBtn.layer.masksToBounds=YES;
  39. [_yuyueBtn addTarget:self action:@selector(yuyueBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  40. }
  41. - (void)yuyueBtnClick:(UIButton *)sender{
  42. if (_yuyueblock) {
  43. _yuyueblock(sender);
  44. }
  45. }
  46. + (instancetype)cellWithTableView:(UITableView *)tableView
  47. {
  48. static NSString *ID = @"JXSiDaiCell";
  49. JXSiDaiCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  50. if (!cell) {
  51. cell = [[NSBundle mainBundle] loadNibNamed:@"JXSiDaiCell" owner:nil options:nil].firstObject;
  52. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  53. }
  54. cell.backgroundColor=[UIColor clearColor];
  55. return cell;
  56. }
  57. - (NSAttributedString *)stringHtml:(NSString *)htmlStr{
  58. NSDictionary *optoins=@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType,
  59. NSFontAttributeName:[UIFont systemFontOfSize:14]};
  60. NSData *data=[htmlStr dataUsingEncoding:NSUnicodeStringEncoding];
  61. NSAttributedString *attributeString=[[NSAttributedString alloc] initWithData:data
  62. options:optoins documentAttributes:nil error:nil];
  63. return attributeString;
  64. }
  65. -(void)setDictData:(NSDictionary *)dictData{
  66. _dictData=dictData;
  67. self.titleName.text=[NSString stringWithFormat:@"%@",dictData[@"name"]];
  68. [self.iconIMG sd_setImageWithURL:[NSURL URLWithString:dictData[@"photoUrl"]] placeholderImage:[UIImage imageNamed:@""]];
  69. self.techerName.attributedText=[self stringHtml:[NSString stringWithFormat:@"%@",dictData[@"intro"]]];
  70. self.techerLevel.attributedText=[self stringHtml:[NSString stringWithFormat:@"%@",dictData[@"message"]]];
  71. self.titleL.attributedText=[self stringHtml:[NSString stringWithFormat:@"%@",dictData[@"income"]]];
  72. CGFloat marginW=15;
  73. if (JX_SCREEN_WIDTH<414) {
  74. marginW=5;
  75. }
  76. CGFloat imageW=60;
  77. NSArray *imageS=dictData[@"achievement"];
  78. for (int i=0; i<imageS.count;i++) {
  79. UIButton *imageV=[[UIButton alloc]init];
  80. [imageV sd_setImageWithURL:[NSURL URLWithString:imageS[i]] forState:UIControlStateNormal];
  81. imageV.tag=i;
  82. [_zhanguoView addSubview:imageV];
  83. imageV.frame=CGRectMake(1+i%3*(imageW +marginW), 0+i/3*(imageW +12), imageW, imageW);
  84. [imageV addTarget:self action:@selector(imageBtClick:) forControlEvents:UIControlEventTouchUpInside];
  85. }
  86. self.kechenPriceL.attributedText=[self stringHtml:[NSString stringWithFormat:@"%@",dictData[@"price"]]];
  87. }
  88. - (void)imageBtClick:(UIButton *)sender{
  89. NSArray *imageS=_dictData[@"achievement"];
  90. MJPhotoBrowser *browser = [[MJPhotoBrowser alloc] init];
  91. // 2.设置图片浏览器显示的所有图片
  92. NSMutableArray *photos = [NSMutableArray array];
  93. NSInteger count = imageS.count;
  94. for (NSInteger i = 0; i<count; i++) {
  95. MJPhoto *photo = [[MJPhoto alloc] init];
  96. photo.url = [NSURL URLWithString:imageS[i]];
  97. UIButton *btnImag=_zhanguoView.subviews[i];
  98. photo.srcImageView =btnImag.imageView;
  99. [photos addObject:photo];
  100. }
  101. browser.photos = photos;
  102. // 3.设置默认显示的图片索引
  103. browser.currentPhotoIndex = sender.tag;
  104. // 3.显示浏览器
  105. [browser show];
  106. }
  107. -(void)setFrame:(CGRect)frame{
  108. frame.origin.y+=20;
  109. frame.size.height-=20;
  110. [super setFrame:frame];
  111. }
  112. @end