FollowerTableViewCell.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //
  2. // FollowerTableViewCell.m
  3. // BuguLive
  4. //
  5. // Created by fanwe2014 on 16/6/18.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "FollowerTableViewCell.h"
  9. #import "SenderModel.h"
  10. @implementation FollowerTableViewCell
  11. - (void)awakeFromNib
  12. {
  13. [super awakeFromNib];
  14. self.backgroundColor = UIColor.clearColor;
  15. self.headImgView.layer.cornerRadius = 25;
  16. self.headImgView.layer.masksToBounds = YES;
  17. self.commentLabel.textColor = kAppGrayColor3;
  18. self.nameLabel.textColor = kAppGrayColor1;
  19. self.lineView.backgroundColor = kAppSpaceColor4;
  20. }
  21. - (void)creatCellWithModel:(SenderModel *)model WithRow:(int)row
  22. {
  23. self.joinBtn.tag = row;
  24. self.user_id = model.user_id;
  25. [self.headImgView sd_setImageWithURL:[NSURL URLWithString:model.head_image] placeholderImage:kDefaultPreloadHeadImg];
  26. if (model.nick_name.length < 1)
  27. {
  28. model.nick_name = ASLocalizedString(@"暂时还未命名");
  29. }
  30. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:model.nick_name];
  31. [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15.0]} range:NSMakeRange(0, model.nick_name.length)];
  32. self.nameLabel.attributedText = attr;
  33. if ([model.sex isEqualToString:@"1"])
  34. {
  35. self.sexImgView.image = [UIImage imageNamed:@"com_male_selected"];
  36. }else
  37. {
  38. self.sexImgView.image = [UIImage imageNamed:@"com_female_selected"];
  39. }
  40. if (model.user_level > 0)
  41. {
  42. self.rankImgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"level%d",model.user_level]];
  43. }else
  44. {
  45. self.rankImgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"rank_1"]];
  46. }
  47. if (model.signature.length < 1)
  48. {
  49. self.commentLabel.text = ASLocalizedString(@"TA好像忘记签名了");
  50. }else
  51. {
  52. self.commentLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  53. NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:model.signature];
  54. self.commentLabel.attributedText = attr1;
  55. }
  56. if ([model.follow_id integerValue] > 0)
  57. {
  58. [self.joinBtn setTitle:ASLocalizedString(@"已关注") forState:UIControlStateNormal];
  59. }else
  60. {
  61. [self.joinBtn setTitle:ASLocalizedString(@"关注") forState:UIControlStateNormal];
  62. // self.rightImgView.image = [UIImage imageNamed:@"关注"];
  63. }
  64. if ([model.user_id isEqualToString:[IMAPlatform sharedInstance].host.imUserId])
  65. {
  66. // self.rightImgView.hidden = YES;
  67. self.joinBtn.hidden = YES;
  68. }else
  69. {
  70. // self.rightImgView.hidden = NO;
  71. self.joinBtn.hidden = NO;
  72. }
  73. // self.rightImgView.tag = 100+row;
  74. }
  75. - (IBAction)photoClick:(UIButton *)sender
  76. {
  77. int section =(int) sender.tag;
  78. if (self.cellType == 3) {
  79. NSMutableDictionary *dictM = [[NSMutableDictionary alloc]init];
  80. [dictM setObject:@"user" forKey:@"ctl"];
  81. [dictM setObject:@"set_black" forKey:@"act"];
  82. if (self.user_id)
  83. {
  84. [dictM setObject:self.user_id forKey:@"to_user_id"];
  85. }
  86. WeakSelf
  87. [[NetHttpsManager manager] POSTWithParameters:dictM SuccessBlock:^(NSDictionary *responseJson)
  88. {
  89. NSMutableDictionary *mDict = [[NSMutableDictionary alloc]init];
  90. if ([responseJson toInt:@"status"] == 1)
  91. {
  92. if (weakSelf.reloadCellData) {
  93. weakSelf.reloadCellData(section);
  94. }
  95. }
  96. } FailureBlock:^(NSError *error)
  97. {
  98. }];
  99. return;
  100. }
  101. self.httpManager = [NetHttpsManager manager];
  102. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  103. [parmDict setObject:@"user" forKey:@"ctl"];
  104. [parmDict setObject:@"follow" forKey:@"act"];
  105. if (self.user_id)
  106. {
  107. [parmDict setObject:self.user_id forKey:@"to_user_id"];
  108. }
  109. [self.httpManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  110. {
  111. if ([responseJson toInt:@"status"] == 1)
  112. {
  113. if ([responseJson toInt:@"has_focus"] == 1)
  114. {
  115. [self.joinBtn setTitle:ASLocalizedString(@"已关注") forState:UIControlStateNormal];
  116. // self.rightImgView.image = [UIImage imageNamed:@"search_had_follow"];
  117. }else
  118. {
  119. [self.joinBtn setTitle:ASLocalizedString(@"关注") forState:UIControlStateNormal];
  120. // self.rightImgView.image = [UIImage imageNamed:@"search_not_follow"];
  121. }
  122. self.hasFonce = [responseJson toInt:@"has_focus"];
  123. if (self.delegate)
  124. {
  125. if ([self.delegate respondsToSelector:@selector(loadAgainSection: withHasFonce:)])
  126. {
  127. [self.delegate loadAgainSection:section withHasFonce:self.hasFonce];
  128. }
  129. }
  130. }
  131. } FailureBlock:^(NSError *error)
  132. {
  133. }];
  134. }
  135. @end