YOUPAIZYIMSessionDetailWindow.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. //
  2. // YOUPAIZYIMSessionDetailWindow.m
  3. // VQU
  4. //
  5. // Created by Elaine on 2020/12/11.
  6. // Copyright © 2020 leo. All rights reserved.
  7. //
  8. #import "YOUPAIZYIMSessionDetailWindow.h"
  9. #import "UIViewController+TFPresent.h"
  10. #import "NTESSessionUtil.h"
  11. #import "LCCommonHttp.h"
  12. #import "CWStarRateView.h"
  13. @interface YOUPAIZYIMSessionDetailWindow ()
  14. @property(nonatomic,strong)UIImageView *youpaipavatarImgV;
  15. @property(nonatomic,strong)UILabel *youpaipnameLabel;
  16. @property (strong, nonatomic) CWStarRateView *youpaipstarRateView;
  17. @property(nonatomic,strong)UILabel *youpaipscoreLabel;
  18. @property(nonatomic,strong)UILabel *youpaipremarkNameLabel;
  19. @property(nonatomic,strong)UILabel *youpaipIDLabel;
  20. @property(nonatomic,strong)UIButton *youpaipblacklistBtn;
  21. @property(nonatomic,strong)YOUPAILCBaseInfo* youpaipbaseInfo;
  22. @property(nonatomic,assign)NSInteger youpaipis_black; //是否拉黑
  23. @property(nonatomic,assign)NSInteger youpaipis_follow; //是否关注
  24. @property(nonatomic,assign)NSInteger youpaipis_set; //是否设置了备注
  25. @end
  26. @implementation YOUPAIZYIMSessionDetailWindow
  27. - (void)youpaifgetData{
  28. [LCHttpHelper requestWithURLString:ChatSetting parameters:@{@"user_id":self.youpaipsession.sessionId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  29. NSDictionary* dict = (NSDictionary*)responseObject;
  30. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  31. if (code==0) {//成功
  32. self.youpaipbaseInfo = [YOUPAILCBaseInfo mj_objectWithKeyValues:[[dict objectForKey:@"data"]objectForKey:@"info"]];
  33. self.youpaipis_black = [[[dict objectForKey:@"data"]objectForKey:@"is_black"]integerValue];
  34. self.youpaipis_follow = [[[dict objectForKey:@"data"]objectForKey:@"is_follow"]integerValue];
  35. self.youpaipis_set = [[[dict objectForKey:@"data"]objectForKey:@"is_set"]integerValue];
  36. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipbaseInfo.youpaipavatar] placeholderImage:nil];
  37. self.youpaipnameLabel.text = self.youpaipbaseInfo.youpaipnickname;//原昵称
  38. self.youpaipstarRateView.scorePercent = 0.9;
  39. self.youpaipscoreLabel.text = @"缺字段";
  40. self.youpaipstarRateView.scorePercent = [self.youpaipbaseInfo.youpaipscore floatValue]/5.0;
  41. self.youpaipscoreLabel.text = [NSString stringWithFormat:@"%.2f分",[self.youpaipbaseInfo.youpaipscore floatValue]];
  42. self.youpaipremarkNameLabel.text = [NSString stringWithFormat:@"备注名:%@",self.youpaipbaseInfo.youpaipremark_name];//昵称 或者备注的名字
  43. self.youpaipIDLabel.text = [NSString stringWithFormat:@"ID:%@",self.youpaipbaseInfo.youpaipusercode];
  44. self.youpaipblacklistBtn.selected = self.youpaipis_black;
  45. }
  46. } failure:^(NSError *error) {
  47. }];
  48. }
  49. - (void)viewDidLoad {
  50. [super viewDidLoad];
  51. // [self.view setFrame:CGRectMake(0, 0, _vWith, _vHeight)];
  52. // CAShapeLayer *maskLayer = [CAShapeLayer layer];
  53. // UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.view.bounds cornerRadius:16];
  54. // maskLayer.path = path.CGPath;
  55. // self.baseView.layer.mask = maskLayer;
  56. // [self.view setBackgroundColor:[UIColor whiteColor]];
  57. UIView *infoView = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.vWidth,90)];
  58. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifinfoViewTapAction)];
  59. [infoView addGestureRecognizer:tap];
  60. [self.baseView addSubview:infoView];
  61. _youpaipavatarImgV = [[UIImageView alloc] init];
  62. _youpaipavatarImgV.layer.cornerRadius = 25;
  63. _youpaipavatarImgV.layer.masksToBounds = YES;
  64. _youpaipavatarImgV.backgroundColor = HexColorFromRGB(0xeeeeee);
  65. _youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  66. [infoView addSubview:_youpaipavatarImgV];
  67. [self.youpaipavatarImgV makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.equalTo(@19);
  69. make.top.equalTo(@20);
  70. make.size.mas_equalTo(CGSizeMake(50, 50));
  71. }];
  72. _youpaipnameLabel = [[UILabel alloc] init];
  73. _youpaipnameLabel.textColor = [UIColor whiteColor];
  74. _youpaipnameLabel.font = LCFont(15);
  75. [infoView addSubview:_youpaipnameLabel];
  76. [_youpaipnameLabel makeConstraints:^(MASConstraintMaker *make) {
  77. make.left.equalTo(self.youpaipavatarImgV.right).offset(@9);
  78. make.top.equalTo(infoView.top).offset(@20);
  79. make.height.equalTo(@18);
  80. }];
  81. self.youpaipstarRateView = [[CWStarRateView alloc] initWithFrame:CGRectMake(0,0,60,15) numberOfStars:5];
  82. self.youpaipstarRateView.allowIncompleteStar = YES;
  83. self.youpaipstarRateView.hasAnimation = YES;
  84. self.youpaipstarRateView.userInteractionEnabled = NO;
  85. [infoView addSubview:self.youpaipstarRateView];
  86. [self.youpaipstarRateView makeConstraints:^(MASConstraintMaker *make) {
  87. make.left.equalTo(self.youpaipnameLabel.right).offset(@(6));
  88. make.top.equalTo(@21);
  89. make.size.mas_equalTo(CGSizeMake(60,15));
  90. }];
  91. self.youpaipstarRateView.hidden = YES;
  92. _youpaipscoreLabel = [[UILabel alloc] init];
  93. _youpaipscoreLabel.textColor = HexColorFromRGB(0x999999);
  94. _youpaipscoreLabel.font = LCFont(10);
  95. [infoView addSubview:_youpaipscoreLabel];
  96. [_youpaipscoreLabel makeConstraints:^(MASConstraintMaker *make) {
  97. make.left.equalTo(self.youpaipstarRateView.right).offset(@3);
  98. make.top.equalTo(infoView.top).offset(@21.5);
  99. make.height.equalTo(@14);
  100. }];
  101. _youpaipscoreLabel.hidden = YES;
  102. _youpaipremarkNameLabel = [[UILabel alloc] init];
  103. _youpaipremarkNameLabel.textColor = HexColorFromRGB(0x999999);
  104. _youpaipremarkNameLabel.font = LCFont(12);
  105. [infoView addSubview:_youpaipremarkNameLabel];
  106. [_youpaipremarkNameLabel makeConstraints:^(MASConstraintMaker *make) {
  107. make.left.equalTo(self.youpaipavatarImgV.right).offset(@9);
  108. make.top.equalTo(self.youpaipnameLabel.bottom).offset(@1);
  109. make.height.equalTo(@15);
  110. }];
  111. _youpaipIDLabel = [[UILabel alloc] init];
  112. _youpaipIDLabel.textColor = HexColorFromRGB(0x999999);
  113. _youpaipIDLabel.font = LCFont(12);
  114. [infoView addSubview:_youpaipIDLabel];
  115. [_youpaipIDLabel makeConstraints:^(MASConstraintMaker *make) {
  116. make.left.equalTo(self.youpaipavatarImgV.right).offset(@9);
  117. make.top.equalTo(self.youpaipremarkNameLabel.bottom).offset(@1);
  118. make.height.equalTo(@15);
  119. }];
  120. UIImageView *arrowImgView = [[UIImageView alloc] initWithFrame:CGRectMake(self.vWidth - 14 - 19 - 14,38, 14, 14)];
  121. arrowImgView.image = [UIImage imageNamed:@"vqu_images_H_cell_arrow_gray"];
  122. [infoView addSubview:arrowImgView];
  123. // UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0,89.5,self.vWidth,0.5)];
  124. // line.backgroundColor = HexColorFromRGB(0xffffff);
  125. // [infoView addSubview:line];
  126. self.youpaipsession = [NIMSession session:self.youpaipsession.sessionId type:NIMSessionTypeP2P];
  127. NIMRecentSession *recent = [[NIMSDK sharedSDK].conversationManager recentSessionBySession:self.youpaipsession];
  128. BOOL isTop = [NTESSessionUtil recentSessionIsMark:recent type:NTESRecentSessionMarkTypeTop];
  129. self.baseView.backgroundColor = HexColorFromRGB(0x2A2935);
  130. NSArray *array = @[@"设置备注名",@"清空该聊天记录",@"置顶该聊天",@"加入黑名单",@"举报"];
  131. NSArray *typearray = @[@"arrow",@"arrow",@"swich",@"swich",@"arrow"];
  132. for (int i = 0; i< array.count; i++){
  133. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(14,90+45*i+(i*5), self.vWidth-28,45)];
  134. [self.baseView addSubview:view];
  135. // if (i != 0) {
  136. // UIView *line = [[UIView alloc] initWithFrame:CGRectMake(18,44.5,self.vWidth-36,0.5)];
  137. // line.backgroundColor = HexColorFromRGB(0xEEEEEE);
  138. // [view addSubview:line];
  139. // }
  140. view.tag = i;
  141. view.backgroundColor = HexColorFromRGB(0x4F4B5B);
  142. view.layer.cornerRadius = 5;
  143. view.layer.masksToBounds = YES;
  144. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(19,14,150,17)];
  145. label.text = array[i];
  146. label.textColor = HexColorFromRGB(0xffffff);
  147. label.font = LCFont(14);
  148. [view addSubview:label];
  149. NSString *typeStr = typearray[i];
  150. if ([typeStr isEqualToString:@"arrow"]) {
  151. UIImageView *arrowImgView = [[UIImageView alloc] initWithFrame:CGRectMake(self.vWidth - 14 - 19 - 28,15.5, 14, 14)];
  152. arrowImgView.image = [UIImage imageNamed:@"vqu_images_H_cell_arrow_gray"];
  153. [view addSubview:arrowImgView];
  154. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifarrowAction:)];
  155. [view addGestureRecognizer:tap];
  156. }else{
  157. UIButton *swichBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  158. swichBtn.frame = CGRectMake(self.vWidth - 47-9-28, 11, 47, 22);
  159. [swichBtn setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_on"] forState:UIControlStateSelected];
  160. [swichBtn setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_off"] forState:UIControlStateNormal];
  161. [swichBtn addTarget:self action:@selector(youpaifswichBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  162. swichBtn.tag = i;
  163. [view addSubview:swichBtn];
  164. if (i == 2) {//置顶聊天
  165. swichBtn.selected = isTop;
  166. }
  167. if (i == 3) {//加入黑名单
  168. self.youpaipblacklistBtn = swichBtn;
  169. }
  170. }
  171. }
  172. [self youpaifgetData];
  173. }
  174. -(void)youpaifarrowAction:(UITapGestureRecognizer *)tap
  175. {
  176. NSArray *typeArr = @[@"updateRemark",@"clearChat",@"top",@"blacklist",@"report"];
  177. if (tap.view.tag == 0) {//设置备注名
  178. if (self.youpaipis_follow == 0) {
  179. [ZCHUDHelper showTitle:@"未关注对方不能设置备注名"];
  180. return;
  181. }
  182. }
  183. [self dismissViewControllerAnimated:YES completion:^{
  184. [self.youpaipdelegate youpaifimSessionDetailWindowAction:typeArr[tap.view.tag] andSession:self.youpaipsession];
  185. }];
  186. }
  187. -(void)youpaifswichBtnAction:(UIButton *)sender
  188. {
  189. sender.selected = !sender.selected;
  190. if (sender.tag == 2) {//置顶聊天
  191. if (sender.selected) {
  192. [NTESSessionUtil addRecentSessionMark:self.youpaipsession type:NTESRecentSessionMarkTypeTop];
  193. }else{
  194. [NTESSessionUtil removeRecentSessionMark:self.youpaipsession type:NTESRecentSessionMarkTypeTop];
  195. }
  196. }
  197. if (sender.tag == 3) {//黑名单
  198. [LCCommonHttp blackUserId:self.youpaipsession.sessionId];
  199. }
  200. [self TFDismissViewController];
  201. }
  202. -(void)youpaifinfoViewTapAction
  203. {
  204. [self TFDismissViewController];
  205. [self.youpaipdelegate showUserVCWithSession:self.youpaipsession];
  206. }
  207. @end