17- 注册和刷新验证码

来源:互联网 发布:linux 当前文件夹大小 编辑:程序博客网 时间:2024/05/15 23:50

一、获取并可以刷新验证码
//1.获取验证码图片GET请求
- (
void)requestData
{
   
NSDictionary*dic = @{
                         
@"device":@"iPhone"
                         
};
//    GET请求数据
   [
NetworkRequestrequestDataWithHttpURL:@"/mobile/checkCode"withRequestType:@"GET"withParameter:[dicmutableCopy]withBlock:^(idresponse) {
       
//        记录数据
       
self.responseDataDict= response;
       
//        设置验证码图片
       
NSURL*url = [NSURLURLWithString:response[@"checkCodeUrl"]];

        [
self.imagesetImageWithURL:url];
       
    }];
   
}
---------------------------------------------------------------------------------------------------- 
//2.刷新验证码
- (void)tapAction
{
//    思路:取得存放到全局的解析数据中得URL,然后设置个时间戳拼接到URL得后面,
//    每次访问的url就会不一样,解决由于缓存验证码不刷新的问题
   
   
NSString*stringURL = self.responseDataDict[@"checkCodeUrl"];
   
   
//取得当前的时间戳
   
NSTimeIntervaltime = [[NSDatedate]timeIntervalSince1970];
    stringURL = [stringURL
stringByAppendingFormat:@"&time=%f",time];
   
   
//加载验证码图片
    [
self.imagesetImageWithURL:[NSURLURLWithString:stringURL]];
}


一、实现点击注册
//注册按钮
- (
IBAction)registe:(UIButton*)sender {
   
   
/*
     device = iPhone
     xum = 15CEEEBF-7042-4D5D-A33C-C7A71A046BF8
     account =34576@qq.com //注册邮箱
     checkUUID = 825794e0123c415eabb4b3945ad41258
     checkCode = xxb5 //验证码
     password = 123456 //密码
     nickname = 头条汤  //用户名
     */
  
//设置请求体
    NSDictionary *dic = @{
                         
@"device":@"iPhone",
                         
@"xum":@"15CEEEBF-7042-4D5D-A33C-C7A71A046BF8",
                         
@"account":self.email.text,
                         
@"checkUUID":self.responseDataDict[@"checkUUID"],
                         
@"checkCode":self.number.text,
                         
@"password":self.passwd.text,
                         
@"nickname":self.name.text
   
//执行请求任务                     };
    [NetworkRequestrequestDataWithHttpURL:@"/mobile/register"withRequestType:@"POST"withParameter:[dicmutableCopy]withBlock:^(idresponse) {
       
       
NSLog(@"%@", response);
       
    }];
   
}
0 1
原创粉丝点击