微信登陆,bug修改

This commit is contained in:
kai60
2020-01-09 09:25:43 +08:00
parent 82590f8fba
commit bfb68dd81c
62 changed files with 5105 additions and 275 deletions
@@ -17,7 +17,8 @@
#import "AgreementViewController.h"
#import "MyIntroductionViewController.h"
#import "ConnectWifiViewController.h"
#import "WXApi.h"
#import "WXApiManager.h"
#import "ChatroomModel.h"
//#import <RongIMKit/RongIMKit.h>
//#import <RongIMLib/RongIMLib.h>
@@ -36,7 +37,7 @@
#import <SMS_SDK/Extend/SMSSDK+ExtexdMethods.h>
#import "XWCountryCodeController.h"
#import <CoreLocation/CoreLocation.h>
@interface RegistViewController ()<UITextFieldDelegate,UIAlertViewDelegate,MBProgressHUDDelegate,CLLocationManagerDelegate>
@interface RegistViewController ()<UITextFieldDelegate,UIAlertViewDelegate,MBProgressHUDDelegate,CLLocationManagerDelegate,WXApiManagerDelegate>
{
BOOL _showed;//显示过了
@@ -48,6 +49,7 @@
@property (weak, nonatomic) IBOutlet UIButton *timeBtn;
@property(nonatomic,copy)NSString*verifyData;
@property(nonatomic,copy) NSString *areaCode;
@property (weak, nonatomic) IBOutlet UIButton *resignBtn;
@property (weak, nonatomic) IBOutlet UIButton *registBtn;
- (IBAction)agreementBtn:(id)sender;
@@ -63,7 +65,9 @@
@property(nonatomic,copy) NSString *adderss;
@property (weak, nonatomic) IBOutlet UILabel *qrcodeSwitchLbl;
@property (nonatomic,copy) NSDictionary *expara;//城市
@property (weak, nonatomic) IBOutlet UIView *styleView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *wechatConstraints;
@end
extern BOOL formLogIn;
@@ -73,7 +77,8 @@ extern BOOL formLogIn;
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.isBind=NO;
self.isFromLogin=NO;
}
return self;
@@ -104,6 +109,15 @@ extern BOOL formLogIn;
self.passwordTextField.delegate=self;
self.navigationItem.hidesBackButton=YES;
[self getLocation];
if ([WXApi isWXAppInstalled]&&!self.isBind)
{
self.styleView.hidden=NO;
if ([CommonUtils isIphoneX])
{
//self.wechatConstraints.constant=-30;
}
}
}
#pragma mark 定位
@@ -284,14 +298,25 @@ extern BOOL formLogIn;
}
#pragma mark-设置导航按钮
-(void)addNaviItem{
UILabel*labe=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 44)];
UILabel*labe=[[UILabel alloc]initWithFrame:CGRectMake((SCREEN_WIDTH-200)/2.0, 0, 200, 44)];
labe.text=@"注册";
labe.textAlignment=NSTextAlignmentCenter;
labe.textColor=[UIColor whiteColor];
self.navigationItem.titleView=labe;
BOOL skiped=NO;
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
UserModel*model=[dataContorl getUserInfo];
if (model.unionId)
{
skiped =[userDefsult boolForKey:model.unionId];
}
UIButton*rightButton = [[UIButton alloc]initWithFrame:CGRectMake(25,0,60,60)];
[rightButton setTitle:@"登录" forState:UIControlStateNormal];
rightButton.backgroundColor=[UIColor clearColor];
[rightButton.titleLabel setFont:[UIFont systemFontOfSize:14]];
[rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
@@ -300,13 +325,59 @@ extern BOOL formLogIn;
UIBarButtonItem*rightItem= [[UIBarButtonItem alloc] initWithCustomView:rightButton];
// rightItem.tintColor=[UIColor whiteColor];
// [rightItem setTintColor:[UIColor whiteColor]];
self.navigationItem.rightBarButtonItem= rightItem;
if (self.isBind)
{
labe.text=@"绑定手机";
[self.resignBtn setTitle:@"确定" forState:UIControlStateNormal];
if (!skiped&&self.isFromLogin)
{
[rightButton setTitle:@"跳过" forState:UIControlStateNormal];
self.navigationItem.rightBarButtonItem= rightItem;
}
else
{
UIButton* _bakbutton = [UIButton buttonWithType:UIButtonTypeCustom];
_bakbutton.frame = CGRectMake(0,0,48,44);
[_bakbutton setImage:[UIImage imageNamed:@"back_btn"] forState:UIControlStateNormal];
_bakbutton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[_bakbutton addTarget: self action: @selector(goBackAction) forControlEvents: UIControlEventTouchUpInside];
// [_bakbutton setContentEdgeInsets:UIEdgeInsetsMake(0, 10, 0, -10)];
UIBarButtonItem*_back =[[UIBarButtonItem alloc] initWithCustomView:_bakbutton];
UIBarButtonItem *fixedButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
fixedButtonItem.width = -kSizeFrom750(30);
self.navigationItem.leftBarButtonItems = @[fixedButtonItem, _back];
}
}
else
{
self.navigationItem.rightBarButtonItem= rightItem;
}
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"blackbar.png"] forBarMetrics:UIBarMetricsDefault];
// [self.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14],UITextAttributeFont, [UIColor whiteColor], UITextAttributeTextColor, nil] forState:UIControlStateNormal];
}
-(void)rightButtonClick:(UIButton *)sender{
LogInViewController *login=[[LogInViewController alloc]init];
[self.navigationController pushViewController:login animated:YES];
if (self.isBind)
{
[[IfishUserDataUnity shareDataInstance] setAppTabRoot];
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
UserModel*model=[dataContorl getUserInfo];
if (model.unionId)
{
[userDefsult setBool:YES forKey:model.unionId];
[userDefsult synchronize];
}
}
else
{
LogInViewController *login=[[LogInViewController alloc]init];
[self.navigationController pushViewController:login animated:YES];
}
}
@@ -380,7 +451,15 @@ extern BOOL formLogIn;
{
NSLog(@"验证成功");
[self ifishAddUser];
if (self.isBind)
{
[self bindPhone];
}
else
{
[self ifishAddUser];
}
}
else
@@ -462,6 +541,73 @@ extern BOOL formLogIn;
}
-(void)bindPhone
{
UserModel*user=[dataContorl getUserInfo];
if (user.unionId)
{
NSMutableDictionary*para=[[NSMutableDictionary alloc]initWithDictionary:@{@"unionId":user.unionId,@"phoneNum":self.phoneNumberTextField.text}];
if (self.passwordTextField.text.length)
{
para[@"password"]=[MyMD5 md5:self.passwordTextField.text];
}
[AFHttpTool requestWihtMethod:RequestMethodTypePost
url:kUserBindPhone
params:para
success:^(id response) {
if (response) {
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
NSLog(@"resultDic:%@",resultDic);
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateUserInfobyValidation" object:nil];
if ([resultDic[@"result"] isEqualToString:@"100"])
{
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
NSString*userName=self.phoneNumberTextField.text;
NSString*password=self.passwordTextField.text;
[userdefult setObject:password forKey:@"password"];
[userdefult setObject:userName forKey:@"name"];
//是否退出登陆
[userdefult setObject:@"0" forKey:@"isExit"];
[userdefult synchronize];
user.phoneNumber=self.phoneNumberTextField.text;
[[DataCenter defaultDtacenter]setValue:user forKey:@"UserLogIn"];
[self.view makeToast:@"绑定成功"];
if (self.isFromLogin)
{
[[IfishUserDataUnity shareDataInstance] setAppTabRoot];
}
else
{
[self.navigationController popViewControllerAnimated:YES];
}
}else if ([resultDic[@"result"] isEqualToString:@"204"]){
[self.view makeToast:@"验证码错误"];
}else{
[self.view makeToast:@"修改失败"];
}
}
} failure:^(NSError *err) {
}];
}
}
-(void)goBackAction{
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark- 极光别名注册
- (void)tagsAliasCallback:(int)iResCode tags:(NSSet*)tags alias:(NSString*)alias {
@@ -497,7 +643,7 @@ extern BOOL formLogIn;
//视图下沉恢复原状
[UIView animateWithDuration:duration animations:^{
self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
self.view.frame = CGRectMake(0, NavigationBarHeight, self.view.frame.size.width, self.view.frame.size.height);
}];
}
@@ -673,8 +819,11 @@ extern BOOL formLogIn;
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
NSString*name=[userDefsult objectForKey:@"name"];
NSString*password=[userDefsult objectForKey:@"password"];
NSString*tokenStr=[MyMD5 md5:password];
NSString*tokenStr=@"";
if (password.length)
{
tokenStr=[MyMD5 md5:password];
}
[AFHttpTool userLogInWithPhoneNumber:name password:tokenStr phoneType:@"ios" address:self.adderss
longitude:self.longitude
latitude:self.latitude success:^(id response) {
@@ -717,10 +866,31 @@ extern BOOL formLogIn;
NSString *erstr =[NSString stringWithFormat:@"%@",err];
BLYLog(BuglyLogLevelError, erstr);
}];
} expara:self.expara];
}
- (IBAction)wechatAuthority:(id)sender {
AppDelegate*del=(AppDelegate*)[UIApplication sharedApplication].delegate;
del.isWechatLogin=YES;
[WXApiManager sharedManager].delegate=self;
SendAuthReq* req =[[SendAuthReq alloc]init];
req.scope = @"snsapi_userinfo";
req.state = @"ifish7";
[WXApi sendReq:req];
}
#pragma mark - WXApiManagerDelegate
- (void)managerDidRecvAuthResponse:(SendAuthResp *)response
{
if (response.errCode==0)
{
self.expara=@{@"code":response.code};
[self logIn];
}
AppDelegate*del=(AppDelegate*)[UIApplication sharedApplication].delegate;
del.isWechatLogin=NO;
}
-(void)creatMyindicaterView{
_indicatorView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];