Commit 4f401008 authored by admin's avatar admin

添加上拉加载更多

parent e92ee35e
...@@ -134,6 +134,8 @@ ...@@ -134,6 +134,8 @@
#define kTaxisViewHeight 150 #define kTaxisViewHeight 150
#define kScreenViewHeight 240 #define kScreenViewHeight 240
#define kMoreScreenViewHeight 410
#define kRefreshInspectPointNotification @"refreshInspectPoint" #define kRefreshInspectPointNotification @"refreshInspectPoint"
#define kRefreshQuestionNotification @"refershQuestionList" #define kRefreshQuestionNotification @"refershQuestionList"
......
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
@property (nonatomic, strong) ScopeTableView *scopeTableView; @property (nonatomic, strong) ScopeTableView *scopeTableView;
@property (nonatomic, strong) GroupTableView *groupTableView; @property (nonatomic, strong) GroupTableView *groupTableView;
@property (nonatomic, strong) CategoryTableView *categoryTableView; @property (nonatomic, strong) CategoryTableView *categoryTableView;
@property (nonatomic, strong) UITextView *textView1;
@property (nonatomic, strong) UITextView *textView2;
@property (nonatomic, strong) StateTableView *stateTableView; @property (nonatomic, strong) StateTableView *stateTableView;
@property (nonatomic, strong) TimeTableView *timeTableView; @property (nonatomic, strong) TimeTableView *timeTableView;
......
...@@ -39,22 +39,28 @@ ...@@ -39,22 +39,28 @@
- (void)setup - (void)setup
{ {
self.groupTabBar = [[GroupTabBar alloc] initWithFrame:CGRectMake(0, 0, 100, 180)]; self.groupTabBar = [[GroupTabBar alloc] initWithFrame:CGRectMake(0, 0, 100, 350)];
_groupTabBar.delegate = self; _groupTabBar.delegate = self;
[self addSubview:_groupTabBar]; [self addSubview:_groupTabBar];
self.scopeTableView = [[ScopeTableView alloc] init]; self.scopeTableView = [[ScopeTableView alloc] init];
GroupItems *scopeItem = [[GroupItems alloc] initWithTitle:@"问题范围" view:_scopeTableView]; GroupItems *scopeItem = [[GroupItems alloc] initWithTitle:@"问题范围" view:_scopeTableView];
self.groupTableView = [[GroupTableView alloc] init]; self.groupTableView = [[GroupTableView alloc] init];
_groupTableView.groupDeleagte = self.categoryTableView;
GroupItems *groupItem = [[GroupItems alloc] initWithTitle:@"问题分组" view:_groupTableView]; GroupItems *groupItem = [[GroupItems alloc] initWithTitle:@"问题分组" view:_groupTableView];
self.categoryTableView = [[CategoryTableView alloc] init]; self.categoryTableView = [[CategoryTableView alloc] init];
GroupItems *categoryItem = [[GroupItems alloc] initWithTitle:@"问题分类" view:_categoryTableView]; GroupItems *categoryItem = [[GroupItems alloc] initWithTitle:@"问题分类" view:_categoryTableView];
self.textView1 = [[UITextView alloc] init];
GroupItems *textViewItem1 = [[GroupItems alloc] initWithTitle:@"标题类似于" view:_textView1];
self.textView2 = [[UITextView alloc] init];
GroupItems *textViewItem2 = [[GroupItems alloc] initWithTitle:@"关键字类似于" view:_textView2];
self.stateTableView = [[StateTableView alloc] init]; self.stateTableView = [[StateTableView alloc] init];
GroupItems *stateItem = [[GroupItems alloc] initWithTitle:@"问题状态" view:_stateTableView]; GroupItems *stateItem = [[GroupItems alloc] initWithTitle:@"问题状态" view:_stateTableView];
...@@ -64,10 +70,12 @@ ...@@ -64,10 +70,12 @@
[self insertSubview:_scopeTableView belowSubview:_groupTabBar]; [self insertSubview:_scopeTableView belowSubview:_groupTabBar];
[self insertSubview:_groupTableView belowSubview:_groupTabBar]; [self insertSubview:_groupTableView belowSubview:_groupTabBar];
[self insertSubview:_categoryTableView belowSubview:_groupTabBar]; [self insertSubview:_categoryTableView belowSubview:_groupTabBar];
[self insertSubview:_textView1 belowSubview:_groupTabBar];
[self insertSubview:_textView2 belowSubview:_groupTabBar];
[self insertSubview:_stateTableView belowSubview:_groupTabBar]; [self insertSubview:_stateTableView belowSubview:_groupTabBar];
[self insertSubview:_timeTableView belowSubview:_groupTabBar]; [self insertSubview:_timeTableView belowSubview:_groupTabBar];
_groupTabBar.items = @[scopeItem, groupItem, categoryItem, stateItem, timeItem]; _groupTabBar.items = @[scopeItem, groupItem, categoryItem, textViewItem1, textViewItem2, stateItem, timeItem];
[_groupTabBar showIndex:0]; [_groupTabBar showIndex:0];
self.backView.backgroundColor = [UIColor whiteColor]; self.backView.backgroundColor = [UIColor whiteColor];
......
...@@ -7,7 +7,15 @@ ...@@ -7,7 +7,15 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "GroupTableView.h"
@interface CategoryTableView : UITableView @protocol CategoryTableViewDelegate <NSObject>
- (void)categoryTableViewClick:(NSInteger)row;
@end
@interface CategoryTableView : UITableView <GroupTableViewDelegate>
@property (nonatomic, assign) id <CategoryTableViewDelegate>categroyDeleagte;
@end @end
...@@ -33,15 +33,26 @@ ...@@ -33,15 +33,26 @@
- (void)setup - (void)setup
{ {
self.titleArray = [NSMutableArray arrayWithObjects:@"全部问题",@"我的问题", nil];
self.delegate = self; self.delegate = self;
self.dataSource = self; self.dataSource = self;
self.titleArray = [NSMutableArray arrayWithObjects:@"111",@"222", nil];
NSInteger selectedIndex = 0; NSInteger selectedIndex = 0;
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0]; NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
[self selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; [self selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
} }
//- (void)groupTableViewClick:(NSInteger)row
//{
// if (row == 0) {
// [self reloadData];
// } else {
// self.titleArray = [NSMutableArray arrayWithObjects:@"211",@"322", nil];
// [self reloadData];
//
// }
//}
#pragma mark - TableView Delegate/DataSource #pragma mark - TableView Delegate/DataSource
...@@ -59,14 +70,17 @@ ...@@ -59,14 +70,17 @@
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"categoryCell"]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"categoryCell"];
} }
cell.textLabel.text = _titleArray[indexPath.row]; cell.textLabel.text = _titleArray[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.textLabel.font = [UIFont systemFontOfSize:14.0];
return cell; return cell;
} }
// cell点击事件 // cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (_categroyDeleagte) {
[_categroyDeleagte categoryTableViewClick:indexPath.row];
}
} }
......
...@@ -7,7 +7,12 @@ ...@@ -7,7 +7,12 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@protocol GroupTableViewDelegate <NSObject>
- (void)groupTableViewClick:(NSInteger)row;
@end
@interface GroupTableView : UITableView @interface GroupTableView : UITableView
@property (nonatomic, assign) id <GroupTableViewDelegate>groupDeleagte;
@end @end
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
- (void)setup - (void)setup
{ {
self.titleArray = [NSMutableArray arrayWithObjects:@"全部问题",@"我的问题", nil]; self.titleArray = [NSMutableArray arrayWithObjects:@"全部",@"服务",@"环境企划",@"环境物业", nil];
self.delegate = self; self.delegate = self;
self.dataSource = self; self.dataSource = self;
...@@ -59,14 +59,17 @@ ...@@ -59,14 +59,17 @@
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"groupCell"]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"groupCell"];
} }
cell.textLabel.text = _titleArray[indexPath.row]; cell.textLabel.text = _titleArray[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.textLabel.font = [UIFont systemFontOfSize:14.0];
return cell; return cell;
} }
// cell点击事件 // cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (_groupDeleagte) {
[_groupDeleagte groupTableViewClick:indexPath.row];
}
} }
......
...@@ -8,6 +8,12 @@ ...@@ -8,6 +8,12 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface ScopeTableView : UITableView @protocol ScopeTableViewDelegate <NSObject>
- (void)scopeTableViewClick:(NSInteger)row;
@end @end
@interface ScopeTableView : UITableView
@property (nonatomic, assign) id <ScopeTableViewDelegate>scopeDeleagte;
@end
...@@ -61,14 +61,17 @@ ...@@ -61,14 +61,17 @@
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"scopeCell"]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"scopeCell"];
} }
cell.textLabel.text = _titleArray[indexPath.row]; cell.textLabel.text = _titleArray[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.textLabel.font = [UIFont systemFontOfSize:14.0];
return cell; return cell;
} }
// cell点击事件 // cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (_scopeDeleagte) {
[_scopeDeleagte scopeTableViewClick:indexPath.row];
}
} }
......
...@@ -7,7 +7,12 @@ ...@@ -7,7 +7,12 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@protocol StateTableViewDelegate <NSObject>
- (void)stateTableViewClick:(NSInteger)row;
@end
@interface StateTableView : UITableView @interface StateTableView : UITableView
@property (nonatomic, assign) id <StateTableViewDelegate>stateDeleagte;
@end @end
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
- (void)setup - (void)setup
{ {
self.titleArray = [NSMutableArray arrayWithObjects:@"全部问题",@"我的问题", nil]; self.titleArray = [NSMutableArray arrayWithObjects:@"已创建",@"已完成",@"已作废",nil];
self.delegate = self; self.delegate = self;
self.dataSource = self; self.dataSource = self;
...@@ -59,14 +59,17 @@ ...@@ -59,14 +59,17 @@
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"stateCell"]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"stateCell"];
} }
cell.textLabel.text = _titleArray[indexPath.row]; cell.textLabel.text = _titleArray[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.textLabel.font = [UIFont systemFontOfSize:14.0];
return cell; return cell;
} }
// cell点击事件 // cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (_stateDeleagte) {
[_stateDeleagte stateTableViewClick:indexPath.row];
}
} }
......
...@@ -7,7 +7,12 @@ ...@@ -7,7 +7,12 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@protocol TimeTableViewDelegate <NSObject>
- (void)timeTableViewClick:(NSInteger)row;
@end
@interface TimeTableView : UITableView @interface TimeTableView : UITableView
@property (nonatomic, assign) id <TimeTableViewDelegate>timeDeleagte;
@end @end
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
- (void)setup - (void)setup
{ {
self.titleArray = [NSMutableArray arrayWithObjects:@"全部问题",@"我的问题", nil]; self.titleArray = [NSMutableArray arrayWithObjects:@"全部",@"一周",@"一月",@"三月",@"一年",@"历史更多", nil];
self.delegate = self; self.delegate = self;
self.dataSource = self; self.dataSource = self;
...@@ -59,14 +59,17 @@ ...@@ -59,14 +59,17 @@
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"timeCell"]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"timeCell"];
} }
cell.textLabel.text = _titleArray[indexPath.row]; cell.textLabel.text = _titleArray[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.textLabel.font = [UIFont systemFontOfSize:14.0];
return cell; return cell;
} }
// cell点击事件 // cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (_timeDeleagte) {
[_timeDeleagte timeTableViewClick:indexPath.row];
}
} }
......
...@@ -15,16 +15,18 @@ ...@@ -15,16 +15,18 @@
#import "QuestionModel.h" #import "QuestionModel.h"
#import "SearchToolBar.h" #import "SearchToolBar.h"
#import "TaxisView.h" #import "TaxisView.h"
#import "ScreenView.h" #import "MoreScreenView.h"
#import "MenuView.h" #import "MenuView.h"
#import "CustomDropMenuView.h" #import "CustomDropMenuView.h"
#import "NoDataView.h" #import "NoDataView.h"
#import <MBProgressHUD.h> #import <MBProgressHUD.h>
#import <MJRefresh.h>
#define kQuestionListCell @"questionListTableViewCell" #define kQuestionListCell @"questionListTableViewCell"
#define kThumbTag 745645 #define kThumbTag 745645
@interface QuestionViewController () <UITableViewDelegate, UITableViewDataSource, ScreenTableDelegate, TaxisViewDelegate, InspectTableViewDelegate> @interface QuestionViewController () <UITableViewDelegate, UITableViewDataSource, TaxisViewDelegate>
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *allQuestionArray; @property (nonatomic, strong) NSMutableArray *allQuestionArray;
...@@ -32,7 +34,7 @@ ...@@ -32,7 +34,7 @@
@property (nonatomic, strong) MenuView *menuView; @property (nonatomic, strong) MenuView *menuView;
@property (nonatomic, strong) TaxisView *taxisView; @property (nonatomic, strong) TaxisView *taxisView;
@property (nonatomic, strong) ScreenView *screenView; @property (nonatomic, strong) MoreScreenView *screenView;
@property (nonatomic, strong) UIView *bgView; @property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) MenuButton *selctedButton; @property (nonatomic, strong) MenuButton *selctedButton;
...@@ -43,6 +45,8 @@ ...@@ -43,6 +45,8 @@
@property (nonatomic, assign) NSInteger selectRow; @property (nonatomic, assign) NSInteger selectRow;
@property (nonatomic, assign) NSInteger timeSelectNum; @property (nonatomic, assign) NSInteger timeSelectNum;
@property (nonatomic, assign) NSInteger page;
@end @end
@implementation QuestionViewController @implementation QuestionViewController
...@@ -69,7 +73,7 @@ ...@@ -69,7 +73,7 @@
name:kRefreshQuestionNotification name:kRefreshQuestionNotification
object:nil]; object:nil];
_page = 0;
} }
- (void)dealloc - (void)dealloc
...@@ -104,8 +108,6 @@ ...@@ -104,8 +108,6 @@
- (void)requestQuestionList - (void)requestQuestionList
{ {
// 初始化数组
self.allQuestionArray = [NSMutableArray array];
// 请求地址 // 请求地址
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL]; NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"]; NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
...@@ -114,7 +116,7 @@ ...@@ -114,7 +116,7 @@
NSDictionary *parameters = @{@"user":user_uuid, NSDictionary *parameters = @{@"user":user_uuid,
@"scope":@"all", @"scope":@"all",
@"pageNumber":@(0), @"pageNumber":@(0),
@"pageSize":@(20) @"pageSize":@(10)
}; };
// 发起请求 // 发起请求
...@@ -134,12 +136,16 @@ ...@@ -134,12 +136,16 @@
[question setValuesForKeysWithDictionary:questionDict]; [question setValuesForKeysWithDictionary:questionDict];
[tempArray addObject:question]; [tempArray addObject:question];
} }
_allQuestionArray = tempArray; _allQuestionArray = [NSMutableArray arrayWithArray:tempArray];
if (_allQuestionArray.count == 0) { if (_allQuestionArray.count == 0) {
weakSelf.noDataView.backgroundColor = [UIColor whiteColor]; weakSelf.noDataView.backgroundColor = [UIColor whiteColor];
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
} else { } else {
[weakSelf setupTableView]; [weakSelf setupTableView];
self.tableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
[self requestMoreList];
}];
[self.tableView reloadData]; [self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
} }
...@@ -147,6 +153,46 @@ ...@@ -147,6 +153,46 @@
}]; }];
} }
- (void)requestMoreList
{
_page++;
// 请求地址
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
// 请求参数
NSDictionary *parameters = @{@"user":user_uuid,
@"scope":@"all",
@"pageNumber":@(_page),
@"pageSize":@(10)
};
// 发起请求
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr];
// 请求问题列表
[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 addObjectsFromArray:tempArray];
if (tempArray.count < 5) {
[self.tableView.footer noticeNoMoreData];
} else {
[self.tableView.footer endRefreshing];
}
[self.tableView reloadData];
}];
}
- (void)setupTableView - (void)setupTableView
{ {
[self.tableView registerClass:[QuestionListTableCell class] forCellReuseIdentifier:kQuestionListCell]; [self.tableView registerClass:[QuestionListTableCell class] forCellReuseIdentifier:kQuestionListCell];
...@@ -316,9 +362,7 @@ ...@@ -316,9 +362,7 @@
[_bgView addGestureRecognizer:tapGR]; [_bgView addGestureRecognizer:tapGR];
} }
if (!_screenView) { if (!_screenView) {
_screenView = [[ScreenView alloc] initWithTitleArray:[NSArray arrayWithObjects:@"待解决", @"已解决",@"已作废",nil]]; _screenView = [[MoreScreenView alloc] init];
_screenView.delegate = self;
_screenView.inspectTableView.inspectDelegate = self;
_screenView.backgroundColor = [UIColor whiteColor]; _screenView.backgroundColor = [UIColor whiteColor];
} }
[_screenView.resetBtn addTarget:self action:@selector(resetClick:) forControlEvents:UIControlEventTouchUpInside]; [_screenView.resetBtn addTarget:self action:@selector(resetClick:) forControlEvents:UIControlEventTouchUpInside];
...@@ -330,8 +374,8 @@ ...@@ -330,8 +374,8 @@
_bgView.alpha = 0; _bgView.alpha = 0;
_bgView.backgroundColor = [UIColor blackColor]; _bgView.backgroundColor = [UIColor blackColor];
CGRect toFrame = CGRectMake(0, 45, kScreenWidth, kScreenViewHeight); CGRect toFrame = CGRectMake(0, 45, kScreenWidth, kMoreScreenViewHeight);
CGRect fromFrame = CGRectMake(0, -kScreenViewHeight, kScreenWidth, kScreenViewHeight); CGRect fromFrame = CGRectMake(0, -kMoreScreenViewHeight, kScreenWidth, kMoreScreenViewHeight);
_screenView.frame = fromFrame; _screenView.frame = fromFrame;
[UIView animateWithDuration:0.3 animations:^{ [UIView animateWithDuration:0.3 animations:^{
...@@ -346,7 +390,7 @@ ...@@ -346,7 +390,7 @@
_selctedButton.isDrop = NO; _selctedButton.isDrop = NO;
_selctedButton.selected = NO; _selctedButton.selected = NO;
[_selctedButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal]; [_selctedButton setTitleColor:kInspectSectionButtonTextColor forState:UIControlStateNormal];
CGRect fromFrame = CGRectMake(0, -kScreenViewHeight, kScreenWidth, kScreenViewHeight); CGRect fromFrame = CGRectMake(0, -kMoreScreenViewHeight, kScreenWidth, kMoreScreenViewHeight);
[UIView animateWithDuration:0.3 animations:^{ [UIView animateWithDuration:0.3 animations:^{
_bgView.alpha = .0f; _bgView.alpha = .0f;
_screenView.frame = fromFrame; _screenView.frame = fromFrame;
...@@ -365,16 +409,7 @@ ...@@ -365,16 +409,7 @@
// 重置按钮 // 重置按钮
- (void)resetClick:(UIButton *)sender - (void)resetClick:(UIButton *)sender
{ {
NSInteger selectedIndex = 0;
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
[_screenView.tableView selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
_screenView.textView.text = @"";
NSInteger timeIndex = 0;
NSIndexPath *timeIndexPath = [NSIndexPath indexPathForRow:timeIndex inSection:0];
[_screenView.tableView selectRowAtIndexPath:timeIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
_selectRow = 0;
} }
// 提交按钮 // 提交按钮
- (void)submitClick:(UIButton *)sender - (void)submitClick:(UIButton *)sender
...@@ -397,74 +432,6 @@ ...@@ -397,74 +432,6 @@
[MBProgressHUD showHUDAddedTo:self.view animated:YES]; [MBProgressHUD showHUDAddedTo:self.view animated:YES];
if (_screenView.groupTabBar.selectNumber == 0) {
NSArray *queryOrder = @[@{@"field":@"state"}];
[parameters setObject:queryOrder forKey:@"queryOrders"];
if (_selectRow == 0) {
[parameters setObject:@"created" forKey:@"state"];
} else if (_selectRow == 1) {
[parameters setObject:@"resolved" forKey:@"state"];
} else {
[parameters setObject:@"aborted" forKey:@"state"];
}
} else if (_screenView.groupTabBar.selectNumber == 1) {
NSArray *queryOrder = @[@{@"field":@"title"}];
[parameters setObject:queryOrder forKey:@"queryOrders"];
if (_screenView.textView.text.length != 0){
[parameters setObject:_screenView.textView.text forKey:@"contentLike"];
} else {
[parameters setObject:_screenView.textView.text forKey:@"contentLike"];
}
} else {
NSArray *queryOrder = @[@{@"field":@"resolveTime",@"direction":@"desc"}];
[parameters setObject:queryOrder forKey:@"queryOrders"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
// 当前时间
NSDate *today = [NSDate date];
NSString *todayStr = [dateFormatter stringFromDate:today];
if (_timeSelectNum == 0) {
NSDate *week = [today dateByAddingTimeInterval:-60*60*24*7];
NSString *weekStr = [dateFormatter stringFromDate:week];
[parameters setObject:weekStr forKey:@"submitTimeFrom"];
[parameters setObject:todayStr forKey:@"submitTimeTo"];
} else if (_timeSelectNum == 1) {
NSDate *oneMonth = [self getPriousorLaterDateFromDate:today withMonth:-1];
NSString *oneMonthStr = [dateFormatter stringFromDate:oneMonth];
NSLog(@"oneMonth = %@", oneMonthStr);
[parameters setObject:oneMonthStr forKey:@"submitTimeFrom"];
[parameters setObject:todayStr forKey:@"submitTimeTo"];
} else if (_timeSelectNum == 2) {
NSDate *threeMonth = [self getPriousorLaterDateFromDate:today withMonth:-3];
NSString *threeMonthStr = [dateFormatter stringFromDate:threeMonth];
[parameters setObject:threeMonthStr forKey:@"submitTimeFrom"];
[parameters setObject:todayStr forKey:@"submitTimeTo"];
} else if (_timeSelectNum == 3) {
NSDate *oneYear = [self getPriousorLaterDateFromDate:today withMonth:-12];
NSString *oneYearStr = [dateFormatter stringFromDate:oneYear];
[parameters setObject:oneYearStr forKey:@"submitTimeFrom"];
[parameters setObject:todayStr forKey:@"submitTimeTo"];
} else {
NSDate *oneYear = [self getPriousorLaterDateFromDate:today withMonth:-12];
NSString *oneYearStr = [dateFormatter stringFromDate:oneYear];
[parameters setObject:oneYearStr forKey:@"submitTimeTo"];
}
}
NSLog(@"parameters = %@",parameters);
// 请求问题列表 // 请求问题列表
...@@ -497,7 +464,6 @@ ...@@ -497,7 +464,6 @@
weakSelf.tableView.dataSource = weakSelf; weakSelf.tableView.dataSource = weakSelf;
[weakSelf.tableView reloadData]; [weakSelf.tableView reloadData];
[MBProgressHUD hideHUDForView:weakSelf.view animated:YES]; [MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
_screenView.textView.text = @"";
[weakSelf closeGreenView]; [weakSelf closeGreenView];
} }
}]; }];
...@@ -591,7 +557,6 @@ ...@@ -591,7 +557,6 @@
weakSelf.tableView.dataSource = weakSelf; weakSelf.tableView.dataSource = weakSelf;
[weakSelf.tableView reloadData]; [weakSelf.tableView reloadData];
[MBProgressHUD hideHUDForView:weakSelf.view animated:YES]; [MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
_screenView.textView.text = @"";
[weakSelf closeGreenView]; [weakSelf closeGreenView];
} }
}]; }];
...@@ -743,16 +708,14 @@ ...@@ -743,16 +708,14 @@
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]; NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight]; [self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-40];
[self.view addConstraint:tableBottom]; [self.view addConstraint:tableBottom];
} }
return _noDataView; return _noDataView;
} }
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
if (![_screenView.textView isExclusiveTouch]) {
[_screenView.textView resignFirstResponder];
}
if (![self.searchBar.searchTextFiled isExclusiveTouch]) { if (![self.searchBar.searchTextFiled isExclusiveTouch]) {
[self.searchBar.searchTextFiled resignFirstResponder]; [self.searchBar.searchTextFiled resignFirstResponder];
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#import "TaskListModel.h" #import "TaskListModel.h"
#import <MBProgressHUD.h> #import <MBProgressHUD.h>
#import "NoDataView.h" #import "NoDataView.h"
#import <MJRefresh.h>
#define kTAxisBtnTag 500232 #define kTAxisBtnTag 500232
...@@ -41,6 +42,7 @@ ...@@ -41,6 +42,7 @@
@property (nonatomic, assign) NSInteger selectRow; @property (nonatomic, assign) NSInteger selectRow;
@property (nonatomic, assign) NSInteger timeSelectNum; @property (nonatomic, assign) NSInteger timeSelectNum;
@property (nonatomic, assign) NSInteger page;
@property (nonatomic, strong) NoDataView *noDataView; @property (nonatomic, strong) NoDataView *noDataView;
...@@ -77,7 +79,7 @@ ...@@ -77,7 +79,7 @@
// 初始化数组 // 初始化数组
self.taskListDataArray = [NSMutableArray array]; // self.taskListDataArray = [NSMutableArray array];
[self requestInspectList]; [self requestInspectList];
...@@ -86,6 +88,8 @@ ...@@ -86,6 +88,8 @@
name:kRefreshInspectPointNotification name:kRefreshInspectPointNotification
object:nil]; object:nil];
_page = 0;
} }
- (void)dealloc - (void)dealloc
...@@ -115,6 +119,42 @@ ...@@ -115,6 +119,42 @@
} }
#pragma mark - Private #pragma mark - Private
- (void)requestMoreList
{
_page++;
NSLog(@"_page = %d", (int)_page);
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSDictionary *parameters = @{
@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
@"queryOrders":@[@{@"field":@"lastModifyInfo"}],
@"pageNumber":@(_page),
@"pageSize":@(10)
};
[httpCilent getInspectListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"巡检列表%@", response);
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
NSMutableArray *taskArray = [NSMutableArray array];
for (NSDictionary *dict in dataArray) {
TaskListModel *taskList = [[TaskListModel alloc] init];
[taskList setValuesForKeysWithDictionary:dict];
[taskArray addObject:taskList];
}
[_taskListDataArray addObjectsFromArray:taskArray];
if (taskArray.count < 10) {
[self.tableView.footer noticeNoMoreData];
} else {
[self.tableView.footer endRefreshing];
}
[self.tableView reloadData];
}];
}
- (void)requestCurrentList - (void)requestCurrentList
{ {
...@@ -124,7 +164,7 @@ ...@@ -124,7 +164,7 @@
@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"], @"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
@"queryOrders":@[@{@"field":@"lastModifyInfo"}], @"queryOrders":@[@{@"field":@"lastModifyInfo"}],
@"pageNumber":@(0), @"pageNumber":@(0),
@"pageSize":@(20) @"pageSize":@(10)
}; };
[MBProgressHUD showHUDAddedTo:self.view animated:YES]; [MBProgressHUD showHUDAddedTo:self.view animated:YES];
...@@ -153,7 +193,7 @@ ...@@ -153,7 +193,7 @@
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
} }
[self.tableView reloadData]; [self.tableView reloadData];
}]; }];
...@@ -180,7 +220,7 @@ ...@@ -180,7 +220,7 @@
@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"], @"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
@"queryOrders":@[@{@"field":@"lastModifyInfo"}], @"queryOrders":@[@{@"field":@"lastModifyInfo"}],
@"pageNumber":@(0), @"pageNumber":@(0),
@"pageSize":@(20) @"pageSize":@(10)
}; };
NSLog(@"parameters = %@", parameters); NSLog(@"parameters = %@", parameters);
[MBProgressHUD showHUDAddedTo:self.view animated:YES]; [MBProgressHUD showHUDAddedTo:self.view animated:YES];
...@@ -191,11 +231,13 @@ ...@@ -191,11 +231,13 @@
NSDictionary *dataDict = response[@"data"]; NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"]; NSArray *dataArray = dataDict[@"records"];
NSMutableArray *tempArray = [NSMutableArray array];
for (NSDictionary *dict in dataArray) { for (NSDictionary *dict in dataArray) {
TaskListModel *taskList = [[TaskListModel alloc] init]; TaskListModel *taskList = [[TaskListModel alloc] init];
[taskList setValuesForKeysWithDictionary:dict]; [taskList setValuesForKeysWithDictionary:dict];
[_taskListDataArray addObject:taskList]; [tempArray addObject:taskList];
} }
_taskListDataArray = [NSMutableArray arrayWithArray:tempArray];
if (_taskListDataArray.count == 0) { if (_taskListDataArray.count == 0) {
self.noDataView.backgroundColor = [UIColor whiteColor]; self.noDataView.backgroundColor = [UIColor whiteColor];
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
...@@ -203,9 +245,14 @@ ...@@ -203,9 +245,14 @@
} else { } else {
self.tableView.delegate = self; self.tableView.delegate = self;
self.tableView.dataSource = self; self.tableView.dataSource = self;
self.tableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
[self requestMoreList];
}];
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
} }
}]; }];
} }
...@@ -565,7 +612,7 @@ ...@@ -565,7 +612,7 @@
@"direction":@"asc"}]; @"direction":@"asc"}];
} }
NSDictionary *parameters = @{@"userUuid":@"", NSDictionary *parameters = @{@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
@"queryOrders":queryOrders, @"queryOrders":queryOrders,
@"pageNumber":@(0), @"pageNumber":@(0),
@"pageSize":@(10) @"pageSize":@(10)
......
...@@ -242,6 +242,9 @@ ...@@ -242,6 +242,9 @@
rankDetailVC.indexRow = section; rankDetailVC.indexRow = section;
rankDetailVC.uuid = rankList.uuid; rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid; rankDetailVC.store_uuid = rankList.store_uuid;
rankDetailVC.storeAddress = rankList.storeAddress;
NSLog(@"storeAddress = %@", rankList.storePictures);
rankDetailVC.storePictures = rankList.storePictures;
[self.navigationController pushViewController:rankDetailVC animated:YES]; [self.navigationController pushViewController:rankDetailVC animated:YES];
} }
......
...@@ -119,14 +119,14 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2); ...@@ -119,14 +119,14 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
if ([permissions containsObject:@"500301"] || [permissions containsObject:@"500302"]) { if ([permissions containsObject:@"500301"] || [permissions containsObject:@"500302"]) {
// [self.titleArray addObject:@"图说口碑"]; [self.titleArray addObject:@"图说口碑"];
} }
if ([permissions containsObject:@"500401"] || [permissions containsObject:@"500402"]) { if ([permissions containsObject:@"500401"] || [permissions containsObject:@"500402"]) {
// [self.titleArray addObject:@"口碑标准"]; [self.titleArray addObject:@"口碑标准"];
} }
if ([permissions containsObject:@"500701"] || [permissions containsObject:@"500702"]) { if ([permissions containsObject:@"500701"] || [permissions containsObject:@"500702"]) {
// [self.titleArray addObject:@"在线抽查"]; [self.titleArray addObject:@"在线抽查"];
} }
[[NSUserDefaults standardUserDefaults] setObject:_titleArray forKey:@"function"]; [[NSUserDefaults standardUserDefaults] setObject:_titleArray forKey:@"function"];
...@@ -514,14 +514,14 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2); ...@@ -514,14 +514,14 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{ {
NSMutableArray *titleArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"function"]; NSMutableArray *titleArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"function"];
return titleArray.count; if (titleArray.count == 6) {
// if (_titleArray.count == 1) { return 3;
// return _titleArray.count; } else if (titleArray.count == 5) {
// } else if (_titleArray.count == 5){ return 2;
// return 2; } else {
// } else { return titleArray.count;
// return 3; }
// }
} }
......
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