123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- //
- // KSChatUserDetailViewController.m
- // KulexiuForStudent
- //
- // Created by 王智 on 2022/10/18.
- //
- #import "KSChatUserDetailViewController.h"
- #import "UserDetailNavView.h"
- #import "ChatUserInfo.h"
- #import "UserDetailBodyView.h"
- #import "UserDetailBottomView.h"
- #import "RecentPracticeModel.h"
- #import "KSBaseWKWebViewController.h"
- @interface KSChatUserDetailViewController ()<UIScrollViewDelegate>
- @property (nonatomic, strong) UserDetailNavView *navView;
- @property (nonatomic, strong) ChatUserInfo *userInfo;
- @property (nonatomic, strong) UserDetailBodyView *bodyView;
- @property (nonatomic, strong) UserDetailBottomView *bottomView;
- @end
- @implementation KSChatUserDetailViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- [self configUI];
-
- }
- - (void)configUI {
-
- UIImage *bgImage = [UIImage imageNamed:@"user_detailBg"];
- CGFloat height = bgImage.size.height / bgImage.size.width * kScreenWidth;
- UIImageView *imageView = [[UIImageView alloc] initWithImage:bgImage];
- imageView.frame = CGRectMake(0, 0, kScreenWidth, height);
- [self.view addSubview:imageView];
-
- [self.view addSubview:self.navView];
- [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.mas_equalTo(self.view);
- make.height.mas_equalTo(kNaviBarHeight);
- }];
- self.scrollView.backgroundColor = [UIColor clearColor];
- self.scrollView.delegate = self;
-
- [self.view bringSubviewToFront:self.scrollView];
- [self.view bringSubviewToFront:self.navView];
- [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.view.mas_top);
- make.left.right.mas_equalTo(self.view);
- make.bottom.mas_equalTo(self.view.mas_bottom);
- }];
-
- UIView *headView = [[UIView alloc] init];
- headView.backgroundColor = [UIColor clearColor];
- [self.scrollView addSubview:headView];
- [headView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.scrollView.mas_top);
- make.left.right.mas_equalTo(self.view);
- make.height.mas_equalTo(kNaviBarHeight);
- }];
-
- [self.view addSubview:self.bodyView];
- CGFloat bodyViewHeight = [UserDetailBodyView getViewHeight];
- if (bodyViewHeight < KPortraitHeight - kNaviBarHeight - 70) {
- bodyViewHeight = KPortraitHeight - kNaviBarHeight - 70;
- }
- [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(headView.mas_bottom);
- make.left.right.mas_equalTo(self.view);
- make.height.mas_equalTo(bodyViewHeight);
- }];
- [self.view addSubview:self.bottomView];
- [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.top.mas_equalTo(self.bodyView.mas_bottom);
- make.bottom.mas_equalTo(self.scrollView.mas_bottom);
- make.height.mas_equalTo(70);
- }];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self requestUserMessage];
- }
- - (void)requestUserMessage {
- [self showhud];
- [KSNetworkingManager queryUserById:KS_GET rongCloudUserId:self.rongCloudId success:^(NSDictionary * _Nonnull dic) {
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- self.userInfo = [[ChatUserInfo alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
- [self requestRecentPractice];
- }
- else {
-
- }
-
- } faliure:^(NSError * _Nonnull error) {
- [self removehub];
- }];
- }
- - (void)requestRecentPractice {
-
- [KSNetworkingManager queryUserRecentRequest:KS_GET userId:[NSString stringWithFormat:@"%.0f",self.userInfo.userId] success:^(NSDictionary * _Nonnull dic) {
- [self removehub];
- NSLog(@"%@", [dic mj_JSONString]);
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSArray *sourceArray = [[dic dictionaryValueForKey:@"data"] arrayValueForKey:@"rows"];
- [self evaluateSource:sourceArray];
- }
- else {
-
- }
- } faliure:^(NSError * _Nonnull error) {
- [self removehub];
- }];
- }
- - (void)evaluateSource:(NSArray *)musicArray {
- NSMutableArray *source = [NSMutableArray array];
- for (NSDictionary *dic in musicArray) {
- RecentPracticeModel *model = [[RecentPracticeModel alloc] initWithDictionary:dic];
- [source addObject:model];
- }
- MJWeakSelf;
- [self.bodyView configUserMessage:self.userInfo musicArray:source callback:^(NSString *songId) {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/music-detail?id=",songId];
- [weakSelf.navigationController pushViewController:ctrl animated:YES];
- }];
- }
- #pragma mark ----- lazying
- - (UserDetailNavView *)navView {
- if (!_navView) {
- _navView = [UserDetailNavView shareInstance];
- MJWeakSelf;
- [_navView navAction:^{
- [weakSelf backAction];
- }];
- }
- return _navView;
- }
- - (UserDetailBodyView *)bodyView {
- if (!_bodyView) {
- _bodyView = [UserDetailBodyView shareInstance];
-
- }
- return _bodyView;
- }
- - (UserDetailBottomView *)bottomView {
- if (!_bottomView) {
- _bottomView = [UserDetailBottomView shareInstance];
- }
- return _bottomView;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|