Commit 2062d29622ae36b0795b6c5ba656f719395344bf
1 parent
946e033e
no message
Showing
2 changed files
with
0 additions
and
718 deletions
CNLiveBLoginModule/Classes/View/CNLiveLoginTipsView.h deleted
100644 → 0
| 1 | -// | ||
| 2 | -// CNLiveLoginTipsView.h | ||
| 3 | -// CNLiveLoginModule | ||
| 4 | -// | ||
| 5 | -// Created by CNLive-zxw on 2019/11/11. | ||
| 6 | -// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | -// | ||
| 8 | - | ||
| 9 | -#import <UIKit/UIKit.h> | ||
| 10 | - | ||
| 11 | -NS_ASSUME_NONNULL_BEGIN | ||
| 12 | - | ||
| 13 | -@interface CNLiveLoginTipsView : UIView | ||
| 14 | - | ||
| 15 | -+ (void)showCenterLoginViewWithVC:(UIViewController *)controller; | ||
| 16 | -+ (void)hide; | ||
| 17 | - | ||
| 18 | -@end | ||
| 19 | - | ||
| 20 | -NS_ASSUME_NONNULL_END |
CNLiveBLoginModule/Classes/View/CNLiveLoginTipsView.m deleted
100644 → 0
| 1 | -// | ||
| 2 | -// CNLiveLoginTipsView.m | ||
| 3 | -// CNLiveLoginModule | ||
| 4 | -// | ||
| 5 | -// Created by CNLive-zxw on 2019/11/11. | ||
| 6 | -// Copyright © 2019 cnlive. All rights reserved. | ||
| 7 | -// | ||
| 8 | - | ||
| 9 | -#import "CNLiveLoginTipsView.h" | ||
| 10 | -#import "CNLiveLoginTextField.h" | ||
| 11 | -#import "NSString+CNLiveExtension.h" | ||
| 12 | -#import "NSString+Category.h" | ||
| 13 | -#import "CNLiveUserAgreementManager.h" | ||
| 14 | -#import "CNLiveCategory.h" | ||
| 15 | - | ||
| 16 | -#import "MJExtension.h" | ||
| 17 | -#import "QMUIKit.h" | ||
| 18 | -#import "YYKit.h" | ||
| 19 | -#import "TIMAdapter.h" | ||
| 20 | -#import "CommonLibrary.h" | ||
| 21 | -#import <Masonry/Masonry.h> | ||
| 22 | - | ||
| 23 | -//#import "CNNavigationController.h" | ||
| 24 | -#import "CNLiveChooseCountryController.h" | ||
| 25 | -#import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h> | ||
| 26 | -#import <CNLiveUserSystemSDK/CNLiveUserSystemTypeDef.h> | ||
| 27 | -#import "CNUserInfoManager.h" | ||
| 28 | -#import "CNLiveEnvironment.h" | ||
| 29 | - | ||
| 30 | - | ||
| 31 | -#import "CNLiveThreeLoginView.h" | ||
| 32 | - | ||
| 33 | - | ||
| 34 | -//三方登录 | ||
| 35 | -//#import "CNThreeLoginViewController.h" | ||
| 36 | -//#import "CNLiveShareImageManager.h" | ||
| 37 | -//#import "CNThreeLoginModel.h" | ||
| 38 | -//#import "CNBindingManageRequest.h" | ||
| 39 | -//#import "NSObject+TransformModel.h" | ||
| 40 | -//#import "CNShareExtensionGroup.h" | ||
| 41 | -//#import "CNLoginIUsernfoViewController.h" | ||
| 42 | - | ||
| 43 | -@interface CNLiveLoginTipsView()<UITextFieldDelegate,ChooseCountriesDelegate,CNLiveThreeLoginViewDelegate>{ | ||
| 44 | - dispatch_source_t _timer; | ||
| 45 | - NSString * _codeStr; | ||
| 46 | - NSString * _countryStr; | ||
| 47 | -} | ||
| 48 | -@property (nonatomic, strong) IMALoginParam *loginParam; | ||
| 49 | - | ||
| 50 | -@property (nonatomic, strong) UIImageView *whiteView; | ||
| 51 | -@property (nonatomic, strong) UIButton *close; | ||
| 52 | - | ||
| 53 | -@property (nonatomic, strong) QMUILabel *countryLbl; | ||
| 54 | -@property (nonatomic, strong) UIButton *countryBtn; | ||
| 55 | -@property (nonatomic, strong) UIView *line; | ||
| 56 | - | ||
| 57 | -@property (nonatomic, strong) CNLiveLoginTextField *telTF; | ||
| 58 | -@property (nonatomic, strong) CNLiveLoginTextField *codeTF; | ||
| 59 | -@property (nonatomic, strong) UIButton *codeBtn; | ||
| 60 | -@property (nonatomic, strong) YYLabel *protocolLab; | ||
| 61 | -@property (nonatomic, strong) UIButton *login; | ||
| 62 | -@property (nonatomic, strong) CNLiveThreeLoginView *threeLoginView; | ||
| 63 | -@property (nonatomic, strong) CNLiveLoginTipsView *loginView; | ||
| 64 | - | ||
| 65 | -@end | ||
| 66 | - | ||
| 67 | -@implementation CNLiveLoginTipsView | ||
| 68 | -#define XWKeyWindow [UIApplication sharedApplication].keyWindow | ||
| 69 | - | ||
| 70 | -static const CGFloat rowHeight = 30; | ||
| 71 | -static const CGFloat margin = 15; | ||
| 72 | - | ||
| 73 | -#pragma mark - 单例 | ||
| 74 | -+ (instancetype)manager { | ||
| 75 | - static CNLiveLoginTipsView *_singleton = nil; | ||
| 76 | - static dispatch_once_t onceToken; | ||
| 77 | - dispatch_once(&onceToken, ^{ | ||
| 78 | - //不能再使用alloc方法 | ||
| 79 | - //因为已经重写了allocWithZone方法,所以这里要调用父类的分配空间的方法 | ||
| 80 | - _singleton = [[super allocWithZone:NULL] init]; | ||
| 81 | - }); | ||
| 82 | - return _singleton; | ||
| 83 | - | ||
| 84 | -} | ||
| 85 | - | ||
| 86 | -+ (void)showCenterLoginViewWithVC:(UIViewController *)controller { | ||
| 87 | - [CNLiveLoginTipsView manager].loginView = [[CNLiveLoginTipsView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]; | ||
| 88 | - [CNLiveLoginTipsView manager].loginView.backgroundColor = [UIColor colorWithWhite:0.2f alpha:0.4f]; | ||
| 89 | - [controller.view addSubview:[CNLiveLoginTipsView manager].loginView]; | ||
| 90 | -} | ||
| 91 | - | ||
| 92 | -#pragma mark - Init | ||
| 93 | -- (instancetype)initWithFrame:(CGRect)frame{ | ||
| 94 | - if(self = [super initWithFrame:frame]){ | ||
| 95 | - _codeStr = @"86"; | ||
| 96 | - _countryStr = @"中国大陆"; | ||
| 97 | - | ||
| 98 | - BOOL isAutoLogin = [IMAPlatform isAutoLogin]; | ||
| 99 | - if (isAutoLogin) { | ||
| 100 | - _loginParam = [IMALoginParam loadFromLocal]; | ||
| 101 | - | ||
| 102 | - } else { | ||
| 103 | - _loginParam = [[IMALoginParam alloc] init]; | ||
| 104 | - | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - [IMAPlatform configWith:_loginParam.config]; | ||
| 108 | - [self setUpUI]; | ||
| 109 | -// UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(closeBtn:)]; | ||
| 110 | -// [self addGestureRecognizer:tap]; | ||
| 111 | - | ||
| 112 | - } | ||
| 113 | - return self; | ||
| 114 | - | ||
| 115 | -} | ||
| 116 | -#pragma mark - UI | ||
| 117 | -- (void)setUpUI{ | ||
| 118 | - [self addSubview:self.whiteView]; | ||
| 119 | - [self addSubview:self.close]; | ||
| 120 | - | ||
| 121 | - [self addSubview:self.countryLbl]; | ||
| 122 | - [self addSubview:self.countryBtn]; | ||
| 123 | - [self addSubview:self.line]; | ||
| 124 | - | ||
| 125 | - [self addSubview:self.telTF]; | ||
| 126 | - [self addSubview:self.codeTF]; | ||
| 127 | - [self addSubview:self.codeBtn]; | ||
| 128 | - | ||
| 129 | - [self addSubview:self.login]; | ||
| 130 | - [self addSubview:self.threeLoginView]; | ||
| 131 | - [self addSubview:self.protocolLab]; | ||
| 132 | - [self.protocolLab mas_makeConstraints:^(MASConstraintMaker *make) { | ||
| 133 | - make.top.mas_equalTo(self.threeLoginView.mas_bottom).mas_offset(0); | ||
| 134 | - make.bottom.mas_equalTo(self.whiteView.mas_bottom).mas_offset(-0); | ||
| 135 | - make.left.mas_equalTo(self.countryLbl.mas_left).mas_offset(0); | ||
| 136 | - make.right.mas_equalTo(self.countryBtn.mas_right).mas_offset(-0); | ||
| 137 | - | ||
| 138 | - }]; | ||
| 139 | - | ||
| 140 | -} | ||
| 141 | -- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { | ||
| 142 | - [self endEditing:YES]; | ||
| 143 | -} | ||
| 144 | - | ||
| 145 | -#pragma mark - UITextFieldDelegate | ||
| 146 | -- (void)textFieldDidChange:(UITextField *)textField { | ||
| 147 | - if (![NSString isEmpty:_telTF.text] && ![NSString isEmpty:_codeTF.text]) { | ||
| 148 | - _login.enabled = YES; | ||
| 149 | - | ||
| 150 | - } | ||
| 151 | - else { | ||
| 152 | - _login.enabled = NO; | ||
| 153 | - | ||
| 154 | - } | ||
| 155 | - | ||
| 156 | -} | ||
| 157 | - | ||
| 158 | -- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { | ||
| 159 | - if ([textField isEqual:self.telTF]) { | ||
| 160 | - NSInteger maxTextLength = 20; | ||
| 161 | - if(string.length == 0) { | ||
| 162 | - //判断是不是删除键 | ||
| 163 | - return YES; | ||
| 164 | - } | ||
| 165 | - else if(textField.text.length >= maxTextLength) { | ||
| 166 | - //输入的字符个数大于11,则无法继续输入,返回NO表示禁止输入 | ||
| 167 | - NSLog(@"输入的字符个数大于20,忽略输入"); | ||
| 168 | - return NO; | ||
| 169 | - } | ||
| 170 | -// else if (!CNLiveStringIsNumber(string)) { | ||
| 171 | -// //string复制的可能为特殊字符,过滤 | ||
| 172 | -// return NO; | ||
| 173 | -// } | ||
| 174 | - else if (textField.text.length + string.length > maxTextLength){ | ||
| 175 | - NSInteger length = textField.text.length; | ||
| 176 | - NSInteger needLen = maxTextLength - length; | ||
| 177 | - textField.text = [textField.text stringByAppendingString:[string substringToIndex:needLen]]; | ||
| 178 | - return NO; | ||
| 179 | - } | ||
| 180 | - else{ | ||
| 181 | - return YES; | ||
| 182 | - } | ||
| 183 | - }else if ([textField isEqual:self.codeTF]){ | ||
| 184 | - NSInteger maxTextLength = 6; | ||
| 185 | - if(string.length == 0) { | ||
| 186 | - //判断是不是删除键 | ||
| 187 | - return YES; | ||
| 188 | - } | ||
| 189 | - else if(textField.text.length >= maxTextLength) { | ||
| 190 | - //输入的字符个数大于6,则无法继续输入,返回NO表示禁止输入 | ||
| 191 | - return NO; | ||
| 192 | - } | ||
| 193 | -// else if (!CNLiveStringIsNumber(string)) { | ||
| 194 | -// //string复制的可能为特殊字符,过滤 | ||
| 195 | -// return NO; | ||
| 196 | -// } | ||
| 197 | - else if (textField.text.length + string.length > maxTextLength){ | ||
| 198 | - //如果textF.text + string > 6 截取6位 | ||
| 199 | -#warning 有个问题,光标没有及时更新到最后一位 | ||
| 200 | - NSInteger length = textField.text.length; | ||
| 201 | - NSInteger needLen = maxTextLength - length; | ||
| 202 | - textField.text = [textField.text stringByAppendingString:[string substringToIndex:needLen]]; | ||
| 203 | - return NO; | ||
| 204 | - } | ||
| 205 | - else{ | ||
| 206 | - return YES; | ||
| 207 | - } | ||
| 208 | - }else | ||
| 209 | - { | ||
| 210 | - return YES; | ||
| 211 | - } | ||
| 212 | -} | ||
| 213 | -/* | ||
| 214 | -// Only override drawRect: if you perform custom drawing. | ||
| 215 | -// An empty implementation adversely affects performance during animation. | ||
| 216 | -- (void)drawRect:(CGRect)rect { | ||
| 217 | - // Drawing code | ||
| 218 | -} | ||
| 219 | -*/ | ||
| 220 | -#pragma mark - Lazy Loading | ||
| 221 | -- (UIImageView *)whiteView{ | ||
| 222 | - if (!_whiteView) { | ||
| 223 | - _whiteView = [[UIImageView alloc] initWithFrame:CGRectMake(([UIScreen mainScreen].bounds.size.width-287)/2.0, ([UIScreen mainScreen].bounds.size.height-396)/2.0, 287, 396)]; | ||
| 224 | - _whiteView.image = [UIImage imageNamed:@"tourists_login_bg"]; | ||
| 225 | - } | ||
| 226 | - return _whiteView; | ||
| 227 | -} | ||
| 228 | - | ||
| 229 | -- (UIButton *)close{ | ||
| 230 | - if (!_close) { | ||
| 231 | - _close = [[UIButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_whiteView.frame)-25-10, CGRectGetMinY(_whiteView.frame)+10, 25, 25)]; | ||
| 232 | - [_close setImage:[UIImage imageNamed:@"tourists_login_close"] forState:UIControlStateNormal]; | ||
| 233 | - [_close addTarget:self action:@selector(closeBtn:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 234 | - } | ||
| 235 | - return _close; | ||
| 236 | -} | ||
| 237 | - | ||
| 238 | -- (QMUILabel *)countryLbl{ | ||
| 239 | - if (!_countryLbl){ | ||
| 240 | - _countryLbl = [[QMUILabel alloc] initWithFrame:CGRectMake(_whiteView.left+margin, _whiteView.top+100, 80, rowHeight)]; | ||
| 241 | - [_countryLbl setFont:UIFontMake(13)]; | ||
| 242 | - _countryLbl.textColor = [UIColor colorWithRed:49/255.0 green:49/255.0 blue:49/255.0 alpha:1.0]; | ||
| 243 | - _countryLbl.text = _countryStr; | ||
| 244 | - _countryLbl.userInteractionEnabled = YES; | ||
| 245 | - } | ||
| 246 | - return _countryLbl; | ||
| 247 | -} | ||
| 248 | - | ||
| 249 | -- (UIButton *)countryBtn{ | ||
| 250 | - if (!_countryBtn){ | ||
| 251 | - _countryBtn = [[UIButton alloc]initWithFrame:CGRectMake(kScreenWidth-_whiteView.left-15-70, _countryLbl.top, 70, _countryLbl.height)]; | ||
| 252 | - _countryBtn.titleLabel.font = UIFontMake(13); | ||
| 253 | - [_countryBtn setTitleColor:[UIColor colorWithRed:49/255.0 green:49/255.0 blue:49/255.0 alpha:1.0] forState:UIControlStateNormal]; | ||
| 254 | - [_countryBtn setTitle:[NSString stringWithFormat:@"+%@", _codeStr] forState:UIControlStateNormal]; | ||
| 255 | - UIImage *image = [self getImageWithImageName:@"login_country" bundleName:@"CNLiveBLoginModule" targetClass:[self class]]; | ||
| 256 | - [_countryBtn setImage:image forState:UIControlStateNormal]; | ||
| 257 | - [_countryBtn addTarget:self action:@selector(countryBtn:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 258 | - _countryBtn.userInteractionEnabled = YES; | ||
| 259 | - //button图片的偏移量,距上左下右分别(0, 0, 0, 0)像素点 | ||
| 260 | - _countryBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 60, 0, 0); | ||
| 261 | - //button标题的偏移量,这个偏移量是相对于图片的 | ||
| 262 | - _countryBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 10); | ||
| 263 | - } | ||
| 264 | - return _countryBtn; | ||
| 265 | -} | ||
| 266 | -- (UIView *)line{ | ||
| 267 | - if(!_line){ | ||
| 268 | - _line = [[UIView alloc] initWithFrame:CGRectMake(_countryLbl.left, _countryBtn.bottom, KScreenWidth - (2*_countryLbl.left), 0.5)]; | ||
| 269 | - _line.backgroundColor = [UIColor colorWithRed:235/255.0 green:235/255.0 blue:235/255.0 alpha:1.0]; | ||
| 270 | - } | ||
| 271 | - return _line; | ||
| 272 | -} | ||
| 273 | -- (CNLiveLoginTextField *)telTF{ | ||
| 274 | - if (!_telTF) { | ||
| 275 | - _telTF = [[CNLiveLoginTextField alloc] initWithFrame:CGRectMake(_countryLbl.left, _countryLbl.bottom + margin, KScreenWidth - (2*_countryLbl.left), rowHeight)]; | ||
| 276 | - _telTF.placeholderColor = KGray173Color; | ||
| 277 | - _telTF.textColor = [UIColor blackColor]; | ||
| 278 | - _telTF.keyboardType = UIKeyboardTypeNumberPad; | ||
| 279 | - _telTF.placeholder = @"请输入手机号号码"; | ||
| 280 | - _telTF.font = UIFontMake(13); | ||
| 281 | - _telTF.clearButtonMode = UITextFieldViewModeAlways; | ||
| 282 | - _telTF.textAlignment = NSTextAlignmentLeft; | ||
| 283 | - [_telTF addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; | ||
| 284 | - _telTF.delegate = self; | ||
| 285 | - } | ||
| 286 | - return _telTF; | ||
| 287 | -} | ||
| 288 | -- (CNLiveLoginTextField *)codeTF { | ||
| 289 | - if (!_codeTF) { | ||
| 290 | - _codeTF = [[CNLiveLoginTextField alloc] initWithFrame:CGRectMake(_telTF.left, _telTF.bottom + margin, 120, _telTF.height)]; | ||
| 291 | - _codeTF.keyboardType = UIKeyboardTypeNumberPad; | ||
| 292 | - _codeTF.placeholder = @"请输入验证码"; | ||
| 293 | - _codeTF.textColor = [UIColor blackColor]; | ||
| 294 | - _codeTF.placeholderColor = KGray173Color; | ||
| 295 | - _codeTF.font = UIFontMake(13); | ||
| 296 | - _codeTF.textAlignment = NSTextAlignmentLeft; | ||
| 297 | - [_codeTF addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; | ||
| 298 | - _codeTF.clearButtonMode = UITextFieldViewModeWhileEditing; | ||
| 299 | - _codeTF.delegate = self; | ||
| 300 | - } | ||
| 301 | - return _codeTF; | ||
| 302 | -} | ||
| 303 | -- (UIButton *)codeBtn{ | ||
| 304 | - if (!_codeBtn) { | ||
| 305 | - _codeBtn = [[UIButton alloc]initWithFrame:CGRectMake(kScreenWidth-_whiteView.left-margin-58, _codeTF.top+(rowHeight-22)/2.0, 58, 22)]; | ||
| 306 | - _codeBtn.titleLabel.font = [UIFont systemFontOfSize:10.0]; | ||
| 307 | - [_codeBtn setBackgroundImage:[UIImage imageNamed:@"dl_yzman"] forState:UIControlStateNormal]; | ||
| 308 | - [_codeBtn setTitleColor:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0] forState:UIControlStateNormal]; | ||
| 309 | - [_codeBtn setBackgroundImage:nil forState:UIControlStateSelected]; | ||
| 310 | - [_codeBtn setTitleColor:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0] forState:UIControlStateSelected]; | ||
| 311 | - [_codeBtn addTarget:self action:@selector(codeBtn:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 312 | - [_codeBtn setAdjustsImageWhenHighlighted:NO]; | ||
| 313 | - } | ||
| 314 | - return _codeBtn; | ||
| 315 | -} | ||
| 316 | -- (UIButton *)login{ | ||
| 317 | - if (!_login) { | ||
| 318 | - _login = [[UIButton alloc]initWithFrame:CGRectMake(([UIScreen mainScreen].bounds.size.width-180)/2.0, _codeTF.bottom + margin, 180, rowHeight)]; | ||
| 319 | - _login.backgroundColor = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0]; | ||
| 320 | - _login.titleLabel.font = [UIFont systemFontOfSize:14.0]; | ||
| 321 | - _login.layer.cornerRadius = 15; | ||
| 322 | - _login.layer.masksToBounds = YES; | ||
| 323 | - [_login setTitle:@"登录" forState:UIControlStateNormal]; | ||
| 324 | - [_login setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | ||
| 325 | - [_login addTarget:self action:@selector(loginBtn:) forControlEvents:UIControlEventTouchUpInside]; | ||
| 326 | - } | ||
| 327 | - return _login; | ||
| 328 | -} | ||
| 329 | - | ||
| 330 | -- (CNLiveThreeLoginView *)threeLoginView{ | ||
| 331 | - if (!_threeLoginView) { | ||
| 332 | - _threeLoginView = [[CNLiveThreeLoginView alloc]initWithFrame:CGRectMake(_whiteView.left, _login.bottom+margin, _whiteView.width, 80)]; | ||
| 333 | - _threeLoginView.delegate = self; | ||
| 334 | - } | ||
| 335 | - return _threeLoginView; | ||
| 336 | -} | ||
| 337 | - | ||
| 338 | -- (YYLabel *)protocolLab { | ||
| 339 | - if (!_protocolLab) { | ||
| 340 | - _protocolLab = [[YYLabel alloc] init]; | ||
| 341 | - _protocolLab.textAlignment = NSTextAlignmentCenter; | ||
| 342 | - | ||
| 343 | - NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"登录即代表阅读并同意《用户协议》及《隐私政策》"]; | ||
| 344 | - NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; | ||
| 345 | - style.alignment = NSTextAlignmentCenter;//对齐方式 | ||
| 346 | - [text addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text.length)]; | ||
| 347 | - | ||
| 348 | - text.color = UIColorMake(201, 202, 203); | ||
| 349 | - text.font = UIFontMake(10); | ||
| 350 | - | ||
| 351 | - __weak typeof(self) weakSelf = self; | ||
| 352 | - [text setTextHighlightRange:NSMakeRange(11, 4) color:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0] backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) { | ||
| 353 | - [weakSelf endEditing:YES]; | ||
| 354 | - [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementUser]; | ||
| 355 | - }]; | ||
| 356 | - [text setTextHighlightRange:NSMakeRange(text.length-5, 4) color:[UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0] backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) { | ||
| 357 | - [weakSelf endEditing:YES]; | ||
| 358 | - [CNLiveUserAgreementManager jumpToAgreementH5WithType:CNLiveUserAgreementPrivacy]; | ||
| 359 | - }]; | ||
| 360 | - | ||
| 361 | - _protocolLab.attributedText = text; | ||
| 362 | - | ||
| 363 | - } | ||
| 364 | - | ||
| 365 | - | ||
| 366 | - return _protocolLab; | ||
| 367 | -} | ||
| 368 | - | ||
| 369 | - | ||
| 370 | -#pragma mark - Action | ||
| 371 | -//点击✘按钮调用方法 | ||
| 372 | -- (void)closeBtn:(UIButton *)btn { | ||
| 373 | - [[CNLiveLoginTipsView manager].loginView removeFromSuperview]; | ||
| 374 | -} | ||
| 375 | - | ||
| 376 | -+ (void)hide { | ||
| 377 | - [[CNLiveLoginTipsView manager].loginView removeFromSuperview]; | ||
| 378 | -} | ||
| 379 | -- (void)codeBtn:(UIButton *)btn { | ||
| 380 | -// [CNTools setFrmId]; | ||
| 381 | - if ([self.telTF.text isEqualToString:@""]) { | ||
| 382 | - [QMUITips showWithText:@"请输入手机号" inView:XWKeyWindow hideAfterDelay:1.5]; | ||
| 383 | - [self cancelVerBtnChange]; | ||
| 384 | - return; | ||
| 385 | - } | ||
| 386 | - | ||
| 387 | - [_codeTF becomeFirstResponder]; | ||
| 388 | - _codeTF.text = nil; | ||
| 389 | - _codeBtn.userInteractionEnabled = NO; | ||
| 390 | - [QMUITips showLoadingInView:XWKeyWindow]; | ||
| 391 | - [CNLiveUserSystemCenter verificationCodeType:VerificationCodeTypeShortcutLogin mobile:_telTF.text countryCode:_codeStr success:^(id result) { | ||
| 392 | - _codeBtn.selected = YES; | ||
| 393 | - [self startTimer];//倒计时结束,打开交互性 | ||
| 394 | - [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; | ||
| 395 | - [QMUITips showWithText:@"验证码已发送" inView:XWKeyWindow hideAfterDelay:1.5]; | ||
| 396 | - | ||
| 397 | - } failure:^(NSDictionary *errorDic) { | ||
| 398 | - [QMUITips hideAllToastInView:XWKeyWindow animated:YES]; | ||
| 399 | - if ([errorDic[@"errorCode"] integerValue] == 408) { | ||
| 400 | - [QMUITips showError:@"请输入正确的手机号" inView:XWKeyWindow hideAfterDelay:1.5]; | ||
| 401 | - | ||
| 402 | - }else{ | ||
| 403 | - [QMUITips showError:errorDic[@"errorMessage"] inView:XWKeyWindow hideAfterDelay:1.5]; | ||
| 404 | - } | ||
| 405 | - [self cancelVerBtnChange];//请求失败,复原按钮,打开交互性 | ||
| 406 | - | ||
| 407 | - }]; | ||
| 408 | - | ||
| 409 | -} | ||
| 410 | -#pragma mark - 倒计时 | ||
| 411 | -//恢复原状 | ||
| 412 | -- (void)cancelVerBtnChange { | ||
| 413 | - dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 414 | - _codeBtn.selected = NO; | ||
| 415 | - [_codeBtn setTitle:@"" forState:UIControlStateNormal]; | ||
| 416 | - [_codeBtn setBackgroundImage:[UIImage imageNamed:@"dl_yzman"] forState:UIControlStateNormal]; | ||
| 417 | - //设置界面的按钮显示 | ||
| 418 | - _codeBtn.layer.borderWidth = 0; | ||
| 419 | - _codeBtn.userInteractionEnabled = YES; | ||
| 420 | - }); | ||
| 421 | - if (_timer) { | ||
| 422 | - dispatch_source_cancel(_timer);//取消定时器 | ||
| 423 | - } | ||
| 424 | -} | ||
| 425 | - | ||
| 426 | -//开始倒计时 | ||
| 427 | -- (void)startTimer { | ||
| 428 | - __block int timeout = 60; //倒计时时间 | ||
| 429 | - | ||
| 430 | - dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | ||
| 431 | - | ||
| 432 | - _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue); | ||
| 433 | - | ||
| 434 | - dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行 | ||
| 435 | - | ||
| 436 | - dispatch_source_set_event_handler(_timer, ^{ | ||
| 437 | - | ||
| 438 | - if(timeout<=0){ //倒计时结束,关闭 | ||
| 439 | - | ||
| 440 | - dispatch_source_cancel(_timer); | ||
| 441 | - | ||
| 442 | - dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 443 | - _codeBtn.selected = NO; | ||
| 444 | - [_codeBtn setTitle:@"" forState:UIControlStateNormal]; | ||
| 445 | - [_codeBtn setBackgroundImage:[UIImage imageNamed:@"dl_yzman"] forState:UIControlStateNormal]; | ||
| 446 | - //设置界面的按钮显示 根据自己需求设置 | ||
| 447 | - _codeBtn.layer.borderWidth = 0; | ||
| 448 | - _codeBtn.userInteractionEnabled = YES; | ||
| 449 | - | ||
| 450 | - }); | ||
| 451 | - | ||
| 452 | - }else{ | ||
| 453 | - | ||
| 454 | - int seconds = timeout % 60; | ||
| 455 | - NSString *strTime = [NSString stringWithFormat:@"%.2d", seconds]; | ||
| 456 | - | ||
| 457 | - if(seconds == 0)strTime = [NSString stringWithFormat:@"%d",timeout]; | ||
| 458 | - dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 459 | - //设置界面的按钮显示 根据自己需求设置 | ||
| 460 | - _codeBtn.selected = YES; | ||
| 461 | - [_codeBtn setBackgroundImage:nil forState:UIControlStateNormal]; | ||
| 462 | - [_codeBtn setTitle:[NSString stringWithFormat:@"%@s",strTime] forState:UIControlStateSelected]; | ||
| 463 | - _codeBtn.layer.borderColor = UIColorMake(89, 210, 75).CGColor; | ||
| 464 | - _codeBtn.layer.borderWidth = 1; | ||
| 465 | - _codeBtn.layer.masksToBounds = YES; | ||
| 466 | - _codeBtn.layer.cornerRadius = 11.0; | ||
| 467 | - _codeBtn.userInteractionEnabled = NO; | ||
| 468 | - }); | ||
| 469 | - timeout--; | ||
| 470 | - | ||
| 471 | - } | ||
| 472 | - }); | ||
| 473 | - | ||
| 474 | - dispatch_resume(_timer); | ||
| 475 | -} | ||
| 476 | - | ||
| 477 | -- (void)countryBtn:(UIButton *)btn { | ||
| 478 | - UIViewController *root = [UIApplication sharedApplication].delegate.window.rootViewController; | ||
| 479 | - CNLiveChooseCountryController *vc = [[CNLiveChooseCountryController alloc] init]; | ||
| 480 | - vc.delegate = self; | ||
| 481 | - vc.modalPresentationStyle = UIModalPresentationFullScreen; | ||
| 482 | - [root presentViewController:vc animated:YES completion:nil]; | ||
| 483 | - | ||
| 484 | -} | ||
| 485 | -#pragma mark - CNLiveSelectCountryViewDelegate | ||
| 486 | -- (void)chooseViewController:(CNLiveChooseCountryController *)controller countryName:(NSString *)countryName countryCode:(NSString *)countryCode{ | ||
| 487 | - _countryLbl.text = countryName; | ||
| 488 | - _countryStr = countryName; | ||
| 489 | - [_countryBtn setTitle:[NSString stringWithFormat:@"+%@",countryCode] forState:UIControlStateNormal]; | ||
| 490 | - _codeStr = countryCode; | ||
| 491 | - NSLog(@"%@---%@",countryName,countryCode); | ||
| 492 | - | ||
| 493 | -} | ||
| 494 | - | ||
| 495 | -- (void)loginBtn:(UIButton *)btn { | ||
| 496 | - if ([_telTF.text isEqualToString:@""]) { | ||
| 497 | - [QMUITips showWithText:@"请输入手机号" inView:XWKeyWindow hideAfterDelay:1.5]; | ||
| 498 | - return; | ||
| 499 | - } | ||
| 500 | - | ||
| 501 | - if ([_codeTF.text isEqualToString:@""]) { | ||
| 502 | - [QMUITips showWithText:@"请输入验证码" inView:XWKeyWindow hideAfterDelay:1.5]; | ||
| 503 | - return; | ||
| 504 | - } | ||
| 505 | - | ||
| 506 | - [self endEditing:YES]; | ||
| 507 | - | ||
| 508 | - [QMUITips showLoading:@"登录中" inView:XWKeyWindow]; | ||
| 509 | - | ||
| 510 | - __weak typeof(self) weakSelf = self; | ||
| 511 | -// [CNLiveUserSystemCenter shortcutLoginWithUserName:_telTF.text countryCode:_codeStr verificationCode:_codeTF.text frmId:[CNTools getFrmId] success:^(id result) { | ||
| 512 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | ||
| 513 | -// if(!strongSelf) return; | ||
| 514 | -// // 连接IM | ||
| 515 | -// [strongSelf connectionIM:result]; | ||
| 516 | -// | ||
| 517 | -// } failure:^(NSDictionary *errorDic) { | ||
| 518 | -// [QMUITips hideAllToastInView:AppKeyWindow animated:YES]; | ||
| 519 | -// [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:AppKeyWindow hideAfterDelay:1.5]; | ||
| 520 | -// | ||
| 521 | -// }]; | ||
| 522 | - | ||
| 523 | -} | ||
| 524 | - | ||
| 525 | -#pragma mark - CNLiveThreeLoginViewDelegate | ||
| 526 | -//- (void)clickedButton:(CNLiveThreeLoginView *)view type:(CNLiveSendAuthResp)type{ | ||
| 527 | -// if(![CNLiveNetworking isNetworking]){ | ||
| 528 | -// [QMUITips showError:@"无法连接网络" inView:AppKeyWindow hideAfterDelay:1.5]; | ||
| 529 | -// return ; | ||
| 530 | -// } | ||
| 531 | -// [self endEditing:YES]; | ||
| 532 | -// __weak typeof(self) weakSelf = self; | ||
| 533 | -// [CNLiveShareImageManager send:type authRespBlock:^(CNLiveSendAuthResp type, CNLiveThirdPartyModel *userInfo, NSError *error) { | ||
| 534 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | ||
| 535 | -// if(!strongSelf) return; | ||
| 536 | -// if(error){ | ||
| 537 | -// [QMUITips hideAllToastInView:AppKeyWindow animated:YES]; | ||
| 538 | -// if(error.code == 10000){ | ||
| 539 | -// //用户取消 | ||
| 540 | -// }else{ | ||
| 541 | -// [QMUITips showError:@"登录失败" inView:AppKeyWindow hideAfterDelay:1.5]; | ||
| 542 | -// } | ||
| 543 | -// return ; | ||
| 544 | -// } | ||
| 545 | -// CNThreeLoginModel *model = [CNThreeLoginModel cn_transformModelFromModel:userInfo]; | ||
| 546 | -// model.countryName = strongSelf->_countryStr; | ||
| 547 | -// model.countryCode = strongSelf->_codeStr; | ||
| 548 | -// model.frmId = [CNTools getFrmId]; | ||
| 549 | -// switch (type) { | ||
| 550 | -// case CNLiveSendAuthRespWX: | ||
| 551 | -// { | ||
| 552 | -// model.thirdPartyPlat = @"3"; | ||
| 553 | -// } | ||
| 554 | -// break; | ||
| 555 | -// case CNLiveSendAuthRespQQ: | ||
| 556 | -// { | ||
| 557 | -// model.thirdPartyPlat = @"2"; | ||
| 558 | -// } | ||
| 559 | -// break; | ||
| 560 | -// case CNLiveSendAuthRespWB: | ||
| 561 | -// { | ||
| 562 | -// model.thirdPartyPlat = @"1"; | ||
| 563 | -// } | ||
| 564 | -// break; | ||
| 565 | -// } | ||
| 566 | -// [strongSelf thirdPartyLoginWithType:type model:model]; | ||
| 567 | -// | ||
| 568 | -// }]; | ||
| 569 | -// | ||
| 570 | -//} | ||
| 571 | - | ||
| 572 | -//- (void)thirdPartyLoginWithType:(CNLiveSendAuthResp)type model:(CNThreeLoginModel *)model{ | ||
| 573 | -// [QMUITips showLoadingInView:AppKeyWindow]; | ||
| 574 | -// __weak typeof(self) weakSelf = self; | ||
| 575 | -// [CNBindingManageRequest thirdPartyLoginWithType:type model:model block:^(NSURLSessionTask * _Nonnull requestTask, id _Nonnull responseObject, NSError * _Nonnull error) { | ||
| 576 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | ||
| 577 | -// if(!strongSelf) return; | ||
| 578 | -// [QMUITips hideAllToastInView:AppKeyWindow animated:YES]; | ||
| 579 | -// if ([responseObject isKindOfClass:[NSDictionary class]] && [responseObject[@"errorCode"] isEqualToString:@"42013"]) { | ||
| 580 | -// //未注册 | ||
| 581 | -// CNThreeLoginViewController *vc = [[CNThreeLoginViewController alloc]initWithModel:model]; | ||
| 582 | -// __weak typeof(strongSelf) weakSelf = strongSelf; | ||
| 583 | -// vc.block = ^(NSString * _Nonnull countryName, NSString * _Nonnull countryCode) { | ||
| 584 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | ||
| 585 | -// if(!strongSelf) return; | ||
| 586 | -// strongSelf->_countryLbl.text = countryName; | ||
| 587 | -// strongSelf->_countryStr = countryName; | ||
| 588 | -// strongSelf->_countryLbl.text = [NSString stringWithFormat:@"+%@",countryCode]; | ||
| 589 | -// strongSelf->_codeStr = countryCode; | ||
| 590 | -// }; | ||
| 591 | -// vc.hidesBottomBarWhenPushed = YES; | ||
| 592 | -// CNNavigationController *nav = [[CNNavigationController alloc] initWithRootViewController:vc]; | ||
| 593 | -// [[AppDelegate sharedAppDelegate].topViewController presentViewController:nav animated:YES completion:^{ | ||
| 594 | -// | ||
| 595 | -// }]; | ||
| 596 | -// | ||
| 597 | -// } | ||
| 598 | -// else if ([responseObject isKindOfClass:[NSDictionary class]] && [responseObject[@"errorCode"] isEqualToString:@"0"]) { | ||
| 599 | -// //登录成功 | ||
| 600 | -// // 连接IM | ||
| 601 | -// [strongSelf connectionIM:responseObject]; | ||
| 602 | -// } | ||
| 603 | -// else if ([responseObject isKindOfClass:[NSDictionary class]] ) { | ||
| 604 | -// [QMUITips showError:responseObject[@"errorMessage"] inView:AppKeyWindow hideAfterDelay:1.5]; | ||
| 605 | -// } | ||
| 606 | -// else{ | ||
| 607 | -// [QMUITips hideAllToastInView:AppKeyWindow animated:YES]; | ||
| 608 | -// [QMUITips showError:@"登录失败" inView:AppKeyWindow hideAfterDelay:1.5]; | ||
| 609 | -// } | ||
| 610 | -// }]; | ||
| 611 | -// | ||
| 612 | -//} | ||
| 613 | -//- (void)connectionIM:(id)result{ | ||
| 614 | -// weakself | ||
| 615 | -// NSLog(@"result:%@",result); | ||
| 616 | -// | ||
| 617 | -// NSMutableDictionary *resDic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]]; | ||
| 618 | -// NSString *deFaceUrl = [resDic objectForKey:@"faceUrl"]; | ||
| 619 | -// NSString *faceUrl = @""; | ||
| 620 | -// if ([deFaceUrl containsString:@"/mobile/images/mobilehead/default/"]) { | ||
| 621 | -// faceUrl = CNLiveNetAddDefaultHead;//网家家默认头像地址 | ||
| 622 | -// [resDic setValue:faceUrl forKey:@"faceUrl"]; | ||
| 623 | -// } | ||
| 624 | -// [CNUserInfoManager saveUserinfoDic:resDic]; | ||
| 625 | -// [CNShareExtensionGroup writeMyInfoToShareGroup]; | ||
| 626 | -// //连接IM | ||
| 627 | -// [_loginParam getTIMLoginToken:CNUserShareModel.uid successBlock:^(NSString *token) { | ||
| 628 | -// | ||
| 629 | -// _loginParam.identifier = CNUserShareModel.uid; | ||
| 630 | -// _loginParam.userSig = token; | ||
| 631 | -// _loginParam.tokenTime = [[NSDate date] timeIntervalSince1970]; | ||
| 632 | -// | ||
| 633 | -// [[IMAPlatform sharedInstance] login:_loginParam succ:^{ | ||
| 634 | -// [NBSAppAgent setUserIdentifier:[CNLiveBusinessTools getSidIdfv]]; | ||
| 635 | -// [QMUITips hideAllToastInView:AppKeyWindow animated:YES]; | ||
| 636 | -// [AppDelegate sharedAppDelegate].loginPrepositionUrl = @"judgeGiftUrl"; | ||
| 637 | -// [QMUITips showSucceed:@"登录成功" inView:AppKeyWindow hideAfterDelay:1.5]; | ||
| 638 | -// [_loginParam saveToLocal]; | ||
| 639 | -// [[AppDelegate sharedAppDelegate] registNotification]; | ||
| 640 | -// [[IMAPlatform sharedInstance] configHost:_loginParam]; | ||
| 641 | -// [IMAPlatform sharedInstance].didConnectSuccess = YES; | ||
| 642 | -// //电商 | ||
| 643 | -// NSString *userID = CNUserShareModel.uid; | ||
| 644 | -// [[DSCnliveShopSDKManager sharedManager] loginUser:userID]; | ||
| 645 | -// //设置APP已活跃 | ||
| 646 | -// [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"]; | ||
| 647 | -// [[NSUserDefaults standardUserDefaults] synchronize]; | ||
| 648 | -// | ||
| 649 | -// | ||
| 650 | -// [AppDelegate sharedAppDelegate].loginAlert = YES; | ||
| 651 | -// if ([result[@"data"][@"isNewUser"] intValue] == 0) { | ||
| 652 | -// //老用户 | ||
| 653 | -// [[AppDelegate sharedAppDelegate] enterMainUI]; | ||
| 654 | -// [[AppDelegate sharedAppDelegate] registNotification]; | ||
| 655 | -// | ||
| 656 | -// } | ||
| 657 | -// else { | ||
| 658 | -// //新用户 | ||
| 659 | -// [OpenInstallSDK reportRegister]; | ||
| 660 | -// CNLoginIUsernfoViewController *vc = [[CNLoginIUsernfoViewController alloc] init]; | ||
| 661 | -// NSString *tel = _telTF.text; | ||
| 662 | -// if(_telTF.text.length == 11){ | ||
| 663 | -// tel = [_telTF.text stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"XXXX"]; | ||
| 664 | -// } | ||
| 665 | -// NSLog(@"tel:%@",tel); | ||
| 666 | -// vc.mobileStr = tel; | ||
| 667 | -// [[AppDelegate sharedAppDelegate] presentViewController:vc animated:NO completion:NULL]; | ||
| 668 | -// } | ||
| 669 | -// [[NSNotificationCenter defaultCenter] postNotificationName:kCNLive_LoginSuccess object:nil]; | ||
| 670 | -// | ||
| 671 | -// [CNDSShopActionViewModel networkParamAction]; | ||
| 672 | -// | ||
| 673 | -// [[IMAPlatform sharedInstance].host asyncSetAllowType:TIM_FRIEND_NEED_CONFIRM succ:^{ | ||
| 674 | -// NSLog(@"asyncSetAllowType Suc"); | ||
| 675 | -// [_loginParam saveToLocal]; | ||
| 676 | -// | ||
| 677 | -// } fail:^(int code, NSString *msg) { | ||
| 678 | -// NSLog(@"asyncSetAllowType failed : %@", msg); | ||
| 679 | -// }]; | ||
| 680 | -// | ||
| 681 | -// } fail:^(int code, NSString *msg) { | ||
| 682 | -// NSLog(@"login failed : %@", msg); | ||
| 683 | -// if (code == 6208) { | ||
| 684 | -// //离线被踢下线重新登录 | ||
| 685 | -//// [weakSelf resumeLogin]; | ||
| 686 | -// } | ||
| 687 | -// else | ||
| 688 | -// [QMUITips showError:msg inView:AppKeyWindow hideAfterDelay:1.5]; | ||
| 689 | -// [QMUITips hideAllToastInView:AppKeyWindow animated:YES]; | ||
| 690 | -// }]; | ||
| 691 | -// | ||
| 692 | -// } failedBlock:^(int code, NSString *errorMsg) { | ||
| 693 | -// [QMUITips hideAllToastInView:AppKeyWindow animated:YES]; | ||
| 694 | -// | ||
| 695 | -// }]; | ||
| 696 | -//} | ||
| 697 | - | ||
| 698 | -@end |