MainPageView.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. //
  2. // MainPageView.m
  3. // BuguLive
  4. //
  5. // Created by fanwe2014 on 16/6/13.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "MainPageView.h"
  9. @interface MainPageView()
  10. @end
  11. @implementation MainPageView
  12. - (void)awakeFromNib
  13. {
  14. [super awakeFromNib];
  15. // [self.followButton setTitleColor:kAppGrayColor1 forState:UIControlStateNormal];
  16. // [self.defriendButton setTitleColor:kAppGrayColor1 forState:UIControlStateNormal];
  17. // [self.personLetterButton setTitleColor:kAppGrayColor1 forState:UIControlStateNormal];
  18. self.HLineView.backgroundColor = self.VLineView1.backgroundColor = self.VLineView2.backgroundColor = kAppSpaceColor4;
  19. self.backGroundView.backgroundColor = kWhiteColor;
  20. for (UIView *subView in self.subviews) {
  21. [subView setLocalizedString];
  22. }
  23. [_followButton setTitle:ASLocalizedString(@"已关注") forState:UIControlStateSelected];
  24. }
  25. - (void)changeState
  26. {
  27. //关注
  28. if (self.has_focus == 1)
  29. {
  30. // [self.followButton setTitle:ASLocalizedString(@"已关注")forState:0];
  31. // [_followButton setImage:nil forState:UIControlStateNormal];
  32. _followButton.selected = YES;
  33. }else
  34. {
  35. // [self.followButton setTitle:ASLocalizedString(@"关注")forState:0];
  36. _followButton.selected = NO;
  37. // [_followButton setImage:[UIImage imageNamed:@"fw_me_noFollow"] forState:UIControlStateNormal];
  38. }
  39. //拉黑
  40. // if (self.has_black == 1)
  41. // {
  42. // [self.defriendButton setTitle:ASLocalizedString(@"解除拉黑")forState:0];
  43. //
  44. // }else
  45. // {
  46. // [self.defriendButton setTitle:ASLocalizedString(@"拉黑")forState:0];
  47. // }
  48. }
  49. //关注
  50. - (IBAction)followButton:(UIButton *)sender
  51. {
  52. NSMutableDictionary *dictM = [[NSMutableDictionary alloc]init];
  53. [dictM setObject:@"user" forKey:@"ctl"];
  54. [dictM setObject:@"follow" forKey:@"act"];
  55. [dictM setObject:[NSString stringWithFormat:@"%@",self.user_id] forKey:@"to_user_id"];
  56. [self.httpsManager POSTWithParameters:dictM SuccessBlock:^(NSDictionary *responseJson)
  57. {
  58. if ([responseJson toInt:@"status"] == 1)
  59. {
  60. NSMutableDictionary *mDict = [[NSMutableDictionary alloc]init];
  61. _has_focus = [responseJson toInt:@"has_focus"];
  62. if ([responseJson toInt:@"status"] == 1)
  63. {
  64. if (_has_focus == 1)//已关注
  65. {
  66. [mDict setObject:@"0" forKey:@"isShowFollow"];
  67. // [_followButton setTitle:ASLocalizedString(@"已关注")forState:0];
  68. // [_followButton setImage:nil forState:UIControlStateNormal];
  69. _followButton.selected = YES;
  70. // if (self.has_black == 1)//解除拉黑
  71. // {
  72. // [self.defriendButton setTitle:ASLocalizedString(@"拉黑")forState:0];
  73. // }
  74. }else if (_has_focus == 0)//关注
  75. {
  76. // [_followButton setTitle:ASLocalizedString(@"关注")forState:0];
  77. _followButton.selected = NO;
  78. // [_followButton setImage:[UIImage imageNamed:@"fw_me_noFollow"] forState:UIControlStateNormal];
  79. [mDict setObject:@"1" forKey:@"isShowFollow"];
  80. }
  81. [mDict setObject:[responseJson toString:@"follow_msg"] forKey:@"follow_msg"];
  82. if (self.user_id.length)
  83. {
  84. [mDict setObject:self.user_id forKey:@"userId"];
  85. }
  86. [[NSNotificationCenter defaultCenter]postNotificationName:@"liveIsShowFollow" object:mDict];
  87. }
  88. }
  89. } FailureBlock:^(NSError *error)
  90. {
  91. }];
  92. }
  93. //私信
  94. - (IBAction)privateLetter:(UIButton *)sender
  95. {
  96. if (self.delegate)
  97. {
  98. if ([self.delegate respondsToSelector:@selector(sentPersonLetter:)])
  99. {
  100. [self.delegate sentPersonLetter:self.user_id];
  101. }
  102. }
  103. }
  104. //拉黑
  105. - (IBAction)defriend:(UIButton *)sender
  106. {
  107. self.defriendButton.userInteractionEnabled = NO;
  108. NSMutableDictionary *dictM = [[NSMutableDictionary alloc]init];
  109. [dictM setObject:@"user" forKey:@"ctl"];
  110. [dictM setObject:@"set_black" forKey:@"act"];
  111. [dictM setObject:[NSString stringWithFormat:@"%@",self.user_id] forKey:@"to_user_id"];
  112. [self.httpsManager POSTWithParameters:dictM SuccessBlock:^(NSDictionary *responseJson)
  113. {
  114. NSMutableDictionary *mDict = [[NSMutableDictionary alloc]init];
  115. if ([responseJson toInt:@"status"] == 1)
  116. {
  117. _has_black = [responseJson toInt:@"has_black"];
  118. if (self.has_black == 1)//未拉黑
  119. {
  120. [_defriendButton setTitle:ASLocalizedString(@"解除拉黑")forState:0];
  121. [mDict setObject:@"0" forKey:@"isShowFollow"];
  122. }else if (self.has_black == 0)//已拉黑
  123. {
  124. [_defriendButton setTitle:ASLocalizedString(@"拉黑")forState:0];
  125. [mDict setObject:@"1" forKey:@"isShowFollow"];
  126. }
  127. self.defriendButton.userInteractionEnabled = YES;
  128. if (self.user_id.length)
  129. {
  130. [mDict setObject:self.user_id forKey:@"userId"];
  131. }
  132. [[NSNotificationCenter defaultCenter]postNotificationName:@"liveIsShowFollow" object:mDict];
  133. }
  134. } FailureBlock:^(NSError *error)
  135. {
  136. }];
  137. }
  138. @end