CNLiveBindingTelController.m 4.76 KB
//
//  CNLiveBindingTelController.m
//  CNLiveBLoginModule
//
//  Created by CNLive-zxw on 2019/9/9.
//  Copyright © 2019 153993236@qq.com. All rights reserved.
//

#import "CNLiveBindingTelController.h"

#import "YYKit.h"
#import "NSAttributedString+YYText.h"
#import "QMUIKit.h"
#import "CNLiveEnvironment.h"
#import "CNLiveUserAgreementManager.h"

#import "CNLiveNavigationBar.h"
#import "CNLiveBindingTelView.h"

@interface CNLiveBindingTelController()<CNLiveBindingTelViewDelegate>
@property (nonatomic, assign) CNLiveThreeLoginType type;
@property (nonatomic, strong) CNLiveNavigationBar *navigationBar;

@property (nonatomic, strong) CNLiveBindingTelView *bindingTelView;
@property (nonatomic, strong) YYLabel *protocol;

@end

@implementation CNLiveBindingTelController
- (instancetype)initWithModel:(CNLiveThreeLoginModel *)model {
    self = [super init];
    if (self) {
        self.model = model;
    }
    return self;

}
#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.navigationController.navigationBar.translucent = NO;
    self.extendedLayoutIncludesOpaqueBars = YES;
    self.edgesForExtendedLayout = UIRectEdgeBottom;
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.navigationBar];
    [self.view addSubview:self.bindingTelView];
    [self.view addSubview:self.protocol];
}

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

#pragma mark - CNLiveBindingTelViewDelegate
- (void)bindingSuccess:(CNLiveBindingTelView *)view type:(CNLiveThreeLoginType)type{

}

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

- (CNLiveBindingTelView *)bindingTelView {
    if (!_bindingTelView) {
        _bindingTelView = [[CNLiveBindingTelView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/8.0, NavigationContentTop, self.view.frame.size.width*3/4.0, 400) type:self.type];
        _bindingTelView.delegate = self;
    }
    return _bindingTelView;
}

- (YYLabel *)protocol {
    if (!_protocol) {
        _protocol = [[YYLabel alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height-30-NavigationContentTop-SafeAreaInsetsConstantForDeviceWithNotch.bottom, self.view.frame.size.width, 30)];
        _protocol.textAlignment = NSTextAlignmentCenter;
        _protocol.textColor = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
        _protocol.font = [UIFont systemFontOfSize:14.0];
        NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"已阅读并同意《账户绑定确认书(网家家)》"];
        NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
        style.alignment = NSTextAlignmentCenter;//对齐方式
        [text addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text.length)];
        text.color = [UIColor colorWithRed:173/255.0 green:173/255.0 blue:173/255.0 alpha:1.0];
        text.font = [UIFont systemFontOfSize:14.0];
        __weak typeof(self) weakSelf = self;
        UIColor *color = BusinessLive?[UIColor colorWithRed:72/255.0 green:168/255.0 blue:249/255.0 alpha:1.0]:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
        [text setTextHighlightRange:NSMakeRange(7, 12) color:color backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
            __strong typeof(weakSelf) strongSelf = weakSelf;
            if(!strongSelf) return;
            [strongSelf.view endEditing:YES];
            [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementUser];

        }];
        _protocol.attributedText = text;
    
    }
    return _protocol;
}

@end