Commit 8c8882792e309ea5043513f0729b6b5ef43d0ba0

Authored by zhangxiaowen
1 parent d78736da

no message

CNLiveLoginModule/Classes/Controller/CNLiveLoginController.m
@@ -97,10 +97,7 @@ @@ -97,10 +97,7 @@
97 97
98 }else{ 98 }else{
99 // 老用户 -> home 99 // 老用户 -> home
100 -// [XWAlertView alertSucceedViewWithTextMessage:@"登录成功" view:self.view block:^{  
101 -// // 通知  
102 -// [XWLoginNotification postUserLoginNotification:result];  
103 -// }]; 100 +
104 } 101 }
105 102
106 } 103 }
@@ -144,7 +141,7 @@ @@ -144,7 +141,7 @@
144 _close = [UIButton buttonWithType:UIButtonTypeCustom]; 141 _close = [UIButton buttonWithType:UIButtonTypeCustom];
145 _close.frame = CGRectMake(SCREEN_WIDTH-44-10, StatusBarHeight, 44, 44); 142 _close.frame = CGRectMake(SCREEN_WIDTH-44-10, StatusBarHeight, 44, 44);
146 _close.hidden = !self.isShowClose; 143 _close.hidden = !self.isShowClose;
147 - UIImage *image = [UIImage cn_getImageName:@"login_close" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; 144 + UIImage *image = [self getImageWithImageName:@"login_close" bundleName:@"CNLiveLoginModule" targetClass:[self class]];
148 [_close setImage:image forState:UIControlStateNormal]; 145 [_close setImage:image forState:UIControlStateNormal];
149 [_close addTarget:self action:@selector(closeDidSelected:) forControlEvents:UIControlEventTouchUpInside]; 146 [_close addTarget:self action:@selector(closeDidSelected:) forControlEvents:UIControlEventTouchUpInside];
150 _close.adjustsImageWhenHighlighted = NO; 147 _close.adjustsImageWhenHighlighted = NO;
CNLiveLoginModule/Classes/Model/CNLiveClassifyOffsetManager.h 0 → 100644
  1 +//
  2 +// CNLiveClassifyOffsetManager.h
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/3/27.
  6 +// Copyright © 2019年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveClassifyOffsetManager : NSObject
  14 ++ (instancetype)manager;
  15 +
  16 +
  17 +@end
  18 +
  19 +NS_ASSUME_NONNULL_END
CNLiveLoginModule/Classes/Model/CNLiveClassifyOffsetManager.m 0 → 100644
  1 +//
  2 +// CNLiveClassifyOffsetManager.m
  3 +// CNLiveLoginModule
  4 +//
  5 +// Created by CNLive-zxw on 2019/3/27.
  6 +// Copyright © 2019年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveClassifyOffsetManager.h"
  10 +
  11 +@interface CNLiveClassifyOffsetManager ()
  12 +
  13 +@end
  14 +
  15 +@implementation CNLiveClassifyOffsetManager
  16 +#pragma mark - 单例
  17 ++ (instancetype)manager {
  18 + static CNLiveClassifyOffsetManager *_singleton = nil;
  19 + static dispatch_once_t onceToken;
  20 + dispatch_once(&onceToken, ^{
  21 + //不能再使用alloc方法
  22 + //因为已经重写了allocWithZone方法,所以这里要调用父类的分配空间的方法
  23 + _singleton = [[super allocWithZone:NULL] init];
  24 + });
  25 + return _singleton;
  26 +
  27 +}
  28 +
  29 +// 防止外部调用alloc 或者 new
  30 ++ (instancetype)allocWithZone:(struct _NSZone *)zone {
  31 + return [CNLiveClassifyOffsetManager manager];
  32 +
  33 +}
  34 +
  35 +// 防止外部调用copy
  36 +- (id)copyWithZone:(nullable NSZone *)zone {
  37 + return [CNLiveClassifyOffsetManager manager];
  38 +
  39 +}
  40 +
  41 +// 防止外部调用mutableCopy
  42 +- (id)mutableCopyWithZone:(nullable NSZone *)zone {
  43 + return [CNLiveClassifyOffsetManager manager];
  44 +
  45 +}
  46 +
  47 +@end
CNLiveLoginModule/Classes/Model/CNLiveLoginRequestModel.h
@@ -9,9 +9,16 @@ @@ -9,9 +9,16 @@
9 #import <Foundation/Foundation.h> 9 #import <Foundation/Foundation.h>
10 10
11 NS_ASSUME_NONNULL_BEGIN 11 NS_ASSUME_NONNULL_BEGIN
  12 +typedef void (^TIMLoginSucc)(void);
  13 +typedef void (^TIMFail)(int code, NSString * msg);
12 14
13 @interface CNLiveLoginRequestModel : NSObject 15 @interface CNLiveLoginRequestModel : NSObject
14 -+ (void)getTIMLoginToken:(NSString *)identifier successBlock:(void (^)(NSString *))successBlock failedBlock:(void (^)(int, NSString *))errorBlock; 16 ++ (instancetype)manager;
  17 +
  18 +- (void)getTIMLoginToken:(NSString *)identifier success:(void (^)(NSString *))success failed:(void (^)(int, NSString *))failed;
  19 +
  20 +
  21 +- (void)loginTIM:(NSString *)uid success:(TIMLoginSucc)success failed:(TIMFail)failed;
15 22
16 @end 23 @end
17 24
CNLiveLoginModule/Classes/Model/CNLiveLoginRequestModel.m
@@ -7,15 +7,65 @@ @@ -7,15 +7,65 @@
7 // 7 //
8 8
9 #import "CNLiveLoginRequestModel.h" 9 #import "CNLiveLoginRequestModel.h"
  10 +#import <UIKit/UIKit.h>
  11 +#import "QMUIKit.h"
  12 +
10 #import "CNUserInfoManager.h" 13 #import "CNUserInfoManager.h"
11 #import "CNLiveEnvironment.h" 14 #import "CNLiveEnvironment.h"
12 #import <CNLiveRequestBastKit/CNLiveNetworking.h> 15 #import <CNLiveRequestBastKit/CNLiveNetworking.h>
  16 +#import "TIMAdapter.h"
  17 +#import "CommonLibrary.h"
  18 +
  19 +@interface CNLiveLoginRequestModel()
  20 +@property (nonatomic, strong) IMALoginParam *loginParam;
  21 +
  22 +@end
13 23
14 @implementation CNLiveLoginRequestModel 24 @implementation CNLiveLoginRequestModel
  25 +#pragma mark - 单例
  26 ++ (instancetype)manager {
  27 + static CNLiveLoginRequestModel *_singleton = nil;
  28 + static dispatch_once_t onceToken;
  29 + dispatch_once(&onceToken, ^{
  30 + //不能再使用alloc方法
  31 + //因为已经重写了allocWithZone方法,所以这里要调用父类的分配空间的方法
  32 + _singleton = [[super allocWithZone:NULL] init];
  33 + BOOL isAutoLogin = [IMAPlatform isAutoLogin];
  34 +
  35 + if (isAutoLogin) {
  36 + _singleton.loginParam = [IMALoginParam loadFromLocal];
  37 +
  38 + } else {
  39 + _singleton.loginParam = [[IMALoginParam alloc] init];
  40 +
  41 + }
  42 + [IMAPlatform configWith:_singleton.loginParam.config];
15 43
16 -//获取token  
17 -+ (void)getTIMLoginToken:(NSString *)identifier successBlock:(void (^)(NSString *))successBlock failedBlock:(void (^)(int, NSString *))errorBlock { 44 + });
  45 + return _singleton;
  46 +
  47 +}
  48 +
  49 +// 防止外部调用alloc 或者 new
  50 ++ (instancetype)allocWithZone:(struct _NSZone *)zone {
  51 + return [CNLiveLoginRequestModel manager];
  52 +
  53 +}
  54 +
  55 +// 防止外部调用copy
  56 +- (id)copyWithZone:(nullable NSZone *)zone {
  57 + return [CNLiveLoginRequestModel manager];
18 58
  59 +}
  60 +
  61 +// 防止外部调用mutableCopy
  62 +- (id)mutableCopyWithZone:(nullable NSZone *)zone {
  63 + return [CNLiveLoginRequestModel manager];
  64 +
  65 +}
  66 +
  67 +//获取token
  68 +- (void)getTIMLoginToken:(NSString *)identifier success:(void (^)(NSString *))success failed:(void (^)(int, NSString *))failed{
19 NSDictionary *params = @{@"appId":AppId, 69 NSDictionary *params = @{@"appId":AppId,
20 @"plat":@"i", 70 @"plat":@"i",
21 @"sdkAppId":SdkAppId, 71 @"sdkAppId":SdkAppId,
@@ -28,21 +78,84 @@ @@ -28,21 +78,84 @@
28 if (responseObject && ![responseObject isKindOfClass:[NSNull class]] && [responseObject isKindOfClass:[NSDictionary class]] && [[responseObject allKeys] containsObject:@"data"] && [[responseObject objectForKey:@"data"] isKindOfClass:[NSDictionary class]]) { 78 if (responseObject && ![responseObject isKindOfClass:[NSNull class]] && [responseObject isKindOfClass:[NSDictionary class]] && [[responseObject allKeys] containsObject:@"data"] && [[responseObject objectForKey:@"data"] isKindOfClass:[NSDictionary class]]) {
29 NSNumber *code = responseObject[@"errorCode"]; 79 NSNumber *code = responseObject[@"errorCode"];
30 if (code && code.intValue == 0) { 80 if (code && code.intValue == 0) {
31 - if (successBlock) {  
32 - successBlock(responseObject[@"data"][@"token"]); 81 + if (success) {
  82 + success(responseObject[@"data"][@"token"]);
33 } 83 }
34 } else { 84 } else {
35 - if (errorBlock) {  
36 - errorBlock(31012, @"获取token失败"); 85 + if (failed) {
  86 + failed(31012, @"获取token失败");
37 } 87 }
38 } 88 }
39 89
40 } 90 }
41 91
42 }else{ 92 }else{
43 - if (errorBlock) errorBlock(31012,@"Token acquisition failure"); 93 + if (failed) failed(31012,@"Token acquisition failure");
44 } 94 }
45 }]; 95 }];
46 96
47 } 97 }
  98 +
  99 +- (void)loginTIM:(NSString *)uid success:(TIMLoginSucc)success failed:(TIMFail)failed{
  100 +
  101 + [self getTIMLoginToken:uid success:^(NSString * _Nonnull token) {
  102 + self.loginParam.identifier = CNUserShareModel.uid;
  103 + self.loginParam.userSig = token;
  104 + self.loginParam.tokenTime = [[NSDate date] timeIntervalSince1970];
  105 +
  106 + [[IMAPlatform sharedInstance] login:self.loginParam succ:^{
  107 +
  108 +// [NBSAppAgent setUserIdentifier:[CNLiveBusinessTools getSidIdfv]];
  109 + [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES];
  110 + [QMUITips showSucceed:@"登录成功" inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:1.5];
  111 + [self.loginParam saveToLocal];
  112 +// [[AppDelegate sharedAppDelegate] registNotification];
  113 + [[IMAPlatform sharedInstance] configHost:self.loginParam];
  114 + [IMAPlatform sharedInstance].didConnectSuccess = YES;
  115 + //电商
  116 + NSString *userID = CNUserShareModel.uid;
  117 +// [[DSCnliveShopSDKManager sharedManager] loginUser:userID];
  118 + //设置APP已活跃
  119 + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"];
  120 + [[NSUserDefaults standardUserDefaults] synchronize];
  121 +
  122 + [[IMAPlatform sharedInstance].contactMgr asyncUpdateContact];
  123 + [[IMAPlatform sharedInstance].contactMgr saveGroupIdList:YES];
  124 + [[IMAPlatform sharedInstance] configHost:self.loginParam];
  125 + [IMAPlatform sharedInstance].didConnectSuccess = YES;
  126 + //电商
  127 +// NSString *userID = CNUserShareModel.uid;
  128 +// [[DSCnliveShopSDKManager sharedManager] loginUser:userID];
  129 + //设置APP已活跃
  130 + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"];
  131 + [[NSUserDefaults standardUserDefaults] synchronize];
  132 +
  133 + [[IMAPlatform sharedInstance].host asyncSetAllowType:TIM_FRIEND_NEED_CONFIRM succ:^{
  134 + NSLog(@"asyncSetAllowType Suc");
  135 + [self.loginParam saveToLocal];
  136 +
  137 + } fail:^(int code, NSString *msg) {
  138 + NSLog(@"asyncSetAllowType failed : %@", msg);
  139 + }];
  140 + success?success():@"";
  141 +
  142 + } fail:^(int code, NSString *msg) {
  143 + NSLog(@"login failed : %@", msg);
  144 + failed?failed(code, msg):@"";
  145 +
  146 + if (code == 6208) {
  147 + //离线被踢下线重新登录
  148 +// [weakSelf resumeLogin];
  149 + }
  150 + else
  151 + [QMUITips showError:msg inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:1.5];
  152 + [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES];
  153 + }];
  154 + } failed:^(int code, NSString * _Nonnull msg) {
  155 + NSLog(@"token code:%d msg:%@", code, msg);
  156 + [QMUITips hideAllToastInView:[UIApplication sharedApplication].keyWindow animated:YES];
  157 + failed?failed(code, msg):@"";
  158 + }];
  159 +
  160 +}
