Commit f362f21d authored by admin's avatar admin

修复首页bug

parent 24cda19e
{
"images" : [
{
"idiom" : "universal",
"filename" : "img_05.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "img_01.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "img_02.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "img_03.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "img_04.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define kQuestionDetailCell @"QuestionDetailCell" // 问题详情 #define kQuestionDetailCell @"QuestionDetailCell" // 问题详情
#define kQuestionCommentCell @"QuestionCommentCell" // 评论 #define kQuestionCommentCell @"QuestionCommentCell" // 评论
#define kQuestionDescribeCell @"QuestionDescribeCell" // 问题描述 #define kQuestionDescribeCell @"QuestionDescribeCell" // 问题描述
@interface QuestionDetailViewController ()<UITableViewDelegate, UITableViewDataSource> @interface QuestionDetailViewController ()<UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate>
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) QuestionDetailFooterView *footerView; @property (nonatomic, strong) QuestionDetailFooterView *footerView;
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
NSString *url = [NSString stringWithFormat:@"%@%@%@?userUuid=%@", kRedStarURL, kQuestionDetailURL, _questionUuid ,user_uuid]; NSString *url = [NSString stringWithFormat:@"%@%@%@?userUuid=%@", kRedStarURL, kQuestionDetailURL, _questionUuid ,user_uuid];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url]; HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[httpClient getQuestionDetailWithParameters:nil completion:^(id response, NSError *error) { [httpClient getQuestionDetailWithParameters:nil completion:^(id response, NSError *error) {
NSDictionary *dict = response[@"data"]; NSDictionary *dict = response[@"data"];
NSLog(@"问题详情 = %@", dict); NSLog(@"问题详情 = %@", dict);
...@@ -93,7 +94,7 @@ ...@@ -93,7 +94,7 @@
[comment setValuesForKeysWithDictionary:dict]; [comment setValuesForKeysWithDictionary:dict];
[_allCommentArray addObject:comment]; [_allCommentArray addObject:comment];
} }
[MBProgressHUD hideHUDForView:self.view animated:YES];
self.tableView.tableFooterView = self.footerView; self.tableView.tableFooterView = self.footerView;
}]; }];
...@@ -169,9 +170,8 @@ ...@@ -169,9 +170,8 @@
NSString *dateString = [dateFormatter stringFromDate:localeDate]; NSString *dateString = [dateFormatter stringFromDate:localeDate];
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"loginData"]; NSString *operId = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_code"];
NSString *operId = dict[@"user_code"]; NSString *operName = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_name"];
NSString *operName = dict[@"user_name"];
NSString *url = [NSString stringWithFormat:@"%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kAddCommentURL , dateString , operId, operName]; NSString *url = [NSString stringWithFormat:@"%@%@?time=%@&operId=%@&operName=%@", kRedStarURL, kAddCommentURL , dateString , operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
...@@ -188,6 +188,7 @@ ...@@ -188,6 +188,7 @@
NSLog(@"respo = %@, error = %@", response , error); NSLog(@"respo = %@, error = %@", response , error);
if ([response[@"message"] isEqualToString:@"ok"]) { if ([response[@"message"] isEqualToString:@"ok"]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"添加评论成功" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"添加评论成功" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
alert.delegate = self;
[alert show]; [alert show];
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
} else { } else {
...@@ -392,7 +393,37 @@ ...@@ -392,7 +393,37 @@
} }
} }
#pragma mark - UIAlertViewDelegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0) {
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSString *url = [NSString stringWithFormat:@"%@%@%@?userUuid=%@", kRedStarURL, kQuestionDetailURL, _questionUuid ,user_uuid];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[httpClient getQuestionDetailWithParameters:nil completion:^(id response, NSError *error) {
NSDictionary *dict = response[@"data"];
NSLog(@"问题详情 = %@", dict);
QuestionDetailModel *quesDetail = [[QuestionDetailModel alloc] init];
[quesDetail setValuesForKeysWithDictionary:dict];
_questionDetailModel = quesDetail;
NSArray *commentArray = _questionDetailModel.comments;
NSMutableArray *tempArray = [NSMutableArray array];
for (NSDictionary *dict in commentArray) {
CommentModel *comment = [[CommentModel alloc] init];
[comment setValuesForKeysWithDictionary:dict];
[tempArray addObject:comment];
}
_allCommentArray = tempArray;
[self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
}
#pragma mark - lazy loading #pragma mark - lazy loading
- (UITableView *)tableView - (UITableView *)tableView
......
...@@ -115,10 +115,24 @@ ...@@ -115,10 +115,24 @@
- (UILabel *)introLabel - (UILabel *)introLabel
{ {
if (!_introLabel) { if (!_introLabel) {
_introLabel = [[UILabel alloc] initWithFrame:CGRectMake(kIntroX, kIntroY, kIntroWidth, kIntroHeight)]; _introLabel = [[UILabel alloc] init];
_introLabel.translatesAutoresizingMaskIntoConstraints = NO;
_introLabel.font = [UIFont systemFontOfSize:15.0]; _introLabel.font = [UIFont systemFontOfSize:15.0];
_introLabel.textColor = kLightBlack; _introLabel.textColor = kLightBlack;
[self addSubview:_introLabel]; [self addSubview:_introLabel];
NSLayoutConstraint *someoneTop = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.takePhotoView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self addConstraint:someoneTop];
NSLayoutConstraint *someoneLeft = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self addConstraint:someoneLeft];
NSLayoutConstraint *someoneRight = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self addConstraint:someoneRight];
NSLayoutConstraint *someoneHeight = [NSLayoutConstraint constraintWithItem:_introLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:40];
[self addConstraint:someoneHeight];
} }
return _introLabel; return _introLabel;
} }
...@@ -128,7 +142,20 @@ ...@@ -128,7 +142,20 @@
if (!_backImageView2) { if (!_backImageView2) {
_backImageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(kBackImageX, kBackImageY, kBackImageWidth, kBackImageHeight)]; _backImageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(kBackImageX, kBackImageY, kBackImageWidth, kBackImageHeight)];
_backImageView2.userInteractionEnabled = YES; _backImageView2.userInteractionEnabled = YES;
_backImageView2.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_backImageView2]; [self addSubview:_backImageView2];
NSLayoutConstraint *someoneTop = [NSLayoutConstraint constraintWithItem:_backImageView2 attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.introLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self addConstraint:someoneTop];
NSLayoutConstraint *someoneLeft = [NSLayoutConstraint constraintWithItem:_backImageView2 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self addConstraint:someoneLeft];
NSLayoutConstraint *someoneRight = [NSLayoutConstraint constraintWithItem:_backImageView2 attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self addConstraint:someoneRight];
NSLayoutConstraint *someoneHeight = [NSLayoutConstraint constraintWithItem:_backImageView2 attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:75];
[self addConstraint:someoneHeight];
} }
return _backImageView2; return _backImageView2;
} }
...@@ -186,12 +213,25 @@ ...@@ -186,12 +213,25 @@
{ {
if (!_reportBtn) { if (!_reportBtn) {
_reportBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _reportBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_reportBtn.frame = CGRectMake(kReportX, kReportY, kReportWidth, kReportHeight); _reportBtn.translatesAutoresizingMaskIntoConstraints = NO;
_reportBtn.titleLabel.font = [UIFont systemFontOfSize:20.0]; _reportBtn.titleLabel.font = [UIFont systemFontOfSize:20.0];
_reportBtn.backgroundColor = kNavigationBarColor; _reportBtn.backgroundColor = kNavigationBarColor;
_reportBtn.layer.cornerRadius = 5.0; _reportBtn.layer.cornerRadius = 5.0;
[_reportBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [_reportBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self addSubview:_reportBtn]; [self addSubview:_reportBtn];
NSLayoutConstraint *someoneTop = [NSLayoutConstraint constraintWithItem:_reportBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.backImageView2 attribute:NSLayoutAttributeBottom multiplier:1.0 constant:10];
[self addConstraint:someoneTop];
NSLayoutConstraint *someoneLeft = [NSLayoutConstraint constraintWithItem:_reportBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self addConstraint:someoneLeft];
NSLayoutConstraint *someoneRight = [NSLayoutConstraint constraintWithItem:_reportBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self addConstraint:someoneRight];
NSLayoutConstraint *someoneHeight = [NSLayoutConstraint constraintWithItem:_reportBtn attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:40];
[self addConstraint:someoneHeight];
} }
return _reportBtn; return _reportBtn;
} }
......
...@@ -608,19 +608,22 @@ ...@@ -608,19 +608,22 @@
} else if (indexPath.section == 1) { } else if (indexPath.section == 1) {
if (indexPath.row != 0) { if (indexPath.row != 0) {
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init]; RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
RankListModel *rankModel = _allRankListArray[indexPath.row - 1];
rankDetailVC.indexRow = indexPath.row - 1; rankDetailVC.indexRow = indexPath.row - 1;
rankDetailVC.uuid = rankModel.uuid;
rankDetailVC.store_uuid = rankModel.store_uuid;
[self.navigationController pushViewController:rankDetailVC animated:YES]; [self.navigationController pushViewController:rankDetailVC animated:YES];
} }
} else if (indexPath.section == 2) { } else if (indexPath.section == 2) {
QuestionDetailViewController *questionDetailVC = [[QuestionDetailViewController alloc] init]; QuestionDetailViewController *questionDetailVC = [[QuestionDetailViewController alloc] init];
QuestionModel *question = _allQuestionArray[indexPath.row]; QuestionModel *question = self.allQuestionArray[indexPath.row];
questionDetailVC.questionUuid = question.uuid; questionDetailVC.questionUuid = question.uuid;
[self.navigationController pushViewController:questionDetailVC animated:YES]; [self.navigationController pushViewController:questionDetailVC animated:YES];
} else { } else {
InspectTaskViewController *inspectTaskVC = [[InspectTaskViewController alloc] init]; InspectTaskViewController *inspectTaskVC = [[InspectTaskViewController alloc] init];
TaskListModel *taskList = _taskListDataArray[indexPath.row]; TaskListModel *taskList = self.taskListDataArray[indexPath.row];
inspectTaskVC.uuid = taskList.uuid; inspectTaskVC.uuid = taskList.uuid;
inspectTaskVC.store_uuid = taskList.store_uuid; inspectTaskVC.store_uuid = taskList.store_uuid;
inspectTaskVC.multiplier = (CGFloat)taskList.reportCount / taskList.questionCount ; inspectTaskVC.multiplier = (CGFloat)taskList.reportCount / taskList.questionCount ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment