CNLiveCompleteInfoController.m 3.64 KB
//
//  CNLiveCompleteInfoController.m
//  CNLiveLoginModule
//
//  Created by 153993236@qq.com on 11/12/2019.
//  Copyright (c) 2019 153993236@qq.com. All rights reserved.
//

#import "CNLiveCompleteInfoController.h"

#import "MJExtension.h"
#import "QMUIKit.h"
#import "YYKit.h"

#import "CNLiveNavigationBar.h"
#import "CNLiveCategory.h"
#import "CNUserInfoManager.h"
#import "CNLiveEnvironment.h"
#import "CNLiveManager.h"

#import "CNLiveCompleteInfoView.h"
#import "CNLiveLoginRequest.h"

@interface CNLiveCompleteInfoController()<CNLiveCompleteInfoViewDelegate>
@property (nonatomic, strong) CNLiveCompleteInfoView *infoView;
@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;

@end

@implementation CNLiveCompleteInfoController
#pragma mark - 生命周期
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    [self createUI];
}

- (void)createUI{
    [self.view addSubview:self.navigationBar];
    [self.view addSubview:self.infoView];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:YES];
}

#pragma mark - CNLiveCompleteInfoViewDelegate
- (void)loginSuccess:(CNLiveCompleteInfoView *)view result:(id _Nonnull)result{
    // 进入tabbar
    
}

/*
#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.
}
*/

#pragma mark - 懒加载
- (CNLiveNavigationBar *)navigationBar {
    if (!_navigationBar) {
        _navigationBar = [CNLiveNavigationBar navigationBar];
        _navigationBar.backgroundColor = [UIColor whiteColor];
        _navigationBar.title.text = @"完善信息";
        __weak typeof(self) weakSelf = self;
        _navigationBar.onClickLeftButton = ^{
            [weakSelf.navigationController popViewControllerAnimated:YES];
        };
        _navigationBar.right = nil;
    }
    return _navigationBar;
}

- (CNLiveCompleteInfoView *)infoView{
    if(!_infoView){
        _infoView = [[CNLiveCompleteInfoView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/8.0, NavigationContentTop+40, self.view.frame.size.width*3/4.0, 250)];
        _infoView.center = CGPointMake(self.view.center.x, self.view.center.y-50);
        _infoView.delegate = self;
    }
    return _infoView;
}

#pragma mark - 连接IM
- (void)connectionIM:(id)result{
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]];
    NSString *faceUrl = [dic objectForKey:@"faceUrl"];
    if ([faceUrl containsString:@"/mobile/images/mobilehead/default/"]) {
        //网家家默认头像地址
        [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"];
    }
    [CNUserInfoManager saveUserinfoDic:dic];

    // 连接IM
    __weak typeof(self) weakSelf = self;
    [[CNLiveLoginRequest manager] loginTIM:CNUserShareModel.uid success:^{
        __strong typeof(weakSelf) strongSelf = weakSelf;
        if(!strongSelf) return;
        // 进入tabbar
        [CNLiveNotificationManager postNotificationName:CNLiveLoginSuccess object:nil];

    } failed:^(int code, NSString * _Nonnull msg) {
        // 错误逻辑
        __strong typeof(weakSelf) strongSelf = weakSelf;
        if(!strongSelf) return;

    }];
}

@end