48 @end 161 @end
CNLiveLoginModule/Classes/ThreeLogin/CNLiveBindingTelView.m
@@ -79,7 +79,7 @@ static const NSInteger timeValue = 1.5; @@ -79,7 +79,7 @@ static const NSInteger timeValue = 1.5;
79 countDown.dataSource = self; 79 countDown.dataSource = self;
80 countDown.delegate = self; 80 countDown.delegate = self;
81 countDown.frame = CGRectMake(frame.size.width-80, account.bottom+space+10, 80, rowHeight-10); 81 countDown.frame = CGRectMake(frame.size.width-80, account.bottom+space+10, 80, rowHeight-10);
82 - UIImage *image2 = [UIImage cn_getImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; 82 + UIImage *image2 = [self getImageWithImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]];
83 [countDown setImage:image2 forState:UIControlStateNormal]; 83 [countDown setImage:image2 forState:UIControlStateNormal];
84 countDown.adjustsImageWhenHighlighted = NO; 84 countDown.adjustsImageWhenHighlighted = NO;
85 [countDown setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 85 [countDown setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
@@ -254,7 +254,7 @@ static const NSInteger timeValue = 1.5; @@ -254,7 +254,7 @@ static const NSInteger timeValue = 1.5;
254 button.backgroundColor = [UIColor whiteColor]; 254 button.backgroundColor = [UIColor whiteColor];
255 button.userInteractionEnabled = YES; 255 button.userInteractionEnabled = YES;
256 [button setTitle:@"" forState:UIControlStateNormal]; 256 [button setTitle:@"" forState:UIControlStateNormal];
257 - UIImage *image2 = [UIImage cn_getImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; 257 + UIImage *image2 = [self getImageWithImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]];
258 [button setImage:image2 forState:UIControlStateNormal]; 258 [button setImage:image2 forState:UIControlStateNormal];
259 } 259 }
260 260
CNLiveLoginModule/Classes/ThreeLogin/CNLiveThreeLoginView.m
@@ -57,7 +57,7 @@ static NSInteger const rowHeight = 80; @@ -57,7 +57,7 @@ static NSInteger const rowHeight = 80;
57 UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 57 UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
58 btn.tag = 10000+i; 58 btn.tag = 10000+i;
59 btn.frame = CGRectMake(btnWidth*i, name.bottom, btnWidth, rowHeight); 59 btn.frame = CGRectMake(btnWidth*i, name.bottom, btnWidth, rowHeight);
60 - UIImage *image = [UIImage cn_getImageName:pics[i] bundleName:@"CNLiveLoginModule" targetClass:[self class]]; 60 + UIImage *image = [self getImageWithImageName:pics[i] bundleName:@"CNLiveLoginModule" targetClass:[self class]];
61 [btn setImage:image forState:UIControlStateNormal]; 61 [btn setImage:image forState:UIControlStateNormal];
62 btn.adjustsImageWhenHighlighted = NO; 62 btn.adjustsImageWhenHighlighted = NO;
63 [btn addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside]; 63 [btn addTarget:self action:@selector(btnDidClicked:) forControlEvents:UIControlEventTouchUpInside];
CNLiveLoginModule/Classes/View/CNLiveCompleteInfoView.m
@@ -62,7 +62,7 @@ static const NSInteger timeValue = 1.5; @@ -62,7 +62,7 @@ static const NSInteger timeValue = 1.5;
62 head.layer.cornerRadius = 40; 62 head.layer.cornerRadius = 40;
63 head.layer.masksToBounds = YES; 63 head.layer.masksToBounds = YES;
64 head.adjustsImageWhenHighlighted = NO; 64 head.adjustsImageWhenHighlighted = NO;
65 - UIImage *image = [UIImage cn_getImageName:@"login_camera" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; 65 + UIImage *image = [self getImageWithImageName:@"login_camera" bundleName:@"CNLiveLoginModule" targetClass:[self class]];
66 [head setImage:image forState:UIControlStateNormal]; 66 [head setImage:image forState:UIControlStateNormal];
67 [head addTarget:self action:@selector(headDidClicked:) forControlEvents:UIControlEventTouchUpInside]; 67 [head addTarget:self action:@selector(headDidClicked:) forControlEvents:UIControlEventTouchUpInside];
68 [self addSubview:head]; 68 [self addSubview:head];
CNLiveLoginModule/Classes/View/CNLiveLoginCountryView.m
@@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
47 [code setTitle:[NSString stringWithFormat:@"+%@",_countryCode] forState:UIControlStateNormal]; 47 [code setTitle:[NSString stringWithFormat:@"+%@",_countryCode] forState:UIControlStateNormal];
48 [code setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal]; 48 [code setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState:UIControlStateNormal];
49 code.titleLabel.font = [UIFont systemFontOfSize:14]; 49 code.titleLabel.font = [UIFont systemFontOfSize:14];
50 - UIImage *image = [UIImage cn_getImageName:@"login_country" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; 50 + UIImage *image = [self getImageWithImageName:@"login_country" bundleName:@"CNLiveLoginModule" targetClass:[self class]];
51 [code setImage:image forState:UIControlStateNormal]; 51 [code setImage:image forState:UIControlStateNormal];
52 code.adjustsImageWhenHighlighted = NO; 52 code.adjustsImageWhenHighlighted = NO;
53 //button图片的偏移量,距上左下右分别(0, 0, 0, 0)像素点 53 //button图片的偏移量,距上左下右分别(0, 0, 0, 0)像素点
CNLiveLoginModule/Classes/View/CNLiveLoginNavigationBar.m
@@ -60,7 +60,7 @@ static const NSInteger margin = 15; @@ -60,7 +60,7 @@ static const NSInteger margin = 15;
60 _left= [UIButton buttonWithType:UIButtonTypeCustom]; 60 _left= [UIButton buttonWithType:UIButtonTypeCustom];
61 _left.adjustsImageWhenHighlighted = NO; 61 _left.adjustsImageWhenHighlighted = NO;
62 _left.frame = CGRectMake(margin, StatusBarHeight, NavigationBarHeight, NavigationBarHeight); 62 _left.frame = CGRectMake(margin, StatusBarHeight, NavigationBarHeight, NavigationBarHeight);
63 - UIImage *image = [UIImage cn_getImageName:@"mine_back_black_b" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; 63 + UIImage *image = [self getImageWithImageName:@"mine_back_black_b" bundleName:@"CNLiveLoginModule" targetClass:[self class]];
64 [_left setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal]; 64 [_left setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
65 _left.titleLabel.font = [UIFont systemFontOfSize:15]; 65 _left.titleLabel.font = [UIFont systemFontOfSize:15];
66 [_left setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; 66 [_left setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
CNLiveLoginModule/Classes/View/CNLiveLoginView.m
@@ -16,6 +16,10 @@ @@ -16,6 +16,10 @@
16 #import "CNUserInfoManager.h" 16 #import "CNUserInfoManager.h"
17 #import "CNLiveEnvironment.h" 17 #import "CNLiveEnvironment.h"
18 #import "CNLiveCategory.h" 18 #import "CNLiveCategory.h"
  19 +#import "TIMAdapter.h"
  20 +#import "CommonLibrary.h"
  21 +
  22 +#import "CNLiveLoginRequestModel.h"
19 23
20 #import "CNLiveLoginCountryView.h" 24 #import "CNLiveLoginCountryView.h"
21 #import "CNLiveLoginTextField.h" 25 #import "CNLiveLoginTextField.h"
@@ -57,7 +61,7 @@ static const NSInteger timeValue = 1.5; @@ -57,7 +61,7 @@ static const NSInteger timeValue = 1.5;
57 } 61 }
58 - (void)createSubviews:(CGRect)frame{ 62 - (void)createSubviews:(CGRect)frame{
59 UIImageView *logo = [[UIImageView alloc] initWithFrame:CGRectMake((frame.size.width-75)/2.0, 0, 75, 100)]; 63 UIImageView *logo = [[UIImageView alloc] initWithFrame:CGRectMake((frame.size.width-75)/2.0, 0, 75, 100)];
60 - UIImage *image = [UIImage cn_getImageName:@"login_logo" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; 64 + UIImage *image = [self getImageWithImageName:@"login_logo" bundleName:@"CNLiveLoginModule" targetClass:[self class]];
61 logo.image = image; 65 logo.image = image;
62 [self addSubview:logo]; 66 [self addSubview:logo];
63 self.logo = logo; 67 self.logo = logo;
@@ -97,7 +101,7 @@ static const NSInteger timeValue = 1.5; @@ -97,7 +101,7 @@ static const NSInteger timeValue = 1.5;
97 countDown.dataSource = self; 101 countDown.dataSource = self;
98 countDown.delegate = self; 102 countDown.delegate = self;
99 countDown.frame = CGRectMake(frame.size.width-80, account.bottom+space+10, 80, rowHeight-10); 103 countDown.frame = CGRectMake(frame.size.width-80, account.bottom+space+10, 80, rowHeight-10);
100 - UIImage *image2 = [UIImage cn_getImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; 104 + UIImage *image2 = [self getImageWithImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]];
101 [countDown setImage:image2 forState:UIControlStateNormal]; 105 [countDown setImage:image2 forState:UIControlStateNormal];
102 countDown.adjustsImageWhenHighlighted = NO; 106 countDown.adjustsImageWhenHighlighted = NO;
103 [countDown setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 107 [countDown setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
@@ -262,8 +266,7 @@ static const NSInteger timeValue = 1.5; @@ -262,8 +266,7 @@ static const NSInteger timeValue = 1.5;
262 button.backgroundColor = [UIColor colorWithRed:222/255.0 green:222/255.0 blue:222/255.0 alpha:1.0]; 266 button.backgroundColor = [UIColor colorWithRed:222/255.0 green:222/255.0 blue:222/255.0 alpha:1.0];
263 button.frame = CGRectMake(self.frame.size.width-110, self.account.bottom+space+10, 110, rowHeight-10); 267 button.frame = CGRectMake(self.frame.size.width-110, self.account.bottom+space+10, 110, rowHeight-10);
264 [button setImage:nil forState:UIControlStateNormal]; 268 [button setImage:nil forState:UIControlStateNormal];
265 - NSString *title = [NSString stringWithFormat:@"%d秒后重新发送", 60];  
266 - [button setTitle:title forState:UIControlStateNormal]; 269 + [button setTitle:[NSString stringWithFormat:@"%d秒后重新发送", 60] forState:UIControlStateNormal];
267 [button startCountDown]; 270 [button startCountDown];
268 271
269 } failure:^(NSDictionary *errorDic) { 272 } failure:^(NSDictionary *errorDic) {
@@ -297,7 +300,7 @@ static const NSInteger timeValue = 1.5; @@ -297,7 +300,7 @@ static const NSInteger timeValue = 1.5;
297 button.backgroundColor = [UIColor whiteColor]; 300 button.backgroundColor = [UIColor whiteColor];
298 button.userInteractionEnabled = YES; 301 button.userInteractionEnabled = YES;
299 [button setTitle:@"" forState:UIControlStateNormal]; 302 [button setTitle:@"" forState:UIControlStateNormal];
300 - UIImage *image2 = [UIImage cn_getImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; 303 + UIImage *image2 = [self getImageWithImageName:@"login_get_code" bundleName:@"CNLiveLoginModule" targetClass:[self class]];
301 [button setImage:image2 forState:UIControlStateNormal]; 304 [button setImage:image2 forState:UIControlStateNormal];
302 } 305 }
303 306
@@ -332,30 +335,107 @@ static const NSInteger timeValue = 1.5; @@ -332,30 +335,107 @@ static const NSInteger timeValue = 1.5;
332 if(!strongSelf) return; 335 if(!strongSelf) return;
333 [QMUITips hideAllToastInView:strongSelf.superview animated:YES]; 336 [QMUITips hideAllToastInView:strongSelf.superview animated:YES];
334 [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:strongSelf.superview hideAfterDelay:timeValue]; 337 [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:strongSelf.superview hideAfterDelay:timeValue];
335 - // YES 新用户 NO 老用户  
336 - BOOL isNewUser = YES;  
337 - if (self.delegate && [self.delegate respondsToSelector:@selector(loginSuccess:isNewUser:result:)]) {  
338 - [self.delegate loginSuccess:self isNewUser:isNewUser result:nil];  
339 - }  
340 }]; 338 }];
341 } 339 }
342 340
343 #pragma mark - 连接IM 341 #pragma mark - 连接IM
344 - (void)connectionIM:(id)result{ 342 - (void)connectionIM:(id)result{
345 - NSMutableDictionary *resDic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]];  
346 - NSString *deFaceUrl = [resDic objectForKey:@"faceUrl"];  
347 - NSString *faceUrl = @"";  
348 - if ([deFaceUrl containsString:@"/mobile/images/mobilehead/default/"]) {  
349 - faceUrl = CNLiveNetAddDefaultHead;//网家家默认头像地址  
350 - [resDic setValue:faceUrl forKey:@"faceUrl"]; 343 + NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:result[@"data"]];
  344 + NSString *faceUrl = [dic objectForKey:@"faceUrl"];
  345 + if ([faceUrl containsString:@"/mobile/images/mobilehead/default/"]) {
  346 + //网家家默认头像地址
  347 + [dic setValue:CNLiveNetAddDefaultHead forKey:@"faceUrl"];
351 } 348 }
352 - [CNUserInfoManager saveUserinfoDic:resDic]; 349 + [CNUserInfoManager saveUserinfoDic:dic];
  350 +
  351 +// // YES 新用户 NO 老用户
  352 +// BOOL isNewUser = [dic[@"isNewUser"] intValue] != 0;
  353 +// if (self.delegate && [self.delegate respondsToSelector:@selector(loginSuccess:isNewUser:result:)]) {
  354 +// [self.delegate loginSuccess:self isNewUser:isNewUser result:result];
  355 +// }
  356 +
  357 + [CNLiveLoginRequestModel getTIMLoginToken:CNUserShareModel.uid successBlock:^(NSString *token) {
  358 +
  359 + _loginParam.identifier = CNUserShareModel.uid;
  360 + _loginParam.userSig = token;
  361 + _loginParam.tokenTime = [[NSDate date] timeIntervalSince1970];
  362 +
  363 + [[IMAPlatform sharedInstance] login:_loginParam succ:^{
  364 +
  365 +// [NBSAppAgent setUserIdentifier:[CNLiveBusinessTools getSidIdfv]];
  366 + [QMUITips hideAllToastInView:self.superview animated:YES];
  367 + [QMUITips showSucceed:@"登录成功" inView:self.superview hideAfterDelay:1.5];
  368 + [_loginParam saveToLocal];
  369 +// [[AppDelegate sharedAppDelegate] registNotification];
  370 + [[IMAPlatform sharedInstance] configHost:_loginParam];
  371 + [IMAPlatform sharedInstance].didConnectSuccess = YES;
  372 + //电商
  373 + NSString *userID = CNUserShareModel.uid;
  374 +// [[DSCnliveShopSDKManager sharedManager] loginUser:userID];
  375 + //设置APP已活跃
  376 + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"];
  377 + [[NSUserDefaults standardUserDefaults] synchronize];
  378 +
  379 +
  380 +
  381 + if ([result[@"data"][@"isNewUser"] intValue] == 0) {
  382 + //老用户
  383 +// [[AppDelegate sharedAppDelegate] enterMainUI];
  384 +// [[AppDelegate sharedAppDelegate] registNotification];
  385 + [[IMAPlatform sharedInstance].contactMgr asyncUpdateContact];
  386 + [[IMAPlatform sharedInstance].contactMgr saveGroupIdList:YES];
  387 + [[IMAPlatform sharedInstance] configHost:_loginParam];
  388 + [IMAPlatform sharedInstance].didConnectSuccess = YES;
  389 + //电商
  390 + NSString *userID = CNUserShareModel.uid;
  391 +// [[DSCnliveShopSDKManager sharedManager] loginUser:userID];
  392 + //设置APP已活跃
  393 + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"is_Active_Application"];
  394 + [[NSUserDefaults standardUserDefaults] synchronize];
  395 +
  396 + }
  397 + else {
  398 + //新用户
  399 +// [OpenInstallSDK reportRegister];
  400 +// CNLoginIUsernfoViewController *vc = [[CNLoginIUsernfoViewController alloc] init];
  401 +// NSString *tel = _accountTextF.text;
  402 +// if(_accountTextF.text.length == 11){
  403 +// tel = [_accountTextF.text stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"XXXX"];
  404 +// }
  405 +// NSLog(@"tel:%@",tel);
  406 +// vc.mobileStr = tel;
  407 +// [self presentViewController:vc animated:NO completion:NULL];
  408 + }
  409 +// [[NSNotificationCenter defaultCenter] postNotificationName:kCNLive_LoginSuccess object:nil];
  410 +
  411 +// [CNDSShopActionViewModel networkParamAction];
  412 +
  413 + [[IMAPlatform sharedInstance].host asyncSetAllowType:TIM_FRIEND_NEED_CONFIRM succ:^{
  414 + NSLog(@"asyncSetAllowType Suc");
  415 + [_loginParam saveToLocal];
  416 +
  417 + } fail:^(int code, NSString *msg) {
  418 + NSLog(@"asyncSetAllowType failed : %@", msg);
  419 + }];
  420 + // [self dismissViewControllerAnimated:YES completion:nil];
  421 +
  422 + } fail:^(int code, NSString *msg) {
  423 + NSLog(@"login failed : %@", msg);
  424 + if (code == 6208) {
  425 + //离线被踢下线重新登录
  426 +// [weakSelf resumeLogin];
  427 + }
  428 + else
  429 + [QMUITips showError:msg inView:self.superview hideAfterDelay:1.5];
  430 + [QMUITips hideAllToastInView:self.superview animated:YES];
  431 + }];
  432 +
  433 + } failedBlock:^(int code, NSString *errorMsg) {
  434 + NSLog(@"token code:%d error:%@", code, errorMsg);
  435 + [QMUITips hideAllToastInView:self.superview animated:YES];
  436 +
  437 + }];
