New file |
| | |
| | | // |
| | | // DynamicService.m |
| | | // screendisplay |
| | | // |
| | | // Created by 单军华 on 2018/7/9. |
| | | // Copyright © 2018年 单军华. All rights reserved. |
| | | // |
| | | |
| | | #import "DynamicService.h" |
| | | #import "PPInterfacedConst.h" |
| | | |
| | | @implementation DynamicService |
| | | |
| | | /** 获取详情列表*/ |
| | | - (NSURLSessionTask *)getDynamicListWithParameters:(id)parameters dataCount:(int)getCount completion:(void(^)(NSString *desc,int code))completion{ |
| | | // 将请求前缀与请求路径拼接成一个完整的URL |
| | | NSString *url = [NSString stringWithFormat:@"%@%@",kApiPrefix,kHistory]; |
| | | |
| | | return [self requestGETWithURL:url parameters:parameters success:^(id responseObject) |
| | | { |
| | | BaseResModel * resModel = [Global toBaseModel:responseObject]; |
| | | if(resModel.code == 1) |
| | | { |
| | | if(!TWIsEmpty(resModel.content)) |
| | | { |
| | | // 成功处理 |
| | | if (getCount > 1) |
| | | { |
| | | self.dynamicViewModels = [DynamicModel mj_objectArrayWithKeyValuesArray:resModel.content]; |
| | | } |
| | | else if(getCount == 1) |
| | | { |
| | | self.dynamicViewModel = [DynamicModel mj_objectWithKeyValues:resModel.content]; |
| | | |
| | | //[self.dynamicViewModels replaceObjectAtIndex:self.dynamicViewModels.count-1 withObject:model]; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // 出错处理 |
| | | resModel.code = -5; |
| | | completion(@"返回数据错误,数据为空!",resModel.code); |
| | | } |
| | | } |
| | | |
| | | // 在这里你可以根据项目自定义其他一些重复操作,比如加载页面时候的等待效果, 提醒弹窗.... |
| | | completion(resModel.desc,resModel.code); |
| | | |
| | | } failure:^(NSError *error) { |
| | | // 同上 |
| | | completion(error.localizedDescription,-1); |
| | | }]; |
| | | } |
| | | |
| | | - (NSMutableArray<DynamicModel *> *)dynamicViewModels |
| | | { |
| | | if(_dynamicViewModels == nil) |
| | | { |
| | | _dynamicViewModels = [NSMutableArray array]; |
| | | } |
| | | return _dynamicViewModels; |
| | | } |
| | | |
| | | - (DynamicModel *)dynamicViewModel |
| | | { |
| | | if(_dynamicViewModel == nil) |
| | | { |
| | | _dynamicViewModel = [DynamicModel new]; |
| | | } |
| | | return _dynamicViewModel; |
| | | } |
| | | |
| | | @end |