注册

 

        __weak typeof(self) weakSelf=self;

        

        NSUserDefaults *use = [NSUserDefaults standardUserDefaults];

        NSLog(@"%@",[use valueForKey:@"clientId"]);

        

        AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];

        

        NSURL *url = [NSURL URLWithString:@"服务器"];

        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

        [request setHTTPMethod:@"POST"];

         NSString *bodyStr = [NSString stringWithFormat:@"verify=%@&phone=%@&password=%@&password2=%@&recommend=@""",_TextCode.text,_phoneNumbertextfield.text,_passwordTextField.text,_againTextField.text];

        //clientid=%@

        bodyStr=[bodyStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

        NSLog(@"%@",kSid);

        [request setHTTPBody:[bodyStr dataUsingEncoding:NSUTF8StringEncoding]];

        manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];

        

        NSOperation *operation = [manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {

            NSLog(@"开始打印%@",responseObject);

            if ([responseObject[@"code"]isEqualToString:@"100"]) {

                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"注册成功,请登录!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];

                [alert show];

                [self.navigationController popViewControllerAnimated:YES];

                

            }else if([responseObject[@"code"]isEqualToString:@"101"]){

                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"该手机号已注册" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];

                [alert show];

            }

            //[responseObject[@"code"]isEqualToString:@"100"]

            

        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

            

            NSLog(@"Error: %@", error);

        }];

        [manager.operationQueue addOperation:operation];

 

你可能感兴趣的:(注册)