// // 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