Commit de4938f8 authored by admin's avatar admin

问题与知识排序完成

parent 81fb9af9
...@@ -378,6 +378,8 @@ ...@@ -378,6 +378,8 @@
if (_screenView.groupTabBar.selectNumber == 0) { if (_screenView.groupTabBar.selectNumber == 0) {
NSArray *queryOrder = @[@{@"field":@"state"}];
[parameters setObject:queryOrder forKey:@"queryOrders"];
if (_selectRow == 0) { if (_selectRow == 0) {
[parameters setObject:@"created" forKey:@"state"]; [parameters setObject:@"created" forKey:@"state"];
} else if (_selectRow == 1) { } else if (_selectRow == 1) {
...@@ -387,13 +389,16 @@ ...@@ -387,13 +389,16 @@
} }
} else if (_screenView.groupTabBar.selectNumber == 1) { } else if (_screenView.groupTabBar.selectNumber == 1) {
NSArray *queryOrder = @[@{@"field":@"title"}];
[parameters setObject:queryOrder forKey:@"queryOrders"];
if (_screenView.textView.text.length != 0){ if (_screenView.textView.text.length != 0){
[parameters setObject:_screenView.textView.text forKey:@"contentLike"]; [parameters setObject:_screenView.textView.text forKey:@"contentLike"];
} else { } else {
[parameters setObject:_screenView.textView.text forKey:@"contentLike"]; [parameters setObject:_screenView.textView.text forKey:@"contentLike"];
} }
} else { } else {
NSArray *queryOrder = @[@{@"field":@"resolveTime",@"direction":@"desc"}];
[parameters setObject:queryOrder forKey:@"queryOrders"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
...@@ -500,6 +505,78 @@ ...@@ -500,6 +505,78 @@
#pragma mark - TaxisDelegate #pragma mark - TaxisDelegate
- (void)timeChange:(UIButton *)sender - (void)timeChange:(UIButton *)sender
{ {
// 请求地址
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSArray *queryOrders;
if (sender.tag - kTAxisBtnTag == 1) {
queryOrders = @[];
} else if (sender.tag - kTAxisBtnTag == 2) {
queryOrders = @[@{@"field":@"likeCount",
@"direction":@"desc"}];
} else {
queryOrders = @[@{@"field":@"likeCount",
@"direction":@"asc"}];
}
NSDictionary *parameters = @{@"user":user_uuid,
@"scope":@"all",
@"pageNumber":@(0),
@"pageSize":@(20),
@"queryOrders":queryOrders
};
// 发起请求
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr];
__block QuestionViewController *weakSelf = self;
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
// 请求问题列表
[httpClient getQuestionListWithParameters:parameters completion:^(id response, NSError *error) {
NSDictionary *dataDict = (NSDictionary *)response[@"data"];
NSDictionary *recordsDict = (NSDictionary *)dataDict[@"records"];
NSLog(@"问题与知识列表recods = %@", response);
NSMutableArray *tempArray = [NSMutableArray array];
for (NSDictionary *questionDict in recordsDict) {
QuestionModel *question = [[QuestionModel alloc] init];
[question setValuesForKeysWithDictionary:questionDict];
[tempArray addObject:question];
}
_allQuestionArray = tempArray;
if (_allQuestionArray.count == 0) {
if (_tableView) {
[_tableView removeFromSuperview];
_tableView = nil;
}
weakSelf.noDataView.backgroundColor = [UIColor whiteColor];
[MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
[weakSelf closeGreenView];
} else {
if (_noDataView) {
[_noDataView removeFromSuperview];
_noDataView = nil;
}
weakSelf.tableView.delegate = weakSelf;
weakSelf.tableView.dataSource = weakSelf;
[weakSelf.tableView reloadData];
[MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
_screenView.textView.text = @"";
[weakSelf closeGreenView];
}
}];
[self closeRedView]; [self closeRedView];
} }
......
...@@ -220,6 +220,7 @@ ...@@ -220,6 +220,7 @@
} }
if (!_taxisView) { if (!_taxisView) {
_taxisView = [[TaxisView alloc] init]; _taxisView = [[TaxisView alloc] init];
_taxisView.tag = 3928342;
_taxisView.backgroundColor = [UIColor whiteColor]; _taxisView.backgroundColor = [UIColor whiteColor];
} }
_taxisView.delegate = self; _taxisView.delegate = self;
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
if (section < 3) { if (section < 3) {
UIImageView *gradeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", section + 1]]]; UIImageView *gradeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", (int)section + 1]]];
[self addSubview:gradeImageView]; [self addSubview:gradeImageView];
_gradeImageView = gradeImageView; _gradeImageView = gradeImageView;
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
gradeLabel.textColor = kLightBlack; gradeLabel.textColor = kLightBlack;
gradeLabel.font = [UIFont systemFontOfSize:16.0]; gradeLabel.font = [UIFont systemFontOfSize:16.0];
[self addSubview:gradeLabel]; [self addSubview:gradeLabel];
gradeLabel.text = [NSString stringWithFormat:@"第%d名", section + 1]; gradeLabel.text = [NSString stringWithFormat:@"第%d名", (int)section + 1];
_gradeLabel = gradeLabel; _gradeLabel = gradeLabel;
} }
_section = section; _section = section;
......
...@@ -57,116 +57,6 @@ ...@@ -57,116 +57,6 @@
} }
//#pragma mark - lazy loading
//- (UIImageView *)bgImageView
//{
// if (!_bgImageView) {
// _bgImageView = [[UIImageView alloc] init];
// _bgImageView.translatesAutoresizingMaskIntoConstraints = NO;
// _bgImageView.userInteractionEnabled = YES;
// [self addSubview:_bgImageView];
//
// NSLayoutConstraint *bgImageTop = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
// [self addConstraint:bgImageTop];
//
// NSLayoutConstraint *bgImageLeft = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
// [self addConstraint:bgImageLeft];
//
// NSLayoutConstraint *bgImageHeight = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:95];
// [self addConstraint:bgImageHeight];
//
// NSLayoutConstraint *bgImageRight = [NSLayoutConstraint constraintWithItem:_bgImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
// [self addConstraint:bgImageRight];
// }
// return _bgImageView;
//}
//
//- (UITextField *)searchTextField
//{
// if (!_searchTextField) {
// _searchTextField = [[UITextField alloc] init];
// _searchTextField.translatesAutoresizingMaskIntoConstraints = NO;
// _searchTextField.font = [UIFont systemFontOfSize:13.0];
// _searchTextField.textAlignment = NSTextAlignmentCenter;
// _searchTextField.layer.cornerRadius = 4.0;
// _searchTextField.textColor = [UIColor whiteColor];
// _searchTextField.layer.borderColor = [[UIColor whiteColor] CGColor];
// _searchTextField.layer.borderWidth = 0.5;
// _searchTextField.placeholder = @"查询";
// [_searchTextField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
// UIImageView *imageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"search"]];
// imageV.contentMode = UIViewContentModeCenter;
// imageV.width += 10;
// _searchTextField.rightView = imageV;
// _searchTextField.rightViewMode = UITextFieldViewModeAlways;
// [self.bgImageView addSubview:_searchTextField];
//
// NSLayoutConstraint *bgImageTop = [NSLayoutConstraint constraintWithItem:_searchTextField attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeTop multiplier:1.0 constant:35];
// [self.bgImageView addConstraint:bgImageTop];
//
// NSLayoutConstraint *bgImageRight = [NSLayoutConstraint constraintWithItem:_searchTextField attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
// [self.bgImageView addConstraint:bgImageRight];
//
// NSLayoutConstraint *bgImageHeight = [NSLayoutConstraint constraintWithItem:_searchTextField attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:28];
// [self.bgImageView addConstraint:bgImageHeight];
//
// NSLayoutConstraint *bgImageWidth = [NSLayoutConstraint constraintWithItem:_searchTextField attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:100];
// [self.bgImageView addConstraint:bgImageWidth];
// }
// return _searchTextField;
//}
//
//- (UILabel *)nameLabel
//{
// if (!_nameLabel) {
// _nameLabel = [[UILabel alloc] init];
// _nameLabel.translatesAutoresizingMaskIntoConstraints = NO;
// _nameLabel.font = [UIFont systemFontOfSize:13.0];
// _nameLabel.textAlignment = NSTextAlignmentRight;
// _nameLabel.textColor = [UIColor whiteColor];
// [self.bgImageView addSubview:_nameLabel];
//
// NSLayoutConstraint *bgImageTop = [NSLayoutConstraint constraintWithItem:_nameLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.searchTextField attribute:NSLayoutAttributeBottom multiplier:1.0 constant:3];
// [self.bgImageView addConstraint:bgImageTop];
//
// NSLayoutConstraint *bgImageRight = [NSLayoutConstraint constraintWithItem:_nameLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
// [self.bgImageView addConstraint:bgImageRight];
//
// NSLayoutConstraint *bgImageBottom = [NSLayoutConstraint constraintWithItem:_nameLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
// [self.bgImageView addConstraint:bgImageBottom];
//
// NSLayoutConstraint *bgImageWidth = [NSLayoutConstraint constraintWithItem:_nameLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:95];
// [self.bgImageView addConstraint:bgImageWidth];
// }
// return _nameLabel;
//}
//
//- (UILabel *)shopnameLabel
//{
// if (!_shopnameLabel) {
// _shopnameLabel = [[UILabel alloc] init];
// _shopnameLabel.translatesAutoresizingMaskIntoConstraints = NO;
// _shopnameLabel.font = [UIFont systemFontOfSize:13.0];
// _shopnameLabel.textAlignment = NSTextAlignmentRight;
// _shopnameLabel.textColor = [UIColor whiteColor];
// [self.bgImageView addSubview:_shopnameLabel];
//
// NSLayoutConstraint *bgImageTop = [NSLayoutConstraint constraintWithItem:_shopnameLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.searchTextField attribute:NSLayoutAttributeBottom multiplier:1.0 constant:3];
// [self.bgImageView addConstraint:bgImageTop];
//
// NSLayoutConstraint *bgImageRight = [NSLayoutConstraint constraintWithItem:_shopnameLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.nameLabel attribute:NSLayoutAttributeLeft multiplier:1.0 constant:-10];
// [self.bgImageView addConstraint:bgImageRight];
//
// NSLayoutConstraint *bgImageBottom = [NSLayoutConstraint constraintWithItem:_shopnameLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
// [self.bgImageView addConstraint:bgImageBottom];
//
// NSLayoutConstraint *bgImageLeft = [NSLayoutConstraint constraintWithItem:_shopnameLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.bgImageView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
// [self.bgImageView addConstraint:bgImageLeft];
// }
// return _shopnameLabel;
//}
- (UIView *)bgView - (UIView *)bgView
{ {
if (!_bgView) { if (!_bgView) {
......
...@@ -943,6 +943,8 @@ ...@@ -943,6 +943,8 @@
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
}]; }];
[self.searchTextField resignFirstResponder];
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
@interface TaxisView () @interface TaxisView ()
@property (nonatomic, strong) NSMutableArray *buttons; @property (nonatomic, strong) NSMutableArray *buttons;
@end @end
@implementation TaxisView @implementation TaxisView
...@@ -45,9 +44,14 @@ ...@@ -45,9 +44,14 @@
{ {
CGFloat buttonW = kScreenWidth; CGFloat buttonW = kScreenWidth;
CGFloat buttonH = self.frame.size.height / 3; CGFloat buttonH = self.frame.size.height / 3;
NSArray *titleArray = @[@"默认排序",@"时间顺序排序",@"时间逆序排序"];
NSArray *titleArray;
if (self.tag == 3928342) {
titleArray = @[@"默认排序",@"按时间顺序排序",@"按时间逆序排序"];
} else {
titleArray = @[@"默认排序",@"按点赞数由大到小排序",@"按点赞数由小到大排序"];
}
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
UIButton *button = [[UIButton alloc] init]; UIButton *button = [[UIButton alloc] init];
button.titleLabel.font = [UIFont systemFontOfSize:15.0]; button.titleLabel.font = [UIFont systemFontOfSize:15.0];
......
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