一、获取并可以刷新验证码
//1.获取验证码图片GET请求
- ( void )requestData { NSDictionary *dic = @{ @"device" : @"iPhone" } ; // GET请求数据 [ NetworkRequest requestDataWithHttpURL : @"/mobile/checkCode" withRequestType : @"GET" withParameter :[dic mutableCopy ] withBlock :^( id response) { // 记录数据 self . responseDataDict = response; // 设置验证码图片 NSURL *url = [ NSURL URLWithString :response[ @"checkCodeUrl" ]]; [ self . image setImageWithURL :url]; }];
}
----------------------------------------------------------------------------------------------------
//2.刷新验证码
- (
void
)tapAction
{
// 思路:取得存放到全局的解析数据中得URL,然后设置个时间戳拼接到URL得后面, // 每次访问的url就会不一样,解决由于缓存验证码不刷新的问题 NSString *stringURL = self . responseDataDict [ @"checkCodeUrl" ]; //取得当前的时间戳 NSTimeInterval time = [[ NSDate date ] timeIntervalSince1970 ]; stringURL = [stringURL stringByAppendingFormat : @"&time=%f" ,time]; //加载验证码图片 [ self . image setImageWithURL :[ NSURL URLWithString :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
//执行请求任务
}
;
[
NetworkRequest
requestDataWithHttpURL
:
@"/mobile/register"
withRequestType
:
@"POST"
withParameter
:[dic
mutableCopy
]
withBlock
:^(
id
response) {
NSLog ( @"%@" , response); }];
}
|