Commit aa92811b cgx

优化网络框架

1 个父辈 5a104512
...@@ -17,6 +17,8 @@ typedef NS_ENUM(NSInteger, DSResCode) { ...@@ -17,6 +17,8 @@ typedef NS_ENUM(NSInteger, DSResCode) {
DSResCodeDataWrong = -666, DSResCodeDataWrong = -666,
/// 无更新(自定义状态) /// 无更新(自定义状态)
DSResCodeNoUpdate = -777, DSResCodeNoUpdate = -777,
/// 服务器内部错误(404等...)
DSResCodeServerErr = -888,
}; };
#import <AFNetworking/AFNetworking-umbrella.h> #import <AFNetworking/AFNetworking-umbrella.h>
......
...@@ -64,6 +64,18 @@ NSString * const NetworkUnableError = @"网络不给力,请检查您的网络 ...@@ -64,6 +64,18 @@ NSString * const NetworkUnableError = @"网络不给力,请检查您的网络
if (loadingInfo) { [DSProgressHUD dissmissProgressHUD]; } if (loadingInfo) { [DSProgressHUD dissmissProgressHUD]; }
}); });
// 处理服务器内部错误
NSHTTPURLResponse *httpRes = (NSHTTPURLResponse *)response;
if (!(httpRes.statusCode == 200)) {
DSLog(@"httpRes:%@", httpRes);
NSString *errInfo = [NSHTTPURLResponse localizedStringForStatusCode:httpRes.statusCode];
failure(@{@"errorCode":@(DSResCodeServerErr), @"errMessage":errInfo});
if (hasFailInfo) {
view ? [DSProgressHUD showDetailInfo:errInfo inView:view] : [DSProgressHUD showDetailInfo:errInfo];
}
return;
}
if (responseObject) { if (responseObject) {
NSDictionary *responseDic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil]; NSDictionary *responseDic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
// 数据验证 // 数据验证
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
[self.courseListView reloadData]; [self.courseListView reloadData];
} else { } else {
self.exceptionView.hidden = NO; self.exceptionView.hidden = NO;
[self.exceptionView showServerErrInfo:requestModel.errMessage];
} }
}]; }];
} }
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
[self.noiseAudioView reloadData]; [self.noiseAudioView reloadData];
} else { } else {
self.exceptionView.hidden = NO; self.exceptionView.hidden = NO;
[self.exceptionView showServerErrInfo:requestModel.errMessage];
} }
}]; }];
} }
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
[self buildUI:requestModel.feedDetailModel]; [self buildUI:requestModel.feedDetailModel];
} else { } else {
self.exceptionView.hidden = NO; self.exceptionView.hidden = NO;
[self.exceptionView showServerErrInfo:requestModel.errMessage];
} }
}]; }];
} }
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
[self.posterScrollView refreshPosterData:requestModel.shareListData]; [self.posterScrollView refreshPosterData:requestModel.shareListData];
} else { } else {
self.exceptionView.hidden = NO; self.exceptionView.hidden = NO;
[self.exceptionView showServerErrInfo:requestModel.errMessage];
} }
}]; }];
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
- (void)updateTodayPointData:(int)points { - (void)updateTodayPointData:(int)points {
self.pointsLab.text = [NSString stringWithFormat:@"%d", points]; self.pointsLab.text = [NSString stringWithFormat:@"%d", points];
self.todayLab.text = @"今日积分";
[self.pointsLab mas_makeConstraints:^(MASConstraintMaker *make) { [self.pointsLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15); make.left.equalTo(self).offset(15);
make.top.equalTo(self).offset(136); make.top.equalTo(self).offset(136);
...@@ -58,7 +59,7 @@ ...@@ -58,7 +59,7 @@
- (UILabel *)todayLab { - (UILabel *)todayLab {
if (!_todayLab) { if (!_todayLab) {
_todayLab = [UILabel labWithText:@"今日积分" font:SysFont(16.0) fit:YES]; _todayLab = [UILabel labWithFont:SysFont(16.0)];
_todayLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE); _todayLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
} }
return _todayLab; return _todayLab;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!