// // YOUPAIZYIMSessionDetailWindow.m // VQU // // Created by Elaine on 2020/12/11. // Copyright © 2020 leo. All rights reserved. // #import "YOUPAIZYIMSessionDetailWindow.h" #import "UIViewController+TFPresent.h" #import "NTESSessionUtil.h" #import "LCCommonHttp.h" #import "CWStarRateView.h" @interface YOUPAIZYIMSessionDetailWindow () @property(nonatomic,strong)UIImageView *youpaipavatarImgV; @property(nonatomic,strong)UILabel *youpaipnameLabel; @property (strong, nonatomic) CWStarRateView *youpaipstarRateView; @property(nonatomic,strong)UILabel *youpaipscoreLabel; @property(nonatomic,strong)UILabel *youpaipremarkNameLabel; @property(nonatomic,strong)UILabel *youpaipIDLabel; @property(nonatomic,strong)UIButton *youpaipblacklistBtn; @property(nonatomic,strong)YOUPAILCBaseInfo* youpaipbaseInfo; @property(nonatomic,assign)NSInteger youpaipis_black; //是否拉黑 @property(nonatomic,assign)NSInteger youpaipis_follow; //是否关注 @property(nonatomic,assign)NSInteger youpaipis_set; //是否设置了备注 @end @implementation YOUPAIZYIMSessionDetailWindow - (void)youpaifgetData{ [LCHttpHelper requestWithURLString:ChatSetting parameters:@{@"user_id":self.youpaipsession.sessionId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 self.youpaipbaseInfo = [YOUPAILCBaseInfo mj_objectWithKeyValues:[[dict objectForKey:@"data"]objectForKey:@"info"]]; self.youpaipis_black = [[[dict objectForKey:@"data"]objectForKey:@"is_black"]integerValue]; self.youpaipis_follow = [[[dict objectForKey:@"data"]objectForKey:@"is_follow"]integerValue]; self.youpaipis_set = [[[dict objectForKey:@"data"]objectForKey:@"is_set"]integerValue]; [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipbaseInfo.youpaipavatar] placeholderImage:nil]; self.youpaipnameLabel.text = self.youpaipbaseInfo.youpaipnickname;//原昵称 self.youpaipstarRateView.scorePercent = 0.9; self.youpaipscoreLabel.text = @"缺字段"; self.youpaipstarRateView.scorePercent = [self.youpaipbaseInfo.youpaipscore floatValue]/5.0; self.youpaipscoreLabel.text = [NSString stringWithFormat:@"%.2f分",[self.youpaipbaseInfo.youpaipscore floatValue]]; self.youpaipremarkNameLabel.text = [NSString stringWithFormat:@"备注名:%@",self.youpaipbaseInfo.youpaipremark_name];//昵称 或者备注的名字 self.youpaipIDLabel.text = [NSString stringWithFormat:@"ID:%@",self.youpaipbaseInfo.youpaipusercode]; self.youpaipblacklistBtn.selected = self.youpaipis_black; } } failure:^(NSError *error) { }]; } - (void)viewDidLoad { [super viewDidLoad]; // [self.view setFrame:CGRectMake(0, 0, _vWith, _vHeight)]; // CAShapeLayer *maskLayer = [CAShapeLayer layer]; // UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.view.bounds cornerRadius:16]; // maskLayer.path = path.CGPath; // self.baseView.layer.mask = maskLayer; // [self.view setBackgroundColor:[UIColor whiteColor]]; UIView *infoView = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.vWidth,90)]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifinfoViewTapAction)]; [infoView addGestureRecognizer:tap]; [self.baseView addSubview:infoView]; _youpaipavatarImgV = [[UIImageView alloc] init]; _youpaipavatarImgV.layer.cornerRadius = 25; _youpaipavatarImgV.layer.masksToBounds = YES; _youpaipavatarImgV.backgroundColor = HexColorFromRGB(0xeeeeee); _youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill; [infoView addSubview:_youpaipavatarImgV]; [self.youpaipavatarImgV makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(@19); make.top.equalTo(@20); make.size.mas_equalTo(CGSizeMake(50, 50)); }]; _youpaipnameLabel = [[UILabel alloc] init]; _youpaipnameLabel.textColor = [UIColor whiteColor]; _youpaipnameLabel.font = LCFont(15); [infoView addSubview:_youpaipnameLabel]; [_youpaipnameLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipavatarImgV.right).offset(@9); make.top.equalTo(infoView.top).offset(@20); make.height.equalTo(@18); }]; self.youpaipstarRateView = [[CWStarRateView alloc] initWithFrame:CGRectMake(0,0,60,15) numberOfStars:5]; self.youpaipstarRateView.allowIncompleteStar = YES; self.youpaipstarRateView.hasAnimation = YES; self.youpaipstarRateView.userInteractionEnabled = NO; [infoView addSubview:self.youpaipstarRateView]; [self.youpaipstarRateView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipnameLabel.right).offset(@(6)); make.top.equalTo(@21); make.size.mas_equalTo(CGSizeMake(60,15)); }]; self.youpaipstarRateView.hidden = YES; _youpaipscoreLabel = [[UILabel alloc] init]; _youpaipscoreLabel.textColor = HexColorFromRGB(0x999999); _youpaipscoreLabel.font = LCFont(10); [infoView addSubview:_youpaipscoreLabel]; [_youpaipscoreLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipstarRateView.right).offset(@3); make.top.equalTo(infoView.top).offset(@21.5); make.height.equalTo(@14); }]; _youpaipscoreLabel.hidden = YES; _youpaipremarkNameLabel = [[UILabel alloc] init]; _youpaipremarkNameLabel.textColor = HexColorFromRGB(0x999999); _youpaipremarkNameLabel.font = LCFont(12); [infoView addSubview:_youpaipremarkNameLabel]; [_youpaipremarkNameLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipavatarImgV.right).offset(@9); make.top.equalTo(self.youpaipnameLabel.bottom).offset(@1); make.height.equalTo(@15); }]; _youpaipIDLabel = [[UILabel alloc] init]; _youpaipIDLabel.textColor = HexColorFromRGB(0x999999); _youpaipIDLabel.font = LCFont(12); [infoView addSubview:_youpaipIDLabel]; [_youpaipIDLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipavatarImgV.right).offset(@9); make.top.equalTo(self.youpaipremarkNameLabel.bottom).offset(@1); make.height.equalTo(@15); }]; UIImageView *arrowImgView = [[UIImageView alloc] initWithFrame:CGRectMake(self.vWidth - 14 - 19 - 14,38, 14, 14)]; arrowImgView.image = [UIImage imageNamed:@"vqu_images_H_cell_arrow_gray"]; [infoView addSubview:arrowImgView]; // UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0,89.5,self.vWidth,0.5)]; // line.backgroundColor = HexColorFromRGB(0xffffff); // [infoView addSubview:line]; self.youpaipsession = [NIMSession session:self.youpaipsession.sessionId type:NIMSessionTypeP2P]; NIMRecentSession *recent = [[NIMSDK sharedSDK].conversationManager recentSessionBySession:self.youpaipsession]; BOOL isTop = [NTESSessionUtil recentSessionIsMark:recent type:NTESRecentSessionMarkTypeTop]; self.baseView.backgroundColor = HexColorFromRGB(0x2A2935); NSArray *array = @[@"设置备注名",@"清空该聊天记录",@"置顶该聊天",@"加入黑名单",@"举报"]; NSArray *typearray = @[@"arrow",@"arrow",@"swich",@"swich",@"arrow"]; for (int i = 0; i< array.count; i++){ UIView *view = [[UIView alloc] initWithFrame:CGRectMake(14,90+45*i+(i*5), self.vWidth-28,45)]; [self.baseView addSubview:view]; // if (i != 0) { // UIView *line = [[UIView alloc] initWithFrame:CGRectMake(18,44.5,self.vWidth-36,0.5)]; // line.backgroundColor = HexColorFromRGB(0xEEEEEE); // [view addSubview:line]; // } view.tag = i; view.backgroundColor = HexColorFromRGB(0x4F4B5B); view.layer.cornerRadius = 5; view.layer.masksToBounds = YES; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(19,14,150,17)]; label.text = array[i]; label.textColor = HexColorFromRGB(0xffffff); label.font = LCFont(14); [view addSubview:label]; NSString *typeStr = typearray[i]; if ([typeStr isEqualToString:@"arrow"]) { UIImageView *arrowImgView = [[UIImageView alloc] initWithFrame:CGRectMake(self.vWidth - 14 - 19 - 28,15.5, 14, 14)]; arrowImgView.image = [UIImage imageNamed:@"vqu_images_H_cell_arrow_gray"]; [view addSubview:arrowImgView]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifarrowAction:)]; [view addGestureRecognizer:tap]; }else{ UIButton *swichBtn = [UIButton buttonWithType:UIButtonTypeCustom]; swichBtn.frame = CGRectMake(self.vWidth - 47-9-28, 11, 47, 22); [swichBtn setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_on"] forState:UIControlStateSelected]; [swichBtn setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_off"] forState:UIControlStateNormal]; [swichBtn addTarget:self action:@selector(youpaifswichBtnAction:) forControlEvents:UIControlEventTouchUpInside]; swichBtn.tag = i; [view addSubview:swichBtn]; if (i == 2) {//置顶聊天 swichBtn.selected = isTop; } if (i == 3) {//加入黑名单 self.youpaipblacklistBtn = swichBtn; } } } [self youpaifgetData]; } -(void)youpaifarrowAction:(UITapGestureRecognizer *)tap { NSArray *typeArr = @[@"updateRemark",@"clearChat",@"top",@"blacklist",@"report"]; if (tap.view.tag == 0) {//设置备注名 if (self.youpaipis_follow == 0) { [ZCHUDHelper showTitle:@"未关注对方不能设置备注名"]; return; } } [self dismissViewControllerAnimated:YES completion:^{ [self.youpaipdelegate youpaifimSessionDetailWindowAction:typeArr[tap.view.tag] andSession:self.youpaipsession]; }]; } -(void)youpaifswichBtnAction:(UIButton *)sender { sender.selected = !sender.selected; if (sender.tag == 2) {//置顶聊天 if (sender.selected) { [NTESSessionUtil addRecentSessionMark:self.youpaipsession type:NTESRecentSessionMarkTypeTop]; }else{ [NTESSessionUtil removeRecentSessionMark:self.youpaipsession type:NTESRecentSessionMarkTypeTop]; } } if (sender.tag == 3) {//黑名单 [LCCommonHttp blackUserId:self.youpaipsession.sessionId]; } [self TFDismissViewController]; } -(void)youpaifinfoViewTapAction { [self TFDismissViewController]; [self.youpaipdelegate showUserVCWithSession:self.youpaipsession]; } @end