// // YBCenterTopView.m // YBVideo // // Created by YB007 on 2022/5/30. // Copyright © 2022 cat. All rights reserved. // #import "YBCenterTopView.h" #import "UIImage+RKImgCategory.h" #import "ShopHomeVC.h" #import "shopDetailVC.h" #import "YBGoodsLikeVC.h" #import "EditVC.h" #import "fansViewController.h" #import "attrViewController.h" #import "Loginbonus.h" #import "JCHATConversationViewController.h" #import "JCHATAlertViewWait.h" #import "YBVipVC.h" #import "BusinessCardVC.h" #import "HeaderBackImgView.h" #import "TZImagePickerController.h" #import "YBStorageObj.h" #import "YBCheckLiveObj.h" #import "YBOtherCenterMore.h" #import "YBCenterMoreView.h" @interface YBCenterTopView(){ CGFloat _btnHeight; Loginbonus *firstLV; NSString *bonus_switch; NSString *bonus_day; NSArray *bonus_list; NSString *dayCount; NSString *is_bonus;//是否签到 MessageListModel *_userModel; UIImage *headBgimg; NSString *headBgStr; } // 背景 @property(nonatomic,strong)HeaderBackImgView *headImgView; @property(nonatomic,strong)UIImageView *bigBgIV; @property(nonatomic,strong)YBButton *returnBtn; // 返回 @property(nonatomic,strong)YBButton *youngBtn; // 青少年 @property(nonatomic,strong)YBButton *moreBtn; // 更多 @property(nonatomic,strong)YBButton *iconBtn; @property(nonatomic,strong)UIView *liveingV; @property(nonatomic,strong)UILabel *liveingL; @property(nonatomic,strong)UILabel *nameL; @property(nonatomic,strong)UILabel *idL; @property(nonatomic,strong)UIButton *qrcodeBtn; @property(nonatomic,strong)UIButton *nameBtn; // 赞、关注、粉丝等父视图 @property(nonatomic,strong)UIView *itemView1; @property(nonatomic,strong)UIView *item1Content; @property(nonatomic,strong)UILabel *zanNumL; @property(nonatomic,strong)UILabel *fansNumL; @property(nonatomic,strong)UILabel *followNumL; @property(nonatomic,strong)YBButton *editBtn; // 自己-编辑 @property(nonatomic,strong)YBButton *signDayBtn; // 自己-签到 @property(nonatomic,strong)YBButton *followBtn; // 他人-关注 @property(nonatomic,strong)YBButton *chatBtn; // 他人-聊天 // 签名、个人资料等父视图 @property(nonatomic,strong)UIView *itemView2; @property(nonatomic,strong)UIView *item2Content; @property(nonatomic,strong)UILabel *signatureL; @property(nonatomic,strong)UIButton *sexBtn; @property(nonatomic,strong)UIButton *ageBtn; @property(nonatomic,strong)UIButton *cityBtn; @property(nonatomic,strong)UIView *vipBgView; @property(nonatomic,strong)UIImageView *vipRightBgIV; @property(nonatomic,strong)UILabel *vipTitleL; @property(nonatomic,strong)UILabel *vipTimeL; // 直播小店、我的收藏、直播动态等父视图 @property(nonatomic,strong)UIView *itemView3; @property(nonatomic,strong)MASConstraint *item2ContentMas; @property(nonatomic,strong)MASConstraint *vipBgMas; @end @implementation YBCenterTopView - (instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { [self createUI]; } return self; } -(void)createUI { _userModel = [[MessageListModel alloc]init]; CGFloat bigIVHeight = _window_width * 200.0/375+20+statusbarHeight; _bigBgIV = [[UIImageView alloc]init]; _bigBgIV.contentMode = UIViewContentModeScaleAspectFill; _bigBgIV.userInteractionEnabled = YES; _bigBgIV.clipsToBounds = YES; [self addSubview:_bigBgIV]; [_bigBgIV mas_makeConstraints:^(MASConstraintMaker *make) { make.width.centerX.top.equalTo(self); make.height.mas_equalTo(bigIVHeight); }]; UITapGestureRecognizer *headTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(headerImgTap)]; [_bigBgIV addGestureRecognizer:headTap]; UIImageView *iconShadow = [[UIImageView alloc]init]; iconShadow.image = [UIImage imageNamed:@"个中头部-遮罩"]; iconShadow.contentMode = UIViewContentModeScaleAspectFill; [_bigBgIV addSubview:iconShadow]; [iconShadow mas_makeConstraints:^(MASConstraintMaker *make) { make.width.bottom.centerX.equalTo(_bigBgIV); make.top.equalTo(_bigBgIV.mas_centerY).multipliedBy(0.2); }]; _returnBtn = [self createBtnStatus:BtnFun_CenterReturn corner:0 havebg:NO]; [_returnBtn setImage:[UIImage imageNamed:@"个中头部-返回"] forState:0]; [self addSubview:_returnBtn]; [_returnBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.mas_left).offset(10); make.top.equalTo(self.mas_top).offset(statusbarHeight+20); make.width.height.mas_equalTo(50); }]; // _youngBtn = [self createBtnStatus:BtnFun_CenterYoung corner:14 havebg:NO]; // [_youngBtn setImage:[UIImage imageNamed:@"个中头部-青年"] forState:0]; // [_youngBtn setTitle:YZMsg(@"青少年模式") forState:0]; // _youngBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 6); // _youngBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0); // _youngBtn.backgroundColor = RGB_COLOR(@"#272727", 0.5); // [self addSubview:_youngBtn]; // [_youngBtn mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(_returnBtn.mas_right); // make.centerY.equalTo(_returnBtn); // make.height.mas_equalTo(28); // }]; _moreBtn = [self createBtnStatus:BtnFun_CenterMore corner:0 havebg:NO]; [_moreBtn setImage:[UIImage imageNamed:@"个中头部-更多"] forState:0]; [self addSubview:_moreBtn]; [_moreBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.mas_right).offset(-15); make.width.height.centerY.equalTo(_returnBtn); }]; _returnBtn.hidden = _youngBtn.hidden = YES; // [self addSubview:self.iconBtn]; [_iconBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(90); make.left.equalTo(self.mas_left).offset(15); make.bottom.equalTo(_bigBgIV.mas_bottom).offset(-30); }]; [self addSubview:self.liveingV]; [_liveingV mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.centerX.centerY.equalTo(_iconBtn); }]; _liveingL.hidden = _liveingV.hidden = YES;; // 昵称 [self addSubview:self.nameL]; [_nameL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(_iconBtn.mas_right).offset(10); make.bottom.equalTo(_iconBtn.mas_centerY).offset(-2); make.right.lessThanOrEqualTo(self.mas_right).offset(-15); }]; [self addSubview:self.nameBtn]; [_nameBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.top.bottom.equalTo(_nameL); }]; // id [self addSubview:self.idL]; [_idL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(_nameL.mas_left); make.top.equalTo(_iconBtn.mas_centerY).offset(2); }]; _qrcodeBtn = [self createBtnStatus:BtnFun_CenterQrcode corner:0 havebg:NO]; [_qrcodeBtn setImage:[UIImage imageNamed:@"center_card"] forState:0]; [self addSubview:_qrcodeBtn]; _qrcodeBtn.hidden = YES; _qrcodeBtn.jk_touchAreaInsets = UIEdgeInsetsMake(10, 10, 10, 10); [_qrcodeBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(16); make.left.equalTo(_idL.mas_right).offset(5); make.centerY.equalTo(_idL); }]; [self addSubview:self.itemView1]; [_itemView1 mas_makeConstraints:^(MASConstraintMaker *make) { make.width.centerX.equalTo(self); make.top.equalTo(_bigBgIV.mas_bottom).offset(-15); make.height.mas_equalTo(70); }]; [self addSubview:self.itemView2]; [_itemView2 mas_makeConstraints:^(MASConstraintMaker *make) { make.width.centerX.equalTo(self); make.top.equalTo(_itemView1.mas_bottom).offset(0); }]; [self addSubview:self.itemView3]; [_itemView3 mas_makeConstraints:^(MASConstraintMaker *make) { make.width.centerX.equalTo(self); make.top.equalTo(_itemView2.mas_bottom).offset(0); make.height.mas_equalTo(70); }]; } - (void)setIsTabbar:(BOOL)isTabbar { _isTabbar = isTabbar; _returnBtn.hidden = isTabbar; } - (void)setOtherUid:(NSString *)otherUid{ _otherUid = otherUid; if ([_otherUid isEqual:@"0"]) { _moreBtn.hidden = YES; _followBtn.hidden = _chatBtn.hidden = YES; }else if ([_otherUid isEqual:[Config getOwnID]]) { _editBtn.hidden = _signDayBtn.hidden = NO; _youngBtn.hidden = NO; _qrcodeBtn.hidden = NO; }else{ _followBtn.hidden = _chatBtn.hidden = NO; _youngBtn.hidden = YES; _qrcodeBtn.hidden = YES; } } - (void)setDataDic:(NSDictionary *)dataDic{ _dataDic = dataDic; [self addLivingAnimation]; NSURL *bg_url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[_dataDic valueForKey:@"bg_img"]]]; [_bigBgIV sd_setImageWithURL:bg_url]; NSString *userId = minstr([_dataDic valueForKey:@"id"]); NSString *userName = minstr([_dataDic valueForKey:@"user_nickname"]); NSString *userIcon = [_dataDic valueForKey:@"avatar"]; NSString *isAtt = minstr([_dataDic valueForKey:@"isattention"]); NSURL *iconUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@",userIcon]]; [_iconBtn sd_setImageWithURL:iconUrl forState:0]; _nameL.text = userName; _idL.text = [NSString stringWithFormat:@"ID:%@",userId]; _userModel.uidStr = userId; _userModel.unameStr = userName; _userModel.iconStr = userIcon; _userModel.isAtt = isAtt; int bonus_switch = [minstr([dataDic valueForKey:@"bonus_switch"]) intValue]; int young_switch = [minstr([dataDic valueForKey:@"teenagers_switch"]) intValue];//[YBYoungManager shareInstance].youngSwitch; BOOL showSign = NO; if (bonus_switch == 1 && young_switch == 0 && ![PublicObj isUp]) { showSign = YES; } [self resetSignDayBtn:showSign]; int isattention = [minstr([dataDic valueForKey:@"isattention"]) intValue]; _followBtn.selected = isattention; _zanNumL.text = minstr([dataDic valueForKey:@"praise"]); _fansNumL.text = minstr([dataDic valueForKey:@"fans"]); _followNumL.text = minstr([dataDic valueForKey:@"follows"]); // 签名 _signatureL.text = minstr([_dataDic valueForKey:@"signature"]); int sex = [minstr([_dataDic valueForKey:@"sex"])intValue]; if (sex == 1) { [_sexBtn setImage:[UIImage imageNamed:@"个中头部-男"] forState:0]; [_sexBtn setTitle:YZMsg(@"男") forState:0]; }else{ [_sexBtn setImage:[UIImage imageNamed:@"个中头部-女"] forState:0]; [_sexBtn setTitle:YZMsg(@"女") forState:0]; } [_ageBtn setTitle:minstr([_dataDic valueForKey:@"age"]) forState:0]; [_cityBtn setTitle:minstr([_dataDic valueForKey:@"city"]) forState:0]; //会员 if ([[_dataDic valueForKey:@"vipinfo"] isKindOfClass:[NSDictionary class]]) { NSDictionary *vipInfo = [_dataDic valueForKey:@"vipinfo"]; NSString *isVip = minstr([vipInfo valueForKey:@"isvip"]); NSString *vipSitch = minstr([vipInfo valueForKey:@"vip_switch"]); _vipBgView.hidden = YES; if ([vipSitch isEqual:@"1"] && [[Config getOwnID] intValue] > 0 && [_otherUid isEqual:[Config getOwnID]] && ![PublicObj isUp] && young_switch == 0) { _vipBgView.hidden = NO; } [self layoutVipView]; NSString *vipEndTime = minstr([vipInfo valueForKey:@"vip_endtime"]); if ([isVip isEqual:@"1"]) { _vipTitleL.text = YZMsg(@"尊贵会员"); _vipTimeL.text = vipEndTime; }else { _vipTitleL.text = YZMsg(@"成为会员"); _vipTimeL.text = YZMsg(@"尊享会员特权"); } [_vipBgView layoutIfNeeded]; [_vipRightBgIV setBackgroundImage:[UIImage rk_gradientColorImageFromColors:@[RGB_COLOR(@"#FBD5AF", 1),RGB_COLOR(@"#F8E7D4", 1)] gradientType:RKGradientTypeLeftToRight imgSize:_vipRightBgIV.size]]; } // 直播小店、直播历史、收藏 [self botSubsItemSet:young_switch]; // 回调整体高度 [self layoutIfNeeded]; [_itemView1 jk_setRoundedCorners:UIRectCornerTopLeft|UIRectCornerTopRight radius:10]; CGFloat getmaxh = CGRectGetMaxY(_itemView3.frame); if (self.topEvent) { self.topEvent(TopCtrType_Layout, @{@"top_height":@(getmaxh)}); } } -(void)layoutVipView { [_item2ContentMas uninstall]; [_vipBgMas uninstall]; if (_vipBgView.hidden == YES) { [_item2ContentMas install]; }else{ [_vipBgMas install]; } } -(void)addLivingAnimation { //直播中动画 NSDictionary *liveInfo = [_dataDic valueForKey:@"liveinfo"]; if ([minstr([liveInfo valueForKey:@"islive"]) isEqual:@"1"] && ![minstr([liveInfo valueForKey:@"uid"]) isEqual:[Config getOwnID]]) { _liveingV.hidden = _liveingL.hidden = NO; [_iconBtn.imageView.layer addAnimation:[PublicObj avatarScaleAnimation] forKey:@"avatar_scale"]; [_liveingV.layer addAnimation:[PublicObj bottomScaleAnimation] forKey:@"bottom_scale"]; _iconBtn.layer.borderColor = Pink_Cor.CGColor; }else { _liveingV.hidden = _liveingL.hidden = YES; _iconBtn.layer.borderColor = UIColor.clearColor.CGColor; } } -(void)removeLivingAnimation { [_iconBtn.imageView.layer removeAllAnimations]; [_liveingV.layer removeAllAnimations]; _liveingV.hidden = _liveingL.hidden = YES; _iconBtn.layer.borderColor = UIColor.clearColor.CGColor; } - (YBButton *)iconBtn{ if (!_iconBtn) { _iconBtn = [YBButton buttonWithType:UIButtonTypeCustom]; _iconBtn.layer.borderWidth = 1; _iconBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill; _iconBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill; _iconBtn.imageView.contentMode = UIViewContentModeScaleAspectFill; _iconBtn.imageView.clipsToBounds = YES; _iconBtn.imageView.layer.masksToBounds = YES; _iconBtn.imageView.layer.cornerRadius = 45; _iconBtn.layer.masksToBounds = YES; _iconBtn.layer.cornerRadius = 45; [_iconBtn addTarget:self action:@selector(clickIconBtn) forControlEvents:UIControlEventTouchUpInside]; } return _iconBtn; } -(void)clickIconBtn { NSDictionary *liveInfo = [_dataDic valueForKey:@"liveinfo"]; if ([minstr([liveInfo valueForKey:@"islive"]) isEqual:@"1"] && ![minstr([liveInfo valueForKey:@"uid"]) isEqual:[Config getOwnID]]) { [YBCheckLiveObj checkLiveManeger].liveUid = minstr([liveInfo valueForKey:@"uid"]); [YBCheckLiveObj checkLiveManeger].liveStream = minstr([liveInfo valueForKey:@"stream"]); [YBCheckLiveObj checkLiveManeger].currentIndex = 0; [YBCheckLiveObj checkLiveManeger].listArray = nil; [[YBCheckLiveObj checkLiveManeger] checkLiving]; }else if([minstr([liveInfo valueForKey:@"uid"]) isEqual:[Config getOwnID]]){ //进入编辑 EditVC *eVC = [[EditVC alloc]init]; [[YBBaseAppDelegate sharedAppDelegate]pushViewController:eVC animated:YES]; } } -(void)nameBtnClick{ NSDictionary *liveInfo = [_dataDic valueForKey:@"liveinfo"]; if([minstr([liveInfo valueForKey:@"uid"]) isEqual:[Config getOwnID]]){ //进入编辑 EditVC *eVC = [[EditVC alloc]init]; [[YBBaseAppDelegate sharedAppDelegate]pushViewController:eVC animated:YES]; } } - (UIView *)liveingV{ if (!_liveingV) { //直播中动画外边缘 _liveingV = [[UIView alloc]init]; _liveingV.layer.borderColor = RGB_COLOR(@"#EA377F", 0.5).CGColor; _liveingV.layer.borderWidth = 0.8; _liveingV.cornerRadius = 45; _liveingV.userInteractionEnabled = NO; _liveingL = [[UILabel alloc]init]; _liveingL.text = YZMsg(@"直播"); _liveingL.textAlignment = NSTextAlignmentCenter; _liveingL.textColor = UIColor.whiteColor; _liveingL.backgroundColor = Pink_Cor; _liveingL.font = SYS_Font(10); _liveingL.layer.cornerRadius = 35; _liveingL.layer.masksToBounds = YES; _liveingL.userInteractionEnabled = YES; [_iconBtn.imageView addSubview:_liveingL]; [_liveingL mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.top.equalTo(_iconBtn.imageView); make.width.equalTo(_iconBtn.imageView.mas_width).multipliedBy(0.85); make.height.mas_equalTo(20); }]; } return _liveingV; } - (UILabel *)nameL{ if (!_nameL) { _nameL = [[UILabel alloc]init]; _nameL.textColor = UIColor.whiteColor; _nameL.font = [UIFont boldSystemFontOfSize:18]; } return _nameL; } - (UIButton *)nameBtn{ if (!_nameBtn) { _nameBtn = [UIButton buttonWithType:0]; [_nameBtn addTarget:self action:@selector(nameBtnClick) forControlEvents:UIControlEventTouchUpInside]; } return _nameBtn; } - (UILabel *)idL{ if (!_idL) { _idL = [[UILabel alloc]init]; _idL.textColor = UIColor.whiteColor; _idL.font = SYS_Font(16); } return _idL; } - (UIView *)itemView1{ if (!_itemView1) { _itemView1 = [[UIView alloc]init]; _itemView1.backgroundColor = UIColor.whiteColor; _item1Content = [[UIView alloc]init]; [_itemView1 addSubview:_item1Content]; [_item1Content mas_makeConstraints:^(MASConstraintMaker *make) { make.width.equalTo(_itemView1.mas_width).offset(-10); make.centerX.height.centerY.equalTo(_itemView1); }]; NSArray *titleA = @[@"获赞",@"粉丝",@"关注"]; NSArray *funA = @[@(BtnFun_CenterZanList),@(Btnfun_CenterFanList),@(Btnfun_CenterFollowList)]; MASViewAttribute *mas_left = _item1Content.mas_left; for (int i = 0; i *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto{ NSLog(@"------多选择图片--:%@",photos); UIImage *img = photos[0]; headBgimg = img; [self updateBgImg]; } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ if (@available(iOS 11, *)) { UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } NSString *type = [info objectForKey:UIImagePickerControllerMediaType]; if ([type isEqualToString:@"public.image"]) { //先把图片转成NSData UIImage* image = [info objectForKey:@"UIImagePickerControllerEditedImage"]; headBgimg = image; [self updateBgImg]; [picker dismissViewControllerAnimated:YES completion:^{ [UIApplication sharedApplication].statusBarHidden=NO; }]; } } -(void)updateBgImg { [MBProgressHUD showMessage:@""]; YBWeakSelf; [[YBStorageObj storageManeger]getCOSType:^(int code) { dispatch_async(dispatch_get_main_queue(), ^{ if (code == 0) { [weakSelf uploadHeadBgImg]; } }); }]; } -(void)uploadHeadBgImg{ dispatch_group_t group = dispatch_group_create(); dispatch_queue_t queue = dispatch_get_global_queue(0, 0); dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); if (headBgimg) { dispatch_group_async(group, queue, ^{ NSString *imageName = [PublicObj getNameBaseCurrentTime:@"_centerHeaderBg.png"]; [[YBStorageObj storageManeger]yb_storageImg:headBgimg andName:imageName progress:^(CGFloat percent) { }complete:^(int code, NSString *key) { //图片成功 headBgStr = key; dispatch_semaphore_signal(semaphore); }]; dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); }); } dispatch_group_notify(group, queue, ^{ dispatch_async(dispatch_get_main_queue(), ^{ [self setBgService]; }); NSLog(@"任务完成执行"); }); } -(void)setBgService{ //YBWeakSelf; NSDictionary *parDic = @{@"uid":[Config getOwnID],@"token":[Config getOwnToken],@"img":headBgStr}; [YBNetworking postWithUrl:@"User.updateBgImg" Dic:parDic Suc:^(int code, id info, NSString *msg) { [MBProgressHUD hideHUD]; if (code == 0) { NSDictionary*infos = [info firstObject]; NSString *newUrl = minstr([infos valueForKey:@"bg_img"]); NSMutableDictionary *m_dic = [NSMutableDictionary dictionaryWithDictionary:_dataDic]; [m_dic setObject:newUrl forKey:@"bg_img"]; _dataDic = [NSDictionary dictionaryWithDictionary:m_dic]; [_bigBgIV sd_setImageWithURL:[NSURL URLWithString:newUrl]]; // [weakSelf pullData]; } } Fail:^(id fail) { [MBProgressHUD hideHUD]; }]; } #pragma mark - 签到 -(void)getSignDayReq { [YBNetworking postWithUrl:@"User.Bonus" Dic:nil Suc:^(int code, id info, NSString *msg) { if (code == 0) { NSArray *infos = info; bonus_switch = [NSString stringWithFormat:@"%@",[[infos lastObject] valueForKey:@"bonus_switch"]]; bonus_day = [[infos lastObject] valueForKey:@"bonus_day"]; bonus_list = [[infos lastObject] valueForKey:@"bonus_list"]; //int day = [bonus_day intValue]; dayCount = minstr([[infos lastObject] valueForKey:@"count_day"]); is_bonus = minstr([[infos lastObject] valueForKey:@"is_bonus"]); if ([bonus_switch isEqual:@"1"]) { [self firstLog]; } } } Fail:^(id fail) { }]; } -(void)firstLog{ firstLV = [[Loginbonus alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height)AndNSArray:bonus_list AndDay:bonus_day andDayCount:dayCount andIsBonus:is_bonus]; firstLV.delegate = self; [[UIApplication sharedApplication].keyWindow addSubview:firstLV]; } -(void)removeView:(NSDictionary*)dic{ [firstLV removeFromSuperview]; firstLV = nil; } #pragma mark - 私信 -(void)goToChat{ if (_isChatPage) { [[YBBaseAppDelegate sharedAppDelegate]popViewController:YES]; return; } NSDictionary *userDic = @{ @"id":_userModel.uidStr, @"user_nickname":_userModel.unameStr, @"avatar":_userModel.iconStr, }; [[YBMessageManager shareManager] chatWithUser:userDic]; } #pragma mark - 关注-取关 -(void)doAttentUser{ YBWeakSelf; NSDictionary *subdic = @{ @"uid":[Config getOwnID], @"touid":[NSString stringWithFormat:@"%@",[_dataDic valueForKey:@"id"]], @"token":[Config getOwnToken], }; [YBNetworking postWithUrl:@"User.setAttent" Dic:subdic Suc:^(int code, id info, NSString *msg) { if(code == 0) { NSDictionary *infoDic = [info firstObject]; NSString *isattent = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"isattent"]]; if (weakSelf.topEvent) { weakSelf.topEvent(TopCtrType_Attent, @{@"isattent":isattent}); } _userModel.isAtt = isattent; if ([isattent isEqual:@"1"]) { [MBProgressHUD showError:YZMsg(@"已关注")]; }else{ [MBProgressHUD showError:YZMsg(@"已取消关注")]; } [weakSelf changeFollowState:[isattent intValue]]; }else if (code == 700) { [PublicObj tokenExpired:msg]; }else{ [MBProgressHUD showError:msg]; } } Fail:^(id fail) { }]; } -(void)changeFollowState:(int)isAttent { _followBtn.selected = isAttent; } #pragma mark - 他人主页更多 -(void)showOtherMore{ if ([[Config getOwnID] intValue]<=0) { [PublicObj warnLogin]; return; } NSString *url = [NSString stringWithFormat:@"User.checkBlack&uid=%@&token=%@&touid=%@",[Config getOwnID],[Config getOwnToken],_otherUid]; YBWeakSelf; [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) { if (code == 0) { NSDictionary *infoDic = [info firstObject]; NSString *u2t = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"u2t"]]; //u2t 0-未拉黑 1-已拉黑 NSString *blackTitle = YZMsg(@"拉黑"); if ([u2t isEqual:@"1"]) { blackTitle = YZMsg(@"解除拉黑"); } [weakSelf showSheetWithAttTitle:@"" andBlackTitle:blackTitle]; }else { [MBProgressHUD showPop:msg]; } } Fail:^(id fail) { }]; } -(void)showSheetWithAttTitle:(NSString *)attStr andBlackTitle:(NSString *)blackStr{ YBWeakSelf; //name_str、id_str、black_str NSDictionary *infoDic = @{ @"name_str":minstr([_dataDic valueForKey:@"user_nickname"]), @"id_str":[NSString stringWithFormat:@"ID:%@",[_dataDic valueForKey:@"id"]], @"black_str":blackStr, }; [YBOtherCenterMore showOtherMoreWithBtns:infoDic complete:^(BtnFunStatus clickType) { dispatch_async(dispatch_get_main_queue(), ^{ if (clickType == BtnFun_CenterImMsg) { [weakSelf goToChat]; }else if(clickType == BtnFun_CenterReport){ [weakSelf doReportUser]; }else if (clickType == BtnFun_CenterBlack){ [weakSelf setBlack]; } }); }]; } #pragma mark - 举报 -(void)doReportUser{ PubH5 *h5vc = [[PubH5 alloc]init]; h5vc.url =[h5url stringByAppendingString:[NSString stringWithFormat:@"/appapi/userreport/index?uid=%@&token=%@&touid=%@",[Config getOwnID],[Config getOwnToken],_otherUid]]; [[YBBaseAppDelegate sharedAppDelegate] pushViewController:h5vc animated:YES]; } #pragma mark - 拉黑 -(void)setBlack { NSString *url = [NSString stringWithFormat:@"User.setBlack&uid=%@&token=%@&touid=%@",[Config getOwnID],[Config getOwnToken],_otherUid]; YBWeakSelf; [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) { if (code == 0) { NSString *infoDic = [info firstObject]; NSString *isBlakc = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"isblack"]]; if ([isBlakc isEqual:@"1"]) { [MBProgressHUD showPop:YZMsg(@"拉黑成功")]; if ([_userModel.isAtt isEqual:@"1"]) { _userModel.isAtt = @"0"; [weakSelf changeFollowState:0]; if (weakSelf.topEvent) { weakSelf.topEvent(TopCtrType_Attent, @{@"isattent":@"0"}); } } }else { [MBProgressHUD showPop:YZMsg(@"解除拉黑成功")]; } }else { [MBProgressHUD showPop:msg]; } } Fail:^(id fail) { }]; } #pragma mark - 自己个人主页更多 -(void)showSelfMore { [YBCenterMoreView showMoreViewWithSeller:minstr([_dataDic valueForKey:@"isshop"])]; } @end