fix
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#import "GiGaBaseAPiRequest.h"
|
||||
#import "GiGaUser.h"
|
||||
#import "GiGaServerConfig.h"
|
||||
#import "GIGAMBHUDHelper.h"
|
||||
|
||||
@interface GiGaUserLoginVC ()
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *userImagView;
|
||||
@@ -148,7 +149,7 @@
|
||||
|
||||
GiGaRegistViewController *registVC = [[GiGaRegistViewController alloc] init];
|
||||
[self.navigationController pushViewController:registVC animated:YES];
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 手机号登录
|
||||
@@ -178,35 +179,39 @@
|
||||
|
||||
-(void)loginWithAction:(UIButton *)btn{
|
||||
|
||||
NSDictionary *params = @{
|
||||
@"username":self.acountTextField.text,
|
||||
@"password":self.passwordTextField.text
|
||||
};
|
||||
|
||||
NSDictionary *weixinInfoDic = [GiGaUserDefault getWeiXinAccessToenDic];
|
||||
NSDictionary *params = nil;
|
||||
if (weixinInfoDic) {
|
||||
|
||||
params = @{
|
||||
@"username":self.acountTextField.text,
|
||||
@"password":self.passwordTextField.text,
|
||||
@"openid":weixinInfoDic[@"openid"],
|
||||
};
|
||||
}else{
|
||||
|
||||
params = @{
|
||||
@"username":self.acountTextField.text,
|
||||
@"password":self.passwordTextField.text
|
||||
};
|
||||
}
|
||||
|
||||
//[GIGAMBHUDHelper messageAddto:self.view title:@"登录中..."];
|
||||
[self.view makeToastActivity:CSToastPositionCenter];
|
||||
|
||||
NSString *url = [NSString stringWithFormat:@"%@sys/v1/login",[GiGaServerConfig getMainUrl]];
|
||||
[GiGaNetManager userLoginrequest:url params:params completionHandler:^(NSURLResponse *response, NSDictionary *resDic, NSError * _Nullable error) {
|
||||
GILog(@"%@",resDic);
|
||||
[self.view hideToastActivity];
|
||||
GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:resDic];
|
||||
|
||||
GILog(@"**登陆***\n code:%ld\n message:%@\n *******\n",result.code,result.message);
|
||||
if (result.success) {
|
||||
//token
|
||||
[GiGaUserDefault saveToken:resDic[@"token"]];
|
||||
//埋点
|
||||
[MobClick endEvent:MobClick_UserLogin];
|
||||
//暂定123 登陆标志
|
||||
[GiGaUserDefault saveUserId:@"123"];
|
||||
GIGA_WIndowTost(@"登录成功!");
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
[self userloginSussecess:resDic];
|
||||
|
||||
}else{
|
||||
GIGA_ShowToast(result.message);
|
||||
}
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
-(void)saveUserData{
|
||||
@@ -229,7 +234,9 @@
|
||||
|
||||
//授权成功获取access_token
|
||||
-(void)WeiXinLongIn:(NSNotification *)notification{
|
||||
|
||||
//检查网络
|
||||
//[self testNetworkStatus];
|
||||
[self.view makeToastActivity:CSToastPositionCenter];
|
||||
NSDictionary *param = @{
|
||||
@"appid":WXin_APPID,
|
||||
@"secret":WXin_APPSecret,
|
||||
@@ -243,14 +250,15 @@
|
||||
[self requstWeiXinUserinfo];
|
||||
|
||||
} failure:^(NSError *err) {
|
||||
[self.view makeToast:err.localizedDescription];
|
||||
GILog(@"access_token err-->%@",err.localizedDescription);
|
||||
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
//获取微信用户信息
|
||||
-(void)requstWeiXinUserinfo{
|
||||
|
||||
|
||||
NSDictionary *tokenDic = [GiGaUserDefault getWeiXinAccessToenDic];
|
||||
NSDictionary *param = @{
|
||||
@"openid":tokenDic[@"openid"],
|
||||
@@ -260,14 +268,66 @@
|
||||
[WeiIXinApiManager getWeiXinUserInfoUrl:@"https://api.weixin.qq.com/sns/userinfo" parameters:param success:^(id response) {
|
||||
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingAllowFragments error:nil];
|
||||
GILog(@"weixinUser info back -->%@",dict);
|
||||
|
||||
[self gigaUploadweixinInfo:dict];
|
||||
} failure:^(NSError *err) {
|
||||
|
||||
[self.view makeToast:err.localizedDescription];
|
||||
GILog(@"weixin_userinfoApi err-->%@",err.localizedDescription);
|
||||
}];
|
||||
}
|
||||
|
||||
//上传微信用户信息
|
||||
-(void)gigaUploadweixinInfo:(NSDictionary *)weiXinUserinfo{
|
||||
|
||||
[self.view makeToastActivity:CSToastPositionCenter];
|
||||
NSString *url = [NSString stringWithFormat:@"%@sys/v1/wechatlogin",[GiGaServerConfig getMainUrl]];
|
||||
[GiGaNetManager requestMethod:RequestPostMethod Url:url params:weiXinUserinfo responseBlock:^(NSDictionary *responseDict, NSDictionary *responseHeaderFields, NSError *error) {
|
||||
[self.view hideToastActivity];
|
||||
|
||||
if (!error) {
|
||||
|
||||
if ([responseDict[@"code"] integerValue] == 0) {
|
||||
//[self userloginSussecess:responseDict];
|
||||
[self.view makeToast:responseDict[@"msg"] duration:2.0 position:CSToastPositionCenter];
|
||||
[self jxt_showAlertWithTitle:@"温馨提示" message:@"请先绑定或注册手机号" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
|
||||
alertMaker.addActionCancelTitle(@"知道了");
|
||||
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
|
||||
|
||||
}];
|
||||
}else if([responseDict[@"code"] integerValue] == 500){
|
||||
//登录流程待定
|
||||
// [self.view makeToast:responseDict[@"msg"] duration:2.0 position:CSToastPositionCenter];
|
||||
// [self jxt_showAlertWithTitle:@"温馨提示" message:@"请绑定手机号" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
|
||||
//
|
||||
// } actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
|
||||
//
|
||||
// }];
|
||||
|
||||
}else{
|
||||
|
||||
[self.view makeToast:responseDict[@"msg"] duration:2.0 position:CSToastPositionCenter];
|
||||
}
|
||||
|
||||
}else{
|
||||
[self.view makeToast:@"用户信息提交异常"];
|
||||
GILog(@"上传微信用户信息error:\n%@",error.localizedDescription);
|
||||
}
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
-(void)userloginSussecess:(NSDictionary *)resDic{
|
||||
|
||||
//token
|
||||
[GiGaUserDefault saveToken:resDic[@"token"]];
|
||||
//埋点
|
||||
[MobClick endEvent:MobClick_UserLogin];
|
||||
//暂定123 登陆标志
|
||||
[GiGaUserDefault saveUserId:@"123"];
|
||||
GIGA_WIndowTost(@"登录成功!");
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
}
|
||||
//接收注册成功通知
|
||||
-(void)userRegistSuccsessNoti:(NSNotification *)noti{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user