iOS--登录注册页面-趣享-接口设计

dao.h文件:

//登录
-(void)loginWithPhoneNumber:(NSString*)e_mail password:(NSString*) password successHandler:(void(^)(User *accoucnt))successBlock errorHandler:(void(^)(NSString *code,NSString *message))errorBlock;
//注册
-(void)registerWithPhone:(NSString*)e_mail password:(NSString*) password verifyCode:(NSString*)verifyCode successHandler:(void(^)(User *accoucnt))successBlock errorHandler:(void(^)(NSString *code,NSString *message))errorBlock;
//验证码
-(void)getVerifyCodeWithPhoneNumber:(NSString*)e_mail successHandler:(void(^)(NSString *verifyCode))successBlock errorHandler:(void(^)(NSString *code,NSString *message))errorBlock;
//忘记密码
-(void)reviseWithPassword:(NSString*)e_mail password:(NSString*) password verifyCode:(NSString*)verifyCode successHandler:(void(^)(User *accoucnt))successBlock errorHandler:(void(^)(NSString *code,NSString *message))errorBlock;

.m文件:

#import "QXAccountDao.h"
#import <AFHTTPRequestOperationManager.h>
#import "ResultInfo.h"
#import "WGJsonParser.h"
#import "Constants.h"

@implementation QXAccountDao

//登录
-(void)loginWithPhoneNumber:(NSString*)e_mail password:(NSString*) password successHandler:(void(^)(User *accoucnt))successBlock errorHandler:(void(^)(NSString *code,NSString *message))errorBlock{
    
    NSString *url = [BASIC_URL stringByAppendingString:@"user/login.php"];
    NSDictionary *parameters = @{@"e_mail":e_mail,@"password":password};
    
    [self post:url params:parameters dataModel:[User class] successHandler:^(id model) {
        if (successBlock != nil) {
            successBlock(model);
        }
    } errorHandler:errorBlock];
}
//注册
-(void)registerWithPhone:(NSString*)e_mail password:(NSString*) password verifyCode:(NSString*)verifyCode successHandler:(void(^)(User *accoucnt))successBlock errorHandler:(void(^)(NSString *code,NSString *message))errorBlock{
    
    NSString *url = [BASIC_URL stringByAppendingString:@"user/register.php"];
    NSDictionary *parameters = @{@"e_mail":e_mail,@"password":password,@"verifyCode":verifyCode};
    
    [self post:url params:parameters dataModel:[User class] successHandler:^(id model) {
        if (successBlock != nil) {
            successBlock(model);
        }
    } errorHandler:errorBlock];

}
//验证码
-(void)getVerifyCodeWithPhoneNumber:(NSString*)e_mail successHandler:(void(^)(NSString *verifyCode))successBlock errorHandler:(void(^)(NSString *code,NSString *message))errorBlock{
    
    NSString *url = [BASIC_URL stringByAppendingString:@"user/getverifycode.php"];
    NSDictionary *parameters = @{@"e_mail":e_mail};

    
    [self post:url params:parameters dataModel:[NSString class] successHandler:^(id model) {
        if (successBlock != nil) {
            successBlock(model);
        }
    } errorHandler:errorBlock];
    
    
}

//忘记密码
-(void)reviseWithPassword:(NSString*)e_mail password:(NSString*) password verifyCode:(NSString*)verifyCode successHandler:(void(^)(User *accoucnt))successBlock errorHandler:(void(^)(NSString *code,NSString *message))errorBlock{
    NSString *url = [BASIC_URL stringByAppendingString:@"user/updatepwd.php"];
    NSDictionary *parameters = @{@"e_mail":e_mail,@"password":password,@"verifyCode":verifyCode};
    
    [self post:url params:parameters dataModel:[User class] successHandler:^(id model) {
        if (successBlock != nil) {
            successBlock(model);
        }
    } errorHandler:errorBlock];
}

文件结构:

 

文件另外上传!

 

posted on 2017-01-11 15:21  麦芽呀~  阅读(289)  评论(0编辑  收藏  举报