20160220 网络请求
//用药宝典
- (void)MedicaRequest
{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc]init];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes=[NSSet setWithObjects:@"text/html",@"text/plain",@"text/json",@"application/json",nil];
NSString *mediaUrl = [NSString stringWithFormat:@"%@medicine",Public_URL];
NSMutableDictionary *mutdic = [NSMutableDictionary dictionary];
mutdic[@"page"] = [NSString stringWithFormat:@"%d",number];
[manager POST:mediaUrl parameters:mutdic success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:operation.responseData options:NSJSONReadingAllowFragments error:nil];
NSString *code=[NSString stringWithFormat:@"%@",dic[@"code"]];
NSLog(@"code ==%@",code);
if ([code isEqualToString:@"1"]) {
[_MedicaMutarray addObjectsFromArray:dic[@"data"]];
// [_MedicatableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}else{
[self showHint:@"查询失败!"];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
if (_MedicaMutarray.count>0) {
imagershuju.hidden = YES;
tiwuxianLab.hidden = YES;
}else{
imagershuju.hidden = NO;
tiwuxianLab.hidden = NO;
}
[_MedicatableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// [MBProgressHUD hideHUDForView:self.view animated:YES];
if (_MedicaMutarray.count>0) {
imagershuju.hidden = YES;
tiwuxianLab.hidden = YES;
}else{
imagershuju.hidden = NO;
tiwuxianLab.hidden = NO;
}
[_MedicatableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}