| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- //
- // FollowerTableViewCell.m
- // BuguLive
- //
- // Created by fanwe2014 on 16/6/18.
- // Copyright © 2016年 xfg. All rights reserved.
- //
- #import "FollowerTableViewCell.h"
- #import "SenderModel.h"
- @implementation FollowerTableViewCell
- - (void)awakeFromNib
- {
- [super awakeFromNib];
-
- self.backgroundColor = UIColor.clearColor;
-
- self.headImgView.layer.cornerRadius = 25;
- self.headImgView.layer.masksToBounds = YES;
-
- self.commentLabel.textColor = kAppGrayColor3;
- self.nameLabel.textColor = kAppGrayColor1;
- self.lineView.backgroundColor = kAppSpaceColor4;
- }
- - (void)creatCellWithModel:(SenderModel *)model WithRow:(int)row
- {
- self.joinBtn.tag = row;
- self.user_id = model.user_id;
- [self.headImgView sd_setImageWithURL:[NSURL URLWithString:model.head_image] placeholderImage:kDefaultPreloadHeadImg];
- if (model.nick_name.length < 1)
- {
- model.nick_name = ASLocalizedString(@"暂时还未命名");
- }
- NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:model.nick_name];
- [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15.0]} range:NSMakeRange(0, model.nick_name.length)];
- self.nameLabel.attributedText = attr;
-
- if ([model.sex isEqualToString:@"1"])
- {
- self.sexImgView.image = [UIImage imageNamed:@"com_male_selected"];
- }else
- {
- self.sexImgView.image = [UIImage imageNamed:@"com_female_selected"];
- }
- if (model.user_level > 0)
- {
- self.rankImgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"level%d",model.user_level]];
- }else
- {
- self.rankImgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"rank_1"]];
- }
-
- if (model.signature.length < 1)
- {
- self.commentLabel.text = ASLocalizedString(@"TA好像忘记签名了");
- }else
- {
- self.commentLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:model.signature];
- self.commentLabel.attributedText = attr1;
- }
-
- if ([model.follow_id integerValue] > 0)
- {
- [self.joinBtn setTitle:ASLocalizedString(@"已关注") forState:UIControlStateNormal];
- }else
- {
- [self.joinBtn setTitle:ASLocalizedString(@"关注") forState:UIControlStateNormal];
- // self.rightImgView.image = [UIImage imageNamed:@"关注"];
- }
-
- if ([model.user_id isEqualToString:[IMAPlatform sharedInstance].host.imUserId])
- {
- // self.rightImgView.hidden = YES;
- self.joinBtn.hidden = YES;
- }else
- {
- // self.rightImgView.hidden = NO;
- self.joinBtn.hidden = NO;
- }
-
- // self.rightImgView.tag = 100+row;
- }
- - (IBAction)photoClick:(UIButton *)sender
- {
- int section =(int) sender.tag;
-
- if (self.cellType == 3) {
- NSMutableDictionary *dictM = [[NSMutableDictionary alloc]init];
- [dictM setObject:@"user" forKey:@"ctl"];
- [dictM setObject:@"set_black" forKey:@"act"];
- if (self.user_id)
- {
- [dictM setObject:self.user_id forKey:@"to_user_id"];
- }
- WeakSelf
- [[NetHttpsManager manager] POSTWithParameters:dictM SuccessBlock:^(NSDictionary *responseJson)
- {
- NSMutableDictionary *mDict = [[NSMutableDictionary alloc]init];
- if ([responseJson toInt:@"status"] == 1)
- {
- if (weakSelf.reloadCellData) {
- weakSelf.reloadCellData(section);
- }
- }
-
- } FailureBlock:^(NSError *error)
- {
-
- }];
- return;
- }
-
-
-
- self.httpManager = [NetHttpsManager manager];
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"user" forKey:@"ctl"];
- [parmDict setObject:@"follow" forKey:@"act"];
- if (self.user_id)
- {
- [parmDict setObject:self.user_id forKey:@"to_user_id"];
- }
- [self.httpManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
- {
- if ([responseJson toInt:@"status"] == 1)
- {
- if ([responseJson toInt:@"has_focus"] == 1)
- {
- [self.joinBtn setTitle:ASLocalizedString(@"已关注") forState:UIControlStateNormal];
- // self.rightImgView.image = [UIImage imageNamed:@"search_had_follow"];
-
- }else
- {
- [self.joinBtn setTitle:ASLocalizedString(@"关注") forState:UIControlStateNormal];
- // self.rightImgView.image = [UIImage imageNamed:@"search_not_follow"];
-
- }
- self.hasFonce = [responseJson toInt:@"has_focus"];
- if (self.delegate)
- {
- if ([self.delegate respondsToSelector:@selector(loadAgainSection: withHasFonce:)])
- {
- [self.delegate loadAgainSection:section withHasFonce:self.hasFonce];
- }
- }
- }
-
- } FailureBlock:^(NSError *error)
- {
-
- }];
- }
- @end
|