| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717 |
- //
- // LoginViewController.m
- // BuguLive
- //
- // Created by fanwe2014 on 16/7/5.
- // Copyright © 2016年 xfg. All rights reserved.
- #import "LoginViewController.h"
- //#import "LPhoneLoginVC.h"
- #import "JSONKit.h"
- //#import "WeiboSDK.h"
- //#import <TencentOpenAPI/TencentOAuth.h>
- #import "PhoneLoginViewController.h"
- #import "MGRegisterViewController.h"//注册界面
- #import "MGLoginView.h"
- #import "LPhoneRegistVC.h"
- #import "BGLoginView.h"
- #import "LoginRecommendVC.h"
- //#import "OpenInstallSDK.h"
- //#import <FBSDKLoginKit/FBSDKLoginKit.h>
- #import <UMLink/UMLink.h>
- //#import <FBSDKCoreKit/FBSDKCoreKit.h>
- #import "AppleIDManager.h"
- @interface LoginViewController ()<NLgDelegate,MobClickLinkDelegate>
- //@property (strong, nonatomic) UIButton *visitorsLoginBtn; //游客登入的btn
- @property (strong, nonatomic) NSMutableArray *Marray; //登入方式的数组
- //@property (strong, nonatomic) UIImageView *selectedImageView; //协议是否选择的图标
- //@property (assign, nonatomic) BOOL isSelectProtocol; //是否选择了协议
- @property (weak, nonatomic) IBOutlet UIButton *vistorLoginBtn;
- @property (weak, nonatomic) IBOutlet UIButton *wechatBtn;
- @property (weak, nonatomic) IBOutlet UIButton *qqBtn;
- @property (weak, nonatomic) IBOutlet UIButton *weiboBtn;
- @property (weak, nonatomic) IBOutlet UIButton *phoneBtn;
- //@property(nonatomic, strong) MGLoginView *loginView;
- @property(nonatomic, strong) BGLoginView *loginView;
- @end
- @implementation LoginViewController{
- NSTimer *_timer; //定时器
- int _timeCount; //定时器时间
- }
- -(BGLoginView *)loginView{
- if (!_loginView) {
- _loginView = [BGLoginView new];
- _loginView.frame = CGRectMake(0, 0, kScreenW , kScreenH);
-
- FWWeakify(self)
-
- _loginView.clickVistorBlock = ^(BOOL isClickVistoers) {
- FWStrongify(self)
- [self visitorLoginBtnAction:nil];
- };
- _loginView.clickForgetPWBlock = ^(BOOL clickForget) {
- MGRegisterViewController *vc = [[MGRegisterViewController alloc]initWithLoginType:MGLOGIN_TYPE_FINDPASSWORD];
- [[AppDelegate sharedAppDelegate]pushViewController:vc animated:YES];
- };
-
- _loginView.clickReigsterBlock = ^(BOOL clickRegister) {
- MGRegisterViewController *vc = [[MGRegisterViewController alloc]initWithLoginType:MGLOGIN_TYPE_REGISTER];
- [[AppDelegate sharedAppDelegate]pushViewController:vc animated:YES];
- };
-
- _loginView.clickLoginBlock = ^(NSInteger i) {
- FWStrongify(self)
- if (i == 0) {
- [self loginCodeBtn];
- }else if (i == 1){
- [self loginByPhone];
- }else if (i == 2){
- [self wechatLoginBtnAction:nil];
- }else if (i == 3){
- [self agreementBtnAction:nil];
- }
-
- if (i == 1000 + 1) {
- [self loginByQQ];
- }else if (i == 1000 + 2){
- [self loginByWechat];
- }else if (i == 1000 + 4){
- MGRegisterViewController *vc = [[MGRegisterViewController alloc]initWithLoginType:MGLOGIN_TYPE_CODELOGIN];
- [[AppDelegate sharedAppDelegate]pushViewController:vc animated:YES];
- }else if (i == 1000 + 5){//facebook
- // [self getUserInfoForPlatform:UMSocialPlatformType_Facebook];
- [self loginByFacebook];
- }else if (i == 1000 + 6){//google
- [self getUserInfoForPlatform:UMSocialPlatformType_GooglePlus];
- }
- };
- }
- return _loginView;
- }
- /*
- -(MGLoginView *)loginView{
- if (!_loginView) {
- _loginView = [MGLoginView new];
- _loginView.frame = CGRectMake(kRealValue(21), 0, kScreenW - kRealValue(21 * 2), kRealValue(405));
- _loginView.centerY = kScreenH / 2 + kRealValue(15);
- _loginView.layer.masksToBounds = YES;
- _loginView.layer.cornerRadius = 5;
- _loginView.backgroundColor = kWhiteColor;
- FWWeakify(self)
- _loginView.clickLoginBlock = ^(NSInteger i) {
- FWStrongify(self)
- if (i == 0) {
- [self loginCodeBtn];
- }else if (i == 1){
- [self loginByPhone];
- }else if (i == 2){
- [self wechatLoginBtnAction:nil];
- }else if (i == 3){
- [self agreementBtnAction:nil];
- }
- };
- }
- return _loginView;
- }
- */
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showVisitorsBtn) name:@"getDeviceTokenComplete" object:nil];
-
- UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
- [imgView setImage:[UIImage imageNamed:@"mg_ig_bgView"]];
- [self.view addSubview:imgView];
- [self.view addSubview:self.loginView];
-
- _timeCount = 60;
- self.LView.LDelegate = self;
-
- [MobClickLink getInstallParams:^(NSDictionary *params, NSURL *URL, NSError *error) {
- if(params != nil)
- {
- NSDictionary *openinstalDic =
- @{
- @"invite_code":[NSString stringWithFormat:@"%@",params[@"invite_code"]],
- @"channel":[NSString stringWithFormat:@"%@",params[@"channel"]],
- };
- [GlobalVariables sharedInstance].openinstallDic = openinstalDic;
- if (!error) {
- [MobClickLink handleLinkURL:URL delegate:self];
- }
- }
- } enablePasteboard:YES];
- // [[OpenInstallSDK defaultManager] getInstallParmsWithTimeoutInterval:300 completed:^(OpeninstallData * _Nullable appData) {
- // if(appData.data != nil)
- // {
- // NSDictionary *openinstalDic =
- // @{
- // @"invite_code":[NSString stringWithFormat:@"%@",appData.data[@"invite_code"]],
- // @"channel":[NSString stringWithFormat:@"%@",appData.data[@"channel"]],
- // };
- // [GlobalVariables sharedInstance].openinstallDic = openinstalDic;
- // }
- // }];
- // [self loginWay];
- }
- #pragma mark - MobClickLinkDelegate
- - (void)getLinkPath:(NSString *)path params:(NSDictionary *)params{
- [GlobalVariables sharedInstance].openinstallDic = params;
- }
- - (void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [self.navigationController setNavigationBarHidden:NO];
- [IQKeyboardManager sharedManager].enable = NO;
- [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
-
- [self setUpLocalizationString];
-
- [self.navigationController setNavigationBarHidden:YES animated:YES];
- // [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:animated];
- [IQKeyboardManager sharedManager].enable = YES;
- [IQKeyboardManager sharedManager].enableAutoToolbar = YES;
- [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
- [IQKeyboardManager sharedManager].keyboardDistanceFromTextField = 5.0f;
- }
- - (void)initFWVariables
- {
- [super initFWVariables];
-
- self.view.backgroundColor = kAppMainColor;
- // _isSelectProtocol = YES;
- _Marray = [[NSMutableArray alloc]init];
- _has_qq_login = (int)self.BuguLive.appModel.has_qq_login;
- _has_wx_login = (int)self.BuguLive.appModel.has_wx_login;
- _has_mobile_login = (int)self.BuguLive.appModel.has_mobile_login;
- _has_sina_login = (int)self.BuguLive.appModel.has_sina_login;
-
- _qqBtn.hidden = (int)self.BuguLive.appModel.has_qq_login == 0;
- _wechatBtn.hidden = (int)self.BuguLive.appModel.has_wx_login == 0;
- _phoneBtn.hidden = (int)self.BuguLive.appModel.has_mobile_login == 0;
- _weiboBtn.hidden = (int)self.BuguLive.appModel.has_sina_login == 0;
-
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(wxloginback:) name:kWXLoginBack object:nil];
-
-
-
-
-
-
-
-
-
-
-
- }
- - (void)initFWUI
- {
- [super initFWUI];
- // [self creatView];
- }
- #pragma mark 主UI
- - (void)showVisitorsBtn
- {
- self.vistorLoginBtn.hidden = YES;
- }
- #pragma mark 登入方式 0qq 1微信 2微博 3手机
- - (void)loginWay
- {
- if (self.has_qq_login == 1)//QQ
- {
- [_Marray addObject:@"1"];
- }
-
- if (self.has_wx_login == 1)//微信
- {
- [_Marray addObject:@"2"];
- }
-
- if (self.has_sina_login == 1)//微博
- {
- [_Marray addObject:@"3"];
- }
-
- // if (self.has_mobile_login == 1)//手机
- // {
- [_Marray addObject:@"4"];
- // }
-
- //如果各种登入方式都没有就将手机的登入方式都显示出来
- if (_Marray.count < 1)
- {
- _Marray = [[NSMutableArray alloc]initWithObjects:@"4", nil];
- }
- self.LView = [[ULGView alloc]initWithFrame:CGRectMake(0, kScreenH*0.7, kScreenW, 47) Array:_Marray];
- self.LView.LDelegate = self;
- [self.view addSubview:self.LView];
- }
- - (IBAction)phoneLoginBtnAction:(id)sender {
- [self loginByPhone];
- }
- //点击获取h验证码
- -(void)loginCodeBtn{
- if (self.loginView.phoneText.text.length < 1)
- {
- [FanweMessage alert:ASLocalizedString(@"手机号限制11位数!")];
- return;
- }
- self.loginView.codeBtn.enabled = NO;
- _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timego) userInfo:nil repeats:YES];
- [self timego];
- FWWeakify(self)
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"login" forKey:@"ctl"];
- [parmDict setObject:@"send_mobile_verify_international" forKey:@"act"];
- // [parmDict setObject:@"1" forKey:@"wx_binding"];
- [parmDict setObject:self.loginView.phoneText.text forKey:@"mobile"];
- [self showMyHud];
- [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
- {
- FWStrongify(self)
- [self hideMyHud];
- [GlobalVariables sharedInstance].otp_message_id = [NSString stringWithFormat:@"%@",[responseJson toString:@"otp_message_id"]];
- if ([responseJson toInt:@"status"] != 1)
- {
- self.loginView.codeBtn.enabled = YES;
- [self.loginView.codeBtn setTitle:ASLocalizedString(@"发送验证码") forState:UIControlStateNormal];
- [_timer invalidate];
- _timer = nil;
- }
- } FailureBlock:^(NSError *error) {
- FWStrongify(self)
- [self hideMyHud];
- [self.loginView.codeBtn setTitle:ASLocalizedString(@"发送验证码") forState:UIControlStateNormal];
- [FanweMessage alert:ASLocalizedString(@"发送失败")];
- self.loginView.codeBtn.enabled = YES;
- }];
- }
- #pragma mark 获取验证码的倒计时
- - (void)timego
- {
- [self timerDec:_timeCount];
- }
- - (void)timerDec:(NSInteger)time
- {
- if(time > 0)
- {
- [self.loginView.codeBtn setTitle:[NSString stringWithFormat:ASLocalizedString(@"重新获取(%lds)"),(long)time] forState:UIControlStateDisabled];
- // [self.loginView.codeBtn setTitleColor:kAppGrayColor1 forState:UIControlStateDisabled];
- _timeCount --;
- }else if(time == 0)
- {
- self.loginView.codeBtn.enabled = YES;
- [self.loginView.codeBtn setTitle:[NSString stringWithFormat:ASLocalizedString(@"获取验证码")] forState:UIControlStateNormal];
- [_timer invalidate];
- _timeCount = 60;
- }
- }
- - (IBAction)wechatLoginBtnAction:(id)sender {
- // if (![WXApi isWXAppInstalled])
- // {
- // [FanweMessage alert:ASLocalizedString(@"微信未安装")];
- // }
- // else
- // {
- // [self loginByWechat];
- // }
- }
- - (IBAction)qqLoginBtnAction:(id)sender {
- // if (![TencentOAuth iphoneQQInstalled])
- // {
- // [FanweMessage alert:ASLocalizedString(@"QQ未安装")];
- // }
- // else
- // {
- [self loginByQQ];
- // }
- }
- - (IBAction)weiboLoginBtnAction:(id)sender {
- // if (![WeiboSDK isWeiboAppInstalled])
- // {
- // [FanweMessage alert:ASLocalizedString(@"新浪微博未安装")];
- // }
- // else
- // {
- [self loginByXinlang];
- // }
- }
- - (IBAction)agreementBtnAction:(id)sender {
- BGMainWebViewController *tmpController = [BGMainWebViewController webControlerWithUrlStr:self.BuguLive.appModel.privacy_link isShowIndicator:YES isShowNavBar:YES isShowBackBtn:YES];
- [[AppDelegate sharedAppDelegate] pushViewController:tmpController animated:YES];
- }
- #pragma mark 获取UserSig等参数
- - (void)getLoginParam:(NSMutableDictionary *)param
- {
- [self showMyHud];
-
- FWWeakify(self)
-
- [self.httpsManager POSTWithParameters:param SuccessBlock:^(NSDictionary *responseJson)
- {
- FWStrongify(self)
-
- if ([responseJson toInt:@"status"] == 1)
- {
- if ([responseJson toInt:@"need_bind_mobile"] == 1)//是否需要绑定手机1需要 0为不需要
- {
- [self hideMyHud];
- PhoneLoginViewController *loginVC = [[PhoneLoginViewController alloc]initWithNibName:NSStringFromClass([PhoneLoginViewController class]) bundle:[NSBundle mainBundle]];
- loginVC.loginId = self.loginId;
- loginVC.loginType = self.loginType;
- loginVC.accessToken = self.accessToken;
- loginVC.LNSecBPhone = YES;
- [[AppDelegate sharedAppDelegate] pushViewController:loginVC animated:YES];
-
- }else
- {
- [BGIMLoginManager sharedInstance].loginParam.identifier = [responseJson toString:@"data"];
- [BGIMLoginManager sharedInstance].loginParam.isAgree = [responseJson toInt:@"is_agree"];
-
- self.BuguLive.appModel.first_login = [responseJson toString:@"first_login"];
- self.BuguLive.appModel.new_level = [responseJson toInt:@"new_level"];
- self.BuguLive.appModel.login_send_score = [responseJson toString:@"login_send_score"];
- [GlobalVariables sharedInstance].token = [responseJson toString:@"token"];
- [[BGIMLoginManager sharedInstance] getUserSig:^{
-
- [[AppDelegate sharedAppDelegate] enterMainUI];
-
- [self hideMyHud];
-
- } failed:^(int errId, NSString *errMsg) {
- [self hideMyHud];
-
- }];
- }
- }
- else
- {
- [self hideMyHud];
- }
-
- } FailureBlock:^(NSError *error)
- {
- [self hideMyHud];
-
- [FanweMessage alertHUD:ASLocalizedString(@"获取登录参数失败,请稍后尝试")];
- }];
- }
- #pragma mark 微信登录
- - (void)loginByWechat
- {
- [self getUserInfoForPlatform:UMSocialPlatformType_WechatSession];
- /*
- // 构造SendAuthReq结构体
- SendAuthReq* req =[[SendAuthReq alloc ] init ];
- req.scope = @"snsapi_userinfo" ;
- req.state = @"123" ;
- // 第三方向微信终端发送一个SendAuthReq消息结构
- [WXApi sendReq:req];
- */
- }
- #pragma mark 微信登录获取code后oc调用js把code等传上去
- - (void)wxloginback:(NSNotification *)text
- {
- /*
- NSString *string = text.object;
- NSDictionary *dict = [string objectFromJSONString];
- NSString *code = [dict toString:@"code"];
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"login" forKey:@"ctl"];
- [parmDict setObject:@"wx_login" forKey:@"act"];
- [parmDict setObject:code forKey:@"code"];
-
- [self getLoginParam:parmDict];
- */
- }
- #pragma mark qq登录
- - (void)loginByQQ
- {
- [self getUserInfoForPlatform:UMSocialPlatformType_QQ];
- }
- #pragma mark 新浪登录
- - (void)loginByXinlang
- {
- [self getUserInfoForPlatform:UMSocialPlatformType_Sina];
- }
- #pragma mark 根据对应类型进行登录操作
- - (void)getUserInfoForPlatform:(UMSocialPlatformType)platformType
- {
- __weak typeof(self) ws = self;
-
- [[UMSocialManager defaultManager] getUserInfoWithPlatform:platformType currentViewController:self completion:^(id result, NSError *error) {
-
- UMSocialUserInfoResponse *resp = result;
-
- if (resp)
- {
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"login" forKey:@"ctl"];
-
- if (platformType == UMSocialPlatformType_QQ)
- {
- [parmDict setObject:@"qq_login" forKey:@"act"];
- [parmDict setObject:resp.openid forKey:@"openid"];
- [parmDict setObject:resp.accessToken forKey:@"access_token"];
- self.loginType = @"qq_login";
- self.loginId = resp.openid;
- }
- else if (platformType == UMSocialPlatformType_WechatSession)
- {
- [parmDict setObject:@"wx_login" forKey:@"act"];
- [parmDict setObject:resp.openid forKey:@"openid"];
- [parmDict setObject:resp.accessToken forKey:@"access_token"];
- self.loginType = @"wx_login";
- self.loginId = resp.openid;
- }
- else if (platformType == UMSocialPlatformType_Sina)
- {
- [parmDict setObject:@"sina_login" forKey:@"act"];
- [parmDict setObject:resp.uid forKey:@"sina_id"];
- [parmDict setObject:resp.accessToken forKey:@"access_token"];
- self.loginType = @"sina_login";
- self.loginId = resp.uid;
- }else if (platformType == UMSocialPlatformType_Facebook){
- [parmDict setObject:@"sina_login" forKey:@"act"];
- [parmDict setObject:resp.uid forKey:@"sina_id"];
- [parmDict setObject:resp.accessToken forKey:@"access_token"];
- self.loginType = @"sina_login";
- self.loginId = resp.uid;
-
-
- }else if (platformType == UMSocialPlatformType_GooglePlus){
-
- }
-
-
- self.accessToken = resp.accessToken;
- [ws getLoginParam:parmDict];
- }
- }];
- }
- #pragma mark 手机登录
- - (void)loginByPhone
- {
-
- if (self.loginView.phoneText.text.length < 1) {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"手机号限制11位数!")];
- return;
- }
-
- //6.28号修改为密码登录
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"login" forKey:@"ctl"];
- [parmDict setObject:@"password_login" forKey:@"act"];
- [parmDict setObject:self.loginView.phoneText.text forKey:@"mobile"];
- [parmDict setObject:self.loginView.codeText.text forKey:@"password"];
- FWWeakify(self)
- [self showMyHud];
- [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
- {
- FWStrongify(self)
- [self hideMyHud];
- if ([responseJson toInt:@"status"] == 1)
- {
- self.BuguLive.appModel.new_level = [responseJson toInt:@"new_level"];
- self.BuguLive.appModel.first_login = [responseJson toString:@"first_login"];
- self.BuguLive.appModel.login_send_score = [responseJson toString:@"login_send_score"];
-
-
- if ([responseJson toInt:@"is_lack"] == 1)
- {
- LPhoneRegistVC *phoneRegist = [[LPhoneRegistVC alloc]init];
- phoneRegist.used_id = [responseJson toString:@"user_id"];
- phoneRegist.userInfoDic = responseJson[@"user_info"];
- phoneRegist.userName = [responseJson[@"user_info"] toString:@"nick_name"];
- // [[AppDelegate sharedAppDelegate]pushViewController:phoneRegist];
- [self.navigationController presentViewController:phoneRegist animated:YES completion:nil];
- }
- else
- {
- [self showMyHud];
-
- NSDictionary *userDic = [responseJson valueForKey:@"user_info"];
-
- self.BuguLive.appModel.is_open_young = [userDic objectForKey:@"is_open_young"];
-
-
- [BGIMLoginManager sharedInstance].loginParam.identifier = [responseJson toString:@"user_id"];
- [BGIMLoginManager sharedInstance].loginParam.isAgree = [responseJson toInt:@"is_agree"];
-
- [GlobalVariables sharedInstance].token = [userDic toString:@"token"];
-
- [[BGIMLoginManager sharedInstance] getUserSig:^{
-
- [[AppDelegate sharedAppDelegate] enterMainUI];
- [self hideMyHud];
- } failed:^(int errId, NSString *errMsg) {
- [self hideMyHud];
- }];
- }
- }
- } FailureBlock:^(NSError *error)
- {
- FWStrongify(self)
- [self hideMyHud];
- }];
- // PhoneLoginViewController *phoneVC = [[PhoneLoginViewController alloc]initWithNibName:NSStringFromClass([PhoneLoginViewController class]) bundle:[NSBundle mainBundle]];
- // [[AppDelegate sharedAppDelegate]pushViewController:phoneVC];
- }
- //游客登录
- - (IBAction)visitorLoginBtnAction:(id)sender {
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"login" forKey:@"ctl"];
- [parmDict setObject:@"visitors_login" forKey:@"act"];
- [parmDict setObject:[GlobalVariables sharedInstance].deviceToken forKey:@"um_reg_id"];
- [self showMyHud];
- FWWeakify(self)
- [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
-
- FWStrongify(self)
- if ([responseJson toInt:@"status"] == 1)
- {
- [BGIMLoginManager sharedInstance].loginParam.identifier = [[responseJson objectForKey:@"user_info"] toString:@"user_id"];
- [BGIMLoginManager sharedInstance].loginParam.isAgree = [[responseJson objectForKey:@"user"] toInt:@"is_agree"];
-
- self.BuguLive.appModel.first_login = [responseJson toString:@"first_login"];
- self.BuguLive.appModel.new_level = [responseJson toInt:@"new_level"];
- self.BuguLive.appModel.login_send_score = [responseJson toString:@"login_send_score"];
-
- [[BGIMLoginManager sharedInstance] getUserSig:^{
-
- [[AppDelegate sharedAppDelegate] enterMainUI];
-
- [self hideMyHud];
-
- } failed:^(int errId, NSString *errMsg) {
-
- [self hideMyHud];
- }];
- }
- else
- {
- [self hideMyHud];
- }
- } FailureBlock:^(NSError *error) {
- FWStrongify(self)
- [self hideMyHud];
- }];
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter]removeObserver:self];
- }
- //- (UIStatusBarStyle)preferredStatusBarStyle{
- //
- // if (@available(iOS 13, *)) {
- // return UIStatusBarStyleLightContent;
- // }
- // return UIStatusBarStyleLightContent;
- //}
- - (void)loginByFacebook {
- #warning Facebook登录,暂时注释
- // FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
- //// [loginManager logOut];
-
- // __weak __typeof(self)weakSelf = self;
- // [loginManager logInWithPermissions:@[@"public_profile"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult * _Nullable result, NSError * _Nullable error) {
- // if(result.isCancelled)
- // {
- //
- // }
- // else
- // {
- //
- //// [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result2, NSError *error) {
- //// NSDictionary *resultDict = (NSDictionary *)result2;
- //// NSString *userName = resultDict[@"name"];
- ////
- //// NSString *headerImage = [NSString stringWithFormat:@"http://graph.facebook.com/%@/picture",resultDict[@"id"]];
- ////
- //// NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- //// [parmDict setObject:@"login" forKey:@"ctl"];
- ////
- //// [parmDict setObject:@"fb_login" forKey:@"act"];
- //// [parmDict setObject:result.token.userID forKey:@"openid"];
- //// [parmDict setObject:result.token.tokenString forKey:@"access_token"];
- ////
- //// [parmDict setObject:userName forKey:@"user_name"];
- //// [parmDict setObject:headerImage forKey:@"user_icon"];
- //// self.loginType = @"fb_login";
- //// self.loginId = result.token.userID;
- ////
- //// [weakSelf getLoginParam:parmDict];
- ////
- ////
- //// }];
- //
- //
- //
- // }
- // }];
- // [loginManager logInWithPermissions:@[] fromViewController:self handler:^(FBSDKLoginManagerLoginResult * _Nullable result, NSError * _Nullable error) {
-
- // }];
-
-
- // [loginManager logInWithReadPermissions:@[@"email"]
- // fromViewController:self
- // handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
- // //TODO: process error or result
- // }];
-
- }
- @end
|