add files apis
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
#import "WXApi.h"
|
||||
#import "GiGaNetManager.h"
|
||||
#import "WeiIXinApiManager.h"
|
||||
#import "GiGaBaseAPiRequest.h"
|
||||
#import "GiGaUser.h"
|
||||
#import "GiGaServerConfig.h"
|
||||
|
||||
@interface GiGaUserLoginVC ()
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *userImagView;
|
||||
@@ -24,6 +27,8 @@
|
||||
@property (weak, nonatomic) IBOutlet UIButton *weiXinLoginBtn;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *registBtn;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *wexinbtnImageView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *secretBtn;
|
||||
|
||||
@end
|
||||
|
||||
@@ -35,16 +40,20 @@
|
||||
// Do any additional setup after loading the view from its nib.
|
||||
[self setUpX];
|
||||
[self textFieldUI];
|
||||
[self.view bringSubviewToFront:self.weiXinLoginBtn];
|
||||
[self.registBtn addTarget:self action:@selector(registBtnAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.loginBtn addTarget:self action:@selector(loginBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.weiXinLoginBtn addTarget:self
|
||||
action:@selector(weiXinLoginAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.secretBtn addTarget:self action:@selector(secretBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
NC_ADD_TARGET_NAME_OBJECT(self, @selector(WeiXinLongIn:), kWeiXinAuthrization_Success, nil)
|
||||
NC_ADD_TARGET_NAME_OBJECT(self, @selector(userRegistSuccsessNoti:), kUserRegistSucccess, nil)
|
||||
|
||||
if (![WXApi isWXAppInstalled]) {
|
||||
self.weiXinLoginBtn.hidden = YES;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)dealloc{
|
||||
@@ -56,8 +65,7 @@
|
||||
|
||||
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
rightBtn.frame = CGRectMake(0, 0, 40, 40);
|
||||
rightBtn.backgroundColor = [UIColor blueColor];
|
||||
[rightBtn setImage:[UIImage imageNamed:@"maske_dismiss_waring"] forState:UIControlStateNormal];
|
||||
[rightBtn setImage:[UIImage imageNamed:@"btn_back"] forState:UIControlStateNormal];
|
||||
[rightBtn addTarget:self action:@selector(rightBtnAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
|
||||
}
|
||||
@@ -66,9 +74,8 @@
|
||||
|
||||
//self.acountTextField.attributedPlaceholder = @"";
|
||||
UIView *acountView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
|
||||
acountView.backgroundColor = [UIColor redColor];
|
||||
UIImageView *acountViewIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 5, 16, 18)];
|
||||
acountViewIcon.image = [UIImage imageNamed:@""];
|
||||
UIImageView *acountViewIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15,9, 12, 22)];
|
||||
acountViewIcon.image = [UIImage imageNamed:@"ic_number"];
|
||||
[acountView addSubview:acountViewIcon];
|
||||
self.acountTextField.leftView = acountView;
|
||||
self.acountTextField.leftViewMode = UITextFieldViewModeAlways;
|
||||
@@ -76,9 +83,8 @@
|
||||
// NSAttributedString *passholderText = [[NSAttributedString alloc] initWithString:@"密码" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor redColor]}];
|
||||
// self.passwordTextField.attributedPlaceholder = passholderText;
|
||||
UIView *passView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
|
||||
passView.backgroundColor = [UIColor redColor];
|
||||
UIImageView *passViewIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 5, 16, 18)];
|
||||
passViewIcon.image = [UIImage imageNamed:@""];
|
||||
UIImageView *passViewIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 9, 12, 22)];
|
||||
passViewIcon.image = [UIImage imageNamed:@"icon_key"];
|
||||
[passView addSubview:passViewIcon];
|
||||
self.passwordTextField.leftView = passView;
|
||||
self.passwordTextField.leftViewMode = UITextFieldViewModeAlways;
|
||||
@@ -121,7 +127,7 @@
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 登录
|
||||
#pragma mark 手机号登录
|
||||
-(void)loginBtnAction:(UIButton *)btn{
|
||||
|
||||
if (self.acountTextField.text == nil) {
|
||||
@@ -137,15 +143,63 @@
|
||||
GIGA_ShowToast(@"密码不能为空");
|
||||
return;
|
||||
}
|
||||
if (self.passwordTextField.text.length < 6) {
|
||||
GIGA_ShowToast(@"密码长度不能小于六位字符");
|
||||
return;
|
||||
}
|
||||
// if (self.passwordTextField.text.length < =6) {
|
||||
// GIGA_ShowToast(@"密码长度不能小于六位字符");
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
// [self dismissViewControllerAnimated:YES completion:nil];
|
||||
[self loginWithAction:btn];
|
||||
|
||||
}
|
||||
|
||||
-(void)loginWithAction:(UIButton *)btn{
|
||||
|
||||
NSDictionary *params = @{
|
||||
@"username":self.acountTextField.text,
|
||||
@"password":self.passwordTextField.text
|
||||
};
|
||||
// GiGaBaseAPiRequest *loginApi = [GiGaBaseAPiRequest initWithRequestPath:@"sys/v1/login" method:RequestPostMethod parms:params];
|
||||
//weakify(self);
|
||||
// [loginApi requstDataWithResult:^(GiGaAPIResult *result) {
|
||||
// GILog(@"**登陆***\n resultDic:%ld\n code:%@\n *******\n",(long)result.code,result.dic);
|
||||
// if (result.success) {
|
||||
// GILog(@"****登陆成功****");
|
||||
// [self saveUserData];
|
||||
// [self dismissViewControllerAnimated:YES completion:nil];
|
||||
// }
|
||||
// }];
|
||||
|
||||
[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) {
|
||||
[GiGaUserDefault saveToken:resDic[@"token"]];
|
||||
//埋点
|
||||
[MobClick endEvent:MobClick_UserLogin];
|
||||
//暂定123 登陆标志
|
||||
[GiGaUserDefault saveUserId:@"123"];
|
||||
GIGA_WIndowTost(@"登录成功!");
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
}
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
-(void)saveUserData{
|
||||
//埋点
|
||||
[MobClick endEvent:MobClick_UserLogin];
|
||||
[GiGaUserDefault saveUserId:@"123"];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 微信登录
|
||||
@@ -201,4 +255,27 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//接收注册成功通知
|
||||
-(void)userRegistSuccsessNoti:(NSNotification *)noti{
|
||||
|
||||
self.acountTextField.text =(NSString *)noti.object;
|
||||
}
|
||||
|
||||
//密码加密按钮
|
||||
-(void)secretBtnAction:(UIButton *)btn{
|
||||
btn.selected = !btn.selected;
|
||||
if (btn.selected) {
|
||||
//秘文
|
||||
self.passwordTextField.secureTextEntry = YES;
|
||||
[btn setImage:[UIImage imageNamed:@"btn_tab_notselect"] forState:UIControlStateSelected];
|
||||
}else{
|
||||
self.passwordTextField.secureTextEntry = NO;
|
||||
[btn setImage:[UIImage imageNamed:@"btn_tab_desplay"] forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user