353 438
354 - // YES 新用户 NO 老用户  
355 - BOOL isNewUser = YES;  
356 - if (self.delegate && [self.delegate respondsToSelector:@selector(loginSuccess:isNewUser:result:)]) {  
357 - [self.delegate loginSuccess:self isNewUser:isNewUser result:result];  
358 - }  
359 } 439 }
360 440
361 @end 441 @end
Example/CNLiveLoginModule.xcodeproj/project.pbxproj
@@ -575,7 +575,7 @@ @@ -575,7 +575,7 @@
575 GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch"; 575 GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch";
576 INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist"; 576 INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist";
577 MODULE_NAME = ExampleApp; 577 MODULE_NAME = ExampleApp;
578 - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd.CNLiveLoginModule; 578 + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd;
579 PRODUCT_NAME = "登录模块"; 579 PRODUCT_NAME = "登录模块";
580 SWIFT_VERSION = 4.0; 580 SWIFT_VERSION = 4.0;
581 WRAPPER_EXTENSION = app; 581 WRAPPER_EXTENSION = app;
@@ -592,7 +592,7 @@ @@ -592,7 +592,7 @@
592 GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch"; 592 GCC_PREFIX_HEADER = "CNLiveLoginModule/CNLiveLoginModule-Prefix.pch";
593 INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist"; 593 INFOPLIST_FILE = "CNLiveLoginModule/CNLiveLoginModule-Info.plist";
594 MODULE_NAME = ExampleApp; 594 MODULE_NAME = ExampleApp;
595 - PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd.CNLiveLoginModule; 595 + PRODUCT_BUNDLE_IDENTIFIER = com.cnlive.CNLiveNetAdd;
596 PRODUCT_NAME = "登录模块"; 596 PRODUCT_NAME = "登录模块";
597 SWIFT_VERSION = 4.0; 597 SWIFT_VERSION = 4.0;
598 WRAPPER_EXTENSION = app; 598 WRAPPER_EXTENSION = app;
Example/CNLiveLoginModule/CNLIVEAppDelegate.m
@@ -48,6 +48,7 @@ @@ -48,6 +48,7 @@
48 @"uid":@"10514405", 48 @"uid":@"10514405",
49 @"wxUid":@"" 49 @"wxUid":@""
50 }]; 50 }];
  51 + [[NSUserDefaults standardUserDefaults] setObject:@"RkFYeLkl/u5S7tW8UcOkT3rfLTP/Ua8NIkdEsKlcolvl/yxTMNbAYXmmJyhKGpkj" forKey:@"CNLiveAuthToken"];
