fans.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // fans.m
  3. // YBVideo
  4. //
  5. // Created by cat on 16/4/1.
  6. // Copyright © 2016年 cat. All rights reserved.
  7. //
  8. #import "fans.h"
  9. #import "fansModel.h"
  10. #import "fansViewController.h"
  11. #import "SDWebImage/UIButton+WebCache.h"
  12. #import "Config.h"
  13. @implementation fans
  14. -(void)drawRect:(CGRect)rect{
  15. // CGContextRef ctx = UIGraphicsGetCurrentContext();
  16. // CGContextSetLineWidth(ctx,1);
  17. // CGContextSetStrokeColorWithColor(ctx,[UIColor groupTableViewBackgroundColor].CGColor);
  18. // CGContextMoveToPoint(ctx,0,self.frame.size.height);
  19. // CGContextAddLineToPoint(ctx,(self.frame.size.width),self.frame.size.height);
  20. // CGContextStrokePath(ctx);
  21. }
  22. -(void)setModel:(fansModel *)model{
  23. _model = model;
  24. _nameL.text = _model.name;
  25. _signatureL.text = _model.signature;
  26. //性别 1男
  27. if ([[_model valueForKey:@"sex"] isEqual:@"1"])
  28. {
  29. self.sexL.image = [UIImage imageNamed:@"choice_sex_nanren"];
  30. }
  31. else
  32. {
  33. self.sexL.image = [UIImage imageNamed:@"choice_sex_nvren"];
  34. }
  35. //级别
  36. self.levelL.image = [UIImage imageNamed:[NSString stringWithFormat:@"host_%@",_model.level_anchor]];
  37. self.hostlevel.image = [UIImage imageNamed:[NSString stringWithFormat:@"leve%@",_model.level]];
  38. // [self.levelL sd_setImageWithURL:[NSURL URLWithString:_model.level_icon] placeholderImage:[UIImage imageNamed:@"leve1"]];
  39. // [self.hostlevel sd_setImageWithURL:[NSURL URLWithString:_model.level_anchor_icon] placeholderImage:[UIImage imageNamed:@"host_1"]];
  40. //头像
  41. [self.iconV sd_setBackgroundImageWithURL:[NSURL URLWithString:_model.icon] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"bg1"]];
  42. self.iconV.layer.cornerRadius = 30;
  43. self.iconV.layer.masksToBounds = YES;
  44. self.IDL.text = [NSString stringWithFormat:@"ID:%@",_model.uid];
  45. self.fansNumL.text = [NSString stringWithFormat:@"%@:%@",YZMsg(@"粉丝"),_model.fansNum];
  46. //关注
  47. // [self.guanzhubtn setImage:[UIImage imageNamed:@"me_following(1)"] forState:UIControlStateSelected];
  48. // [self.guanzhubtn setImage:[UIImage imageNamed:@"me_follow(1)"] forState:UIControlStateNormal];
  49. self.guanzhubtn.layer.masksToBounds = YES;
  50. self.guanzhubtn.layer.cornerRadius = 13;
  51. self.guanzhubtn.layer.borderWidth = 1;
  52. if ([_model.isattention isEqual:@"0"]) {
  53. //self.guanzhubtn.selected = NO;
  54. self.guanzhubtn.layer.borderColor = Pink_Cor.CGColor;
  55. [self.guanzhubtn setTitle:YZMsg(@"关注") forState:0];
  56. [self.guanzhubtn setTitleColor:Pink_Cor forState:0];
  57. }else{
  58. self.guanzhubtn.layer.borderColor = RGB_COLOR(@"#4A4A52", 1).CGColor;
  59. [self.guanzhubtn setTitleColor:RGB_COLOR(@"#4A4A52", 1) forState:0];
  60. [self.guanzhubtn setTitle:YZMsg(@"已关注") forState:0];
  61. //self.guanzhubtn.selected = YES;
  62. }
  63. }
  64. +(fans *)cellWithTableView:(UITableView *)tv{
  65. fans *cell = [tv dequeueReusableCellWithIdentifier:@"a"];
  66. if (!cell) {
  67. cell = [[NSBundle mainBundle]loadNibNamed:@"fans" owner:self options:nil].lastObject;
  68. }
  69. return cell;
  70. }
  71. - (IBAction)gaunzhuBTN:(UIButton *)btn{
  72. if ([[Config getOwnID] intValue]<=0) {
  73. [PublicObj warnLogin];
  74. return;
  75. }
  76. if ([[Config getOwnID] isEqual:_model.uid]) {
  77. [MBProgressHUD showError:YZMsg(@"不能关注自己")];
  78. return;
  79. }
  80. NSString *url = [NSString stringWithFormat:@"User.setAttent&uid=%@&touid=%@&token=%@",[Config getOwnID],_model.uid,[Config getOwnToken]];
  81. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  82. if (code == 0) {
  83. NSString *infoDic = [info firstObject];
  84. NSString *isattent = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"isattent"]];
  85. if ([isattent isEqual:@"0"]) {
  86. self.guanzhubtn.layer.borderColor = Pink_Cor.CGColor;
  87. [self.guanzhubtn setTitle:YZMsg(@"关注") forState:0];
  88. [self.guanzhubtn setTitleColor:Pink_Cor forState:0];
  89. }else{
  90. self.guanzhubtn.layer.borderColor = RGB_COLOR(@"#4A4A52", 1).CGColor;
  91. [self.guanzhubtn setTitleColor:RGB_COLOR(@"#4A4A52", 1) forState:0];
  92. [self.guanzhubtn setTitle:YZMsg(@"已关注") forState:0];
  93. }
  94. [self.guanzhuDelegate doGuanzhu:nil];
  95. }else{
  96. [MBProgressHUD showPop:msg];
  97. }
  98. } Fail:^(id fail) {
  99. }];
  100. }
  101. @end