105 lines
3.6 KiB
Mathematica
105 lines
3.6 KiB
Mathematica
|
|
//
|
||
|
|
// TXSingleChatVC.m
|
||
|
|
// romantic
|
||
|
|
//
|
||
|
|
// Created by bj_szd on 2022/9/5.
|
||
|
|
// Copyright © 2022 romantic. All rights reserved.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "TXSingleChatVC.h"
|
||
|
|
#import "TUIChat.h"
|
||
|
|
#import "SPHomepageModel.h"
|
||
|
|
#import "SPTrendReportVC.h"
|
||
|
|
|
||
|
|
@interface TXSingleChatVC ()
|
||
|
|
|
||
|
|
@property(nonatomic, strong) UIButton *focusBtn;
|
||
|
|
@property(nonatomic, strong) SPHomepageModel *model;
|
||
|
|
|
||
|
|
@end
|
||
|
|
|
||
|
|
@implementation TXSingleChatVC
|
||
|
|
|
||
|
|
- (void)viewDidLoad {
|
||
|
|
[super viewDidLoad];
|
||
|
|
|
||
|
|
[self loadBar:YES needBack:YES needBackground:NO];
|
||
|
|
self.titleLabel.text = self.titleStr;
|
||
|
|
|
||
|
|
// self.view.backgroundColor = self.barView.backgroundColor = HEXCOLOR(0xFFFFFF);
|
||
|
|
// self.titleLabel.textColor = kWhiteColor;
|
||
|
|
|
||
|
|
// 创建会话信息
|
||
|
|
TUIChatConversationModel *data = [[TUIChatConversationModel alloc] init];
|
||
|
|
data.userID = self.userId;
|
||
|
|
// 创建 TUIC2CChatViewController
|
||
|
|
TUIC2CChatViewController *vc = [[TUIC2CChatViewController alloc] init];
|
||
|
|
[vc setConversationData:data];
|
||
|
|
// 把 TUIC2CChatViewController 添加到自己的 ViewController
|
||
|
|
[self addChildViewController:vc];
|
||
|
|
[self.view addSubview:vc.view];
|
||
|
|
|
||
|
|
[vc.view mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.top.mas_equalTo(yb_NavigationBar_H);
|
||
|
|
make.left.right.bottom.equalTo(self.view);
|
||
|
|
}];
|
||
|
|
|
||
|
|
// [self setupFocusAndReportUI];
|
||
|
|
// [self fetchHomepageData];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)fetchHomepageData {
|
||
|
|
NSDictionary *params = @{@"from_id":C_string(self.userId)};
|
||
|
|
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/player/player_home_page" Loading:YES Hud:NO Success:^(id _Nonnull responseDic) {
|
||
|
|
SPHomepageModel *model = [SPHomepageModel mj_objectWithKeyValues:responseDic[@"data"]];
|
||
|
|
self.model = model;
|
||
|
|
|
||
|
|
self.focusBtn.selected = model.is_follow == 2;
|
||
|
|
|
||
|
|
} Failure:^(id _Nonnull errorData) {
|
||
|
|
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)setupFocusAndReportUI {
|
||
|
|
UIButton *reportBtn = [ControlCreator createButton:nil rect:CGRectZero text:nil font:nil color:nil backguoundColor:nil imageName:@"trend_more" target:self action:@selector(onReport)];
|
||
|
|
[self.view addSubview:reportBtn];
|
||
|
|
|
||
|
|
UIButton *focusBtn = [ControlCreator createButton:nil rect:CGRectZero text:@"关注" font:YBMediumFont(13) color:HEXCOLOR(0x13131F) backguoundColor:mainDeepColor imageName:nil target:self action:@selector(onFocus)];
|
||
|
|
[focusBtn setTitle:@"已关注" forState:UIControlStateSelected];
|
||
|
|
focusBtn.layer.masksToBounds = YES;
|
||
|
|
focusBtn.layer.cornerRadius = 10;
|
||
|
|
[self.view addSubview:focusBtn];
|
||
|
|
self.focusBtn = focusBtn;
|
||
|
|
|
||
|
|
[reportBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.top.mas_equalTo(yb_StatusBar_H);
|
||
|
|
make.right.mas_equalTo(0);
|
||
|
|
make.size.mas_equalTo(CGSizeMake(40, 44));
|
||
|
|
}];
|
||
|
|
[focusBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
make.centerY.equalTo(reportBtn);
|
||
|
|
make.right.equalTo(reportBtn.mas_left);
|
||
|
|
make.size.mas_equalTo(CGSizeMake(55, 20));
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)onReport {
|
||
|
|
SPTrendReportVC *vc = [[SPTrendReportVC alloc] init];
|
||
|
|
vc.userId = self.userId;
|
||
|
|
[vc pushSelf];
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)onFocus {
|
||
|
|
NSDictionary *params = @{@"follow_uid":C_string(self.userId)};
|
||
|
|
NSString *urlStr = self.model.is_follow == 2 ? @"api/user/unfollow_user" : @"api/user/follow_user";
|
||
|
|
[[AFNetworkRequset shared] postRequestWithParams:params Path:urlStr Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
|
||
|
|
self.model.is_follow = self.model.is_follow == 2 ? 1 : 2;
|
||
|
|
self.focusBtn.selected = self.model.is_follow == 2;
|
||
|
|
} Failure:^(id _Nonnull errorData) {
|
||
|
|
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
@end
|