51 52
52 CNLiveLoginController *vc = [[CNLiveLoginController alloc] init]; 53 CNLiveLoginController *vc = [[CNLiveLoginController alloc] init];
53 vc.isShowClose = YES; 54 vc.isShowClose = YES;
Example/CNLiveLoginModule/CNLiveLoginModule-Info.plist
@@ -2,19 +2,6 @@ @@ -2,19 +2,6 @@
2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 <plist version="1.0"> 3 <plist version="1.0">
4 <dict> 4 <dict>
5 - <key>NSAppTransportSecurity</key>  
6 - <dict>  
7 - <key>NSAllowsArbitraryLoads</key>  
8 - <true/>  
9 - </dict>  
10 - <key>NSCameraUsageDescription</key>  
11 - <string>App需要您的同意,才能访问相机</string>  
12 - <key>NSMicrophoneUsageDescription</key>  
13 - <string>App需要您的同意,才能访问麦克风</string>  
14 - <key>NSPhotoLibraryAddUsageDescription</key>  
15 - <string>App需要您的同意,才能访问相册</string>  
16 - <key>NSPhotoLibraryUsageDescription</key>  
17 - <string>App需要您的同意,才能访问相册</string>  
18 <key>CFBundleDevelopmentRegion</key> 5 <key>CFBundleDevelopmentRegion</key>
19 <string>en</string> 6 <string>en</string>
20 <key>CFBundleDisplayName</key> 7 <key>CFBundleDisplayName</key>
@@ -37,6 +24,19 @@ @@ -37,6 +24,19 @@
37 <string>1.0</string> 24 <string>1.0</string>
38 <key>LSRequiresIPhoneOS</key> 25 <key>LSRequiresIPhoneOS</key>
39 <true/> 26 <true/>
  27 + <key>NSAppTransportSecurity</key>
  28 + <dict>
  29 + <key>NSAllowsArbitraryLoads</key>
  30 + <true/>
  31 + </dict>
  32 + <key>NSCameraUsageDescription</key>
  33 + <string>App需要您的同意,才能访问相机</string>
  34 + <key>NSMicrophoneUsageDescription</key>
  35 + <string>App需要您的同意,才能访问麦克风</string>
  36 + <key>NSPhotoLibraryAddUsageDescription</key>
  37 + <string>App需要您的同意,才能访问相册</string>
  38 + <key>NSPhotoLibraryUsageDescription</key>
  39 + <string>App需要您的同意,才能访问相册</string>
40 <key>UILaunchStoryboardName</key> 40 <key>UILaunchStoryboardName</key>
41 <string>LaunchScreen</string> 41 <string>LaunchScreen</string>
42 <key>UIMainStoryboardFile</key> 42 <key>UIMainStoryboardFile</key>