add files apis

This commit is contained in:
lianxiang
2018-08-30 18:07:16 +08:00
parent 54e936535f
commit 3efde8e0ea
68 changed files with 1254 additions and 374 deletions
@@ -9,6 +9,12 @@
#import "GiGaRegistViewController.h"
#import "TTTAttributedLabel.h"
#import "GiGaWebViewController.h"
#import "NSTimer+Convenience.h"
#import "GiGaBaseAPiRequest.h"
#import "GiGaNetManager.h"
#import "MBProgressHUD.h"
#import "GiGaAttributedLabel.h"
@interface GiGaRegistViewController ()<TTTAttributedLabelDelegate>
@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextField;
@property (weak, nonatomic) IBOutlet UITextField *codeTextField;
@@ -17,7 +23,9 @@
@property (weak, nonatomic) IBOutlet UIButton *checkBtn;
@property (weak, nonatomic) IBOutlet UIButton *registBtn;
@property (weak, nonatomic) IBOutlet TTTAttributedLabel *useragreementLabel;
@property (weak, nonatomic) IBOutlet GiGaAttributedLabel *useragreementLabel;
@property(nonatomic,strong) NSTimer*timer;
@property(nonatomic) NSInteger time;
@end
@@ -26,10 +34,73 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"注册";
_time = 60;
// Do any additional setup after loading the view from its nib.
[self confirmUI];
[self.sendCodeBtn addTarget:self action:@selector(sendCodeBtnAction:) forControlEvents:UIControlEventTouchUpInside];
[self.registBtn addTarget:self action:@selector(registBtnAction:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)dealloc{
if (_timer) {
[_timer unfireTimer];
[_timer invalidate];
_timer = nil;
}
}
-(void)sendCodeBtnAction:(UIButton *)btn{
if (self.phoneNumberTextField.text == nil) {
GIGA_ShowToast(@"请输入手机号");
return;
}
if (![GiGaHelper isPhoneNumber:self.phoneNumberTextField.text]) {
GIGA_ShowToast(@"请输入正确手机号");
return;
}
btn.userInteractionEnabled = NO;
[self startTimer:btn];
[self sendVerifiCode:btn];
}
-(void)startTimer:(UIButton *)btn{
if (_time>0) {
_timer = [NSTimer scheduledTimerWithTimeInterval:1 count:60 callback:^{
NSString *timeStr=[NSString stringWithFormat:@"%lds",(long)self->_time];
[btn setTitle:timeStr forState:UIControlStateNormal];
self->_time--;
if (self->_time==0) {
[self.sendCodeBtn setTitle:@"发送短信" forState:UIControlStateNormal];
[btn setBackgroundColor:GIGAUIColorFromRGBA(0x28b9ff)];
self->_time =60;
btn.userInteractionEnabled = YES;
}
}];
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
}
}
#pragma mark 发送短信验证码
-(void)sendVerifiCode:(UIButton *)btn{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
NSString *phoneNumber = self.phoneNumberTextField.text;
NSDictionary *param = @{
@"mobile":phoneNumber
};
GiGaBaseAPiRequest *api = [GiGaBaseAPiRequest initWithRequestPath:@"msg/sms/v1/sendcode" method:RequestPostMethod parms:param];
[api requstDataWithResult:^(GiGaAPIResult *result) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
GILog(@"短信获取%@",result.message);
btn.userInteractionEnabled = YES;
}];
}
-(void)confirmUI{
@@ -79,6 +150,57 @@
webView.souceType = WebSourceTypeUrlLink;
webView.url = @"http://www.youtansu.com";
[self.navigationController pushViewController:webView animated:YES];
}
#pragma mark 注册
-(void)registBtnAction:(UIButton *)btn{
if (self.phoneNumberTextField.text.length ==0) {
GIGA_ShowToast(@"请输入手机号");
return;
}
if (![GiGaHelper isPhoneNumber:self.phoneNumberTextField.text]) {
GIGA_ShowToast(@"请输入正确手机号");
return;
}
if (self.codeTextField.text.length == 0) {
GIGA_ShowToast(@"请输入验证码");
return;
}
if (!(self.passTexFied.text.length >=6 && self.passTexFied.text.length <=20) || self.passTexFied.text.length == 0) {
GIGA_ShowToast(@"请输入6~20位密码");
return;
}
[self regeist:btn];
}
//注册
-(void)regeist:(UIButton *)btn{
btn.userInteractionEnabled = NO;
NSDictionary *param = @{@"username":self.phoneNumberTextField.text,@"verifiedCode":self.codeTextField.text,@"password":self.passTexFied.text};
GiGaBaseAPiRequest *api = [GiGaBaseAPiRequest initWithRequestPath:@"sys/v1/phoneregister" method:RequestPostMethod parms:param];
[api requstDataWithResult:^(GiGaAPIResult *result) {
btn.userInteractionEnabled = YES;
GILog(@"注册->%@",result.message);
if (result.code == 0) {
NC_POST_NAME_OBJECT(kUserRegistSucccess,self.phoneNumberTextField.text);
}else if (result.code == GiGAErrorCode_USER_EXIST){
GIGA_ShowToast(@"用户已存在");
NC_POST_NAME_OBJECT(kUserRegistSucccess,self.phoneNumberTextField.text);
}else{
GIGA_ShowToast(result.message);
}
}];
}
- (void)didReceiveMemoryWarning {